Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6f069f0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Moving AppStandbyController to the module background thread."

parents 9e8ffee3 2c75eb86
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -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);
+3 −2
Original line number Diff line number Diff line
@@ -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) {
+1 −2
Original line number Diff line number Diff line
@@ -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() {