diff options
author | John Spurlock <jspurlock@google.com> | 2015-06-08 16:39:32 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-08 16:39:36 +0000 |
commit | 20ac61b8c0abd5af4ce32707e01cc1a501cbb7f0 (patch) | |
tree | 3836aeef229645f994193f21d38266184428e352 /core/java | |
parent | 616bb3d50c79842eeb5183d8637bc3a270a7d1a0 (diff) | |
parent | 7c74f78a85283912d7239214024ccca702622f21 (diff) | |
download | frameworks_base-20ac61b8c0abd5af4ce32707e01cc1a501cbb7f0.zip frameworks_base-20ac61b8c0abd5af4ce32707e01cc1a501cbb7f0.tar.gz frameworks_base-20ac61b8c0abd5af4ce32707e01cc1a501cbb7f0.tar.bz2 |
Merge "Zen: New user flow for requesting DND access." into mnc-dev
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/app/INotificationManager.aidl | 2 | ||||
-rw-r--r-- | core/java/android/app/INotificationManagerCallback.aidl | 24 | ||||
-rw-r--r-- | core/java/android/app/NotificationManager.java | 77 | ||||
-rw-r--r-- | core/java/android/provider/Settings.java | 18 |
4 files changed, 42 insertions, 79 deletions
diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl index 63ff005..f78fb47 100644 --- a/core/java/android/app/INotificationManager.aidl +++ b/core/java/android/app/INotificationManager.aidl @@ -17,7 +17,6 @@ package android.app; -import android.app.INotificationManagerCallback; import android.app.ITransientNotification; import android.app.Notification; import android.app.NotificationManager; @@ -87,7 +86,6 @@ interface INotificationManager oneway void setZenMode(int mode, in Uri conditionId, String reason); oneway void notifyConditions(String pkg, in IConditionProvider provider, in Condition[] conditions); oneway void requestZenModeConditions(in IConditionListener callback, int relevance); - oneway void requestNotificationPolicyAccess(String pkg, in INotificationManagerCallback callback); boolean isNotificationPolicyAccessGranted(String pkg); NotificationManager.Policy getNotificationPolicy(String pkg); void setNotificationPolicy(String pkg, in NotificationManager.Policy policy); diff --git a/core/java/android/app/INotificationManagerCallback.aidl b/core/java/android/app/INotificationManagerCallback.aidl deleted file mode 100644 index 9929745..0000000 --- a/core/java/android/app/INotificationManagerCallback.aidl +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2015, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.app; - -import android.app.NotificationManager; - -/** @hide */ -oneway interface INotificationManagerCallback { - void onPolicyRequestResult(boolean granted); -} diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java index 557964b..0904e21 100644 --- a/core/java/android/app/NotificationManager.java +++ b/core/java/android/app/NotificationManager.java @@ -101,6 +101,16 @@ public class NotificationManager = "android.os.action.ACTION_EFFECTS_SUPPRESSOR_CHANGED"; /** + * Intent that is broadcast when the state of {@link #isNotificationPolicyAccessGranted()} + * changes. + * + * This broadcast is only sent to registered receivers, and only to the apps that have changed. + */ + @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED + = "android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED"; + + /** * Intent that is broadcast when the state of getNotificationPolicy() changes. * This broadcast is only sent to registered receivers. */ @@ -403,55 +413,18 @@ public class NotificationManager } /** - * Requests the ability to read/modify notification policy for the calling package. - * - * @param callback required, used to receive the granted or the denied signal. - * @param handler The handler used when receiving the result. - * If null, the current thread is used. - */ - public void requestPolicyAccess(@NonNull final NotificationPolicyAccessRequestCallback callback, - @Nullable Handler handler) { - checkRequired("callback", callback); - final Handler h = handler != null ? handler : new Handler(); - INotificationManager service = getService(); - try { - service.requestNotificationPolicyAccess(mContext.getOpPackageName(), - new INotificationManagerCallback.Stub() { - @Override - public void onPolicyRequestResult(final boolean granted) throws RemoteException { - h.post(new Runnable() { - @Override - public void run() { - if (granted) { - callback.onAccessGranted(); - } else { - callback.onAccessDenied(); - } - } - }); - } - }); - } catch (RemoteException e) { - } - } - - /** Callback for receiving the result of a policy access request. */ - public static abstract class NotificationPolicyAccessRequestCallback { - /** - * Received if the request was granted for this package. - */ - public abstract void onAccessGranted(); - - /** - * Received if the request was denied for this package. - */ - public abstract void onAccessDenied(); - } - - /** * Checks the ability to read/modify notification policy for the calling package. * + * <p> * Returns true if the calling package can read/modify notification policy. + * + * <p> + * Request policy access by sending the user to the activity that matches the system intent + * action {@link android.provider.Settings#ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS}. + * + * <p> + * Use {@link #ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED} to listen for + * user grant or denial of this access. */ public boolean isNotificationPolicyAccessGranted() { INotificationManager service = getService(); @@ -476,7 +449,8 @@ public class NotificationManager * Gets the current notification policy. * * <p> - * Only available if policy access is granted. + * Only available if policy access is granted to this package. + * See {@link #isNotificationPolicyAccessGranted}. */ public Policy getNotificationPolicy() { INotificationManager service = getService(); @@ -491,7 +465,8 @@ public class NotificationManager * Sets the current notification policy. * * <p> - * Only available if policy access is granted. + * Only available if policy access is granted to this package. + * See {@link #isNotificationPolicyAccessGranted}. * * @param policy The new desired policy. */ @@ -716,7 +691,8 @@ public class NotificationManager * unavailable. * * <p> - * Only available if policy access is granted. + * Only available if policy access is granted to this package. + * See {@link #isNotificationPolicyAccessGranted}. */ public final int getCurrentInterruptionFilter() { final INotificationManager service = getService(); @@ -738,7 +714,8 @@ public class NotificationManager * unavailable. * * <p> - * Only available if policy access is granted. + * Only available if policy access is granted to this package. + * See {@link #isNotificationPolicyAccessGranted}. */ public final void setInterruptionFilter(int interruptionFilter) { final INotificationManager service = getService(); diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 37645b5..cac4a53 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -811,14 +811,17 @@ public final class Settings { /** * Activity Action: Show Do Not Disturb access settings. * <p> - * In some cases, a matching Activity may not exist, so ensure you safeguard against this. + * Users can grant and deny access to Do Not Disturb configuration from here. + * See {@link android.app.NotificationManager#isNotificationPolicyAccessGranted()} for more + * details. * <p> * Input: Nothing. * <p> * Output: Nothing. */ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) - public static final String ACTION_ZEN_ACCESS_SETTINGS = "android.settings.ZEN_ACCESS_SETTINGS"; + public static final String ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS + = "android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS"; /** * @hide @@ -5425,7 +5428,7 @@ public final class Settings { public static final String ASSIST_STRUCTURE_ENABLED = "assist_structure_enabled"; /** - * Names of the packages that the current user has explicitly allowed to + * Names of the service components that the current user has explicitly allowed to * see all of the user's notifications, separated by ':'. * * @hide @@ -5433,6 +5436,15 @@ public final class Settings { public static final String ENABLED_NOTIFICATION_LISTENERS = "enabled_notification_listeners"; /** + * Names of the packages that the current user has explicitly allowed to + * manage notification policy configuration, separated by ':'. + * + * @hide + */ + public static final String ENABLED_NOTIFICATION_POLICY_ACCESS_PACKAGES = + "enabled_notification_policy_access_packages"; + + /** * @hide */ public static final String ENABLED_CONDITION_PROVIDERS = "enabled_condition_providers"; |