Set up StatsCompanionService.java

Introduces StatsCompanionService.java and sets it up as a system service.

This service is a helper for statsd. It will be responsible for setting
and cancelling alarms related to polling stats and anomaly detection.

It currently does not have selinux permission, so must be started
manually (or with selinux temporarily disabled).

Test: disable enforcing selinux, then set and cancel alarms and make
sure they work.

Change-Id: I3bd73acdd998ee424696cce40965134c14220d8f
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index d6f67f6..6ac352e 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -3074,6 +3074,12 @@
     <permission android:name="android.permission.BATTERY_STATS"
         android:protectionLevel="signature|privileged|development" />
 
+    <!--Allows an application to manage statscompanion.
+    <p>Not for use by third-party applications.
+         @hide -->
+    <permission android:name="android.permission.STATSCOMPANION"
+        android:protectionLevel="signature" />
+
     <!-- @SystemApi Allows an application to control the backup and restore process.
     <p>Not for use by third-party applications.
          @hide pending API council -->
@@ -3854,6 +3860,16 @@
             </intent-filter>
         </receiver>
 
+        <receiver android:name="com.android.server.stats.StatsCompanionService$AnomalyAlarmReceiver"
+                  android:permission="android.permission.STATSCOMPANION"
+                  android:exported="false">
+        </receiver>
+
+        <receiver android:name="com.android.server.stats.StatsCompanionService$PollingAlarmReceiver"
+                  android:permission="android.permission.STATSCOMPANION"
+                  android:exported="false">
+        </receiver>
+
         <service android:name="android.hardware.location.GeofenceHardwareService"
             android:permission="android.permission.LOCATION_HARDWARE"
             android:exported="false" />