Initial commit
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user