Switch framework to using new scheduled-work API

Also add the intended permission-use enforcement to said API.

Bug 14994893
Bug 14993295

Change-Id: I5a3ffd32d0702c68f4ef6da68f7fa6e9de674380
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 90d49968..d34181e 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1754,12 +1754,13 @@
         android:label="@string/permlab_recovery"
         android:description="@string/permdesc_recovery" />
 
-    <!-- Allows the system to bind to an application's idle services
+    <!-- Allows the system to bind to an application's task services
          @hide -->
-    <permission android:name="android.permission.BIND_IDLE_SERVICE"
+    <permission android:name="android.permission.BIND_TASK_SERVICE"
         android:protectionLevel="signature"
-        android:label="@string/permlab_bindIdleService"
-        android:description="@string/permdesc_bindIdleService" />
+        android:label="@string/permlab_bindTaskService"
+        android:description="@string/permdesc_bindTaskService" />
+    <uses-permission android:name="android.permission.BIND_TASK_SERVICE"/>
 
     <!-- ========================================= -->
     <!-- Permissions for special development tools -->
@@ -2875,10 +2876,7 @@
 
         <service android:name="com.android.server.MountServiceIdler"
                  android:exported="false"
-                 android:permission="android.permission.BIND_IDLE_SERVICE" >
-            <intent-filter>
-                <action android:name="android.service.idle.IdleService" />
-            </intent-filter>
+                 android:permission="android.permission.BIND_TASK_SERVICE" >
         </service>
 
     </application>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 241526e..10edcc8 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1260,11 +1260,11 @@
     <!-- Title of a permission that is never presented to the user.  This is not a
          permission that an application must be granted by the user.  Instead, it
          is part of a mechanism that applications use to indicate to the system
-         that they want to do occasional work while the device is idle.  -->
-    <string name="permlab_bindIdleService">run application during idle time</string>
+         that they want to do scheduled background work.  -->
+    <string name="permlab_bindTaskService">run the application\'s scheduled background work</string>
     <!-- Description of an application permission, so that the user can understand
          what is being done if they are curious. -->
-    <string name="permdesc_bindIdleService">This permission allows the Android system to run the application in the background while the device is not in use.</string>
+    <string name="permdesc_bindTaskService">This permission allows the Android system to run the application in the background when requested.</string>
 
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permlab_diagnostic">read/write to resources owned by diag</string>