summaryrefslogtreecommitdiffstats
path: root/core/java/android/app
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/app')
-rw-r--r--core/java/android/app/INotificationManager.aidl2
-rw-r--r--core/java/android/app/INotificationManagerCallback.aidl24
-rw-r--r--core/java/android/app/NotificationManager.java77
3 files changed, 27 insertions, 76 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();