diff options
author | Philip P. Moltmann <moltmann@google.com> | 2018-06-14 11:52:14 -0700 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-06-18 23:34:04 +0000 |
commit | 0f6254b0ebb7a6502b8f51c12cc89f36f3fb148d (patch) | |
tree | 32414781383216f9cb269ed5610ff591231b0f49 | |
parent | 24dbe31c2e9c6788b7a8d271f760a3a3c8c2a0f7 (diff) | |
download | base-0f6254b0ebb7a6502b8f51c12cc89f36f3fb148d.tar.gz |
Abbreviate permission labels less aggressively
We switched the package installer app to always abbreviate all labels
loaded from foreign packages. This is done so that a foreign app cannot
crorrupt the UI via super-long strings.
The default abbreviation is very aggressive and abbreviates to ~5 cm.
When an app with a targetSDK <= M gets installed, all permissions will
get auto-granted. Hence when a user side-loads such an app, we show the
permissions during install so that the user is aware of this.
Unfortunately most permission labels and restrictions do not fit into a
single line.
This change allows much longer strings for permissions names and
descriptions. It still abbreviates eventually and handles permission
descriptions with weird characters (such as back-space) correctly.
Fixes: 110209410
Test: Side-loaded old app and verified that permission labels and
descriptions are not abbreviated.
Change-Id: Ie1db240883c9f5cb9c1b74ca7bdcb80625e3f7f2
(cherry picked from commit 004e489a251d6adf94922368e98a730185642123)
-rw-r--r-- | core/java/android/widget/AppSecurityPermissions.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/core/java/android/widget/AppSecurityPermissions.java b/core/java/android/widget/AppSecurityPermissions.java index 6df76fa2e09a..e6f948f2d969 100644 --- a/core/java/android/widget/AppSecurityPermissions.java +++ b/core/java/android/widget/AppSecurityPermissions.java @@ -21,6 +21,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; +import android.content.pm.PackageItemInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PermissionGroupInfo; @@ -590,7 +591,8 @@ public class AppSecurityPermissions { private void addPermToList(List<MyPermissionInfo> permList, MyPermissionInfo pInfo) { if (pInfo.mLabel == null) { - pInfo.mLabel = pInfo.loadLabel(mPm); + pInfo.mLabel = pInfo.loadSafeLabel(mPm, 20000, PackageItemInfo.SAFE_LABEL_FLAG_TRIM + | PackageItemInfo.SAFE_LABEL_FLAG_FIRST_LINE); } int idx = Collections.binarySearch(permList, pInfo, mPermComparator); if(localLOGV) Log.i(TAG, "idx="+idx+", list.size="+permList.size()); @@ -611,7 +613,9 @@ public class AppSecurityPermissions { } MyPermissionGroupInfo group = mPermGroups.get(pInfo.group); if (group != null) { - pInfo.mLabel = pInfo.loadLabel(mPm); + pInfo.mLabel = pInfo.loadSafeLabel(mPm, 20000, + PackageItemInfo.SAFE_LABEL_FLAG_TRIM + | PackageItemInfo.SAFE_LABEL_FLAG_FIRST_LINE); addPermToList(group.mAllPermissions, pInfo); if (pInfo.mNew) { addPermToList(group.mNewPermissions, pInfo); @@ -622,14 +626,18 @@ public class AppSecurityPermissions { for (MyPermissionGroupInfo pgrp : mPermGroups.values()) { if (pgrp.labelRes != 0 || pgrp.nonLocalizedLabel != null) { - pgrp.mLabel = pgrp.loadLabel(mPm); + pgrp.mLabel = pgrp.loadSafeLabel(mPm, 20000, PackageItemInfo.SAFE_LABEL_FLAG_TRIM + | PackageItemInfo.SAFE_LABEL_FLAG_FIRST_LINE); } else { ApplicationInfo app; try { app = mPm.getApplicationInfo(pgrp.packageName, 0); - pgrp.mLabel = app.loadLabel(mPm); + pgrp.mLabel = app.loadSafeLabel(mPm, 20000, PackageItemInfo.SAFE_LABEL_FLAG_TRIM + | PackageItemInfo.SAFE_LABEL_FLAG_FIRST_LINE); } catch (NameNotFoundException e) { - pgrp.mLabel = pgrp.loadLabel(mPm); + pgrp.mLabel = pgrp.loadSafeLabel(mPm, 20000, + PackageItemInfo.SAFE_LABEL_FLAG_TRIM + | PackageItemInfo.SAFE_LABEL_FLAG_FIRST_LINE); } } mPermGroupsList.add(pgrp); |