Merge "Make a11y shortcut robust to services w/no summary"

This commit is contained in:
TreeHugger Robot
2018-02-27 02:19:26 +00:00
committed by Android (Google) Code Review
2 changed files with 12 additions and 1 deletions

View File

@@ -319,7 +319,7 @@ public class AccessibilityShortcutController {
}
final PackageManager pm = mContext.getPackageManager();
String label = serviceInfo.getResolveInfo().loadLabel(pm).toString();
String summary = serviceInfo.loadSummary(pm).toString();
CharSequence summary = serviceInfo.loadSummary(pm);
if (!includeSummary || TextUtils.isEmpty(summary)) {
return label;
}

View File

@@ -397,6 +397,17 @@ public class AccessibilityShortcutControllerTest {
}
}
@Test
public void testOnAccessibilityShortcut_forServiceWithNoSummary_doesNotCrash()
throws Exception {
configureShortcutEnabled(ENABLED_EXCEPT_LOCK_SCREEN);
configureValidShortcutService();
when(mServiceInfo.loadSummary(any())).thenReturn(null);
Settings.Secure.putInt(mContentResolver, ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, 1);
getController().performAccessibilityShortcut();
verify(mAccessibilityManagerService).performAccessibilityShortcut();
}
@Test
public void testOnAccessibilityShortcut_forFrameworkFeature_callsServiceWithNoToast()
throws Exception {