Allow sysui-managed remote volume controllers.

- Relax restriction on audio service calls that assume the volume
  ui is systemui, allow calls from a blessed component app.
- Blessed component app service saved in secure settings.
- SystemUI mediates requests to replace the volume dialog, prompts
  the user on activation.
- Show a low pri ongoing notification when the volume dialog is
  being replaced, to allow user restoration at any time.
- Replace the controller management code in VolumeUI to use a
  ServiceMonitor, backed by the new blessed app component setting.
- Add proper zen-related noman client wrappers, make avail to the
  registered volume controller.
- Everything is still @hidden, no api impact.

Bug: 19260237
Change-Id: Ie1383f57659090318a7eda737fdad5b8f88737d4
diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl
index 88b9080..5d864df 100644
--- a/core/java/android/app/INotificationManager.aidl
+++ b/core/java/android/app/INotificationManager.aidl
@@ -75,6 +75,7 @@
 
     ZenModeConfig getZenModeConfig();
     boolean setZenModeConfig(in ZenModeConfig config);
+    oneway void setZenMode(int mode);
     oneway void notifyConditions(String pkg, in IConditionProvider provider, in Condition[] conditions);
     oneway void requestZenModeConditions(in IConditionListener callback, int relevance);
     oneway void setZenModeCondition(in Condition condition);
diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java
index cf54107..479327d 100644
--- a/core/java/android/app/NotificationManager.java
+++ b/core/java/android/app/NotificationManager.java
@@ -27,6 +27,9 @@
 import android.os.ServiceManager;
 import android.os.StrictMode;
 import android.os.UserHandle;
+import android.service.notification.Condition;
+import android.service.notification.IConditionListener;
+import android.service.notification.ZenModeConfig;
 import android.util.Log;
 
 /**
@@ -276,5 +279,53 @@
         }
     }
 
+    /**
+     * @hide
+     */
+    public void setZenMode(int mode) {
+        INotificationManager service = getService();
+        try {
+            service.setZenMode(mode);
+        } catch (RemoteException e) {
+        }
+    }
+
+    /**
+     * @hide
+     */
+    public void requestZenModeConditions(IConditionListener listener, int relevance) {
+        INotificationManager service = getService();
+        try {
+            service.requestZenModeConditions(listener, relevance);
+        } catch (RemoteException e) {
+        }
+    }
+
+    /**
+     * @hide
+     */
+    public void setZenModeCondition(Condition exitCondition) {
+        INotificationManager service = getService();
+        try {
+            service.setZenModeCondition(exitCondition);
+        } catch (RemoteException e) {
+        }
+    }
+
+    /**
+     * @hide
+     */
+    public Condition getZenModeCondition() {
+        INotificationManager service = getService();
+        try {
+            final ZenModeConfig config = service.getZenModeConfig();
+            if (config != null) {
+                return config.exitCondition;
+            }
+        } catch (RemoteException e) {
+        }
+        return null;
+    }
+
     private Context mContext;
 }
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index dddbe78..5380cd6 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -4762,6 +4762,10 @@
         public static final String BAR_SERVICE_COMPONENT = "bar_service_component";
 
         /** @hide */
+        public static final String VOLUME_CONTROLLER_SERVICE_COMPONENT
+                = "volume_controller_service_component";
+
+        /** @hide */
         public static final String IMMERSIVE_MODE_CONFIRMATIONS = "immersive_mode_confirmations";
 
         /**