317 lines
14 KiB
Java
317 lines
14 KiB
Java
|
package com.google.android.gms.common.util;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.content.pm.ApplicationInfo;
|
||
|
import android.content.pm.PackageManager;
|
||
|
import android.os.Process;
|
||
|
import android.os.WorkSource;
|
||
|
import com.google.android.gms.common.internal.Preconditions;
|
||
|
import com.google.android.gms.common.wrappers.Wrappers;
|
||
|
import java.lang.reflect.Method;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.List;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public class WorkSourceUtil {
|
||
|
private static final int zza = Process.myUid();
|
||
|
private static final Method zzb;
|
||
|
private static final Method zzc;
|
||
|
private static final Method zzd;
|
||
|
private static final Method zze;
|
||
|
private static final Method zzf;
|
||
|
private static final Method zzg;
|
||
|
private static final Method zzh;
|
||
|
private static final Method zzi;
|
||
|
|
||
|
/* JADX WARN: Can't wrap try/catch for region: R(25:1|2|3|4|(21:47|48|7|8|9|10|11|12|13|(12:39|40|16|(9:35|36|19|(6:31|32|22|(2:27|28)|24|25)|21|22|(0)|24|25)|18|19|(0)|21|22|(0)|24|25)|15|16|(0)|18|19|(0)|21|22|(0)|24|25)|6|7|8|9|10|11|12|13|(0)|15|16|(0)|18|19|(0)|21|22|(0)|24|25) */
|
||
|
/* JADX WARN: Code restructure failed: missing block: B:44:0x0053, code lost:
|
||
|
|
||
|
r0 = null;
|
||
|
*/
|
||
|
/* JADX WARN: Code restructure failed: missing block: B:46:0x0041, code lost:
|
||
|
|
||
|
r0 = null;
|
||
|
*/
|
||
|
/* JADX WARN: Removed duplicated region for block: B:27:0x00a8 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:31:0x0088 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:35:0x0074 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:39:0x005c A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
||
|
static {
|
||
|
/*
|
||
|
java.lang.String r0 = "add"
|
||
|
int r1 = android.os.Process.myUid()
|
||
|
com.google.android.gms.common.util.WorkSourceUtil.zza = r1
|
||
|
r1 = 1
|
||
|
r2 = 0
|
||
|
r3 = 0
|
||
|
java.lang.Class[] r4 = new java.lang.Class[r1] // Catch: java.lang.Exception -> L18
|
||
|
java.lang.Class r5 = java.lang.Integer.TYPE // Catch: java.lang.Exception -> L18
|
||
|
r4[r2] = r5 // Catch: java.lang.Exception -> L18
|
||
|
java.lang.Class<android.os.WorkSource> r5 = android.os.WorkSource.class
|
||
|
java.lang.reflect.Method r4 = r5.getMethod(r0, r4) // Catch: java.lang.Exception -> L18
|
||
|
goto L19
|
||
|
L18:
|
||
|
r4 = r3
|
||
|
L19:
|
||
|
com.google.android.gms.common.util.WorkSourceUtil.zzb = r4
|
||
|
boolean r4 = com.google.android.gms.common.util.PlatformVersion.isAtLeastJellyBeanMR2()
|
||
|
r5 = 2
|
||
|
if (r4 == 0) goto L33
|
||
|
java.lang.Class[] r4 = new java.lang.Class[r5] // Catch: java.lang.Exception -> L33
|
||
|
java.lang.Class r6 = java.lang.Integer.TYPE // Catch: java.lang.Exception -> L33
|
||
|
r4[r2] = r6 // Catch: java.lang.Exception -> L33
|
||
|
java.lang.Class<java.lang.String> r6 = java.lang.String.class
|
||
|
r4[r1] = r6 // Catch: java.lang.Exception -> L33
|
||
|
java.lang.Class<android.os.WorkSource> r6 = android.os.WorkSource.class
|
||
|
java.lang.reflect.Method r0 = r6.getMethod(r0, r4) // Catch: java.lang.Exception -> L33
|
||
|
goto L34
|
||
|
L33:
|
||
|
r0 = r3
|
||
|
L34:
|
||
|
com.google.android.gms.common.util.WorkSourceUtil.zzc = r0
|
||
|
java.lang.Class[] r0 = new java.lang.Class[r2] // Catch: java.lang.Exception -> L41
|
||
|
java.lang.Class<android.os.WorkSource> r4 = android.os.WorkSource.class
|
||
|
java.lang.String r6 = "size"
|
||
|
java.lang.reflect.Method r0 = r4.getMethod(r6, r0) // Catch: java.lang.Exception -> L41
|
||
|
goto L42
|
||
|
L41:
|
||
|
r0 = r3
|
||
|
L42:
|
||
|
com.google.android.gms.common.util.WorkSourceUtil.zzd = r0
|
||
|
java.lang.Class[] r0 = new java.lang.Class[r1] // Catch: java.lang.Exception -> L53
|
||
|
java.lang.Class r4 = java.lang.Integer.TYPE // Catch: java.lang.Exception -> L53
|
||
|
r0[r2] = r4 // Catch: java.lang.Exception -> L53
|
||
|
java.lang.Class<android.os.WorkSource> r4 = android.os.WorkSource.class
|
||
|
java.lang.String r6 = "get"
|
||
|
java.lang.reflect.Method r0 = r4.getMethod(r6, r0) // Catch: java.lang.Exception -> L53
|
||
|
goto L54
|
||
|
L53:
|
||
|
r0 = r3
|
||
|
L54:
|
||
|
com.google.android.gms.common.util.WorkSourceUtil.zze = r0
|
||
|
boolean r0 = com.google.android.gms.common.util.PlatformVersion.isAtLeastJellyBeanMR2()
|
||
|
if (r0 == 0) goto L6b
|
||
|
java.lang.Class[] r0 = new java.lang.Class[r1] // Catch: java.lang.Exception -> L6b
|
||
|
java.lang.Class r4 = java.lang.Integer.TYPE // Catch: java.lang.Exception -> L6b
|
||
|
r0[r2] = r4 // Catch: java.lang.Exception -> L6b
|
||
|
java.lang.Class<android.os.WorkSource> r4 = android.os.WorkSource.class
|
||
|
java.lang.String r6 = "getName"
|
||
|
java.lang.reflect.Method r0 = r4.getMethod(r6, r0) // Catch: java.lang.Exception -> L6b
|
||
|
goto L6c
|
||
|
L6b:
|
||
|
r0 = r3
|
||
|
L6c:
|
||
|
com.google.android.gms.common.util.WorkSourceUtil.zzf = r0
|
||
|
boolean r0 = com.google.android.gms.common.util.PlatformVersion.isAtLeastP()
|
||
|
if (r0 == 0) goto L7f
|
||
|
java.lang.Class[] r0 = new java.lang.Class[r2] // Catch: java.lang.Exception -> L7f
|
||
|
java.lang.Class<android.os.WorkSource> r4 = android.os.WorkSource.class
|
||
|
java.lang.String r6 = "createWorkChain"
|
||
|
java.lang.reflect.Method r0 = r4.getMethod(r6, r0) // Catch: java.lang.Exception -> L7f
|
||
|
goto L80
|
||
|
L7f:
|
||
|
r0 = r3
|
||
|
L80:
|
||
|
com.google.android.gms.common.util.WorkSourceUtil.zzg = r0
|
||
|
boolean r0 = com.google.android.gms.common.util.PlatformVersion.isAtLeastP()
|
||
|
if (r0 == 0) goto L9f
|
||
|
java.lang.String r0 = "android.os.WorkSource$WorkChain"
|
||
|
java.lang.Class r0 = java.lang.Class.forName(r0) // Catch: java.lang.Exception -> L9f
|
||
|
java.lang.Class[] r4 = new java.lang.Class[r5] // Catch: java.lang.Exception -> L9f
|
||
|
java.lang.Class r5 = java.lang.Integer.TYPE // Catch: java.lang.Exception -> L9f
|
||
|
r4[r2] = r5 // Catch: java.lang.Exception -> L9f
|
||
|
java.lang.Class<java.lang.String> r5 = java.lang.String.class
|
||
|
r4[r1] = r5 // Catch: java.lang.Exception -> L9f
|
||
|
java.lang.String r5 = "addNode"
|
||
|
java.lang.reflect.Method r0 = r0.getMethod(r5, r4) // Catch: java.lang.Exception -> L9f
|
||
|
goto La0
|
||
|
L9f:
|
||
|
r0 = r3
|
||
|
La0:
|
||
|
com.google.android.gms.common.util.WorkSourceUtil.zzh = r0
|
||
|
boolean r0 = com.google.android.gms.common.util.PlatformVersion.isAtLeastP()
|
||
|
if (r0 == 0) goto Lb5
|
||
|
java.lang.Class[] r0 = new java.lang.Class[r2] // Catch: java.lang.Exception -> Lb5
|
||
|
java.lang.Class<android.os.WorkSource> r2 = android.os.WorkSource.class
|
||
|
java.lang.String r4 = "isEmpty"
|
||
|
java.lang.reflect.Method r3 = r2.getMethod(r4, r0) // Catch: java.lang.Exception -> Lb5
|
||
|
r3.setAccessible(r1) // Catch: java.lang.Exception -> Lb5
|
||
|
Lb5:
|
||
|
com.google.android.gms.common.util.WorkSourceUtil.zzi = r3
|
||
|
return
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.common.util.WorkSourceUtil.<clinit>():void");
|
||
|
}
|
||
|
|
||
|
public static void add(WorkSource workSource, int i, String str) {
|
||
|
Method method = zzc;
|
||
|
if (method != null) {
|
||
|
if (str == null) {
|
||
|
str = "";
|
||
|
}
|
||
|
try {
|
||
|
method.invoke(workSource, Integer.valueOf(i), str);
|
||
|
return;
|
||
|
} catch (Exception unused) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
Method method2 = zzb;
|
||
|
if (method2 != null) {
|
||
|
try {
|
||
|
method2.invoke(workSource, Integer.valueOf(i));
|
||
|
} catch (Exception unused2) {
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static WorkSource fromPackage(Context context, String str) {
|
||
|
if (context == null || context.getPackageManager() == null || str == null) {
|
||
|
return null;
|
||
|
}
|
||
|
try {
|
||
|
ApplicationInfo applicationInfo = Wrappers.packageManager(context).getApplicationInfo(str, 0);
|
||
|
if (applicationInfo == null) {
|
||
|
return null;
|
||
|
}
|
||
|
int i = applicationInfo.uid;
|
||
|
WorkSource workSource = new WorkSource();
|
||
|
add(workSource, i, str);
|
||
|
return workSource;
|
||
|
} catch (PackageManager.NameNotFoundException unused) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Removed duplicated region for block: B:13:0x001e A[RETURN] */
|
||
|
/* JADX WARN: Removed duplicated region for block: B:15:0x001f */
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
public static android.os.WorkSource fromPackageAndModuleExperimentalPi(android.content.Context r8, java.lang.String r9, java.lang.String r10) {
|
||
|
/*
|
||
|
r0 = 0
|
||
|
if (r8 == 0) goto L56
|
||
|
android.content.pm.PackageManager r1 = r8.getPackageManager()
|
||
|
if (r1 == 0) goto L56
|
||
|
if (r10 == 0) goto L56
|
||
|
if (r9 == 0) goto L56
|
||
|
r1 = 0
|
||
|
com.google.android.gms.common.wrappers.PackageManagerWrapper r8 = com.google.android.gms.common.wrappers.Wrappers.packageManager(r8) // Catch: android.content.pm.PackageManager.NameNotFoundException -> L1b
|
||
|
android.content.pm.ApplicationInfo r8 = r8.getApplicationInfo(r9, r1) // Catch: android.content.pm.PackageManager.NameNotFoundException -> L1b
|
||
|
if (r8 == 0) goto L1b
|
||
|
int r8 = r8.uid
|
||
|
goto L1c
|
||
|
L1b:
|
||
|
r8 = -1
|
||
|
L1c:
|
||
|
if (r8 >= 0) goto L1f
|
||
|
return r0
|
||
|
L1f:
|
||
|
android.os.WorkSource r0 = new android.os.WorkSource
|
||
|
r0.<init>()
|
||
|
java.lang.reflect.Method r2 = com.google.android.gms.common.util.WorkSourceUtil.zzg
|
||
|
if (r2 == 0) goto L53
|
||
|
java.lang.reflect.Method r3 = com.google.android.gms.common.util.WorkSourceUtil.zzh
|
||
|
if (r3 == 0) goto L53
|
||
|
java.lang.Object[] r4 = new java.lang.Object[r1] // Catch: java.lang.Exception -> L56
|
||
|
java.lang.Object r2 = r2.invoke(r0, r4) // Catch: java.lang.Exception -> L56
|
||
|
int r4 = com.google.android.gms.common.util.WorkSourceUtil.zza // Catch: java.lang.Exception -> L56
|
||
|
r5 = 1
|
||
|
r6 = 2
|
||
|
if (r8 == r4) goto L45
|
||
|
java.lang.Object[] r7 = new java.lang.Object[r6] // Catch: java.lang.Exception -> L56
|
||
|
java.lang.Integer r8 = java.lang.Integer.valueOf(r8) // Catch: java.lang.Exception -> L56
|
||
|
r7[r1] = r8 // Catch: java.lang.Exception -> L56
|
||
|
r7[r5] = r9 // Catch: java.lang.Exception -> L56
|
||
|
r3.invoke(r2, r7) // Catch: java.lang.Exception -> L56
|
||
|
L45:
|
||
|
java.lang.Object[] r8 = new java.lang.Object[r6] // Catch: java.lang.Exception -> L56
|
||
|
java.lang.Integer r9 = java.lang.Integer.valueOf(r4) // Catch: java.lang.Exception -> L56
|
||
|
r8[r1] = r9 // Catch: java.lang.Exception -> L56
|
||
|
r8[r5] = r10 // Catch: java.lang.Exception -> L56
|
||
|
r3.invoke(r2, r8) // Catch: java.lang.Exception -> L56
|
||
|
goto L56
|
||
|
L53:
|
||
|
add(r0, r8, r9)
|
||
|
L56:
|
||
|
return r0
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.common.util.WorkSourceUtil.fromPackageAndModuleExperimentalPi(android.content.Context, java.lang.String, java.lang.String):android.os.WorkSource");
|
||
|
}
|
||
|
|
||
|
public static int get(WorkSource workSource, int i) {
|
||
|
Method method = zze;
|
||
|
if (method != null) {
|
||
|
try {
|
||
|
Object invoke = method.invoke(workSource, Integer.valueOf(i));
|
||
|
Preconditions.checkNotNull(invoke);
|
||
|
return ((Integer) invoke).intValue();
|
||
|
} catch (Exception unused) {
|
||
|
}
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
public static String getName(WorkSource workSource, int i) {
|
||
|
Method method = zzf;
|
||
|
if (method == null) {
|
||
|
return null;
|
||
|
}
|
||
|
try {
|
||
|
return (String) method.invoke(workSource, Integer.valueOf(i));
|
||
|
} catch (Exception unused) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static List<String> getNames(WorkSource workSource) {
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
int size = workSource == null ? 0 : size(workSource);
|
||
|
if (size != 0) {
|
||
|
for (int i = 0; i < size; i++) {
|
||
|
String name = getName(workSource, i);
|
||
|
if (!Strings.isEmptyOrWhitespace(name)) {
|
||
|
Preconditions.checkNotNull(name);
|
||
|
arrayList.add(name);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
public static boolean hasWorkSourcePermission(Context context) {
|
||
|
return (context == null || context.getPackageManager() == null || Wrappers.packageManager(context).checkPermission("android.permission.UPDATE_DEVICE_STATS", context.getPackageName()) != 0) ? false : true;
|
||
|
}
|
||
|
|
||
|
public static boolean isEmpty(WorkSource workSource) {
|
||
|
Method method = zzi;
|
||
|
if (method != null) {
|
||
|
try {
|
||
|
Object invoke = method.invoke(workSource, new Object[0]);
|
||
|
Preconditions.checkNotNull(invoke);
|
||
|
return ((Boolean) invoke).booleanValue();
|
||
|
} catch (Exception unused) {
|
||
|
}
|
||
|
}
|
||
|
return size(workSource) == 0;
|
||
|
}
|
||
|
|
||
|
public static int size(WorkSource workSource) {
|
||
|
Method method = zzd;
|
||
|
if (method != null) {
|
||
|
try {
|
||
|
Object invoke = method.invoke(workSource, new Object[0]);
|
||
|
Preconditions.checkNotNull(invoke);
|
||
|
return ((Integer) invoke).intValue();
|
||
|
} catch (Exception unused) {
|
||
|
}
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
private WorkSourceUtil() {
|
||
|
}
|
||
|
}
|