Skip to content

Commit cd8fd0c

Browse files
committed
[Accessibility] Ignore Resources.NotFoundException
In some custom ROMs (e.g., Huawei), the AOSP-default string names are not used which causes the app to crash as it attempts to get the value of those strings. Signed-off-by: Muntashir Al-Islam <muntashirakon@riseup.net>
1 parent b64f7ba commit cd8fd0c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

app/src/main/java/io/github/muntashirakon/AppManager/accessibility/NoRootAccessibilityService.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,14 @@ private void automateInstallationUninstallation(@NonNull AccessibilityEvent even
136136

137137
private boolean navigateToStorageAndCache(AccessibilityEvent event) {
138138
String storageSettings;
139-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
140-
storageSettings = getString(event, "storage_settings_for_app");
141-
} else storageSettings = getString(event, "storage_label");
139+
try {
140+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
141+
storageSettings = getString(event, "storage_settings_for_app");
142+
} else storageSettings = getString(event, "storage_label");
143+
} catch (Resources.NotFoundException e) {
144+
// Failed: non-AOSP device
145+
return false;
146+
}
142147
SystemClock.sleep(500); // It may take a few moments to initialise the Recycler/List views
143148
AccessibilityNodeInfo storageNode = findViewByTextRecursive(getRootInActiveWindow(), storageSettings);
144149
if (storageNode != null) {

0 commit comments

Comments
 (0)