Initial commit
This commit is contained in:
6
sources/com/yanzhenjie/permission/Action.java
Normal file
6
sources/com/yanzhenjie/permission/Action.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.yanzhenjie.permission;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface Action<T> {
|
||||
void a(T t);
|
||||
}
|
33
sources/com/yanzhenjie/permission/AndPermission.java
Normal file
33
sources/com/yanzhenjie/permission/AndPermission.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.yanzhenjie.permission;
|
||||
|
||||
import android.content.Context;
|
||||
import com.yanzhenjie.permission.checker.PermissionChecker;
|
||||
import com.yanzhenjie.permission.checker.StandardChecker;
|
||||
import com.yanzhenjie.permission.source.ContextSource;
|
||||
import com.yanzhenjie.permission.source.Source;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class AndPermission {
|
||||
private static final PermissionChecker a = new StandardChecker();
|
||||
|
||||
public static Options a(Context context) {
|
||||
return new Options(new ContextSource(context));
|
||||
}
|
||||
|
||||
public static boolean b(Context context, String... strArr) {
|
||||
return a.a(context, strArr);
|
||||
}
|
||||
|
||||
public static boolean a(Context context, String... strArr) {
|
||||
return a(new ContextSource(context), strArr);
|
||||
}
|
||||
|
||||
private static boolean a(Source source, String... strArr) {
|
||||
for (String str : strArr) {
|
||||
if (!source.a(str)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
265
sources/com/yanzhenjie/permission/FileProvider.java
Normal file
265
sources/com/yanzhenjie/permission/FileProvider.java
Normal file
@@ -0,0 +1,265 @@
|
||||
package com.yanzhenjie.permission;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ProviderInfo;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.database.Cursor;
|
||||
import android.database.MatrixCursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.text.TextUtils;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
||||
import com.unity3d.ads.metadata.MediationMetaData;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class FileProvider extends ContentProvider {
|
||||
private static final String[] b = {"_display_name", "_size"};
|
||||
private static final File c = new File("/");
|
||||
private static final HashMap<String, PathStrategy> d = new HashMap<>();
|
||||
private PathStrategy a;
|
||||
|
||||
interface PathStrategy {
|
||||
File a(Uri uri);
|
||||
}
|
||||
|
||||
private static int a(String str) {
|
||||
if ("r".equals(str)) {
|
||||
return 268435456;
|
||||
}
|
||||
if ("w".equals(str) || "wt".equals(str)) {
|
||||
return 738197504;
|
||||
}
|
||||
if ("wa".equals(str)) {
|
||||
return 704643072;
|
||||
}
|
||||
if ("rw".equals(str)) {
|
||||
return 939524096;
|
||||
}
|
||||
if ("rwt".equals(str)) {
|
||||
return 1006632960;
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid mode: " + str);
|
||||
}
|
||||
|
||||
private static PathStrategy b(Context context, String str) {
|
||||
PathStrategy pathStrategy;
|
||||
synchronized (d) {
|
||||
pathStrategy = d.get(str);
|
||||
if (pathStrategy == null) {
|
||||
try {
|
||||
pathStrategy = c(context, str);
|
||||
d.put(str, pathStrategy);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException("Failed to parse android.support.FILE_PROVIDER_PATHS meta-data", e);
|
||||
} catch (XmlPullParserException e2) {
|
||||
throw new IllegalArgumentException("Failed to parse android.support.FILE_PROVIDER_PATHS meta-data", e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pathStrategy;
|
||||
}
|
||||
|
||||
private static PathStrategy c(Context context, String str) throws IOException, XmlPullParserException {
|
||||
SimplePathStrategy simplePathStrategy = new SimplePathStrategy(str);
|
||||
XmlResourceParser loadXmlMetaData = context.getPackageManager().resolveContentProvider(str, PeripheralType.SERVO).loadXmlMetaData(context.getPackageManager(), "android.support.FILE_PROVIDER_PATHS");
|
||||
if (loadXmlMetaData == null) {
|
||||
throw new IllegalArgumentException("Missing android.support.FILE_PROVIDER_PATHS meta-data");
|
||||
}
|
||||
while (true) {
|
||||
int next = loadXmlMetaData.next();
|
||||
if (next == 1) {
|
||||
return simplePathStrategy;
|
||||
}
|
||||
if (next == 2) {
|
||||
String name = loadXmlMetaData.getName();
|
||||
File file = null;
|
||||
String attributeValue = loadXmlMetaData.getAttributeValue(null, MediationMetaData.KEY_NAME);
|
||||
String attributeValue2 = loadXmlMetaData.getAttributeValue(null, FileDownloadModel.PATH);
|
||||
if ("root-path".equals(name)) {
|
||||
file = c;
|
||||
} else if ("files-path".equals(name)) {
|
||||
file = context.getFilesDir();
|
||||
} else if ("cache-path".equals(name)) {
|
||||
file = context.getCacheDir();
|
||||
} else if ("external-path".equals(name)) {
|
||||
file = Environment.getExternalStorageDirectory();
|
||||
} else if ("external-files-path".equals(name)) {
|
||||
File[] a = a(context, (String) null);
|
||||
if (a.length > 0) {
|
||||
file = a[0];
|
||||
}
|
||||
} else if ("external-cache-path".equals(name)) {
|
||||
File[] a2 = a(context);
|
||||
if (a2.length > 0) {
|
||||
file = a2[0];
|
||||
}
|
||||
} else if (Build.VERSION.SDK_INT >= 21 && "external-media-path".equals(name)) {
|
||||
File[] externalMediaDirs = context.getExternalMediaDirs();
|
||||
if (externalMediaDirs.length > 0) {
|
||||
file = externalMediaDirs[0];
|
||||
}
|
||||
}
|
||||
if (file != null) {
|
||||
simplePathStrategy.a(attributeValue, a(file, attributeValue2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.content.ContentProvider
|
||||
public void attachInfo(Context context, ProviderInfo providerInfo) {
|
||||
super.attachInfo(context, providerInfo);
|
||||
if (providerInfo.exported) {
|
||||
throw new SecurityException("Provider must not be exported");
|
||||
}
|
||||
if (!providerInfo.grantUriPermissions) {
|
||||
throw new SecurityException("Provider must grant uri permissions");
|
||||
}
|
||||
this.a = b(context, providerInfo.authority);
|
||||
}
|
||||
|
||||
@Override // android.content.ContentProvider
|
||||
public int delete(Uri uri, String str, String[] strArr) {
|
||||
return this.a.a(uri).delete() ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override // android.content.ContentProvider
|
||||
public String getType(Uri uri) {
|
||||
File a = this.a.a(uri);
|
||||
int lastIndexOf = a.getName().lastIndexOf(46);
|
||||
if (lastIndexOf < 0) {
|
||||
return "application/octet-stream";
|
||||
}
|
||||
String mimeTypeFromExtension = MimeTypeMap.getSingleton().getMimeTypeFromExtension(a.getName().substring(lastIndexOf + 1));
|
||||
return mimeTypeFromExtension != null ? mimeTypeFromExtension : "application/octet-stream";
|
||||
}
|
||||
|
||||
@Override // android.content.ContentProvider
|
||||
public Uri insert(Uri uri, ContentValues contentValues) {
|
||||
throw new UnsupportedOperationException("No external inserts");
|
||||
}
|
||||
|
||||
@Override // android.content.ContentProvider
|
||||
public boolean onCreate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // android.content.ContentProvider
|
||||
public ParcelFileDescriptor openFile(Uri uri, String str) throws FileNotFoundException {
|
||||
return ParcelFileDescriptor.open(this.a.a(uri), a(str));
|
||||
}
|
||||
|
||||
@Override // android.content.ContentProvider
|
||||
public Cursor query(Uri uri, String[] strArr, String str, String[] strArr2, String str2) {
|
||||
int i;
|
||||
File a = this.a.a(uri);
|
||||
if (strArr == null) {
|
||||
strArr = b;
|
||||
}
|
||||
String[] strArr3 = new String[strArr.length];
|
||||
Object[] objArr = new Object[strArr.length];
|
||||
int i2 = 0;
|
||||
for (String str3 : strArr) {
|
||||
if ("_display_name".equals(str3)) {
|
||||
strArr3[i2] = "_display_name";
|
||||
i = i2 + 1;
|
||||
objArr[i2] = a.getName();
|
||||
} else if ("_size".equals(str3)) {
|
||||
strArr3[i2] = "_size";
|
||||
i = i2 + 1;
|
||||
objArr[i2] = Long.valueOf(a.length());
|
||||
}
|
||||
i2 = i;
|
||||
}
|
||||
String[] a2 = a(strArr3, i2);
|
||||
Object[] a3 = a(objArr, i2);
|
||||
MatrixCursor matrixCursor = new MatrixCursor(a2, 1);
|
||||
matrixCursor.addRow(a3);
|
||||
return matrixCursor;
|
||||
}
|
||||
|
||||
@Override // android.content.ContentProvider
|
||||
public int update(Uri uri, ContentValues contentValues, String str, String[] strArr) {
|
||||
throw new UnsupportedOperationException("No external updates");
|
||||
}
|
||||
|
||||
static class SimplePathStrategy implements PathStrategy {
|
||||
private final HashMap<String, File> a = new HashMap<>();
|
||||
|
||||
SimplePathStrategy(String str) {
|
||||
}
|
||||
|
||||
void a(String str, File file) {
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
throw new IllegalArgumentException("Name must not be empty");
|
||||
}
|
||||
try {
|
||||
this.a.put(str, file.getCanonicalFile());
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException("Failed to resolve canonical path for " + file, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.FileProvider.PathStrategy
|
||||
public File a(Uri uri) {
|
||||
String encodedPath = uri.getEncodedPath();
|
||||
int indexOf = encodedPath.indexOf(47, 1);
|
||||
String decode = Uri.decode(encodedPath.substring(1, indexOf));
|
||||
String decode2 = Uri.decode(encodedPath.substring(indexOf + 1));
|
||||
File file = this.a.get(decode);
|
||||
if (file != null) {
|
||||
File file2 = new File(file, decode2);
|
||||
try {
|
||||
File canonicalFile = file2.getCanonicalFile();
|
||||
if (canonicalFile.getPath().startsWith(file.getPath())) {
|
||||
return canonicalFile;
|
||||
}
|
||||
throw new SecurityException("Resolved path jumped beyond configured root");
|
||||
} catch (IOException unused) {
|
||||
throw new IllegalArgumentException("Failed to resolve canonical path for " + file2);
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unable to find configured root for " + uri);
|
||||
}
|
||||
}
|
||||
|
||||
private static File a(File file, String... strArr) {
|
||||
for (String str : strArr) {
|
||||
if (str != null) {
|
||||
file = new File(file, str);
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
private static String[] a(String[] strArr, int i) {
|
||||
String[] strArr2 = new String[i];
|
||||
System.arraycopy(strArr, 0, strArr2, 0, i);
|
||||
return strArr2;
|
||||
}
|
||||
|
||||
private static Object[] a(Object[] objArr, int i) {
|
||||
Object[] objArr2 = new Object[i];
|
||||
System.arraycopy(objArr, 0, objArr2, 0, i);
|
||||
return objArr2;
|
||||
}
|
||||
|
||||
private static File[] a(Context context, String str) {
|
||||
return Build.VERSION.SDK_INT >= 19 ? context.getExternalFilesDirs(str) : new File[]{context.getExternalFilesDir(str)};
|
||||
}
|
||||
|
||||
public static File[] a(Context context) {
|
||||
return Build.VERSION.SDK_INT >= 19 ? context.getExternalCacheDirs() : new File[]{context.getExternalCacheDir()};
|
||||
}
|
||||
}
|
41
sources/com/yanzhenjie/permission/Options.java
Normal file
41
sources/com/yanzhenjie/permission/Options.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.yanzhenjie.permission;
|
||||
|
||||
import android.os.Build;
|
||||
import com.yanzhenjie.permission.install.NRequestFactory;
|
||||
import com.yanzhenjie.permission.install.ORequestFactory;
|
||||
import com.yanzhenjie.permission.overlay.LRequestFactory;
|
||||
import com.yanzhenjie.permission.overlay.MRequestFactory;
|
||||
import com.yanzhenjie.permission.runtime.Runtime;
|
||||
import com.yanzhenjie.permission.source.Source;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Options {
|
||||
private Source a;
|
||||
|
||||
public interface InstallRequestFactory {
|
||||
}
|
||||
|
||||
public interface OverlayRequestFactory {
|
||||
}
|
||||
|
||||
static {
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
new ORequestFactory();
|
||||
} else {
|
||||
new NRequestFactory();
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
new MRequestFactory();
|
||||
} else {
|
||||
new LRequestFactory();
|
||||
}
|
||||
}
|
||||
|
||||
Options(Source source) {
|
||||
this.a = source;
|
||||
}
|
||||
|
||||
public Runtime a() {
|
||||
return new Runtime(this.a);
|
||||
}
|
||||
}
|
17
sources/com/yanzhenjie/permission/Permission$Group.java
Normal file
17
sources/com/yanzhenjie/permission/Permission$Group.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.yanzhenjie.permission;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class Permission$Group {
|
||||
public static final String[] a = {"android.permission.CAMERA"};
|
||||
public static final String[] b = {"android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"};
|
||||
public static final String[] c = {"android.permission.RECORD_AUDIO"};
|
||||
public static final String[] d = {"android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE"};
|
||||
|
||||
static {
|
||||
new String[]{"android.permission.READ_CALENDAR", "android.permission.WRITE_CALENDAR"};
|
||||
new String[]{"android.permission.READ_CONTACTS", "android.permission.WRITE_CONTACTS", "android.permission.GET_ACCOUNTS"};
|
||||
new String[]{"android.permission.READ_PHONE_STATE", "android.permission.CALL_PHONE", "android.permission.READ_CALL_LOG", "android.permission.WRITE_CALL_LOG", "com.android.voicemail.permission.ADD_VOICEMAIL", "android.permission.USE_SIP", "android.permission.PROCESS_OUTGOING_CALLS"};
|
||||
new String[]{"android.permission.BODY_SENSORS"};
|
||||
new String[]{"android.permission.SEND_SMS", "android.permission.RECEIVE_SMS", "android.permission.READ_SMS", "android.permission.RECEIVE_WAP_PUSH", "android.permission.RECEIVE_MMS"};
|
||||
}
|
||||
}
|
123
sources/com/yanzhenjie/permission/PermissionActivity.java
Normal file
123
sources/com/yanzhenjie/permission/PermissionActivity.java
Normal file
@@ -0,0 +1,123 @@
|
||||
package com.yanzhenjie.permission;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import com.yanzhenjie.permission.overlay.setting.AlertWindowSettingPage;
|
||||
import com.yanzhenjie.permission.overlay.setting.OverlaySettingPage;
|
||||
import com.yanzhenjie.permission.runtime.setting.RuntimeSettingPage;
|
||||
import com.yanzhenjie.permission.source.ContextSource;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class PermissionActivity extends Activity {
|
||||
private static RequestListener a;
|
||||
|
||||
public interface RequestListener {
|
||||
void a();
|
||||
}
|
||||
|
||||
public static void a(Context context, String[] strArr, RequestListener requestListener) {
|
||||
a = requestListener;
|
||||
Intent intent = new Intent(context, (Class<?>) PermissionActivity.class);
|
||||
intent.putExtra("KEY_INPUT_OPERATION", 1);
|
||||
intent.putExtra("KEY_INPUT_PERMISSIONS", strArr);
|
||||
intent.setFlags(268435456);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public void finish() {
|
||||
a = null;
|
||||
super.finish();
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onActivityResult(int i, int i2, Intent intent) {
|
||||
RequestListener requestListener = a;
|
||||
if (requestListener != null) {
|
||||
requestListener.a();
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
Intent intent = getIntent();
|
||||
int intExtra = intent.getIntExtra("KEY_INPUT_OPERATION", 0);
|
||||
if (intExtra == 1) {
|
||||
String[] stringArrayExtra = intent.getStringArrayExtra("KEY_INPUT_PERMISSIONS");
|
||||
if (stringArrayExtra == null || a == null) {
|
||||
finish();
|
||||
return;
|
||||
} else {
|
||||
requestPermissions(stringArrayExtra, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (intExtra == 2) {
|
||||
if (a != null) {
|
||||
new RuntimeSettingPage(new ContextSource(this)).a(2);
|
||||
return;
|
||||
} else {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (intExtra == 3) {
|
||||
if (a == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
Intent intent2 = new Intent("android.settings.MANAGE_UNKNOWN_APP_SOURCES");
|
||||
intent2.setData(Uri.fromParts("package", getPackageName(), null));
|
||||
startActivityForResult(intent2, 3);
|
||||
return;
|
||||
}
|
||||
if (intExtra == 4) {
|
||||
if (a != null) {
|
||||
new OverlaySettingPage(new ContextSource(this)).a(4);
|
||||
return;
|
||||
} else {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (intExtra != 5) {
|
||||
throw new AssertionError("This should not be the case.");
|
||||
}
|
||||
if (a != null) {
|
||||
new AlertWindowSettingPage(new ContextSource(this)).a(5);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Activity, android.view.KeyEvent.Callback
|
||||
public boolean onKeyDown(int i, KeyEvent keyEvent) {
|
||||
if (i == 4) {
|
||||
return true;
|
||||
}
|
||||
return super.onKeyDown(i, keyEvent);
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
|
||||
RequestListener requestListener = a;
|
||||
if (requestListener != null) {
|
||||
requestListener.a();
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
public static void a(Context context, RequestListener requestListener) {
|
||||
a = requestListener;
|
||||
Intent intent = new Intent(context, (Class<?>) PermissionActivity.class);
|
||||
intent.putExtra("KEY_INPUT_OPERATION", 2);
|
||||
intent.setFlags(268435456);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
8
sources/com/yanzhenjie/permission/Rationale.java
Normal file
8
sources/com/yanzhenjie/permission/Rationale.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.yanzhenjie.permission;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface Rationale<T> {
|
||||
void a(Context context, T t, RequestExecutor requestExecutor);
|
||||
}
|
6
sources/com/yanzhenjie/permission/RequestExecutor.java
Normal file
6
sources/com/yanzhenjie/permission/RequestExecutor.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.yanzhenjie.permission;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface RequestExecutor {
|
||||
void execute();
|
||||
}
|
13
sources/com/yanzhenjie/permission/Setting.java
Normal file
13
sources/com/yanzhenjie/permission/Setting.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.yanzhenjie.permission;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface Setting extends SettingService {
|
||||
|
||||
public interface Action {
|
||||
void a();
|
||||
}
|
||||
|
||||
Setting a(Action action);
|
||||
|
||||
void start();
|
||||
}
|
6
sources/com/yanzhenjie/permission/SettingService.java
Normal file
6
sources/com/yanzhenjie/permission/SettingService.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.yanzhenjie.permission;
|
||||
|
||||
@Deprecated
|
||||
/* loaded from: classes2.dex */
|
||||
public interface SettingService {
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentUris;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.provider.VoicemailContract;
|
||||
import android.text.TextUtils;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class AddVoicemailTest implements PermissionTest {
|
||||
private ContentResolver a;
|
||||
|
||||
AddVoicemailTest(Context context) {
|
||||
this.a = context.getContentResolver();
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
try {
|
||||
Uri uri = VoicemailContract.Voicemails.CONTENT_URI;
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put("date", Long.valueOf(System.currentTimeMillis()));
|
||||
contentValues.put("number", "1");
|
||||
contentValues.put("duration", (Integer) 1);
|
||||
contentValues.put("source_package", "permission");
|
||||
contentValues.put("source_data", "permission");
|
||||
contentValues.put("is_read", (Integer) 0);
|
||||
return this.a.delete(uri, "_id=?", new String[]{Long.toString(ContentUris.parseId(this.a.insert(uri, contentValues)))}) > 0;
|
||||
} catch (Exception e) {
|
||||
if (TextUtils.isEmpty(e.getMessage())) {
|
||||
return false;
|
||||
}
|
||||
return !r0.toLowerCase().contains("add_voicemail");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.provider.CalendarContract;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import com.unity3d.ads.metadata.MediationMetaData;
|
||||
import com.yanzhenjie.permission.checker.PermissionTest;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class CalendarReadTest implements PermissionTest {
|
||||
private ContentResolver a;
|
||||
|
||||
CalendarReadTest(Context context) {
|
||||
this.a = context.getContentResolver();
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
Cursor query = this.a.query(CalendarContract.Calendars.CONTENT_URI, new String[]{FileDownloadModel.ID, MediationMetaData.KEY_NAME}, null, null, null);
|
||||
if (query == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
PermissionTest.CursorTest.a(query);
|
||||
query.close();
|
||||
return true;
|
||||
} catch (Throwable th) {
|
||||
query.close();
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentUris;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.provider.CalendarContract;
|
||||
import com.baidu.cloud.media.player.IMediaPlayer;
|
||||
import com.unity3d.ads.metadata.MediationMetaData;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class CalendarWriteTest implements PermissionTest {
|
||||
private ContentResolver a;
|
||||
|
||||
CalendarWriteTest(Context context) {
|
||||
this.a = context.getContentResolver();
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
try {
|
||||
TimeZone timeZone = TimeZone.getDefault();
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(MediationMetaData.KEY_NAME, "PERMISSION");
|
||||
contentValues.put("account_name", "permission@gmail.com");
|
||||
contentValues.put("account_type", "LOCAL");
|
||||
contentValues.put("calendar_displayName", "PERMISSION");
|
||||
contentValues.put("visible", (Integer) 1);
|
||||
contentValues.put("calendar_color", (Integer) (-16776961));
|
||||
contentValues.put("calendar_access_level", Integer.valueOf(IMediaPlayer.MEDIA_INFO_VIDEO_TRACK_LAGGING));
|
||||
contentValues.put("sync_events", (Integer) 1);
|
||||
contentValues.put("calendar_timezone", timeZone.getID());
|
||||
contentValues.put("ownerAccount", "PERMISSION");
|
||||
contentValues.put("canOrganizerRespond", (Integer) 0);
|
||||
return ContentUris.parseId(this.a.insert(CalendarContract.Calendars.CONTENT_URI.buildUpon().appendQueryParameter("caller_is_syncadapter", "true").appendQueryParameter("account_name", "PERMISSION").appendQueryParameter("account_type", "LOCAL").build(), contentValues)) > 0;
|
||||
} finally {
|
||||
this.a.delete(CalendarContract.Calendars.CONTENT_URI.buildUpon().build(), "account_name=?", new String[]{"permission@gmail.com"});
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.provider.CallLog;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import com.yanzhenjie.permission.checker.PermissionTest;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class CallLogReadTest implements PermissionTest {
|
||||
private ContentResolver a;
|
||||
|
||||
CallLogReadTest(Context context) {
|
||||
this.a = context.getContentResolver();
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
Cursor query = this.a.query(CallLog.Calls.CONTENT_URI, new String[]{FileDownloadModel.ID, "number", "type"}, null, null, null);
|
||||
if (query == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
PermissionTest.CursorTest.a(query);
|
||||
query.close();
|
||||
return true;
|
||||
} catch (Throwable th) {
|
||||
query.close();
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentUris;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.provider.CallLog;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class CallLogWriteTest implements PermissionTest {
|
||||
private ContentResolver a;
|
||||
|
||||
CallLogWriteTest(Context context) {
|
||||
this.a = context.getContentResolver();
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
try {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put("type", (Integer) 1);
|
||||
contentValues.put("number", "1");
|
||||
contentValues.put("date", (Integer) 20080808);
|
||||
contentValues.put("new", "0");
|
||||
return ContentUris.parseId(this.a.insert(CallLog.Calls.CONTENT_URI, contentValues)) > 0;
|
||||
} finally {
|
||||
this.a.delete(CallLog.Calls.CONTENT_URI, "number=?", new String[]{"1"});
|
||||
}
|
||||
}
|
||||
}
|
70
sources/com/yanzhenjie/permission/checker/CameraTest.java
Normal file
70
sources/com/yanzhenjie/permission/checker/CameraTest.java
Normal file
@@ -0,0 +1,70 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.Camera;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class CameraTest implements PermissionTest {
|
||||
private static final Camera.PreviewCallback b = new Camera.PreviewCallback() { // from class: com.yanzhenjie.permission.checker.CameraTest.1
|
||||
@Override // android.hardware.Camera.PreviewCallback
|
||||
public void onPreviewFrame(byte[] bArr, Camera camera) {
|
||||
}
|
||||
};
|
||||
private static final SurfaceHolder.Callback c = new SurfaceHolder.Callback() { // from class: com.yanzhenjie.permission.checker.CameraTest.2
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceCreated(SurfaceHolder surfaceHolder) {
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
|
||||
}
|
||||
};
|
||||
private Context a;
|
||||
|
||||
CameraTest(Context context) {
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
Camera camera;
|
||||
SurfaceHolder holder = new SurfaceView(this.a).getHolder();
|
||||
holder.addCallback(c);
|
||||
try {
|
||||
camera = Camera.open();
|
||||
try {
|
||||
camera.setParameters(camera.getParameters());
|
||||
camera.setPreviewDisplay(holder);
|
||||
camera.setPreviewCallback(b);
|
||||
camera.startPreview();
|
||||
return true;
|
||||
} catch (Throwable unused) {
|
||||
try {
|
||||
boolean z = !this.a.getPackageManager().hasSystemFeature("android.hardware.camera");
|
||||
if (camera != null) {
|
||||
camera.stopPreview();
|
||||
camera.setPreviewDisplay(null);
|
||||
camera.setPreviewCallback(null);
|
||||
camera.release();
|
||||
}
|
||||
return z;
|
||||
} finally {
|
||||
if (camera != null) {
|
||||
camera.stopPreview();
|
||||
camera.setPreviewDisplay(null);
|
||||
camera.setPreviewCallback(null);
|
||||
camera.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable unused2) {
|
||||
camera = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.provider.ContactsContract;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import com.yanzhenjie.permission.checker.PermissionTest;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class ContactsReadTest implements PermissionTest {
|
||||
private ContentResolver a;
|
||||
|
||||
ContactsReadTest(Context context) {
|
||||
this.a = context.getContentResolver();
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
Cursor query = this.a.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[]{FileDownloadModel.ID, "data1"}, null, null, null);
|
||||
if (query == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
PermissionTest.CursorTest.a(query);
|
||||
query.close();
|
||||
return true;
|
||||
} catch (Throwable th) {
|
||||
query.close();
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentUris;
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.provider.ContactsContract;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class ContactsWriteTest implements PermissionTest {
|
||||
private ContentResolver a;
|
||||
|
||||
ContactsWriteTest(ContentResolver contentResolver) {
|
||||
this.a = contentResolver;
|
||||
}
|
||||
|
||||
private boolean b() {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put("raw_contact_id", Long.valueOf(ContentUris.parseId(this.a.insert(ContactsContract.RawContacts.CONTENT_URI, contentValues))));
|
||||
contentValues.put("data1", "PERMISSION");
|
||||
contentValues.put("data2", "PERMISSION");
|
||||
contentValues.put("mimetype", "vnd.android.cursor.item/name");
|
||||
return ContentUris.parseId(this.a.insert(ContactsContract.Data.CONTENT_URI, contentValues)) > 0;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
Cursor query = this.a.query(ContactsContract.Data.CONTENT_URI, new String[]{"raw_contact_id"}, "mimetype=? and data1=?", new String[]{"vnd.android.cursor.item/name", "PERMISSION"}, null);
|
||||
if (query == null) {
|
||||
return false;
|
||||
}
|
||||
if (!query.moveToFirst()) {
|
||||
query.close();
|
||||
return b();
|
||||
}
|
||||
long j = query.getLong(0);
|
||||
query.close();
|
||||
return a(j);
|
||||
}
|
||||
|
||||
private boolean a(long j) {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put("raw_contact_id", Long.valueOf(j));
|
||||
contentValues.put("data1", "PERMISSION");
|
||||
contentValues.put("data2", "PERMISSION");
|
||||
contentValues.put("mimetype", "vnd.android.cursor.item/name");
|
||||
return ContentUris.parseId(this.a.insert(ContactsContract.Data.CONTENT_URI, contentValues)) > 0;
|
||||
}
|
||||
}
|
14
sources/com/yanzhenjie/permission/checker/DoubleChecker.java
Normal file
14
sources/com/yanzhenjie/permission/checker/DoubleChecker.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class DoubleChecker implements PermissionChecker {
|
||||
private static final PermissionChecker a = new StandardChecker();
|
||||
private static final PermissionChecker b = new StrictChecker();
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionChecker
|
||||
public boolean a(Context context, String... strArr) {
|
||||
return b.a(context, strArr) && a.a(context, strArr);
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.LocationManager;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class LocationCoarseTest implements PermissionTest {
|
||||
private Context a;
|
||||
|
||||
LocationCoarseTest(Context context) {
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
if (!((LocationManager) this.a.getSystemService("location")).getProviders(true).contains("network") && this.a.getPackageManager().hasSystemFeature("android.hardware.location.network")) {
|
||||
return !r0.isProviderEnabled("network");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.LocationManager;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class LocationFineTest implements PermissionTest {
|
||||
private Context a;
|
||||
|
||||
LocationFineTest(Context context) {
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
List<String> providers = ((LocationManager) this.a.getSystemService("location")).getProviders(true);
|
||||
boolean contains = providers.contains("gps");
|
||||
boolean contains2 = providers.contains("passive");
|
||||
if (contains || contains2 || !this.a.getPackageManager().hasSystemFeature("android.hardware.location.gps")) {
|
||||
return true;
|
||||
}
|
||||
return !r0.isProviderEnabled("gps");
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface PermissionChecker {
|
||||
boolean a(Context context, String... strArr);
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.database.Cursor;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
interface PermissionTest {
|
||||
|
||||
public static class CursorTest {
|
||||
public static void a(Cursor cursor) {
|
||||
if (cursor.getCount() > 0) {
|
||||
cursor.moveToFirst();
|
||||
int type = cursor.getType(0);
|
||||
if (type == 0 || type == 4) {
|
||||
return;
|
||||
}
|
||||
cursor.getString(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean a() throws Throwable;
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class PhoneStateReadTest implements PermissionTest {
|
||||
private Context a;
|
||||
|
||||
PhoneStateReadTest(Context context) {
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
if (!this.a.getPackageManager().hasSystemFeature("android.hardware.telephony")) {
|
||||
return true;
|
||||
}
|
||||
TelephonyManager telephonyManager = (TelephonyManager) this.a.getSystemService("phone");
|
||||
return (telephonyManager.getPhoneType() != 0 && TextUtils.isEmpty(telephonyManager.getDeviceId()) && TextUtils.isEmpty(telephonyManager.getSubscriberId())) ? false : true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.MediaRecorder;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class RecordAudioTest implements PermissionTest {
|
||||
private Context a;
|
||||
|
||||
RecordAudioTest(Context context) {
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
MediaRecorder mediaRecorder = new MediaRecorder();
|
||||
File file = null;
|
||||
try {
|
||||
try {
|
||||
file = File.createTempFile("permission", "test");
|
||||
mediaRecorder.setAudioSource(1);
|
||||
mediaRecorder.setOutputFormat(3);
|
||||
mediaRecorder.setAudioEncoder(1);
|
||||
mediaRecorder.setOutputFile(file.getAbsolutePath());
|
||||
mediaRecorder.prepare();
|
||||
mediaRecorder.start();
|
||||
try {
|
||||
mediaRecorder.stop();
|
||||
} catch (Exception unused) {
|
||||
}
|
||||
try {
|
||||
mediaRecorder.release();
|
||||
} catch (Exception unused2) {
|
||||
}
|
||||
if (file != null && file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
return true;
|
||||
} catch (Throwable th) {
|
||||
try {
|
||||
mediaRecorder.stop();
|
||||
} catch (Exception unused3) {
|
||||
}
|
||||
try {
|
||||
mediaRecorder.release();
|
||||
} catch (Exception unused4) {
|
||||
}
|
||||
if (file == null) {
|
||||
throw th;
|
||||
}
|
||||
if (!file.exists()) {
|
||||
throw th;
|
||||
}
|
||||
file.delete();
|
||||
throw th;
|
||||
}
|
||||
} catch (Throwable unused5) {
|
||||
boolean hasSystemFeature = true ^ this.a.getPackageManager().hasSystemFeature("android.hardware.microphone");
|
||||
try {
|
||||
mediaRecorder.stop();
|
||||
} catch (Exception unused6) {
|
||||
}
|
||||
try {
|
||||
mediaRecorder.release();
|
||||
} catch (Exception unused7) {
|
||||
}
|
||||
if (file != null && file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
return hasSystemFeature;
|
||||
}
|
||||
}
|
||||
}
|
38
sources/com/yanzhenjie/permission/checker/SensorsTest.java
Normal file
38
sources/com/yanzhenjie/permission/checker/SensorsTest.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class SensorsTest implements PermissionTest {
|
||||
private static final SensorEventListener b = new SensorEventListener() { // from class: com.yanzhenjie.permission.checker.SensorsTest.1
|
||||
@Override // android.hardware.SensorEventListener
|
||||
public void onAccuracyChanged(Sensor sensor, int i) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.SensorEventListener
|
||||
public void onSensorChanged(SensorEvent sensorEvent) {
|
||||
}
|
||||
};
|
||||
private Context a;
|
||||
|
||||
SensorsTest(Context context) {
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
SensorManager sensorManager = (SensorManager) this.a.getSystemService("sensor");
|
||||
try {
|
||||
Sensor defaultSensor = sensorManager.getDefaultSensor(21);
|
||||
sensorManager.registerListener(b, defaultSensor, 3);
|
||||
sensorManager.unregisterListener(b, defaultSensor);
|
||||
return true;
|
||||
} catch (Throwable unused) {
|
||||
return !this.a.getPackageManager().hasSystemFeature("android.hardware.sensor.heartrate");
|
||||
}
|
||||
}
|
||||
}
|
28
sources/com/yanzhenjie/permission/checker/SipTest.java
Normal file
28
sources/com/yanzhenjie/permission/checker/SipTest.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.sip.SipManager;
|
||||
import android.net.sip.SipProfile;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class SipTest implements PermissionTest {
|
||||
private Context a;
|
||||
|
||||
SipTest(Context context) {
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
SipManager newInstance;
|
||||
if (!SipManager.isApiSupported(this.a) || (newInstance = SipManager.newInstance(this.a)) == null) {
|
||||
return true;
|
||||
}
|
||||
SipProfile.Builder builder = new SipProfile.Builder("Permission", "127.0.0.1");
|
||||
builder.setPassword("password");
|
||||
SipProfile build = builder.build();
|
||||
newInstance.open(build);
|
||||
newInstance.close(build.getUriString());
|
||||
return true;
|
||||
}
|
||||
}
|
33
sources/com/yanzhenjie/permission/checker/SmsReadTest.java
Normal file
33
sources/com/yanzhenjie/permission/checker/SmsReadTest.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.provider.Telephony;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import com.yanzhenjie.permission.checker.PermissionTest;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class SmsReadTest implements PermissionTest {
|
||||
private ContentResolver a;
|
||||
|
||||
SmsReadTest(Context context) {
|
||||
this.a = context.getContentResolver();
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
Cursor query = this.a.query(Telephony.Sms.CONTENT_URI, new String[]{FileDownloadModel.ID, "address", "person", "body"}, null, null, null);
|
||||
if (query == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
PermissionTest.CursorTest.a(query);
|
||||
query.close();
|
||||
return true;
|
||||
} catch (Throwable th) {
|
||||
query.close();
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.app.AppOpsManager;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Process;
|
||||
import android.text.TextUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class StandardChecker implements PermissionChecker {
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionChecker
|
||||
public boolean a(Context context, String... strArr) {
|
||||
return a(context, Arrays.asList(strArr));
|
||||
}
|
||||
|
||||
public boolean a(Context context, List<String> list) {
|
||||
if (Build.VERSION.SDK_INT < 23) {
|
||||
return true;
|
||||
}
|
||||
AppOpsManager appOpsManager = null;
|
||||
for (String str : list) {
|
||||
if (context.checkPermission(str, Process.myPid(), Process.myUid()) == -1) {
|
||||
return false;
|
||||
}
|
||||
String permissionToOp = AppOpsManager.permissionToOp(str);
|
||||
if (!TextUtils.isEmpty(permissionToOp)) {
|
||||
if (appOpsManager == null) {
|
||||
appOpsManager = (AppOpsManager) context.getSystemService("appops");
|
||||
}
|
||||
if (appOpsManager.checkOpNoThrow(permissionToOp, Process.myUid(), context.getPackageName()) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.os.Environment;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class StorageReadTest implements PermissionTest {
|
||||
StorageReadTest() {
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
File externalStorageDirectory = Environment.getExternalStorageDirectory();
|
||||
if (externalStorageDirectory.exists() && externalStorageDirectory.canRead()) {
|
||||
return externalStorageDirectory.lastModified() > 0 && externalStorageDirectory.list() != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.os.Environment;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class StorageWriteTest implements PermissionTest {
|
||||
StorageWriteTest() {
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionTest
|
||||
public boolean a() throws Throwable {
|
||||
File externalStorageDirectory = Environment.getExternalStorageDirectory();
|
||||
if (!externalStorageDirectory.exists() || !externalStorageDirectory.canWrite()) {
|
||||
return false;
|
||||
}
|
||||
File file = new File(externalStorageDirectory, "Android");
|
||||
if (file.exists() && file.isFile() && !file.delete()) {
|
||||
return false;
|
||||
}
|
||||
if (!file.exists() && !file.mkdirs()) {
|
||||
return false;
|
||||
}
|
||||
File file2 = new File(file, "ANDROID.PERMISSION.TEST");
|
||||
return file2.exists() ? file2.delete() : file2.createNewFile();
|
||||
}
|
||||
}
|
145
sources/com/yanzhenjie/permission/checker/StrictChecker.java
Normal file
145
sources/com/yanzhenjie/permission/checker/StrictChecker.java
Normal file
@@ -0,0 +1,145 @@
|
||||
package com.yanzhenjie.permission.checker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class StrictChecker implements PermissionChecker {
|
||||
private static boolean b(Context context) throws Throwable {
|
||||
return new CameraTest(context).a();
|
||||
}
|
||||
|
||||
private static boolean c(Context context) throws Throwable {
|
||||
return new LocationCoarseTest(context).a();
|
||||
}
|
||||
|
||||
private static boolean d(Context context) throws Throwable {
|
||||
return new LocationFineTest(context).a();
|
||||
}
|
||||
|
||||
private static boolean e(Context context) throws Throwable {
|
||||
return new CalendarReadTest(context).a();
|
||||
}
|
||||
|
||||
private static boolean f(Context context) throws Throwable {
|
||||
return new CallLogReadTest(context).a();
|
||||
}
|
||||
|
||||
private static boolean g(Context context) throws Throwable {
|
||||
return new ContactsReadTest(context).a();
|
||||
}
|
||||
|
||||
private static boolean h(Context context) throws Throwable {
|
||||
return new PhoneStateReadTest(context).a();
|
||||
}
|
||||
|
||||
private static boolean i(Context context) throws Throwable {
|
||||
return new SmsReadTest(context).a();
|
||||
}
|
||||
|
||||
private static boolean j(Context context) throws Throwable {
|
||||
return new RecordAudioTest(context).a();
|
||||
}
|
||||
|
||||
private static boolean k(Context context) throws Throwable {
|
||||
return new SensorsTest(context).a();
|
||||
}
|
||||
|
||||
private static boolean l(Context context) throws Throwable {
|
||||
return new SipTest(context).a();
|
||||
}
|
||||
|
||||
private static boolean m(Context context) throws Throwable {
|
||||
return new CalendarWriteTest(context).a();
|
||||
}
|
||||
|
||||
private static boolean n(Context context) throws Throwable {
|
||||
return new CallLogWriteTest(context).a();
|
||||
}
|
||||
|
||||
private static boolean o(Context context) throws Throwable {
|
||||
return new ContactsWriteTest(context.getContentResolver()).a();
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.checker.PermissionChecker
|
||||
public boolean a(Context context, String... strArr) {
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
return true;
|
||||
}
|
||||
for (String str : strArr) {
|
||||
if (!a(context, str)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean b() throws Throwable {
|
||||
return new StorageWriteTest().a();
|
||||
}
|
||||
|
||||
private boolean a(Context context, String str) {
|
||||
try {
|
||||
switch (str) {
|
||||
case "android.permission.READ_CALENDAR":
|
||||
return e(context);
|
||||
case "android.permission.WRITE_CALENDAR":
|
||||
return m(context);
|
||||
case "android.permission.CAMERA":
|
||||
return b(context);
|
||||
case "android.permission.READ_CONTACTS":
|
||||
return g(context);
|
||||
case "android.permission.WRITE_CONTACTS":
|
||||
return o(context);
|
||||
case "android.permission.GET_ACCOUNTS":
|
||||
return true;
|
||||
case "android.permission.ACCESS_COARSE_LOCATION":
|
||||
return c(context);
|
||||
case "android.permission.ACCESS_FINE_LOCATION":
|
||||
return d(context);
|
||||
case "android.permission.RECORD_AUDIO":
|
||||
return j(context);
|
||||
case "android.permission.READ_PHONE_STATE":
|
||||
return h(context);
|
||||
case "android.permission.CALL_PHONE":
|
||||
return true;
|
||||
case "android.permission.READ_CALL_LOG":
|
||||
return f(context);
|
||||
case "android.permission.WRITE_CALL_LOG":
|
||||
return n(context);
|
||||
case "com.android.voicemail.permission.ADD_VOICEMAIL":
|
||||
return a(context);
|
||||
case "android.permission.USE_SIP":
|
||||
return l(context);
|
||||
case "android.permission.PROCESS_OUTGOING_CALLS":
|
||||
return true;
|
||||
case "android.permission.BODY_SENSORS":
|
||||
return k(context);
|
||||
case "android.permission.SEND_SMS":
|
||||
case "android.permission.RECEIVE_MMS":
|
||||
return true;
|
||||
case "android.permission.READ_SMS":
|
||||
return i(context);
|
||||
case "android.permission.RECEIVE_WAP_PUSH":
|
||||
case "android.permission.RECEIVE_SMS":
|
||||
return true;
|
||||
case "android.permission.READ_EXTERNAL_STORAGE":
|
||||
return a();
|
||||
case "android.permission.WRITE_EXTERNAL_STORAGE":
|
||||
return b();
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
} catch (Throwable unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean a(Context context) throws Throwable {
|
||||
return new AddVoicemailTest(context).a();
|
||||
}
|
||||
|
||||
private static boolean a() throws Throwable {
|
||||
return new StorageReadTest().a();
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package com.yanzhenjie.permission.install;
|
||||
|
||||
import com.yanzhenjie.permission.Options;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class NRequestFactory implements Options.InstallRequestFactory {
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package com.yanzhenjie.permission.install;
|
||||
|
||||
import com.yanzhenjie.permission.Options;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ORequestFactory implements Options.InstallRequestFactory {
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package com.yanzhenjie.permission.overlay;
|
||||
|
||||
import com.yanzhenjie.permission.Options;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class LRequestFactory implements Options.OverlayRequestFactory {
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package com.yanzhenjie.permission.overlay;
|
||||
|
||||
import com.yanzhenjie.permission.Options;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class MRequestFactory implements Options.OverlayRequestFactory {
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
package com.yanzhenjie.permission.overlay.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 AlertWindowSettingPage {
|
||||
private static final String b = Build.MANUFACTURER.toLowerCase();
|
||||
private Source a;
|
||||
|
||||
public AlertWindowSettingPage(Source source) {
|
||||
this.a = source;
|
||||
}
|
||||
|
||||
private Intent b(Context context) {
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.permissionmanager.ui.MainActivity"));
|
||||
if (a(context, intent)) {
|
||||
return intent;
|
||||
}
|
||||
intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.addviewmonitor.AddViewMonitorActivity"));
|
||||
if (a(context, intent)) {
|
||||
return intent;
|
||||
}
|
||||
intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.notificationmanager.ui.NotificationManagmentActivity"));
|
||||
return intent;
|
||||
}
|
||||
|
||||
private Intent c(Context 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 Intent d(Context context) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(Constant.SelectRobot.PACKAGE_NAME_KEY, context.getPackageName());
|
||||
intent.setClassName("com.color.safecenter", "com.color.safecenter.permission.floatwindow.FloatWindowListActivity");
|
||||
if (a(context, intent)) {
|
||||
return intent;
|
||||
}
|
||||
intent.setClassName("com.coloros.safecenter", "com.coloros.safecenter.sysfloatwindow.FloatWindowListActivity");
|
||||
if (a(context, intent)) {
|
||||
return intent;
|
||||
}
|
||||
intent.setClassName("com.oppo.safe", "com.oppo.safe.permission.PermissionAppListActivity");
|
||||
return intent;
|
||||
}
|
||||
|
||||
private Intent e(Context context) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClassName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.FloatWindowManager");
|
||||
intent.putExtra("packagename", context.getPackageName());
|
||||
if (a(context, intent)) {
|
||||
return intent;
|
||||
}
|
||||
intent.setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.safeguard.SoftPermissionDetailActivity"));
|
||||
return intent;
|
||||
}
|
||||
|
||||
private Intent f(Context context) {
|
||||
Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
|
||||
intent.putExtra("extra_pkgname", context.getPackageName());
|
||||
if (a(context, intent)) {
|
||||
return intent;
|
||||
}
|
||||
intent.setPackage("com.miui.securitycenter");
|
||||
if (a(context, intent)) {
|
||||
return intent;
|
||||
}
|
||||
intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
|
||||
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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
package com.yanzhenjie.permission.overlay.setting;
|
||||
|
||||
import android.content.ComponentName;
|
||||
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 OverlaySettingPage {
|
||||
private static final String b = Build.MANUFACTURER.toLowerCase();
|
||||
private Source a;
|
||||
|
||||
public OverlaySettingPage(Source source) {
|
||||
this.a = source;
|
||||
}
|
||||
|
||||
private void b(int i) {
|
||||
Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
|
||||
intent.setData(Uri.fromParts("package", this.a.a().getPackageName(), null));
|
||||
this.a.a(intent, i);
|
||||
}
|
||||
|
||||
private boolean c(int i) {
|
||||
Intent intent = new Intent("android.settings.action.MANAGE_OVERLAY_PERMISSION");
|
||||
intent.setData(Uri.fromParts("package", this.a.a().getPackageName(), null));
|
||||
try {
|
||||
this.a.a(intent, i);
|
||||
return true;
|
||||
} catch (Exception unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean d(int i) {
|
||||
Intent intent = new Intent("com.meizu.safe.security.SHOW_APPSEC");
|
||||
intent.putExtra(Constant.SelectRobot.PACKAGE_NAME_KEY, this.a.a().getPackageName());
|
||||
intent.setComponent(new ComponentName("com.meizu.safe", "com.meizu.safe.security.AppSecActivity"));
|
||||
try {
|
||||
this.a.a(intent, i);
|
||||
return true;
|
||||
} catch (Exception unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void a(int i) {
|
||||
if (!b.contains("meizu")) {
|
||||
if (c(i)) {
|
||||
return;
|
||||
}
|
||||
b(i);
|
||||
} else {
|
||||
if (d(i) || c(i)) {
|
||||
return;
|
||||
}
|
||||
b(i);
|
||||
}
|
||||
}
|
||||
}
|
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;
|
||||
}
|
||||
}
|
54
sources/com/yanzhenjie/permission/source/ContextSource.java
Normal file
54
sources/com/yanzhenjie/permission/source/ContextSource.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.yanzhenjie.permission.source;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class ContextSource extends Source {
|
||||
private Context a;
|
||||
|
||||
public ContextSource(Context context) {
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.source.Source
|
||||
public Context a() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.source.Source
|
||||
public void a(Intent intent, int i) {
|
||||
Context context = this.a;
|
||||
if (context instanceof Activity) {
|
||||
((Activity) context).startActivityForResult(intent, i);
|
||||
} else {
|
||||
intent.addFlags(268435456);
|
||||
this.a.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.yanzhenjie.permission.source.Source
|
||||
public boolean a(String str) {
|
||||
if (Build.VERSION.SDK_INT < 23) {
|
||||
return false;
|
||||
}
|
||||
Context context = this.a;
|
||||
if (context instanceof Activity) {
|
||||
return ((Activity) context).shouldShowRequestPermissionRationale(str);
|
||||
}
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
try {
|
||||
Method method = packageManager.getClass().getMethod("shouldShowRequestPermissionRationale", String.class);
|
||||
if (!method.isAccessible()) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
return ((Boolean) method.invoke(packageManager, str)).booleanValue();
|
||||
} catch (Exception unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
13
sources/com/yanzhenjie/permission/source/Source.java
Normal file
13
sources/com/yanzhenjie/permission/source/Source.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.yanzhenjie.permission.source;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class Source {
|
||||
public abstract Context a();
|
||||
|
||||
public abstract void a(Intent intent, int i);
|
||||
|
||||
public abstract boolean a(String str);
|
||||
}
|
13
sources/com/yanzhenjie/permission/util/MainExecutor.java
Normal file
13
sources/com/yanzhenjie/permission/util/MainExecutor.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.yanzhenjie.permission.util;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class MainExecutor {
|
||||
private static final Handler a = new Handler(Looper.getMainLooper());
|
||||
|
||||
public void a(Runnable runnable, long j) {
|
||||
a.postDelayed(runnable, j);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user