Fixing the crash when tapping the "Downloaded apps" in Accessibility page.

Root cause:
When Accessibility settings parse the application which is from google
play store, the settings have no check if the resource is valid before
delivery the parameter into the corresponding fragment.

Solution:
Check if the resource is valid before creating the image uri.

Bug: 190716289
Test: manual test
Change-Id: I56eba2232ddf6ed5b2e526d4698479465a012e52
This commit is contained in:
Peter_Liang
2021-06-11 10:21:12 +08:00
committed by PETER LIANG
parent d2c4944cbb
commit 652c425acb
2 changed files with 12 additions and 8 deletions

View File

@@ -396,10 +396,12 @@ public class ToggleAccessibilityServicePreferenceFragment extends
// Settings animated image.
final int animatedImageRes = arguments.getInt(
AccessibilitySettings.EXTRA_ANIMATED_IMAGE_RES);
mImageUri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
.authority(mComponentName.getPackageName())
.appendPath(String.valueOf(animatedImageRes))
.build();
if (animatedImageRes > 0) {
mImageUri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
.authority(mComponentName.getPackageName())
.appendPath(String.valueOf(animatedImageRes))
.build();
}
// Get Accessibility service name.
mPackageName = getAccessibilityServiceInfo().getResolveInfo().loadLabel(