package com.google.android.gms.common; import android.annotation.TargetApi; 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 com.google.android.gms.common.internal.Preconditions; import com.google.android.gms.common.internal.zzp; import com.google.android.gms.common.util.ClientLibraryUtils; import com.google.android.gms.common.util.DeviceProperties; import com.google.android.gms.common.util.PlatformVersion; import com.google.android.gms.common.util.UidVerifier; import com.google.android.gms.common.wrappers.Wrappers; import com.ubt.jimu.unity.bluetooth.UnityActivity; import java.util.Iterator; import java.util.concurrent.atomic.AtomicBoolean; /* loaded from: classes.dex */ public class GooglePlayServicesUtilLight { static final int GMS_AVAILABILITY_NOTIFICATION_ID = 10436; static final int GMS_GENERAL_ERROR_NOTIFICATION_ID = 39789; public static final String GOOGLE_PLAY_GAMES_PACKAGE = "com.google.android.play.games"; @Deprecated public static final String GOOGLE_PLAY_SERVICES_PACKAGE = "com.google.android.gms"; @Deprecated public static final int GOOGLE_PLAY_SERVICES_VERSION_CODE = 12451000; public static final String GOOGLE_PLAY_STORE_PACKAGE = "com.android.vending"; private static boolean zzag = false; private static boolean zzah = false; private static boolean zzai = false; private static boolean zzaj = false; static final AtomicBoolean sCanceledAvailabilityNotification = new AtomicBoolean(); private static final AtomicBoolean zzak = new AtomicBoolean(); GooglePlayServicesUtilLight() { } @Deprecated public static void cancelAvailabilityErrorNotifications(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) { } } public static void enableUsingApkIndependentContext() { zzak.set(true); } @Deprecated public static void ensurePlayServicesAvailable(Context context, int i) throws GooglePlayServicesRepairableException, GooglePlayServicesNotAvailableException { int a = GoogleApiAvailabilityLight.a().a(context, i); if (a != 0) { Intent a2 = GoogleApiAvailabilityLight.a().a(context, a, "e"); StringBuilder sb = new StringBuilder(57); sb.append("GooglePlayServices not available due to error "); sb.append(a); Log.e("GooglePlayServicesUtil", sb.toString()); if (a2 != null) { throw new GooglePlayServicesRepairableException(a, "Google Play Services not available", a2); } throw new GooglePlayServicesNotAvailableException(a); } } @Deprecated public static int getApkVersion(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; } } @Deprecated public static int getClientVersion(Context context) { Preconditions.b(true); return ClientLibraryUtils.a(context, context.getPackageName()); } @Deprecated public static PendingIntent getErrorPendingIntent(int i, Context context, int i2) { return GoogleApiAvailabilityLight.a().a(context, i, i2); } @Deprecated public static String getErrorString(int i) { return ConnectionResult.zza(i); } @Deprecated public static Intent getGooglePlayServicesAvailabilityRecoveryIntent(int i) { return GoogleApiAvailabilityLight.a().a((Context) null, i, (String) null); } public static Context getRemoteContext(Context context) { try { return context.createPackageContext("com.google.android.gms", 3); } catch (PackageManager.NameNotFoundException unused) { return null; } } public static Resources getRemoteResource(Context context) { try { return context.getPackageManager().getResourcesForApplication("com.google.android.gms"); } catch (PackageManager.NameNotFoundException unused) { return null; } } public static boolean honorsDebugCertificates(Context context) { try { if (!zzaj) { PackageInfo b = Wrappers.a(context).b("com.google.android.gms", 64); GoogleSignatureVerifier.a(context); if (b == null || GoogleSignatureVerifier.a(b, false) || !GoogleSignatureVerifier.a(b, true)) { zzai = false; } else { zzai = true; } } } catch (PackageManager.NameNotFoundException e) { Log.w("GooglePlayServicesUtil", "Cannot find Google Play services package name.", e); } finally { zzaj = true; } return zzai || !DeviceProperties.a(); } @Deprecated public static int isGooglePlayServicesAvailable(Context context) { return isGooglePlayServicesAvailable(context, GOOGLE_PLAY_SERVICES_VERSION_CODE); } @Deprecated public static boolean isGooglePlayServicesUid(Context context, int i) { return UidVerifier.a(context, i); } @Deprecated public static boolean isPlayServicesPossiblyUpdating(Context context, int i) { if (i == 18) { return true; } if (i == 1) { return isUninstalledAppPossiblyUpdating(context, "com.google.android.gms"); } return false; } @Deprecated public static boolean isPlayStorePossiblyUpdating(Context context, int i) { if (i == 9) { return isUninstalledAppPossiblyUpdating(context, "com.android.vending"); } return false; } @TargetApi(18) public static boolean isRestrictedUserProfile(Context context) { Bundle applicationRestrictions; return PlatformVersion.d() && (applicationRestrictions = ((UserManager) context.getSystemService("user")).getApplicationRestrictions(context.getPackageName())) != null && "true".equals(applicationRestrictions.getString("restricted_profile")); } @Deprecated public static boolean isSidewinderDevice(Context context) { return DeviceProperties.a(context); } @TargetApi(21) static boolean isUninstalledAppPossiblyUpdating(Context context, String str) { ApplicationInfo applicationInfo; boolean equals = str.equals("com.google.android.gms"); if (PlatformVersion.g()) { try { Iterator it = context.getPackageManager().getPackageInstaller().getAllSessions().iterator(); while (it.hasNext()) { if (str.equals(it.next().getAppPackageName())) { return true; } } } catch (Exception unused) { return false; } } try { applicationInfo = context.getPackageManager().getApplicationInfo(str, UnityActivity.BLOCKLY_TYPE_NONE); } catch (PackageManager.NameNotFoundException unused2) { } return equals ? applicationInfo.enabled : applicationInfo.enabled && !isRestrictedUserProfile(context); } @Deprecated public static boolean isUserRecoverableError(int i) { return i == 1 || i == 2 || i == 3 || i == 9; } @TargetApi(19) @Deprecated public static boolean uidHasPackageName(Context context, int i, String str) { return UidVerifier.a(context, i, str); } private static int zza(Context context, boolean z, int i) { Preconditions.a(i >= 0); PackageManager packageManager = context.getPackageManager(); PackageInfo packageInfo = null; if (z) { try { packageInfo = packageManager.getPackageInfo("com.android.vending", 8256); } catch (PackageManager.NameNotFoundException unused) { Log.w("GooglePlayServicesUtil", "Google Play Store is missing."); return 9; } } try { PackageInfo packageInfo2 = packageManager.getPackageInfo("com.google.android.gms", 64); GoogleSignatureVerifier.a(context); if (!GoogleSignatureVerifier.a(packageInfo2, true)) { Log.w("GooglePlayServicesUtil", "Google Play services signature invalid."); return 9; } if (z && (!GoogleSignatureVerifier.a(packageInfo, true) || !packageInfo.signatures[0].equals(packageInfo2.signatures[0]))) { Log.w("GooglePlayServicesUtil", "Google Play Store signature invalid."); return 9; } if (com.google.android.gms.common.util.zzb.a(packageInfo2.versionCode) >= com.google.android.gms.common.util.zzb.a(i)) { ApplicationInfo applicationInfo = packageInfo2.applicationInfo; if (applicationInfo == null) { try { applicationInfo = packageManager.getApplicationInfo("com.google.android.gms", 0); } catch (PackageManager.NameNotFoundException e) { Log.wtf("GooglePlayServicesUtil", "Google Play services missing when getting application info.", e); return 1; } } return !applicationInfo.enabled ? 3 : 0; } int i2 = packageInfo2.versionCode; StringBuilder sb = new StringBuilder(77); sb.append("Google Play services out of date. Requires "); sb.append(i); sb.append(" but found "); sb.append(i2); Log.w("GooglePlayServicesUtil", sb.toString()); return 2; } catch (PackageManager.NameNotFoundException unused2) { Log.w("GooglePlayServicesUtil", "Google Play services is missing."); return 1; } } @Deprecated public static int isGooglePlayServicesAvailable(Context context, int i) { 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()) && !zzak.get()) { int b = zzp.b(context); if (b == 0) { throw new IllegalStateException("A required meta-data tag in your app's AndroidManifest.xml does not exist. You must have the following declaration within the element: "); } int i2 = GOOGLE_PLAY_SERVICES_VERSION_CODE; if (b != i2) { StringBuilder sb = new StringBuilder(320); sb.append("The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected "); sb.append(i2); sb.append(" but found "); sb.append(b); sb.append(". You must have the following declaration within the element: "); throw new IllegalStateException(sb.toString()); } } return zza(context, (DeviceProperties.c(context) || DeviceProperties.d(context)) ? false : true, i); } }