Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ public static void uninstallApp(Context context, String packageName) throws Exce
*
* adb shell pm grant com.your.package android.permission.GET_APP_OPS_STATS
*
* In the behind, setMode is called.
*
* @param context context
* @param opCode code
* @param uid uid
Expand All @@ -131,28 +129,6 @@ public static void setAppOpsMode(Context context, int opCode, int uid, String pa
DSMClinetImplement.setAppOpsMode(context, opCode, uid, packageName, mode);
}

/**
*
* Set the AppOps state.
*
* The device owner can only SET the AppOps states but can not GET the AppOps states.
* For get the AppOps state you have to register the "android.permission.GET_APP_OPS_STATS" permission in manifests.
* Then ask user to grant it manually through ADB command:
*
* adb shell pm grant com.your.package android.permission.GET_APP_OPS_STATS
*
* In the behind, setUidMode is called.
*
* @param context context
* @param opCode code
* @param uid uid
* @param mode mode
*/
@RequiresApi(api = Build.VERSION_CODES.P)
public static void setAppOpsUidMode(Context context, int opCode, int uid, int mode) throws Exception {
DSMClinetImplement.setAppOpsUidMode(context, opCode, uid, mode);
}

/**
*
* Reset the AppOps state.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,6 @@ public static void setAppOpsMode(Context context, int opCode, int uid, String pa
}
}

@RequiresApi(api = Build.VERSION_CODES.P)
public static void setAppOpsUidMode(Context context, int opCode, int uid, int mode) throws Exception {
Bundle bundle = new Bundle();
bundle.putInt(EXTRA_APP_OP_CODE, opCode);
bundle.putInt(Intent.EXTRA_UID, uid);
bundle.putInt(EXTRA_APP_OP_MODE, mode);
Bundle call = context.getContentResolver().call(Uri.parse("content://" + getOwnerPackageNameInternal(context) +
".DSM_CENTER"),
METHOD_SET_APP_OPS, null, bundle);
if (call != null && call.containsKey(Intent.ACTION_APP_ERROR)) {
throw (Exception) call.getSerializable(Intent.ACTION_APP_ERROR);
}
}

@RequiresApi(api = Build.VERSION_CODES.P)
public static void resetAppOps(Context context, int userId, String packageName) throws Exception {
Bundle bundle = new Bundle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,11 @@ private static Bundle uninstallApp(Context context, Bundle extras) {

@SuppressLint("NewApi")
private static Bundle setAppOps(Context context, Bundle extras) {
if (extras.containsKey(Intent.EXTRA_PACKAGE_NAME)) {
AppOpsUtil.setMode(context,
extras.getInt(EXTRA_APP_OP_CODE),
extras.getInt(Intent.EXTRA_UID),
extras.getString(Intent.EXTRA_PACKAGE_NAME),
extras.getInt(EXTRA_APP_OP_MODE));
} else {
AppOpsUtil.setUidMode(context,
extras.getInt(EXTRA_APP_OP_CODE),
extras.getInt(Intent.EXTRA_UID),
extras.getInt(EXTRA_APP_OP_MODE));
}

AppOpsUtil.setMode(context,
extras.getInt(EXTRA_APP_OP_CODE),
extras.getInt(Intent.EXTRA_UID),
extras.getString(Intent.EXTRA_PACKAGE_NAME),
extras.getInt(EXTRA_APP_OP_MODE));
return new Bundle();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,6 @@ public static void setMode(Context context, int opCode, int uid, String packageN
.on(sManager);
}

@RequiresApi(api = Build.VERSION_CODES.P)
public static void setUidMode(Context context, int opCode, int uid, int mode) {
if (sManager == null) {
sManager = context.getSystemService(AppOpsManager.class);
}
Hack.into(AppOpsManager.class)
.method("setUidMode")
.returning(void.class)
.withParams(int.class, int.class, int.class)
.invoke(opCode, uid, mode)
.on(sManager);
}

@RequiresApi(api = Build.VERSION_CODES.P)
public static void resetAllModes(int userId, String packageName) throws RemoteException {
IBinder binder = Hack.into("android.os.ServiceManager")
Expand Down