First iteration of a public UsageStats API
UsageStats API that allows apps to get a list of packages that have been
recently used, along with basic stats like how long they have been in
the foreground and the most recent time they were running.
Bug: 15165667
Change-Id: I2a2d1ff69bd0b5703ac3d9de1780df42ad90d439
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index de929cb..bf2edc8 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -20,6 +20,7 @@
import android.app.ActivityThread;
import android.app.IAlarmManager;
import android.app.INotificationManager;
+import android.app.usage.UsageStatsManagerInternal;
import android.bluetooth.BluetoothAdapter;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -91,6 +92,7 @@
import com.android.server.trust.TrustManagerService;
import com.android.server.tv.TvInputManagerService;
import com.android.server.twilight.TwilightService;
+import com.android.server.usage.UsageStatsService;
import com.android.server.usb.UsbService;
import com.android.server.wallpaper.WallpaperManagerService;
import com.android.server.webkit.WebViewUpdateService;
@@ -366,6 +368,11 @@
// Tracks the battery level. Requires LightService.
mSystemServiceManager.startService(BatteryService.class);
+
+ // Tracks application usage stats.
+ mSystemServiceManager.startService(UsageStatsService.class);
+ mActivityManagerService.setUsageStatsManager(
+ LocalServices.getService(UsageStatsManagerInternal.class));
}
/**