77 lines
2.5 KiB
Java
77 lines
2.5 KiB
Java
package com.google.android.gms.common.wrappers;
|
|
|
|
import android.annotation.TargetApi;
|
|
import android.app.AppOpsManager;
|
|
import android.content.Context;
|
|
import android.content.pm.ApplicationInfo;
|
|
import android.content.pm.PackageInfo;
|
|
import android.content.pm.PackageManager;
|
|
import android.os.Binder;
|
|
import android.os.Process;
|
|
import com.google.android.gms.common.util.PlatformVersion;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class PackageManagerWrapper {
|
|
private final Context a;
|
|
|
|
public PackageManagerWrapper(Context context) {
|
|
this.a = context;
|
|
}
|
|
|
|
public ApplicationInfo a(String str, int i) throws PackageManager.NameNotFoundException {
|
|
return this.a.getPackageManager().getApplicationInfo(str, i);
|
|
}
|
|
|
|
public PackageInfo b(String str, int i) throws PackageManager.NameNotFoundException {
|
|
return this.a.getPackageManager().getPackageInfo(str, i);
|
|
}
|
|
|
|
public final PackageInfo a(String str, int i, int i2) throws PackageManager.NameNotFoundException {
|
|
return this.a.getPackageManager().getPackageInfo(str, 64);
|
|
}
|
|
|
|
public CharSequence b(String str) throws PackageManager.NameNotFoundException {
|
|
return this.a.getPackageManager().getApplicationLabel(this.a.getPackageManager().getApplicationInfo(str, 0));
|
|
}
|
|
|
|
public final String[] a(int i) {
|
|
return this.a.getPackageManager().getPackagesForUid(i);
|
|
}
|
|
|
|
@TargetApi(19)
|
|
public final boolean a(int i, String str) {
|
|
if (PlatformVersion.e()) {
|
|
try {
|
|
((AppOpsManager) this.a.getSystemService("appops")).checkPackage(i, str);
|
|
return true;
|
|
} catch (SecurityException unused) {
|
|
return false;
|
|
}
|
|
}
|
|
String[] packagesForUid = this.a.getPackageManager().getPackagesForUid(i);
|
|
if (str != null && packagesForUid != null) {
|
|
for (String str2 : packagesForUid) {
|
|
if (str.equals(str2)) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public int a(String str) {
|
|
return this.a.checkCallingOrSelfPermission(str);
|
|
}
|
|
|
|
public boolean a() {
|
|
String nameForUid;
|
|
if (Binder.getCallingUid() == Process.myUid()) {
|
|
return InstantApps.a(this.a);
|
|
}
|
|
if (!PlatformVersion.i() || (nameForUid = this.a.getPackageManager().getNameForUid(Binder.getCallingUid())) == null) {
|
|
return false;
|
|
}
|
|
return this.a.getPackageManager().isInstantApp(nameForUid);
|
|
}
|
|
}
|