alexandroid/decompiled/jadx/sources/com/google/android/gms/common/GooglePlayServicesUtilLight.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

357 lines
14 KiB
Java

package com.google.android.gms.common;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.UserManager;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.google.android.gms.common.annotation.KeepForSdk;
import com.google.android.gms.common.internal.HideFirstParty;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.internal.ShowFirstParty;
import com.google.android.gms.common.util.ClientLibraryUtils;
import com.google.android.gms.common.util.DeviceProperties;
import com.google.android.gms.common.util.UidVerifier;
import com.google.android.gms.common.wrappers.Wrappers;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicBoolean;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@ShowFirstParty
@KeepForSdk
/* loaded from: classes7.dex */
public class GooglePlayServicesUtilLight {
@KeepForSdk
static final int GMS_AVAILABILITY_NOTIFICATION_ID = 10436;
@KeepForSdk
static final int GMS_GENERAL_ERROR_NOTIFICATION_ID = 39789;
@NonNull
@KeepForSdk
public static final String GOOGLE_PLAY_GAMES_PACKAGE = "com.google.android.play.games";
@NonNull
@KeepForSdk
@Deprecated
public static final String GOOGLE_PLAY_SERVICES_PACKAGE = "com.google.android.gms";
@KeepForSdk
@Deprecated
public static final int GOOGLE_PLAY_SERVICES_VERSION_CODE = 12451000;
@NonNull
@KeepForSdk
public static final String GOOGLE_PLAY_STORE_PACKAGE = "com.android.vending";
@NonNull
@KeepForSdk
public static final String GOOGLE_SERVICES_FRAMEWORK_PACKAGE = "com.google.android.gsf";
@VisibleForTesting
public static boolean zza = false;
@VisibleForTesting
public static boolean zzb = false;
@KeepForSdk
@Deprecated
static final AtomicBoolean sCanceledAvailabilityNotification = new AtomicBoolean();
private static final AtomicBoolean zzc = new AtomicBoolean();
@KeepForSdk
public GooglePlayServicesUtilLight() {
}
@KeepForSdk
@Deprecated
public static void cancelAvailabilityErrorNotifications(@NonNull Context context) {
if (sCanceledAvailabilityNotification.getAndSet(true)) {
return;
}
try {
NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
if (notificationManager != null) {
notificationManager.cancel(GMS_AVAILABILITY_NOTIFICATION_ID);
}
} catch (SecurityException unused) {
}
}
@ShowFirstParty
@KeepForSdk
public static void enableUsingApkIndependentContext() {
zzc.set(true);
}
@KeepForSdk
@Deprecated
public static void ensurePlayServicesAvailable(@NonNull Context context, int i) throws GooglePlayServicesRepairableException, GooglePlayServicesNotAvailableException {
int isGooglePlayServicesAvailable = GoogleApiAvailabilityLight.getInstance().isGooglePlayServicesAvailable(context, i);
if (isGooglePlayServicesAvailable != 0) {
Intent errorResolutionIntent = GoogleApiAvailabilityLight.getInstance().getErrorResolutionIntent(context, isGooglePlayServicesAvailable, "e");
StringBuilder sb = new StringBuilder(String.valueOf(isGooglePlayServicesAvailable).length() + 46);
sb.append("GooglePlayServices not available due to error ");
sb.append(isGooglePlayServicesAvailable);
Log.e("GooglePlayServicesUtil", sb.toString());
if (errorResolutionIntent != null) {
throw new GooglePlayServicesRepairableException(isGooglePlayServicesAvailable, "Google Play Services not available", errorResolutionIntent);
}
throw new GooglePlayServicesNotAvailableException(isGooglePlayServicesAvailable);
}
}
@ShowFirstParty
@KeepForSdk
@Deprecated
public static int getApkVersion(@NonNull Context context) {
try {
return context.getPackageManager().getPackageInfo("com.google.android.gms", 0).versionCode;
} catch (PackageManager.NameNotFoundException unused) {
Log.w("GooglePlayServicesUtil", "Google Play services is missing.");
return 0;
}
}
@ShowFirstParty
@KeepForSdk
@Deprecated
public static int getClientVersion(@NonNull Context context) {
Preconditions.checkState(true);
return ClientLibraryUtils.getClientVersion(context, context.getPackageName());
}
@Nullable
@KeepForSdk
@Deprecated
public static PendingIntent getErrorPendingIntent(int i, @NonNull Context context, int i2) {
return GoogleApiAvailabilityLight.getInstance().getErrorResolutionPendingIntent(context, i, i2);
}
@NonNull
@KeepForSdk
@Deprecated
public static String getErrorString(int i) {
return ConnectionResult.zza(i);
}
@Deprecated
@Nullable
@ShowFirstParty
@KeepForSdk
public static Intent getGooglePlayServicesAvailabilityRecoveryIntent(int i) {
return GoogleApiAvailabilityLight.getInstance().getErrorResolutionIntent(null, i, null);
}
@Nullable
@KeepForSdk
public static Context getRemoteContext(@NonNull Context context) {
try {
return context.createPackageContext("com.google.android.gms", 3);
} catch (PackageManager.NameNotFoundException unused) {
return null;
}
}
@Nullable
@KeepForSdk
public static Resources getRemoteResource(@NonNull Context context) {
try {
return context.getPackageManager().getResourcesForApplication("com.google.android.gms");
} catch (PackageManager.NameNotFoundException unused) {
return null;
}
}
@ShowFirstParty
@KeepForSdk
public static boolean honorsDebugCertificates(@NonNull Context context) {
try {
if (!zzb) {
try {
PackageInfo packageInfo = Wrappers.packageManager(context).getPackageInfo("com.google.android.gms", 134217792);
GoogleSignatureVerifier.getInstance(context);
if (packageInfo == null || GoogleSignatureVerifier.zza(packageInfo, false) || !GoogleSignatureVerifier.zza(packageInfo, true)) {
zza = false;
} else {
zza = true;
}
zzb = true;
} catch (PackageManager.NameNotFoundException e) {
Log.w("GooglePlayServicesUtil", "Cannot find Google Play services package name.", e);
zzb = true;
}
}
return zza || !DeviceProperties.isUserBuild();
} catch (Throwable th) {
zzb = true;
throw th;
}
}
@KeepForSdk
@Deprecated
public static int isGooglePlayServicesAvailable(@NonNull Context context, int i) {
PackageInfo packageInfo;
try {
context.getResources().getString(R.string.common_google_play_services_unknown_issue);
} catch (Throwable unused) {
Log.e("GooglePlayServicesUtil", "The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.");
}
if (!"com.google.android.gms".equals(context.getPackageName()) && !zzc.get()) {
int zzb2 = com.google.android.gms.common.internal.zzae.zzb(context);
if (zzb2 == 0) {
throw new GooglePlayServicesMissingManifestValueException();
}
if (zzb2 != GOOGLE_PLAY_SERVICES_VERSION_CODE) {
throw new GooglePlayServicesIncorrectManifestValueException(zzb2);
}
}
boolean z = (DeviceProperties.isWearableWithoutPlayStore(context) || DeviceProperties.zzd(context)) ? false : true;
Preconditions.checkArgument(i >= 0);
String packageName = context.getPackageName();
PackageManager packageManager = context.getPackageManager();
if (z) {
try {
packageInfo = packageManager.getPackageInfo("com.android.vending", 134225984);
} catch (PackageManager.NameNotFoundException unused2) {
Log.w("GooglePlayServicesUtil", String.valueOf(packageName).concat(" requires the Google Play Store, but it is missing."));
}
} else {
packageInfo = null;
}
try {
PackageInfo packageInfo2 = packageManager.getPackageInfo("com.google.android.gms", 134217792);
GoogleSignatureVerifier.getInstance(context);
if (GoogleSignatureVerifier.zza(packageInfo2, true)) {
if (z) {
Preconditions.checkNotNull(packageInfo);
if (!GoogleSignatureVerifier.zza(packageInfo, true)) {
Log.w("GooglePlayServicesUtil", String.valueOf(packageName).concat(" requires Google Play Store, but its signature is invalid."));
}
}
if (!z || packageInfo == null || packageInfo.signatures[0].equals(packageInfo2.signatures[0])) {
if (com.google.android.gms.common.util.zzb.zza(packageInfo2.versionCode) >= com.google.android.gms.common.util.zzb.zza(i)) {
ApplicationInfo applicationInfo = packageInfo2.applicationInfo;
if (applicationInfo == null) {
try {
applicationInfo = packageManager.getApplicationInfo("com.google.android.gms", 0);
} catch (PackageManager.NameNotFoundException e) {
Log.wtf("GooglePlayServicesUtil", String.valueOf(packageName).concat(" requires Google Play services, but they're missing when getting application info."), e);
return 1;
}
}
return !applicationInfo.enabled ? 3 : 0;
}
int i2 = packageInfo2.versionCode;
StringBuilder sb = new StringBuilder(String.valueOf(packageName).length() + 49 + String.valueOf(i).length() + 11 + String.valueOf(i2).length());
sb.append("Google Play services out of date for ");
sb.append(packageName);
sb.append(". Requires ");
sb.append(i);
sb.append(" but found ");
sb.append(i2);
Log.w("GooglePlayServicesUtil", sb.toString());
return 2;
}
Log.w("GooglePlayServicesUtil", String.valueOf(packageName).concat(" requires Google Play Store, but its signature doesn't match that of Google Play services."));
} else {
Log.w("GooglePlayServicesUtil", String.valueOf(packageName).concat(" requires Google Play services, but their signature is invalid."));
}
return 9;
} catch (PackageManager.NameNotFoundException unused3) {
Log.w("GooglePlayServicesUtil", String.valueOf(packageName).concat(" requires Google Play services, but they are missing."));
return 1;
}
}
@KeepForSdk
@Deprecated
public static boolean isGooglePlayServicesUid(@NonNull Context context, int i) {
return UidVerifier.isGooglePlayServicesUid(context, i);
}
@ShowFirstParty
@KeepForSdk
@Deprecated
public static boolean isPlayServicesPossiblyUpdating(@NonNull Context context, int i) {
if (i == 18) {
return true;
}
if (i == 1) {
return zza(context, "com.google.android.gms");
}
return false;
}
@ShowFirstParty
@KeepForSdk
@Deprecated
public static boolean isPlayStorePossiblyUpdating(@NonNull Context context, int i) {
if (i == 9) {
return zza(context, "com.android.vending");
}
return false;
}
@KeepForSdk
public static boolean isRestrictedUserProfile(@NonNull Context context) {
Object systemService = context.getSystemService("user");
Preconditions.checkNotNull(systemService);
Bundle applicationRestrictions = ((UserManager) systemService).getApplicationRestrictions(context.getPackageName());
return applicationRestrictions != null && "true".equals(applicationRestrictions.getString("restricted_profile"));
}
@ShowFirstParty
@KeepForSdk
@Deprecated
public static boolean isSidewinderDevice(@NonNull Context context) {
return DeviceProperties.isSidewinder(context);
}
@KeepForSdk
@Deprecated
public static boolean isUserRecoverableError(int i) {
return i == 1 || i == 2 || i == 3 || i == 9;
}
@KeepForSdk
@Deprecated
public static boolean uidHasPackageName(@NonNull Context context, int i, @NonNull String str) {
return UidVerifier.uidHasPackageName(context, i, str);
}
public static boolean zza(Context context, String str) {
ApplicationInfo applicationInfo;
boolean equals = str.equals("com.google.android.gms");
try {
Iterator<PackageInstaller.SessionInfo> it2 = context.getPackageManager().getPackageInstaller().getAllSessions().iterator();
while (it2.hasNext()) {
if (str.equals(it2.next().getAppPackageName())) {
return true;
}
}
applicationInfo = context.getPackageManager().getApplicationInfo(str, 8192);
} catch (PackageManager.NameNotFoundException | Exception unused) {
}
return equals ? applicationInfo.enabled : applicationInfo.enabled && !isRestrictedUserProfile(context);
}
@HideFirstParty
@KeepForSdk
@Deprecated
public static int isGooglePlayServicesAvailable(@NonNull Context context) {
return isGooglePlayServicesAvailable(context, GOOGLE_PLAY_SERVICES_VERSION_CODE);
}
}