Loading apex/jobscheduler/service/java/com/android/server/job/restrictions/ThermalStatusRestriction.java +18 −25 Original line number Diff line number Diff line Loading @@ -17,13 +17,8 @@ package com.android.server.job.restrictions; import android.app.job.JobParameters; import android.content.Context; import android.os.IThermalService; import android.os.IThermalStatusListener; import android.os.RemoteException; import android.os.ServiceManager; import android.os.Temperature; import android.util.Slog; import android.os.PowerManager; import android.os.PowerManager.OnThermalStatusChangedListener; import android.util.proto.ProtoOutputStream; import com.android.internal.util.IndentingPrintWriter; Loading @@ -36,20 +31,22 @@ public class ThermalStatusRestriction extends JobRestriction { private volatile boolean mIsThermalRestricted = false; private PowerManager mPowerManager; public ThermalStatusRestriction(JobSchedulerService service) { super(service, JobParameters.REASON_DEVICE_THERMAL); } @Override public void onSystemServicesReady() { final IThermalService thermalService = IThermalService.Stub.asInterface( ServiceManager.getService(Context.THERMAL_SERVICE)); if (thermalService != null) { try { thermalService.registerThermalStatusListener(new IThermalStatusListener.Stub() { mPowerManager = mService.getContext().getSystemService(PowerManager.class); // Use MainExecutor mPowerManager.addThermalStatusListener(new OnThermalStatusChangedListener() { @Override public void onStatusChange(int status) { final boolean shouldBeActive = status >= Temperature.THROTTLING_SEVERE; public void onThermalStatusChanged(int status) { // This is called on the main thread. Do not do any slow operations in it. // mService.onControllerStateChanged() will just post a message, which is okay. final boolean shouldBeActive = status >= PowerManager.THERMAL_STATUS_SEVERE; if (mIsThermalRestricted == shouldBeActive) { return; } Loading @@ -57,10 +54,6 @@ public class ThermalStatusRestriction extends JobRestriction { mService.onControllerStateChanged(); } }); } catch (RemoteException e) { Slog.e(TAG, "Failed to register thermal callback.", e); } } } @Override Loading Loading
apex/jobscheduler/service/java/com/android/server/job/restrictions/ThermalStatusRestriction.java +18 −25 Original line number Diff line number Diff line Loading @@ -17,13 +17,8 @@ package com.android.server.job.restrictions; import android.app.job.JobParameters; import android.content.Context; import android.os.IThermalService; import android.os.IThermalStatusListener; import android.os.RemoteException; import android.os.ServiceManager; import android.os.Temperature; import android.util.Slog; import android.os.PowerManager; import android.os.PowerManager.OnThermalStatusChangedListener; import android.util.proto.ProtoOutputStream; import com.android.internal.util.IndentingPrintWriter; Loading @@ -36,20 +31,22 @@ public class ThermalStatusRestriction extends JobRestriction { private volatile boolean mIsThermalRestricted = false; private PowerManager mPowerManager; public ThermalStatusRestriction(JobSchedulerService service) { super(service, JobParameters.REASON_DEVICE_THERMAL); } @Override public void onSystemServicesReady() { final IThermalService thermalService = IThermalService.Stub.asInterface( ServiceManager.getService(Context.THERMAL_SERVICE)); if (thermalService != null) { try { thermalService.registerThermalStatusListener(new IThermalStatusListener.Stub() { mPowerManager = mService.getContext().getSystemService(PowerManager.class); // Use MainExecutor mPowerManager.addThermalStatusListener(new OnThermalStatusChangedListener() { @Override public void onStatusChange(int status) { final boolean shouldBeActive = status >= Temperature.THROTTLING_SEVERE; public void onThermalStatusChanged(int status) { // This is called on the main thread. Do not do any slow operations in it. // mService.onControllerStateChanged() will just post a message, which is okay. final boolean shouldBeActive = status >= PowerManager.THERMAL_STATUS_SEVERE; if (mIsThermalRestricted == shouldBeActive) { return; } Loading @@ -57,10 +54,6 @@ public class ThermalStatusRestriction extends JobRestriction { mService.onControllerStateChanged(); } }); } catch (RemoteException e) { Slog.e(TAG, "Failed to register thermal callback.", e); } } } @Override Loading