Merge "Moving AppStandbyController to the module background thread."
This commit is contained in:
committed by
Android (Google) Code Review
commit
b6f069f0a0
@@ -7,7 +7,6 @@ import android.app.usage.UsageEvents;
|
||||
import android.app.usage.UsageStatsManager.StandbyBuckets;
|
||||
import android.app.usage.UsageStatsManager.SystemForcedReasons;
|
||||
import android.content.Context;
|
||||
import android.os.Looper;
|
||||
import android.util.IndentingPrintWriter;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
@@ -21,13 +20,12 @@ public interface AppStandbyInternal {
|
||||
* TODO AppStandbyController should probably be a binder service, and then we shouldn't need
|
||||
* this method.
|
||||
*/
|
||||
static AppStandbyInternal newAppStandbyController(ClassLoader loader, Context context,
|
||||
Looper looper) {
|
||||
static AppStandbyInternal newAppStandbyController(ClassLoader loader, Context context) {
|
||||
try {
|
||||
final Class<?> clazz = Class.forName("com.android.server.usage.AppStandbyController",
|
||||
true, loader);
|
||||
final Constructor<?> ctor = clazz.getConstructor(Context.class, Looper.class);
|
||||
return (AppStandbyInternal) ctor.newInstance(context, looper);
|
||||
final Constructor<?> ctor = clazz.getConstructor(Context.class);
|
||||
return (AppStandbyInternal) ctor.newInstance(context);
|
||||
} catch (NoSuchMethodException | InstantiationException
|
||||
| IllegalAccessException | InvocationTargetException | ClassNotFoundException e) {
|
||||
throw new RuntimeException("Unable to instantiate AppStandbyController!", e);
|
||||
|
||||
@@ -110,6 +110,7 @@ import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.app.IBatteryStats;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.internal.util.ConcurrentUtils;
|
||||
import com.android.server.JobSchedulerBackgroundThread;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.pm.parsing.pkg.AndroidPackage;
|
||||
import com.android.server.usage.AppIdleHistory.AppUsageHistory;
|
||||
@@ -418,8 +419,8 @@ public class AppStandbyController implements AppStandbyInternal {
|
||||
}
|
||||
}
|
||||
|
||||
public AppStandbyController(Context context, Looper looper) {
|
||||
this(new Injector(context, looper));
|
||||
public AppStandbyController(Context context) {
|
||||
this(new Injector(context, JobSchedulerBackgroundThread.get().getLooper()));
|
||||
}
|
||||
|
||||
AppStandbyController(Injector injector) {
|
||||
|
||||
@@ -215,8 +215,7 @@ public class UsageStatsService extends SystemService implements
|
||||
mHandler = new H(BackgroundThread.get().getLooper());
|
||||
|
||||
mAppStandby = AppStandbyInternal.newAppStandbyController(
|
||||
UsageStatsService.class.getClassLoader(), getContext(),
|
||||
BackgroundThread.get().getLooper());
|
||||
UsageStatsService.class.getClassLoader(), getContext());
|
||||
|
||||
mAppTimeLimit = new AppTimeLimitController(
|
||||
new AppTimeLimitController.TimeLimitCallbackListener() {
|
||||
|
||||
Reference in New Issue
Block a user