summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author eunjeongshin <eunjeongshin@google.com> 2022-04-12 20:38:39 +0000
committer eunjeongshin <eunjeongshin@google.com> 2022-04-12 20:42:43 +0000
commit4ae1ea9fba8ec8a9e38b377df4b3cf1c14e90c39 (patch)
tree27b0d0036a7bc1d814ab2f4a79849e028e2da287
parentd405fc4491a270a28d9acc1b3c313690024cce31 (diff)
Handling exception when per-use prompt cannot be generated
Add handling corner cases when the system fails to generate per-use prompt for device log access. This change addresses when the passed package name is null or the application info cannot be found. Bug: 228053177 Test: CtsVerifier Ignore-AOSP-First: pending fix for logcat privacy issue Change-Id: I03058599332108821d461bbe38072a23bae2ed3c
-rw-r--r--services/core/java/com/android/server/logcat/LogAccessDialogActivity.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/logcat/LogAccessDialogActivity.java b/services/core/java/com/android/server/logcat/LogAccessDialogActivity.java
index b45bfb1c2d92..79088d0398d2 100644
--- a/services/core/java/com/android/server/logcat/LogAccessDialogActivity.java
+++ b/services/core/java/com/android/server/logcat/LogAccessDialogActivity.java
@@ -116,6 +116,10 @@ public class LogAccessDialogActivity extends Activity implements
}
mPackageName = intent.getStringExtra(Intent.EXTRA_PACKAGE_NAME);
+ if (mPackageName == null || mPackageName.length() == 0) {
+ throw new NullPointerException("Package Name is null");
+ }
+
mUid = intent.getIntExtra("com.android.server.logcat.uid", 0);
mGid = intent.getIntExtra("com.android.server.logcat.gid", 0);
mPid = intent.getIntExtra("com.android.server.logcat.pid", 0);
@@ -154,12 +158,17 @@ public class LogAccessDialogActivity extends Activity implements
CharSequence appLabel = pm.getApplicationInfoAsUser(callingPackage,
PackageManager.MATCH_DIRECT_BOOT_AUTO,
UserHandle.getUserId(uid)).loadLabel(pm);
- if (appLabel == null) {
+ if (appLabel == null || appLabel.length() == 0) {
throw new NameNotFoundException("Application Label is null");
}
- return context.getString(com.android.internal.R.string.log_access_confirmation_title,
- appLabel);
+ String titleString = context.getString(
+ com.android.internal.R.string.log_access_confirmation_title, appLabel);
+ if (titleString == null || titleString.length() == 0) {
+ throw new NullPointerException("Title is null");
+ }
+
+ return titleString;
}
/**