Skip to content

Commit 99222d2

Browse files
author
Dianne Hackborn
committed
Finish up issue #6249094: Display permissions based on relevance to private data
Added bitmaps for permission group icons. We had to pick either icons for a dark or light background, and it had to be light for settings, so the installer theme has gone back to dark. Tweaked the permission groups to match the icons. Redid the group priorities to make them correct (they were written with higher priorities being less important). Fixed bug where priority was not being used for system apps. Change-Id: Ia3d3f0c1614a11b4cfd11682ce9e6c9f87d75c06
1 parent 139e5aa commit 99222d2

File tree

91 files changed

+157
-68
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+157
-68
lines changed

api/current.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ package android {
144144
field public static final java.lang.String AFFECTS_BATTERY = "android.permission-group.AFFECTS_BATTERY";
145145
field public static final java.lang.String APP_INFO = "android.permission-group.APP_INFO";
146146
field public static final java.lang.String AUDIO_SETTINGS = "android.permission-group.AUDIO_SETTINGS";
147+
field public static final java.lang.String BLUETOOTH_NETWORK = "android.permission-group.BLUETOOTH_NETWORK";
147148
field public static final java.lang.String BOOKMARKS = "android.permission-group.BOOKMARKS";
148149
field public static final java.lang.String CALENDAR = "android.permission-group.CALENDAR";
149150
field public static final java.lang.String CAMERA = "android.permission-group.CAMERA";
@@ -169,6 +170,7 @@ package android {
169170
field public static final java.lang.String USER_DICTIONARY = "android.permission-group.USER_DICTIONARY";
170171
field public static final java.lang.String VOICEMAIL = "android.permission-group.VOICEMAIL";
171172
field public static final java.lang.String WALLPAPER = "android.permission-group.WALLPAPER";
173+
field public static final java.lang.String WRITE_USER_DICTIONARY = "android.permission-group.WRITE_USER_DICTIONARY";
172174
}
173175

174176
public final class R {

core/java/android/content/pm/PackageParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ private PermissionGroup parsePermissionGroup(Package owner, int flags, Resources
14581458
com.android.internal.R.styleable.AndroidManifestPermissionGroup_permissionGroupFlags, 0);
14591459
perm.info.priority = sa.getInt(
14601460
com.android.internal.R.styleable.AndroidManifestPermissionGroup_priority, 0);
1461-
if (perm.info.priority > 0 && (flags&PARSE_IS_SYSTEM) != 0) {
1461+
if (perm.info.priority > 0 && (flags&PARSE_IS_SYSTEM) == 0) {
14621462
perm.info.priority = 0;
14631463
}
14641464

core/java/android/widget/AppSecurityPermissions.java

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,20 @@ static class MyPermissionGroupInfo extends PermissionGroupInfo {
9898
MyPermissionGroupInfo(PermissionGroupInfo info) {
9999
super(info);
100100
}
101+
102+
public Drawable loadGroupIcon(PackageManager pm) {
103+
if (icon != 0) {
104+
return loadIcon(pm);
105+
} else {
106+
ApplicationInfo appInfo;
107+
try {
108+
appInfo = pm.getApplicationInfo(packageName, 0);
109+
return appInfo.loadIcon(pm);
110+
} catch (NameNotFoundException e) {
111+
}
112+
}
113+
return null;
114+
}
101115
}
102116

103117
static class MyPermissionInfo extends PermissionInfo {
@@ -155,16 +169,7 @@ public void setPermission(MyPermissionGroupInfo grp, MyPermissionInfo perm,
155169
PackageManager pm = getContext().getPackageManager();
156170
Drawable icon = null;
157171
if (first) {
158-
if (grp.icon != 0) {
159-
icon = grp.loadIcon(pm);
160-
} else {
161-
ApplicationInfo appInfo;
162-
try {
163-
appInfo = pm.getApplicationInfo(grp.packageName, 0);
164-
icon = appInfo.loadIcon(pm);
165-
} catch (NameNotFoundException e) {
166-
}
167-
}
172+
icon = grp.loadGroupIcon(pm);
168173
}
169174
CharSequence label = perm.mLabel;
170175
if (perm.mNew && newPermPrefix != null) {
@@ -191,10 +196,28 @@ public void onClick(View v) {
191196
if (mDialog != null) {
192197
mDialog.dismiss();
193198
}
199+
PackageManager pm = getContext().getPackageManager();
194200
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
195201
builder.setTitle(mGroup.mLabel);
196-
builder.setMessage(mPerm.loadDescription(getContext().getPackageManager()));
202+
if (mPerm.descriptionRes != 0) {
203+
builder.setMessage(mPerm.loadDescription(pm));
204+
} else {
205+
CharSequence appName;
206+
try {
207+
ApplicationInfo app = pm.getApplicationInfo(mPerm.packageName, 0);
208+
appName = app.loadLabel(pm);
209+
} catch (NameNotFoundException e) {
210+
appName = mPerm.packageName;
211+
}
212+
StringBuilder sbuilder = new StringBuilder(128);
213+
sbuilder.append(getContext().getString(
214+
R.string.perms_description_app, appName));
215+
sbuilder.append("\n\n");
216+
sbuilder.append(mPerm.name);
217+
builder.setMessage(sbuilder.toString());
218+
}
197219
builder.setCancelable(true);
220+
builder.setIcon(mGroup.loadGroupIcon(pm));
198221
mDialog = builder.show();
199222
mDialog.setCanceledOnTouchOutside(true);
200223
}
@@ -611,9 +634,26 @@ private void setPermissions(List<MyPermissionInfo> permList) {
611634
}
612635

613636
for (MyPermissionGroupInfo pgrp : mPermGroups.values()) {
614-
pgrp.mLabel = pgrp.loadLabel(mPm);
637+
if (pgrp.labelRes != 0 || pgrp.nonLocalizedLabel != null) {
638+
pgrp.mLabel = pgrp.loadLabel(mPm);
639+
} else {
640+
ApplicationInfo app;
641+
try {
642+
app = mPm.getApplicationInfo(pgrp.packageName, 0);
643+
pgrp.mLabel = app.loadLabel(mPm);
644+
} catch (NameNotFoundException e) {
645+
pgrp.mLabel = pgrp.loadLabel(mPm);
646+
}
647+
}
615648
mPermGroupsList.add(pgrp);
616649
}
617650
Collections.sort(mPermGroupsList, mPermGroupComparator);
651+
if (false) {
652+
for (MyPermissionGroupInfo grp : mPermGroupsList) {
653+
Log.i("foo", "Group " + grp.name + " personal="
654+
+ ((grp.flags&PermissionGroupInfo.FLAG_PERSONAL_INFO) != 0)
655+
+ " priority=" + grp.priority);
656+
}
657+
}
618658
}
619659
}

0 commit comments

Comments
 (0)