From 088c448e79498fbe44783a7d62d919d3b9a869d1 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Wed, 10 Apr 2019 12:43:27 -0400 Subject: [PATCH] Rename capabilities to adjustments To match existing API Test: make, cts Fixes: 130224929 Change-Id: I881ce11b583b389ee43bad6b45f837c85f949aa5 --- api/system-current.txt | 4 ++-- api/test-current.txt | 8 ++++---- core/java/android/app/INotificationManager.aidl | 6 +++--- core/java/android/app/NotificationManager.java | 12 ++++++------ .../service/notification/INotificationListener.aidl | 2 +- .../service/notification/NotificationAssistantService.java | 14 +++++++------- .../service/notification/NotificationListenerService.java | 2 +- .../server/notification/NotificationManagerService.java | 12 ++++++------ .../notification/NotificationManagerServiceTest.java | 10 +++++----- 9 files changed, 35 insertions(+), 35 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index 76b8f6610590..f2423437c3fc 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -553,7 +553,7 @@ package android.app { } public class NotificationManager { - method @NonNull public java.util.List getAllowedAssistantCapabilities(); + method @NonNull public java.util.List getAllowedAssistantAdjustments(); method @Nullable public android.content.ComponentName getAllowedNotificationAssistant(); method public boolean isNotificationAssistantAccessGranted(@NonNull android.content.ComponentName); method public void setNotificationAssistantAccessGranted(@Nullable android.content.ComponentName, boolean); @@ -6631,8 +6631,8 @@ package android.service.notification { method public final void adjustNotification(@NonNull android.service.notification.Adjustment); method public final void adjustNotifications(@NonNull java.util.List); method public void onActionInvoked(@NonNull String, @NonNull android.app.Notification.Action, int); + method public void onAllowedAdjustmentsChanged(); method @NonNull public final android.os.IBinder onBind(@Nullable android.content.Intent); - method public void onCapabilitiesChanged(); method public void onNotificationDirectReplied(@NonNull String); method @Nullable public abstract android.service.notification.Adjustment onNotificationEnqueued(@NonNull android.service.notification.StatusBarNotification); method @Nullable public android.service.notification.Adjustment onNotificationEnqueued(@NonNull android.service.notification.StatusBarNotification, @NonNull android.app.NotificationChannel); diff --git a/api/test-current.txt b/api/test-current.txt index 7121a549176a..2932ad6a4ee0 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -328,9 +328,9 @@ package android.app { } public class NotificationManager { - method public void allowAssistantCapability(String); - method public void disallowAssistantCapability(String); - method @NonNull public java.util.List getAllowedAssistantCapabilities(); + method public void allowAssistantAdjustment(String); + method public void disallowAssistantAdjustment(String); + method @NonNull public java.util.List getAllowedAssistantAdjustments(); method @Nullable public android.content.ComponentName getAllowedNotificationAssistant(); method public android.content.ComponentName getEffectsSuppressor(); method public boolean isNotificationAssistantAccessGranted(@NonNull android.content.ComponentName); @@ -2488,8 +2488,8 @@ package android.service.notification { method public final void adjustNotification(@NonNull android.service.notification.Adjustment); method public final void adjustNotifications(@NonNull java.util.List); method public void onActionInvoked(@NonNull String, @NonNull android.app.Notification.Action, int); + method public void onAllowedAdjustmentsChanged(); method @NonNull public final android.os.IBinder onBind(@Nullable android.content.Intent); - method public void onCapabilitiesChanged(); method public void onNotificationDirectReplied(@NonNull String); method @Nullable public abstract android.service.notification.Adjustment onNotificationEnqueued(@NonNull android.service.notification.StatusBarNotification); method @Nullable public android.service.notification.Adjustment onNotificationEnqueued(@NonNull android.service.notification.StatusBarNotification, @NonNull android.app.NotificationChannel); diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl index 7884872a7ef3..b3c2429004b8 100644 --- a/core/java/android/app/INotificationManager.aidl +++ b/core/java/android/app/INotificationManager.aidl @@ -70,9 +70,9 @@ interface INotificationManager boolean areNotificationsEnabled(String pkg); int getPackageImportance(String pkg); - List getAllowedAssistantCapabilities(String pkg); - void allowAssistantCapability(String adjustmentType); - void disallowAssistantCapability(String adjustmentType); + List getAllowedAssistantAdjustments(String pkg); + void allowAssistantAdjustment(String adjustmentType); + void disallowAssistantAdjustment(String adjustmentType); boolean shouldHideSilentStatusIcons(String callingPkg); void setHideSilentStatusIcons(boolean hide); diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java index d54aca89c50d..dd39376f80ca 100644 --- a/core/java/android/app/NotificationManager.java +++ b/core/java/android/app/NotificationManager.java @@ -1206,10 +1206,10 @@ public class NotificationManager { */ @SystemApi @TestApi - public @NonNull @Adjustment.Keys List getAllowedAssistantCapabilities() { + public @NonNull @Adjustment.Keys List getAllowedAssistantAdjustments() { INotificationManager service = getService(); try { - return service.getAllowedAssistantCapabilities(mContext.getOpPackageName()); + return service.getAllowedAssistantAdjustments(mContext.getOpPackageName()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1219,10 +1219,10 @@ public class NotificationManager { * @hide */ @TestApi - public void allowAssistantCapability(String capability) { + public void allowAssistantAdjustment(String capability) { INotificationManager service = getService(); try { - service.allowAssistantCapability(capability); + service.allowAssistantAdjustment(capability); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -1232,10 +1232,10 @@ public class NotificationManager { * @hide */ @TestApi - public void disallowAssistantCapability(String capability) { + public void disallowAssistantAdjustment(String capability) { INotificationManager service = getService(); try { - service.disallowAssistantCapability(capability); + service.disallowAssistantAdjustment(capability); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/core/java/android/service/notification/INotificationListener.aidl b/core/java/android/service/notification/INotificationListener.aidl index 8bb5f97ca878..5977bafd7cf1 100644 --- a/core/java/android/service/notification/INotificationListener.aidl +++ b/core/java/android/service/notification/INotificationListener.aidl @@ -53,5 +53,5 @@ oneway interface INotificationListener void onNotificationDirectReply(String key); void onSuggestedReplySent(String key, in CharSequence reply, int source); void onActionClicked(String key, in Notification.Action action, int source); - void onCapabilitiesChanged(); + void onAllowedAdjustmentsChanged(); } diff --git a/core/java/android/service/notification/NotificationAssistantService.java b/core/java/android/service/notification/NotificationAssistantService.java index b4fd39701233..cafeb87691bd 100644 --- a/core/java/android/service/notification/NotificationAssistantService.java +++ b/core/java/android/service/notification/NotificationAssistantService.java @@ -220,10 +220,10 @@ public abstract class NotificationAssistantService extends NotificationListenerS /** * Implement this to know when a user has changed which features of * their notifications the assistant can modify. - *

Query {@link NotificationManager#getAllowedAssistantCapabilities()} to see what + *

Query {@link NotificationManager#getAllowedAssistantAdjustments()} to see what * {@link Adjustment adjustments} you are currently allowed to make.

*/ - public void onCapabilitiesChanged() { + public void onAllowedAdjustmentsChanged() { } /** @@ -361,8 +361,8 @@ public abstract class NotificationAssistantService extends NotificationListenerS } @Override - public void onCapabilitiesChanged() { - mHandler.obtainMessage(MyHandler.MSG_ON_CAPABILITIES_CHANGED).sendToTarget(); + public void onAllowedAdjustmentsChanged() { + mHandler.obtainMessage(MyHandler.MSG_ON_ALLOWED_ADJUSTMENTS_CHANGED).sendToTarget(); } } @@ -374,7 +374,7 @@ public abstract class NotificationAssistantService extends NotificationListenerS public static final int MSG_ON_NOTIFICATION_DIRECT_REPLY_SENT = 5; public static final int MSG_ON_SUGGESTED_REPLY_SENT = 6; public static final int MSG_ON_ACTION_INVOKED = 7; - public static final int MSG_ON_CAPABILITIES_CHANGED = 8; + public static final int MSG_ON_ALLOWED_ADJUSTMENTS_CHANGED = 8; public MyHandler(Looper looper) { super(looper, null, false); @@ -456,8 +456,8 @@ public abstract class NotificationAssistantService extends NotificationListenerS onActionInvoked(key, action, source); break; } - case MSG_ON_CAPABILITIES_CHANGED: { - onCapabilitiesChanged(); + case MSG_ON_ALLOWED_ADJUSTMENTS_CHANGED: { + onAllowedAdjustmentsChanged(); break; } } diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java index 016f4aacef2a..ed236ebe965f 100644 --- a/core/java/android/service/notification/NotificationListenerService.java +++ b/core/java/android/service/notification/NotificationListenerService.java @@ -1399,7 +1399,7 @@ public abstract class NotificationListenerService extends Service { } @Override - public void onCapabilitiesChanged() { + public void onAllowedAdjustmentsChanged() { // no-op in the listener } diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index dec47a1082fc..be6c017a2d11 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -2856,7 +2856,7 @@ public class NotificationManagerService extends SystemService { } @Override - public List getAllowedAssistantCapabilities(String pkg) { + public List getAllowedAssistantAdjustments(String pkg) { checkCallerIsSystemOrSameApp(pkg); if (!isCallerSystemOrPhone() @@ -2864,11 +2864,11 @@ public class NotificationManagerService extends SystemService { throw new SecurityException("Not currently an assistant"); } - return mAssistants.getAllowedAssistantCapabilities(); + return mAssistants.getAllowedAssistantAdjustments(); } @Override - public void allowAssistantCapability(String adjustmentType) { + public void allowAssistantAdjustment(String adjustmentType) { checkCallerIsSystemOrSystemUiOrShell(); mAssistants.allowAdjustmentType(adjustmentType); @@ -2876,7 +2876,7 @@ public class NotificationManagerService extends SystemService { } @Override - public void disallowAssistantCapability(String adjustmentType) { + public void disallowAssistantAdjustment(String adjustmentType) { checkCallerIsSystemOrSystemUiOrShell(); mAssistants.disallowAdjustmentType(adjustmentType); @@ -7410,7 +7410,7 @@ public class NotificationManagerService extends SystemService { } } - protected List getAllowedAssistantCapabilities() { + protected List getAllowedAssistantAdjustments() { synchronized (mLock) { List types = new ArrayList<>(); types.addAll(mAllowedAdjustments); @@ -7470,7 +7470,7 @@ public class NotificationManagerService extends SystemService { private void notifyCapabilitiesChanged(final ManagedServiceInfo info) { final INotificationListener assistant = (INotificationListener) info.service; try { - assistant.onCapabilitiesChanged(); + assistant.onAllowedAdjustmentsChanged(); } catch (RemoteException ex) { Slog.e(TAG, "unable to notify assistant (capabilities): " + assistant, ex); } diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java index b0788253d0a7..659ec746444d 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -4918,15 +4918,15 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertEquals(1, mService.getNotificationRecordCount()); } - public void testGetAllowedAssistantCapabilities() throws Exception { - List capabilities = mBinderService.getAllowedAssistantCapabilities(null); + public void testGetAllowedAssistantAdjustments() throws Exception { + List capabilities = mBinderService.getAllowedAssistantAdjustments(null); assertNotNull(capabilities); for (int i = capabilities.size() - 1; i >= 0; i--) { String capability = capabilities.get(i); - mBinderService.disallowAssistantCapability(capability); - assertEquals(i + 1, mBinderService.getAllowedAssistantCapabilities(null).size()); - List currentCapabilities = mBinderService.getAllowedAssistantCapabilities(null); + mBinderService.disallowAssistantAdjustment(capability); + assertEquals(i + 1, mBinderService.getAllowedAssistantAdjustments(null).size()); + List currentCapabilities = mBinderService.getAllowedAssistantAdjustments(null); assertNotNull(currentCapabilities); assertFalse(currentCapabilities.contains(capability)); } -- 2.11.0