Use AppOpsManager#setUidMode instead of #setMode

Security related app-ops should be set with AppOpsManager#setUidMode
instead of AppOpsManager#setMode.

Test: manual - toggle All Files Access for a test app, reboot device and
observe in /data/system/appops.xml that the mode was for UID instead of
package
Test: ensure that the right state is reflected in the relevant Settings
activities

Change-Id: I261953ff88bc049cf0a2f04f8caac00b8cc6f704
This commit is contained in:
shafik
2020-02-21 15:35:18 +00:00
parent 3c1b99c1dc
commit ac8aba0c4a
2 changed files with 28 additions and 5 deletions

View File

@@ -23,7 +23,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
@@ -110,8 +109,8 @@ public class ManageExternalStorageDetails extends AppInfoWithHeader implements
*/
private void setManageExternalStorageState(boolean newState) {
logSpecialPermissionChange(newState, mPackageName);
mAppOpsManager.setMode(AppOpsManager.OP_MANAGE_EXTERNAL_STORAGE,
mPackageInfo.applicationInfo.uid, mPackageName, newState
mAppOpsManager.setUidMode(AppOpsManager.OP_MANAGE_EXTERNAL_STORAGE,
mPackageInfo.applicationInfo.uid, newState
? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_ERRORED);
}