summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2021-12-16 22:54:12 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2021-12-16 22:54:12 +0000
commit4ad1a3d750f4f8355d7b89ff12f1b87fca70b88c (patch)
treea3e2ac9527cc7c2faa9f229a8da4d3ae617f9998
parent2d46f6c8f5b094ca6ddf846d34b97d9bff6e5a06 (diff)
parent4413f9d635792aebb35c58284eac89ba79b3b184 (diff)
Merge "Merge "Prevent bad intents from crashing sysui" into sc-v2-dev am: 08d6bcbd19" into sc-v2-dev-plus-aosp am: 4413f9d635
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16493100 Change-Id: Ib805bf25905b75ab2646b14221cb57c4db980857
-rw-r--r--packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java15
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt5
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt7
3 files changed, 21 insertions, 6 deletions
diff --git a/packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java b/packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java
index a16f5cd5d930..da9a92a1f6b4 100644
--- a/packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java
+++ b/packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java
@@ -20,9 +20,11 @@ import android.app.PendingIntent;
import android.app.smartspace.SmartspaceAction;
import android.app.smartspace.SmartspaceTarget;
import android.app.smartspace.SmartspaceTargetEvent;
+import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Parcelable;
+import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
@@ -39,6 +41,7 @@ import java.util.List;
public interface BcSmartspaceDataPlugin extends Plugin {
String ACTION = "com.android.systemui.action.PLUGIN_BC_SMARTSPACE_DATA";
int VERSION = 1;
+ String TAG = "BcSmartspaceDataPlugin";
/** Register a listener to get Smartspace data. */
void registerListener(SmartspaceTargetListener listener);
@@ -124,10 +127,14 @@ public interface BcSmartspaceDataPlugin extends Plugin {
/** Interface for launching Intents, which can differ on the lockscreen */
interface IntentStarter {
default void startFromAction(SmartspaceAction action, View v, boolean showOnLockscreen) {
- if (action.getIntent() != null) {
- startIntent(v, action.getIntent(), showOnLockscreen);
- } else if (action.getPendingIntent() != null) {
- startPendingIntent(action.getPendingIntent(), showOnLockscreen);
+ try {
+ if (action.getIntent() != null) {
+ startIntent(v, action.getIntent(), showOnLockscreen);
+ } else if (action.getPendingIntent() != null) {
+ startPendingIntent(action.getPendingIntent(), showOnLockscreen);
+ }
+ } catch (ActivityNotFoundException e) {
+ Log.w(TAG, "Could not launch intent for action: " + action, e);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt
index a44de2ce5699..a4e2d5ec0829 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt
@@ -241,6 +241,10 @@ class LockscreenSmartspaceController @Inject constructor(
configurationController.addCallback(configChangeListener)
statusBarStateController.addCallback(statusBarStateListener)
+ plugin.registerSmartspaceEventNotifier {
+ e -> session?.notifySmartspaceEvent(e)
+ }
+
reloadSmartspace()
}
@@ -266,6 +270,7 @@ class LockscreenSmartspaceController @Inject constructor(
statusBarStateController.removeCallback(statusBarStateListener)
session = null
+ plugin?.registerSmartspaceEventNotifier(null)
plugin?.onTargetsAvailable(emptyList())
Log.d(TAG, "Ending smartspace session for lockscreen")
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt
index de627de2e1d0..1961ab269267 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt
@@ -214,6 +214,8 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
// THEN the session is created
verify(smartspaceManager).createSmartspaceSession(any())
+ // THEN an event notifier is registered
+ verify(plugin).registerSmartspaceEventNotifier(any())
}
@Test
@@ -241,7 +243,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
}
@Test
- fun testEmptyListIsEmittedAfterDisconnect() {
+ fun testEmptyListIsEmittedAndNotifierRemovedAfterDisconnect() {
// GIVEN a registered listener on an active session
connectSession()
clearInvocations(plugin)
@@ -250,8 +252,9 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
controller.stateChangeListener.onViewDetachedFromWindow(smartspaceView as View)
controller.disconnect()
- // THEN the listener receives an empty list of targets
+ // THEN the listener receives an empty list of targets and unregisters the notifier
verify(plugin).onTargetsAvailable(emptyList())
+ verify(plugin).registerSmartspaceEventNotifier(null)
}
@Test