Fix DND crash from SpringboardActivity

Special case Uris need to explicitly add their intents.
This unfortunately duplicates a list of special-cased Slices,
but I have attached a bug with a plan to address this duplicity in Q.

Change-Id: I346915c32543713d33716422018d7c950cce323d
Fixes: 80065409
Test: atest SliceDeepLinkSpringBoardTest
This commit is contained in:
Matthew Fritze
2018-05-24 16:09:05 -07:00
parent 2e0709b3b8
commit a559103b1b
6 changed files with 132 additions and 45 deletions

View File

@@ -100,6 +100,17 @@ public class BluetoothSliceBuilder {
.build();
}
public static Intent getIntent(Context context) {
final String screenTitle = context.getText(R.string.bluetooth_settings_title).toString();
final Uri contentUri = new Uri.Builder().appendPath(
SettingsSlicesContract.KEY_BLUETOOTH).build();
return DatabaseIndexingUtils.buildSearchResultPageIntent(context,
BluetoothDashboardFragment.class.getName(), null /* key */, screenTitle,
MetricsProto.MetricsEvent.SETTINGS_CONNECTED_DEVICE_CATEGORY)
.setClassName(context.getPackageName(), SubSettings.class.getName())
.setData(contentUri);
}
/**
* Update the current Bluetooth status to the boolean value keyed by
* {@link android.app.slice.Slice#EXTRA_TOGGLE_STATE} on {@param intent}.
@@ -122,15 +133,7 @@ public class BluetoothSliceBuilder {
}
private static PendingIntent getPrimaryAction(Context context) {
final String screenTitle = context.getText(R.string.bluetooth_settings_title).toString();
final Uri contentUri = new Uri.Builder().appendPath(
SettingsSlicesContract.KEY_BLUETOOTH).build();
final Intent intent = DatabaseIndexingUtils.buildSearchResultPageIntent(context,
BluetoothDashboardFragment.class.getName(), null /* key */, screenTitle,
MetricsProto.MetricsEvent.SETTINGS_CONNECTED_DEVICE_CATEGORY)
.setClassName(context.getPackageName(), SubSettings.class.getName())
.setData(contentUri);
final Intent intent = getIntent(context);
return PendingIntent.getActivity(context, 0 /* requestCode */,
intent, 0 /* flags */);
}