diff options
author | Philip P. Moltmann <moltmann@google.com> | 2018-04-23 09:09:16 -0700 |
---|---|---|
committer | Philip P. Moltmann <moltmann@google.com> | 2018-05-08 11:27:41 -0700 |
commit | a6f5c70b91ca7dc7c3a331d6ddce37ee64d14fe6 (patch) | |
tree | 0e6ed8859057733787b7092b3fbb57d26f63a0c3 /services/companion | |
parent | 96930e4faad8ec28e2bbfeffeed8f02109fdcc47 (diff) |
Allow to influence how loadSafeLabel works
Also remove all references to old loadSafeLabel method to prevent
proliferation of old method via copy+paste.
The implementation assumes that there are three cases:
- Short labels that don't have anything wrong with them
- Labels that are fine, but are a little too long
- Intentionally bad label that try to break stuff and slow things down.
In the first two cases no characters are marked for removal, in the
third case we have an implementation that does not use a lot of memory
and has linear performance when there are a lot of bad characters.
Test: gts-tradefed run gts-dev -m GtsContentTestCases
Bug: 77964730
Change-Id: I3feb17b2a12018cd5407c88fe3603f2ebbc9d14e
Diffstat (limited to 'services/companion')
-rw-r--r-- | services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java index d44fe4dbc450..3865b2779466 100644 --- a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java +++ b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java @@ -23,7 +23,6 @@ import static com.android.internal.util.Preconditions.checkNotNull; import static com.android.internal.util.Preconditions.checkState; import static com.android.internal.util.function.pooled.PooledLambda.obtainRunnable; -import android.Manifest; import android.annotation.CheckResult; import android.annotation.Nullable; import android.app.PendingIntent; @@ -39,6 +38,7 @@ import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.FeatureInfo; import android.content.pm.PackageInfo; +import android.content.pm.PackageItemInfo; import android.content.pm.PackageManager; import android.net.NetworkPolicyManager; import android.os.Binder; @@ -289,7 +289,10 @@ public class CompanionDeviceManagerService extends SystemService implements Bind String packageTitle = BidiFormatter.getInstance().unicodeWrap( getPackageInfo(callingPackage, userId) .applicationInfo - .loadSafeLabel(getContext().getPackageManager()) + .loadSafeLabel(getContext().getPackageManager(), + PackageItemInfo.DEFAULT_MAX_LABEL_SIZE_PX, + PackageItemInfo.SAFE_LABEL_FLAG_TRIM + | PackageItemInfo.SAFE_LABEL_FLAG_FIRST_LINE) .toString()); long identity = Binder.clearCallingIdentity(); try { |