Merge "Fix bugs with null AppOp permissions."
This commit is contained in:
committed by
Android (Google) Code Review
commit
f6ab51cd67
@@ -123,17 +123,19 @@ public class AppOpsDetails extends Fragment {
|
|||||||
mOperationsSection, false);
|
mOperationsSection, false);
|
||||||
mOperationsSection.addView(view);
|
mOperationsSection.addView(view);
|
||||||
String perm = AppOpsManager.opToPermission(op.getOp());
|
String perm = AppOpsManager.opToPermission(op.getOp());
|
||||||
try {
|
if (perm != null) {
|
||||||
PermissionInfo pi = mPm.getPermissionInfo(perm, 0);
|
try {
|
||||||
if (pi.group != null && !lastPermGroup.equals(pi.group)) {
|
PermissionInfo pi = mPm.getPermissionInfo(perm, 0);
|
||||||
lastPermGroup = pi.group;
|
if (pi.group != null && !lastPermGroup.equals(pi.group)) {
|
||||||
PermissionGroupInfo pgi = mPm.getPermissionGroupInfo(pi.group, 0);
|
lastPermGroup = pi.group;
|
||||||
if (pgi.icon != 0) {
|
PermissionGroupInfo pgi = mPm.getPermissionGroupInfo(pi.group, 0);
|
||||||
((ImageView)view.findViewById(R.id.op_icon)).setImageDrawable(
|
if (pgi.icon != 0) {
|
||||||
pgi.loadIcon(mPm));
|
((ImageView)view.findViewById(R.id.op_icon)).setImageDrawable(
|
||||||
|
pgi.loadIcon(mPm));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
}
|
}
|
||||||
} catch (NameNotFoundException e) {
|
|
||||||
}
|
}
|
||||||
((TextView)view.findViewById(R.id.op_name)).setText(mState.getLabelText(op));
|
((TextView)view.findViewById(R.id.op_name)).setText(mState.getLabelText(op));
|
||||||
((TextView)view.findViewById(R.id.op_time)).setText(mState.getTimeText(op));
|
((TextView)view.findViewById(R.id.op_time)).setText(mState.getTimeText(op));
|
||||||
|
@@ -359,7 +359,7 @@ public class AppOpsState {
|
|||||||
ArrayList<Integer> permOps = new ArrayList<Integer>();
|
ArrayList<Integer> permOps = new ArrayList<Integer>();
|
||||||
for (int i=0; i<tpl.ops.length; i++) {
|
for (int i=0; i<tpl.ops.length; i++) {
|
||||||
String perm = AppOpsManager.opToPermission(tpl.ops[i]);
|
String perm = AppOpsManager.opToPermission(tpl.ops[i]);
|
||||||
if (!perms.contains(perm)) {
|
if (perm != null && !perms.contains(perm)) {
|
||||||
perms.add(perm);
|
perms.add(perm);
|
||||||
permOps.add(tpl.ops[i]);
|
permOps.add(tpl.ops[i]);
|
||||||
}
|
}
|
||||||
@@ -408,36 +408,38 @@ public class AppOpsState {
|
|||||||
}
|
}
|
||||||
List<AppOpsManager.OpEntry> dummyOps = null;
|
List<AppOpsManager.OpEntry> dummyOps = null;
|
||||||
AppOpsManager.PackageOps pkgOps = null;
|
AppOpsManager.PackageOps pkgOps = null;
|
||||||
for (int j=0; j<appInfo.requestedPermissions.length; j++) {
|
if (appInfo.requestedPermissions != null) {
|
||||||
if (appInfo.requestedPermissionsFlags != null) {
|
for (int j=0; j<appInfo.requestedPermissions.length; j++) {
|
||||||
if ((appInfo.requestedPermissionsFlags[j]
|
if (appInfo.requestedPermissionsFlags != null) {
|
||||||
& PackageInfo.REQUESTED_PERMISSION_GRANTED) == 0) {
|
if ((appInfo.requestedPermissionsFlags[j]
|
||||||
if (DEBUG) Log.d(TAG, "Pkg " + appInfo.packageName + " perm "
|
& PackageInfo.REQUESTED_PERMISSION_GRANTED) == 0) {
|
||||||
+ appInfo.requestedPermissions[j] + " not granted; skipping");
|
if (DEBUG) Log.d(TAG, "Pkg " + appInfo.packageName + " perm "
|
||||||
break;
|
+ appInfo.requestedPermissions[j] + " not granted; skipping");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (DEBUG) Log.d(TAG, "Pkg " + appInfo.packageName + ": requested perm "
|
||||||
if (DEBUG) Log.d(TAG, "Pkg " + appInfo.packageName + ": requested perm "
|
+ appInfo.requestedPermissions[j]);
|
||||||
+ appInfo.requestedPermissions[j]);
|
for (int k=0; k<perms.size(); k++) {
|
||||||
for (int k=0; k<perms.size(); k++) {
|
if (!perms.get(k).equals(appInfo.requestedPermissions[j])) {
|
||||||
if (!perms.get(k).equals(appInfo.requestedPermissions[j])) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
if (DEBUG) Log.d(TAG, "Pkg " + appInfo.packageName + " perm " + perms.get(k)
|
||||||
if (DEBUG) Log.d(TAG, "Pkg " + appInfo.packageName + " perm " + perms.get(k)
|
+ " has op " + permOps.get(k) + ": " + appEntry.hasOp(permOps.get(k)));
|
||||||
+ " has op " + permOps.get(k) + ": " + appEntry.hasOp(permOps.get(k)));
|
if (appEntry.hasOp(permOps.get(k))) {
|
||||||
if (appEntry.hasOp(permOps.get(k))) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
if (dummyOps == null) {
|
||||||
if (dummyOps == null) {
|
dummyOps = new ArrayList<AppOpsManager.OpEntry>();
|
||||||
dummyOps = new ArrayList<AppOpsManager.OpEntry>();
|
pkgOps = new AppOpsManager.PackageOps(
|
||||||
pkgOps = new AppOpsManager.PackageOps(
|
appInfo.packageName, appInfo.applicationInfo.uid, dummyOps);
|
||||||
appInfo.packageName, appInfo.applicationInfo.uid, dummyOps);
|
|
||||||
|
|
||||||
|
}
|
||||||
|
AppOpsManager.OpEntry opEntry = new AppOpsManager.OpEntry(
|
||||||
|
permOps.get(k), AppOpsManager.MODE_ALLOWED, 0, 0, 0);
|
||||||
|
dummyOps.add(opEntry);
|
||||||
|
addOp(entries, pkgOps, appEntry, opEntry);
|
||||||
}
|
}
|
||||||
AppOpsManager.OpEntry opEntry = new AppOpsManager.OpEntry(
|
|
||||||
permOps.get(k), AppOpsManager.MODE_ALLOWED, 0, 0, 0);
|
|
||||||
dummyOps.add(opEntry);
|
|
||||||
addOp(entries, pkgOps, appEntry, opEntry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user