diff --git a/core/java/android/content/pm/ShortcutManager.java b/core/java/android/content/pm/ShortcutManager.java index eaccb3aeab55a..36ab804a0b021 100644 --- a/core/java/android/content/pm/ShortcutManager.java +++ b/core/java/android/content/pm/ShortcutManager.java @@ -17,6 +17,7 @@ package android.content.pm; import android.annotation.NonNull; import android.annotation.TestApi; +import android.annotation.UserIdInt; import android.app.usage.UsageStatsManager; import android.content.Context; import android.os.RemoteException; @@ -379,6 +380,22 @@ public class ShortcutManager { } } + /** + * Called internally when an application is considered to have come to foreground + * even when technically it's not. This method resets the throttling for this package. + * For example, when the user sends an "inline reply" on an notification, the system UI will + * call it. + * + * @hide + */ + public void onApplicationActive(@NonNull String packageName, @UserIdInt int userId) { + try { + mService.onApplicationActive(packageName, userId); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + /** @hide injection point */ @VisibleForTesting protected int injectMyUserId() { diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 25dc3575d5f81..809774b2efb42 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -165,6 +165,9 @@ + + + - mService.onApplicationActive(CALLING_PACKAGE_1, USER_0)); + mManager.onApplicationActive(CALLING_PACKAGE_1, USER_0)); // Has permission, now it should pass. mCallerPermissions.add(permission.RESET_SHORTCUT_MANAGER_THROTTLING); - mService.onApplicationActive(CALLING_PACKAGE_1, USER_0); + mManager.onApplicationActive(CALLING_PACKAGE_1, USER_0); } public void testDumpsys_crossProfile() { diff --git a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest2.java b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest2.java index 399fddfcfb872..45a06eba06ead 100644 --- a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest2.java +++ b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest2.java @@ -1414,7 +1414,7 @@ public class ShortcutManagerTest2 extends BaseShortcutManagerTest { // Simulate a call from sys UI. mCallerPermissions.add(permission.RESET_SHORTCUT_MANAGER_THROTTLING); - mService.onApplicationActive(CALLING_PACKAGE_1, USER_0); + mManager.onApplicationActive(CALLING_PACKAGE_1, USER_0); runWithCaller(CALLING_PACKAGE_1, USER_0, () -> { assertEquals(3, mManager.getRemainingCallCount()); @@ -1435,7 +1435,7 @@ public class ShortcutManagerTest2 extends BaseShortcutManagerTest { MoreAsserts.assertNotEqual(3, mManager.getRemainingCallCount()); }); - mService.onApplicationActive(CALLING_PACKAGE_3, USER_0); + mManager.onApplicationActive(CALLING_PACKAGE_3, USER_0); runWithCaller(CALLING_PACKAGE_1, USER_0, () -> { assertEquals(3, mManager.getRemainingCallCount()); @@ -1456,7 +1456,7 @@ public class ShortcutManagerTest2 extends BaseShortcutManagerTest { MoreAsserts.assertNotEqual(3, mManager.getRemainingCallCount()); }); - mService.onApplicationActive(CALLING_PACKAGE_1, USER_10); + mManager.onApplicationActive(CALLING_PACKAGE_1, USER_10); runWithCaller(CALLING_PACKAGE_1, USER_0, () -> { assertEquals(3, mManager.getRemainingCallCount());