Implement long-term condition subscriptions.

Bind long-term conditions (like "in a meeting") to enter/exit
zen mode automatically.

Persist automatic condition subscriptions to maintain them across
reboots.

Normalize condition state binding: true => enter zen, false => exit.

Change-Id: Icba2b8b25c0a352ae8215f4c0a324e4f966c0165
diff --git a/services/core/java/com/android/server/notification/ManagedServices.java b/services/core/java/com/android/server/notification/ManagedServices.java
index 0621f58..d34b09c 100644
--- a/services/core/java/com/android/server/notification/ManagedServices.java
+++ b/services/core/java/com/android/server/notification/ManagedServices.java
@@ -101,7 +101,7 @@
 
     abstract protected IInterface asInterface(IBinder binder);
 
-    abstract protected void onServiceAdded(IInterface service);
+    abstract protected void onServiceAdded(ManagedServiceInfo info);
 
     protected void onServiceRemovedLocked(ManagedServiceInfo removed) { }
 
@@ -368,11 +368,12 @@
                             @Override
                             public void onServiceConnected(ComponentName name, IBinder binder) {
                                 boolean added = false;
+                                ManagedServiceInfo info = null;
                                 synchronized (mMutex) {
                                     mServicesBinding.remove(servicesBindingTag);
                                     try {
                                         mService = asInterface(binder);
-                                        ManagedServiceInfo info = newServiceInfo(mService, name,
+                                        info = newServiceInfo(mService, name,
                                                 userid, false /*isSystem*/, this, targetSdkVersion);
                                         binder.linkToDeath(info, 0);
                                         added = mServices.add(info);
@@ -381,7 +382,7 @@
                                     }
                                 }
                                 if (added) {
-                                    onServiceAdded(mService);
+                                    onServiceAdded(info);
                                 }
                             }