summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/android/src/com/adobe/phonegap/push/PermissionUtils.java
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-08-31 22:37:03 +0200
committerJules Laplace <julescarbon@gmail.com>2020-08-31 22:37:03 +0200
commitd22d51a1ae49680015326857360eb699f31efced (patch)
tree43ac5007de26848f516b37b863daeb77f86d97d2 /StoneIsland/platforms/android/src/com/adobe/phonegap/push/PermissionUtils.java
parenta81d20bc18d002623fc24cdcea8df7eed6d85bc9 (diff)
NO MORE ANDROID BUILD
Diffstat (limited to 'StoneIsland/platforms/android/src/com/adobe/phonegap/push/PermissionUtils.java')
-rw-r--r--StoneIsland/platforms/android/src/com/adobe/phonegap/push/PermissionUtils.java55
1 files changed, 0 insertions, 55 deletions
diff --git a/StoneIsland/platforms/android/src/com/adobe/phonegap/push/PermissionUtils.java b/StoneIsland/platforms/android/src/com/adobe/phonegap/push/PermissionUtils.java
deleted file mode 100644
index 6aa5c9bf..00000000
--- a/StoneIsland/platforms/android/src/com/adobe/phonegap/push/PermissionUtils.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.adobe.phonegap.push;
-
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-public class PermissionUtils {
-
- private static final String CHECK_OP_NO_THROW = "checkOpNoThrow";
-
- public static boolean hasPermission(Context appContext, String appOpsServiceId) throws UnknownError {
-
- ApplicationInfo appInfo = appContext.getApplicationInfo();
-
- String pkg = appContext.getPackageName();
- int uid = appInfo.uid;
- Class appOpsClass = null;
- Object appOps = appContext.getSystemService("appops");
-
- try {
-
- appOpsClass = Class.forName("android.app.AppOpsManager");
-
- Method checkOpNoThrowMethod = appOpsClass.getMethod(
- CHECK_OP_NO_THROW,
- Integer.TYPE,
- Integer.TYPE,
- String.class
- );
-
- Field opValue = appOpsClass.getDeclaredField(appOpsServiceId);
-
- int value = (int) opValue.getInt(Integer.class);
- Object result = checkOpNoThrowMethod.invoke(appOps, value, uid, pkg);
-
- return Integer.parseInt(result.toString()) == 0; // AppOpsManager.MODE_ALLOWED
-
- } catch (ClassNotFoundException e) {
- throw new UnknownError("class not found");
- } catch (NoSuchMethodException e) {
- throw new UnknownError("no such method");
- } catch (NoSuchFieldException e) {
- throw new UnknownError("no such field");
- } catch (InvocationTargetException e) {
- throw new UnknownError("invocation target");
- } catch (IllegalAccessException e) {
- throw new UnknownError("illegal access");
- }
-
- }
-
-}