Skip to content

Commit

Permalink
Merge branch 'microg:master' into patch-4
Browse files Browse the repository at this point in the history
  • Loading branch information
ale5000-git authored Aug 13, 2023
2 parents 4cbd55b + 4651ed5 commit b839e88
Show file tree
Hide file tree
Showing 71 changed files with 488 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Build
import android.os.Build.VERSION.SDK_INT
import android.os.Handler
import android.os.Parcel
import android.provider.Telephony
Expand Down Expand Up @@ -62,7 +62,7 @@ private val UserProfileChangeRequest.deleteAttributeList: List<String>
}

private fun Intent.getSmsMessages(): Array<SmsMessage> {
return if (Build.VERSION.SDK_INT >= 19) {
return if (SDK_INT >= 19) {
Telephony.Sms.Intents.getMessagesFromIntent(this)
} else {
(getSerializableExtra("pdus") as? Array<ByteArray>)?.map { SmsMessage.createFromPdu(it) }.orEmpty().toTypedArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class MobileAdsSettingManagerImpl(private val context: Context?) : IMobileAdsSet
return true
}

override fun getVersionString(): String {
return ""
}

override fun registerRtbAdapter(className: String?) {
Log.d(TAG, "registerRtbAdapter($className)")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface IMobileAdsSettingManager {
void fetchAppSettings(String appId, IObjectWrapper runnable) = 5;
float getAdVolume() = 6;
boolean isAdMuted() = 7;
String getVersionString() = 8;
void registerRtbAdapter(String className) = 9;
void addInitializationCallback(IInitializationCallback callback) = 11;
List<AdapterStatusParcel> getAdapterStatus() = 12;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* SPDX-FileCopyrightText: 2023 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package com.google.android.gms.credential.manager.common;

import com.google.android.gms.common.api.Status;

interface IPendingIntentCallback {
void onPendingIntent(in Status status, in PendingIntent pendingIntent);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* SPDX-FileCopyrightText: 2023 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package com.google.android.gms.credential.manager.common;

import com.google.android.gms.common.api.Status;

interface ISettingsCallback {
void onSetting(in Status status, in byte[] value);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* SPDX-FileCopyrightText: 2023 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package com.google.android.gms.credential.manager.firstparty.internal;

import com.google.android.gms.common.api.internal.IStatusCallback;
import com.google.android.gms.credential.manager.common.IPendingIntentCallback;
import com.google.android.gms.credential.manager.common.ISettingsCallback;
import com.google.android.gms.credential.manager.invocationparams.CredentialManagerInvocationParams;

interface ICredentialManagerService {
void getCredentialManagerIntent(IPendingIntentCallback callback, in CredentialManagerInvocationParams params) = 0;
void getSetting(ISettingsCallback callback, String key) = 1;
void setSetting(IStatusCallback callback, String key, in byte[] value) = 2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* SPDX-FileCopyrightText: 2023 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package com.google.android.gms.credential.manager.invocationparams;

parcelable CredentialManagerInvocationParams;
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* SPDX-FileCopyrightText: 2023 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package com.google.android.gms.credential.manager.invocationparams;

import androidx.annotation.NonNull;
import org.microg.safeparcel.AutoSafeParcelable;

public class CallerInfo extends AutoSafeParcelable {
@Field(1)
public String s1;
@Field(2)
public String s2;
@Field(3)
public String s3;
@Field(4)
public String s4;

@NonNull
@Override
public String toString() {
return "CallerInfo(" + s1 + "," + s2 + "," + s3 + "," + s4 + ")";
}

public static final Creator<CallerInfo> CREATOR = new AutoCreator<>(CallerInfo.class);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* SPDX-FileCopyrightText: 2023 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package com.google.android.gms.credential.manager.invocationparams;

import androidx.annotation.NonNull;
import org.microg.safeparcel.AutoSafeParcelable;

public class CredentialManagerAccount extends AutoSafeParcelable {
@Field(1)
public String name;

@NonNull
@Override
public String toString() {
return name;
}

public static final String NAME_LOCAL = "pwm.constant.LocalAccount";
public static final Creator<CredentialManagerAccount> CREATOR = new AutoCreator<>(CredentialManagerAccount.class);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* SPDX-FileCopyrightText: 2023 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package com.google.android.gms.credential.manager.invocationparams;

import androidx.annotation.NonNull;
import org.microg.gms.utils.ToStringHelper;
import org.microg.safeparcel.AutoSafeParcelable;

public class CredentialManagerInvocationParams extends AutoSafeParcelable {
@Field(1)
public CredentialManagerAccount account;
@Field(2)
public CallerInfo caller;

@NonNull
@Override
public String toString() {
return ToStringHelper.name("CredentialManagerInvocationParams")
.field("account", account)
.field("caller", caller)
.end();
}

public static final Creator<CredentialManagerInvocationParams> CREATOR = new AutoCreator<>(CredentialManagerInvocationParams.class);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.opengl.GLES10;
import android.os.Build;
import android.util.DisplayMetrics;
import org.microg.gms.profile.Build;
import org.microg.gms.profile.ProfileManager;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -56,6 +57,7 @@ public class DeviceConfiguration {
public int widthPixels;

public DeviceConfiguration(Context context) {
ProfileManager.ensureInitialized(context);
ConfigurationInfo configurationInfo = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getDeviceConfigurationInfo();
touchScreen = configurationInfo.reqTouchScreen;
keyboardType = configurationInfo.reqKeyboardType;
Expand Down Expand Up @@ -101,7 +103,7 @@ public DeviceConfiguration(Context context) {
@SuppressWarnings({"deprecation", "InlinedApi"})
private static List<String> getNativePlatforms() {
List<String> nativePlatforms;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (Build.VERSION.SDK_INT >= 21) {
return Arrays.asList(Build.SUPPORTED_ABIS);
} else {
nativePlatforms = new ArrayList<String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.os.Build;
import android.os.PowerManager;
import android.util.Log;

import androidx.annotation.RequiresApi;

import org.microg.gms.base.core.R;

import static android.os.Build.VERSION.SDK_INT;

public class ForegroundServiceContext extends ContextWrapper {
private static final String TAG = "ForegroundService";
public static final String EXTRA_FOREGROUND = "foreground";
Expand All @@ -26,15 +27,15 @@ public ForegroundServiceContext(Context base) {

@Override
public ComponentName startService(Intent service) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !isIgnoringBatteryOptimizations()) {
if (SDK_INT >= 26 && !isIgnoringBatteryOptimizations()) {
Log.d(TAG, "Starting in foreground mode.");
service.putExtra(EXTRA_FOREGROUND, true);
return super.startForegroundService(service);
}
return super.startService(service);
}

@RequiresApi(api = Build.VERSION_CODES.M)
@RequiresApi(23)
private boolean isIgnoringBatteryOptimizations() {
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
return powerManager.isIgnoringBatteryOptimizations(getPackageName());
Expand Down Expand Up @@ -64,7 +65,7 @@ private static String getServiceName(Service service) {
}

public static void completeForegroundService(Service service, Intent intent, String tag) {
if (intent != null && intent.getBooleanExtra(EXTRA_FOREGROUND, false) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (intent != null && intent.getBooleanExtra(EXTRA_FOREGROUND, false) && SDK_INT >= 26) {
String serviceName = getServiceName(service);
Log.d(tag, "Started " + serviceName + " in foreground mode.");
try {
Expand All @@ -77,7 +78,7 @@ public static void completeForegroundService(Service service, Intent intent, Str
}
}

@RequiresApi(api = Build.VERSION_CODES.O)
@RequiresApi(26)
private static Notification buildForegroundNotification(Context context, String serviceName) {
NotificationChannel channel = new NotificationChannel("foreground-service", "Foreground Service", NotificationManager.IMPORTANCE_NONE);
channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public static String firstPackageFromUserId(Context context, int uid) {
@SuppressWarnings("deprecation")
public static String packageFromPendingIntent(PendingIntent pi) {
if (pi == null) return null;
if (SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (SDK_INT < 17) {
return pi.getTargetPackage();
} else {
return pi.getCreatorPackage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ object Build {

@JvmField
var SECURITY_PATCH: String? = null

@JvmField
var DEVICE_INITIAL_SDK_INT: Int = 0
}

fun generateWebViewUserAgentString(original: String): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ object ProfileManager {
return serial
}

@SuppressLint("BlockedPrivateApi")
private fun getRealData(): Map<String, String> = mutableMapOf(
"Build.BOARD" to android.os.Build.BOARD,
"Build.BOOTLOADER" to android.os.Build.BOOTLOADER,
Expand Down Expand Up @@ -235,6 +236,12 @@ object ProfileManager {
if (android.os.Build.VERSION.SDK_INT >= 23) {
put("Build.VERSION.SECURITY_PATCH", android.os.Build.VERSION.SECURITY_PATCH)
}
try {
val field = android.os.Build.VERSION::class.java.getDeclaredField("DEVICE_INITIAL_SDK_INT")
field.isAccessible = true
put("Build.VERSION.DEVICE_INITIAL_SDK_INT", field.getInt(null).toString())
} catch (ignored: Exception) {
}
}

private fun applyProfileData(profileData: Map<String, String>) {
Expand Down Expand Up @@ -267,6 +274,7 @@ object ProfileManager {
applyStringField("Build.VERSION.RELEASE") { Build.VERSION.RELEASE = it }
applyStringField("Build.VERSION.SDK") { Build.VERSION.SDK = it }
applyIntField("Build.VERSION.SDK_INT") { Build.VERSION.SDK_INT = it }
applyIntField("Build.VERSION.DEVICE_INITIAL_SDK_INT") { Build.VERSION.DEVICE_INITIAL_SDK_INT = it }
if (android.os.Build.VERSION.SDK_INT >= 21) {
Build.SUPPORTED_ABIS = profileData["Build.SUPPORTED_ABIS"]?.split(",")?.toTypedArray() ?: emptyArray()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package org.microg.gms.ui
import android.content.Context
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.os.Build
import android.os.Build.VERSION.SDK_INT
import android.os.Bundle
import android.provider.Settings
import android.util.Log
Expand Down Expand Up @@ -47,7 +47,7 @@ val Context.systemAnimationsEnabled: Boolean
get() {
val duration: Float
val transition: Float
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (SDK_INT >= 17) {
duration = Settings.Global.getFloat(contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1f)
transition = Settings.Global.getFloat(contentResolver, Settings.Global.TRANSITION_ANIMATION_SCALE, 1f)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import android.database.Cursor;
import android.database.CursorWindow;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;

Expand All @@ -38,6 +37,8 @@
import java.util.List;
import java.util.Map;

import static android.os.Build.VERSION.SDK_INT;

/**
* Class for accessing collections of data, organized into columns. This provides the backing
* support for DataBuffer. Much like a cursor, the holder supports the notion of a current
Expand Down Expand Up @@ -155,7 +156,7 @@ public static DataHolder empty(int statusCode) {
@SuppressWarnings("deprecation")
@SuppressLint({"NewApi", "ObsoleteSdkInt"})
static int getCursorType(Cursor cursor, int i) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
if (SDK_INT >= 11) {
return cursor.getType(i);
}
if (cursor instanceof AbstractWindowedCursor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public enum GmsService {
CONSTELLATION(155, "com.google.android.gms.constellation.service.START"),
AUDIT(154, "com.google.android.gms.audit.service.START"),
SYSTEM_UPDATE(157, "com.google.android.gms.update.START_API_SERVICE"),
MOBSTORE(160, "com.google.android.mobstore.service.START"),
USER_LOCATION(163, "com.google.android.gms.userlocation.service.START"),
AD_HTTP(166, "com.google.android.gms.ads.service.HTTP"),
LANGUAGE_PROFILE(167, "com.google.android.gms.languageprofile.service.START"),
Expand All @@ -134,6 +135,7 @@ public enum GmsService {
APP_USAGE(193, "com.google.android.gms.appusage.service.START"),
NEARBY_SHARING_2(194, "com.google.android.gms.nearby.sharing.START_SERVICE"),
AD_CONSENT_LOOKUP(195, "com.google.android.gms.ads.service.CONSENT_LOOKUP"),
CREDENTIAL_MANAGER(196, "com.google.android.gms.credential.manager.service.firstparty.START"),
PHONE_INTERNAL(197, "com.google.android.gms.auth.api.phone.service.InternalService.START"),
PAY(198, "com.google.android.gms.pay.service.BIND"),
ASTERISM(199, "com.google.android.gms.asterism.service.START"),
Expand All @@ -143,6 +145,7 @@ public enum GmsService {
CONTACT_SYNC(208, "com.google.android.gms.people.contactssync.service.START"),
IDENTITY_SIGN_IN(212, "com.google.android.gms.auth.api.identity.service.signin.START"),
CREDENTIAL_STORE(214, "com.google.android.gms.fido.credentialstore.internal_service.START"),
MDI_SYNC(215, "com.google.android.gms.mdisync.service.START"),
EVENT_ATTESTATION(216, "com.google.android.gms.ads.identifier.service.EVENT_ATTESTATION"),
SCHEDULER(218, "com.google.android.gms.scheduler.ACTION_PROXY_SCHEDULE"),
AUTHORIZATION(219, "com.google.android.gms.auth.api.identity.service.authorization.START"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package org.microg.gms.utils;

import android.os.Build;
import android.os.WorkSource;
import android.util.Log;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import android.net.Uri;
import android.net.nsd.NsdManager;
import android.net.nsd.NsdServiceInfo;
import android.os.Build;
import android.os.Bundle;
import android.os.AsyncTask;
import android.os.Handler;
Expand Down
Loading

0 comments on commit b839e88

Please sign in to comment.