From eefce6a1f30bab0d52ae45d3fc64808fed40fa06 Mon Sep 17 00:00:00 2001 From: Varun Shah Date: Mon, 2 Aug 2021 13:16:03 -0700 Subject: [PATCH] Handle blobs and leases that never expire correctly. Add logic to properly handle blobs and leases that never expire. Also add the relevant strings required in this package. Fixes: 194439893 Test: make RunSettingsRoboTests ROBOTEST_FILTER=SharedDataPreferenceControllerTest Test: manual (visual) Change-Id: Ifeb216a92a3be8d1db3574b4f63e2d04adace4ea --- res/values/strings.xml | 5 +++++ .../development/storage/BlobInfoListView.java | 10 ++++++++-- .../development/storage/LeaseInfoListView.java | 11 +++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index f790314ef80..89b1541c1de 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -13307,6 +13307,11 @@ Suspend execution for cached apps + + Never expires. + + Lease never expires. + Allow screen overlays on Settings diff --git a/src/com/android/settings/development/storage/BlobInfoListView.java b/src/com/android/settings/development/storage/BlobInfoListView.java index 54579645f16..d3c70336756 100644 --- a/src/com/android/settings/development/storage/BlobInfoListView.java +++ b/src/com/android/settings/development/storage/BlobInfoListView.java @@ -156,10 +156,16 @@ public class BlobInfoListView extends ListActivity { final BlobInfo blob = getItem(position); holder.blobLabel.setText(blob.getLabel()); holder.blobId.setText(getString(R.string.blob_id_text, blob.getId())); - holder.blobExpiry.setText(getString(R.string.blob_expires_text, - SharedDataUtils.formatTime(blob.getExpiryTimeMs()))); + holder.blobExpiry.setText(formatExpiryTime(blob.getExpiryTimeMs())); holder.blobSize.setText(SharedDataUtils.formatSize(blob.getSizeBytes())); return convertView; } + + private String formatExpiryTime(long expiryTimeMs) { + if (expiryTimeMs == 0) { + return getString(R.string.blob_never_expires_text); + } + return getString(R.string.blob_expires_text, SharedDataUtils.formatTime(expiryTimeMs)); + } } } diff --git a/src/com/android/settings/development/storage/LeaseInfoListView.java b/src/com/android/settings/development/storage/LeaseInfoListView.java index 22002fb49f4..597e155908b 100644 --- a/src/com/android/settings/development/storage/LeaseInfoListView.java +++ b/src/com/android/settings/development/storage/LeaseInfoListView.java @@ -171,8 +171,7 @@ public class LeaseInfoListView extends ListActivity { holder.appIcon.setImageDrawable(appIcon); holder.leasePackageName.setText(lease.getPackageName()); holder.leaseDescription.setText(getDescriptionString(lease)); - holder.leaseExpiry.setText(getString(R.string.accessor_expires_text, - SharedDataUtils.formatTime(lease.getExpiryTimeMillis()))); + holder.leaseExpiry.setText(formatExpiryTime(lease.getExpiryTimeMillis())); return convertView; } @@ -191,5 +190,13 @@ public class LeaseInfoListView extends ListActivity { } return description; } + + private String formatExpiryTime(long expiryTimeMillis) { + if (expiryTimeMillis == 0) { + return getString(R.string.accessor_never_expires_text); + } + return getString(R.string.accessor_expires_text, + SharedDataUtils.formatTime(expiryTimeMillis)); + } } }