Initial commit
This commit is contained in:
81
sources/com/yanzhenjie/permission/runtime/LRequest.java
Normal file
81
sources/com/yanzhenjie/permission/runtime/LRequest.java
Normal file
@@ -0,0 +1,81 @@
|
||||
package com.yanzhenjie.permission.runtime;
|
||||
|
||||
import com.yanzhenjie.permission.Action;
|
||||
import com.yanzhenjie.permission.checker.PermissionChecker;
|
||||
import com.yanzhenjie.permission.checker.StrictChecker;
|
||||
import com.yanzhenjie.permission.source.Source;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class LRequest implements PermissionRequest {
|
||||
private static final PermissionChecker e = new StrictChecker();
|
||||
private Source a;
|
||||
private String[] b;
|
||||
private Action<List<String>> c;
|
||||
private Action<List<String>> d;
|
||||
|
||||
LRequest(Source source) {
|
||||
this.a = source;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.runtime.PermissionRequest
|
||||
public PermissionRequest a(String... strArr) {
|
||||
this.b = strArr;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.runtime.PermissionRequest
|
||||
public PermissionRequest b(Action<List<String>> action) {
|
||||
this.d = action;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.runtime.PermissionRequest
|
||||
public void start() {
|
||||
List<String> a = a(this.a, this.b);
|
||||
if (a.isEmpty()) {
|
||||
a();
|
||||
} else {
|
||||
a(a);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.runtime.PermissionRequest
|
||||
public PermissionRequest a(Action<List<String>> action) {
|
||||
this.c = action;
|
||||
return this;
|
||||
}
|
||||
|
||||
private void a() {
|
||||
if (this.c != null) {
|
||||
List<String> asList = Arrays.asList(this.b);
|
||||
try {
|
||||
this.c.a(asList);
|
||||
} catch (Exception unused) {
|
||||
Action<List<String>> action = this.d;
|
||||
if (action != null) {
|
||||
action.a(asList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void a(List<String> list) {
|
||||
Action<List<String>> action = this.d;
|
||||
if (action != null) {
|
||||
action.a(list);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> a(Source source, String... strArr) {
|
||||
ArrayList arrayList = new ArrayList(1);
|
||||
for (String str : strArr) {
|
||||
if (!e.a(source.a(), str)) {
|
||||
arrayList.add(str);
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package com.yanzhenjie.permission.runtime;
|
||||
|
||||
import com.yanzhenjie.permission.runtime.Runtime;
|
||||
import com.yanzhenjie.permission.source.Source;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class LRequestFactory implements Runtime.PermissionRequestFactory {
|
||||
@Override // com.yanzhenjie.permission.runtime.Runtime.PermissionRequestFactory
|
||||
public PermissionRequest a(Source source) {
|
||||
return new LRequest(source);
|
||||
}
|
||||
}
|
140
sources/com/yanzhenjie/permission/runtime/MRequest.java
Normal file
140
sources/com/yanzhenjie/permission/runtime/MRequest.java
Normal file
@@ -0,0 +1,140 @@
|
||||
package com.yanzhenjie.permission.runtime;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import com.yanzhenjie.permission.Action;
|
||||
import com.yanzhenjie.permission.PermissionActivity;
|
||||
import com.yanzhenjie.permission.Rationale;
|
||||
import com.yanzhenjie.permission.RequestExecutor;
|
||||
import com.yanzhenjie.permission.checker.DoubleChecker;
|
||||
import com.yanzhenjie.permission.checker.PermissionChecker;
|
||||
import com.yanzhenjie.permission.checker.StandardChecker;
|
||||
import com.yanzhenjie.permission.source.Source;
|
||||
import com.yanzhenjie.permission.util.MainExecutor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class MRequest implements PermissionRequest, RequestExecutor, PermissionActivity.RequestListener {
|
||||
private static final MainExecutor g = new MainExecutor();
|
||||
private static final PermissionChecker h = new StandardChecker();
|
||||
private static final PermissionChecker i = new DoubleChecker();
|
||||
private Source a;
|
||||
private String[] b;
|
||||
private Rationale<List<String>> c = new Rationale<List<String>>(this) { // from class: com.yanzhenjie.permission.runtime.MRequest.1
|
||||
@Override // com.yanzhenjie.permission.Rationale
|
||||
public void a(Context context, List<String> list, RequestExecutor requestExecutor) {
|
||||
requestExecutor.execute();
|
||||
}
|
||||
};
|
||||
private Action<List<String>> d;
|
||||
private Action<List<String>> e;
|
||||
private String[] f;
|
||||
|
||||
MRequest(Source source) {
|
||||
this.a = source;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void c() {
|
||||
List<String> a = a(i, this.a, this.b);
|
||||
if (a.isEmpty()) {
|
||||
b();
|
||||
} else {
|
||||
a(a);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.runtime.PermissionRequest
|
||||
public PermissionRequest b(Action<List<String>> action) {
|
||||
this.e = action;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.RequestExecutor
|
||||
public void execute() {
|
||||
PermissionActivity.a(this.a.a(), this.f, this);
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.runtime.PermissionRequest
|
||||
public void start() {
|
||||
List<String> a = a(h, this.a, this.b);
|
||||
this.f = (String[]) a.toArray(new String[a.size()]);
|
||||
String[] strArr = this.f;
|
||||
if (strArr.length <= 0) {
|
||||
c();
|
||||
return;
|
||||
}
|
||||
List<String> a2 = a(this.a, strArr);
|
||||
if (a2.size() > 0) {
|
||||
this.c.a(this.a.a(), a2, this);
|
||||
} else {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
private void b() {
|
||||
if (this.d != null) {
|
||||
List<String> asList = Arrays.asList(this.b);
|
||||
try {
|
||||
this.d.a(asList);
|
||||
} catch (Exception e) {
|
||||
Log.e("AndPermission", "Please check the onGranted() method body for bugs.", e);
|
||||
Action<List<String>> action = this.e;
|
||||
if (action != null) {
|
||||
action.a(asList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.runtime.PermissionRequest
|
||||
public PermissionRequest a(String... strArr) {
|
||||
this.b = strArr;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.runtime.PermissionRequest
|
||||
public PermissionRequest a(Action<List<String>> action) {
|
||||
this.d = action;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.PermissionActivity.RequestListener
|
||||
public void a() {
|
||||
g.a(new Runnable() { // from class: com.yanzhenjie.permission.runtime.MRequest.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
MRequest.this.c();
|
||||
}
|
||||
}, 100L);
|
||||
}
|
||||
|
||||
private void a(List<String> list) {
|
||||
Action<List<String>> action = this.e;
|
||||
if (action != null) {
|
||||
action.a(list);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> a(PermissionChecker permissionChecker, Source source, String... strArr) {
|
||||
ArrayList arrayList = new ArrayList(1);
|
||||
for (String str : strArr) {
|
||||
if (!permissionChecker.a(source.a(), str)) {
|
||||
arrayList.add(str);
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
private static List<String> a(Source source, String... strArr) {
|
||||
ArrayList arrayList = new ArrayList(1);
|
||||
for (String str : strArr) {
|
||||
if (source.a(str)) {
|
||||
arrayList.add(str);
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package com.yanzhenjie.permission.runtime;
|
||||
|
||||
import com.yanzhenjie.permission.runtime.Runtime;
|
||||
import com.yanzhenjie.permission.source.Source;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class MRequestFactory implements Runtime.PermissionRequestFactory {
|
||||
@Override // com.yanzhenjie.permission.runtime.Runtime.PermissionRequestFactory
|
||||
public PermissionRequest a(Source source) {
|
||||
return new MRequest(source);
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package com.yanzhenjie.permission.runtime;
|
||||
|
||||
import com.yanzhenjie.permission.Action;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface PermissionRequest {
|
||||
PermissionRequest a(Action<List<String>> action);
|
||||
|
||||
PermissionRequest a(String... strArr);
|
||||
|
||||
PermissionRequest b(Action<List<String>> action);
|
||||
|
||||
void start();
|
||||
}
|
70
sources/com/yanzhenjie/permission/runtime/Runtime.java
Normal file
70
sources/com/yanzhenjie/permission/runtime/Runtime.java
Normal file
@@ -0,0 +1,70 @@
|
||||
package com.yanzhenjie.permission.runtime;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import com.ubt.jimu.base.util.FileUtil;
|
||||
import com.yanzhenjie.permission.Setting;
|
||||
import com.yanzhenjie.permission.runtime.setting.RuntimeSetting;
|
||||
import com.yanzhenjie.permission.source.Source;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Runtime {
|
||||
private static final PermissionRequestFactory b;
|
||||
private static List<String> c;
|
||||
private Source a;
|
||||
|
||||
public interface PermissionRequestFactory {
|
||||
PermissionRequest a(Source source);
|
||||
}
|
||||
|
||||
static {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
b = new MRequestFactory();
|
||||
} else {
|
||||
b = new LRequestFactory();
|
||||
}
|
||||
}
|
||||
|
||||
public Runtime(Source source) {
|
||||
this.a = source;
|
||||
}
|
||||
|
||||
private void b(String... strArr) {
|
||||
if (c == null) {
|
||||
c = a(this.a.a());
|
||||
}
|
||||
if (strArr == null || strArr.length == 0) {
|
||||
throw new IllegalArgumentException("Please enter at least one permission.");
|
||||
}
|
||||
for (String str : strArr) {
|
||||
if (!c.contains(str)) {
|
||||
throw new IllegalStateException(String.format("The permission %1$s is not registered in manifest.xml", str));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PermissionRequest a(String... strArr) {
|
||||
b(strArr);
|
||||
return b.a(this.a).a(strArr);
|
||||
}
|
||||
|
||||
public Setting a() {
|
||||
return new RuntimeSetting(this.a);
|
||||
}
|
||||
|
||||
private static List<String> a(Context context) {
|
||||
try {
|
||||
String[] strArr = context.getPackageManager().getPackageInfo(context.getPackageName(), FileUtil.ZIP_BUFFER_SIZE).requestedPermissions;
|
||||
if (strArr != null && strArr.length != 0) {
|
||||
return Collections.unmodifiableList(Arrays.asList(strArr));
|
||||
}
|
||||
throw new IllegalStateException("You did not register any permissions in the manifest.xml.");
|
||||
} catch (PackageManager.NameNotFoundException unused) {
|
||||
throw new AssertionError("Package name cannot be found.");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
package com.yanzhenjie.permission.runtime.setting;
|
||||
|
||||
import com.yanzhenjie.permission.PermissionActivity;
|
||||
import com.yanzhenjie.permission.Setting;
|
||||
import com.yanzhenjie.permission.source.Source;
|
||||
import com.yanzhenjie.permission.util.MainExecutor;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class RuntimeSetting implements Setting, PermissionActivity.RequestListener {
|
||||
private static final MainExecutor c = new MainExecutor();
|
||||
private Source a;
|
||||
private Setting.Action b;
|
||||
|
||||
public RuntimeSetting(Source source) {
|
||||
this.a = source;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.Setting
|
||||
public void start() {
|
||||
PermissionActivity.a(this.a.a(), this);
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.Setting
|
||||
public Setting a(Setting.Action action) {
|
||||
this.b = action;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.PermissionActivity.RequestListener
|
||||
public void a() {
|
||||
c.a(new Runnable() { // from class: com.yanzhenjie.permission.runtime.setting.RuntimeSetting.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (RuntimeSetting.this.b != null) {
|
||||
RuntimeSetting.this.b.a();
|
||||
}
|
||||
}
|
||||
}, 100L);
|
||||
}
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
package com.yanzhenjie.permission.runtime.setting;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import com.ubt.jimu.base.entities.Constant;
|
||||
import com.yanzhenjie.permission.source.Source;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class RuntimeSettingPage {
|
||||
private static final String b = Build.MANUFACTURER.toLowerCase();
|
||||
private Source a;
|
||||
|
||||
public RuntimeSettingPage(Source source) {
|
||||
this.a = source;
|
||||
}
|
||||
|
||||
private static Intent b(Context context) {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
return a(context);
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.permissionmanager.ui.MainActivity"));
|
||||
return intent;
|
||||
}
|
||||
|
||||
private static Intent c(Context context) {
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
return a(context);
|
||||
}
|
||||
Intent intent = new Intent("com.meizu.safe.security.SHOW_APPSEC");
|
||||
intent.putExtra(Constant.SelectRobot.PACKAGE_NAME_KEY, context.getPackageName());
|
||||
intent.setComponent(new ComponentName("com.meizu.safe", "com.meizu.safe.security.AppSecActivity"));
|
||||
return intent;
|
||||
}
|
||||
|
||||
private static Intent d(Context context) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(Constant.SelectRobot.PACKAGE_NAME_KEY, context.getPackageName());
|
||||
intent.setComponent(new ComponentName("com.color.safecenter", "com.color.safecenter.permission.PermissionManagerActivity"));
|
||||
return intent;
|
||||
}
|
||||
|
||||
private static Intent e(Context context) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("packagename", context.getPackageName());
|
||||
intent.setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.SoftPermissionDetailActivity"));
|
||||
if (a(context, intent)) {
|
||||
return intent;
|
||||
}
|
||||
intent.setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.safeguard.SoftPermissionDetailActivity"));
|
||||
return intent;
|
||||
}
|
||||
|
||||
private static Intent f(Context context) {
|
||||
Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
|
||||
intent.putExtra("extra_pkgname", context.getPackageName());
|
||||
return intent;
|
||||
}
|
||||
|
||||
public void a(int i) {
|
||||
try {
|
||||
this.a.a(b.contains("huawei") ? b(this.a.a()) : b.contains("xiaomi") ? f(this.a.a()) : b.contains("oppo") ? d(this.a.a()) : b.contains("vivo") ? e(this.a.a()) : b.contains("meizu") ? c(this.a.a()) : a(this.a.a()), i);
|
||||
} catch (Exception unused) {
|
||||
this.a.a(a(this.a.a()), i);
|
||||
}
|
||||
}
|
||||
|
||||
private static Intent a(Context context) {
|
||||
Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
|
||||
intent.setData(Uri.fromParts("package", context.getPackageName(), null));
|
||||
return intent;
|
||||
}
|
||||
|
||||
private static boolean a(Context context, Intent intent) {
|
||||
return context.getPackageManager().queryIntentActivities(intent, 65536).size() > 0;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user