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

Commit d5d07c8d authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Undo the jobscheduler / device idle initialization with callbacks"

parents cdc4a55c 152742f2
Loading
Loading
Loading
Loading
+0 −19
Original line number Diff line number Diff line
@@ -19,14 +19,8 @@ package android.app;
import android.content.Context;
import android.os.DeviceIdleManager;
import android.os.IDeviceIdleController;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;

/**
 * This class needs to be pre-loaded by zygote.  This is where the device idle manager wrapper
 * is registered.
 *
 * @hide
 */
public class DeviceIdleFrameworkInitializer {
@@ -37,18 +31,5 @@ public class DeviceIdleFrameworkInitializer {
                Context.DEVICE_IDLE_CONTROLLER, DeviceIdleManager.class,
                (context, b) -> new DeviceIdleManager(
                        context, IDeviceIdleController.Stub.asInterface(b)));
        PowerManager.setIsIgnoringBatteryOptimizationsCallback((packageName) -> {
            // No need for synchronization on sIDeviceIdleController; worst case
            // we just initialize it twice.
            if (sIDeviceIdleController == null) {
                sIDeviceIdleController = IDeviceIdleController.Stub.asInterface(
                        ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER));
            }
            try {
                return sIDeviceIdleController.isPowerSaveWhitelistApp(packageName);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        });
    }
}
+19 −1
Original line number Diff line number Diff line
@@ -68,7 +68,11 @@ public class JobParameters implements Parcelable {
            REASON_DEVICE_THERMAL,
    };

    /** @hide */
    /**
     * @hide
     * @deprecated use {@link #getReasonCodeDescription(int)}
     */
    @Deprecated
    public static String getReasonName(int reason) {
        switch (reason) {
            case REASON_CANCELED: return "canceled";
@@ -81,6 +85,20 @@ public class JobParameters implements Parcelable {
        }
    }

    /** @hide */
    // @SystemApi TODO make it a system api for mainline
    @NonNull
    public static int[] getJobStopReasonCodes() {
        return JOB_STOP_REASON_CODES;
    }

    /** @hide */
    // @SystemApi TODO make it a system api for mainline
    @NonNull
    public static String getReasonCodeDescription(int reasonCode) {
        return getReasonName(reasonCode);
    }

    @UnsupportedAppUsage
    private final int jobId;
    private final PersistableBundle extras;
+0 −7
Original line number Diff line number Diff line
@@ -19,12 +19,8 @@ package android.app.job;
import android.app.JobSchedulerImpl;
import android.app.SystemServiceRegistry;
import android.content.Context;
import android.os.BatteryStats;

/**
 * This class needs to be pre-loaded by zygote.  This is where the job scheduler service wrapper
 * is registered.
 *
 * @hide
 */
public class JobSchedulerFrameworkInitializer {
@@ -32,8 +28,5 @@ public class JobSchedulerFrameworkInitializer {
        SystemServiceRegistry.registerStaticService(
                Context.JOB_SCHEDULER_SERVICE, JobScheduler.class,
                (b) -> new JobSchedulerImpl(IJobScheduler.Stub.asInterface(b)));

        BatteryStats.setJobStopReasons(JobParameters.JOB_STOP_REASON_CODES,
                JobParameters::getReasonName);
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -84,4 +84,17 @@ public class DeviceIdleManager {
            return 0;
        }
    }

    /**
     * Return whether a given package is in the power-save whitelist or not.
     * @hide
     */
    public boolean isApplicationWhitelisted(@NonNull String packageName) {
        try {
            return mService.isPowerSaveWhitelistApp(packageName);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
            return false;
        }
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -200,7 +200,6 @@ android.app.ContentProviderHolder
android.app.ContextImpl$1
android.app.ContextImpl$ApplicationContentResolver
android.app.ContextImpl
android.app.DeviceIdleFrameworkInitializer
android.app.DexLoadReporter
android.app.Dialog$ListenersHandler
android.app.Dialog
Loading