Loading packages/SystemUI/src/com/android/systemui/power/PowerUI.java +26 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; import android.os.BatteryManager; Loading Loading @@ -56,6 +58,7 @@ public class PowerUI extends SystemUI { private PowerManager mPowerManager; private HardwarePropertiesManager mHardwarePropertiesManager; private WarningsUI mWarnings; private final Configuration mLastConfiguration = new Configuration(); private int mBatteryLevel = 100; private int mBatteryStatus = BatteryManager.BATTERY_STATUS_UNKNOWN; private int mPlugType = 0; Loading @@ -71,6 +74,11 @@ public class PowerUI extends SystemUI { private int mNumTemps; private long mNextLogTime; // We create a method reference here so that we are guaranteed that we can remove a callback // by using the same instance (method references are not guaranteed to be the same object // each time they are created). private final Runnable mUpdateTempCallback = this::updateTemperatureWarning; public void start() { mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); mHardwarePropertiesManager = (HardwarePropertiesManager) Loading @@ -80,6 +88,7 @@ public class PowerUI extends SystemUI { mContext, (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE), getComponent(StatusBar.class)); mLastConfiguration.setTo(mContext.getResources().getConfiguration()); ContentObserver obs = new ContentObserver(mHandler) { @Override Loading @@ -101,6 +110,16 @@ public class PowerUI extends SystemUI { initTemperatureWarning(); } @Override protected void onConfigurationChanged(Configuration newConfig) { final int mask = ActivityInfo.CONFIG_MCC | ActivityInfo.CONFIG_MNC; // Safe to modify mLastConfiguration here as it's only updated by the main thread (here). if ((mLastConfiguration.updateFrom(newConfig) & mask) != 0) { mHandler.post(this::initTemperatureWarning); } } void updateBatteryWarningLevels() { int critLevel = mContext.getResources().getInteger( com.android.internal.R.integer.config_criticalBatteryWarningLevel); Loading Loading @@ -255,8 +274,14 @@ public class PowerUI extends SystemUI { } mThresholdTemp = throttlingTemps[0]; } setNextLogTime(); // This initialization method may be called on a configuration change. Only one set of // ongoing callbacks should be occurring, so remove any now. updateTemperatureWarning will // schedule an ongoing callback. mHandler.removeCallbacks(mUpdateTempCallback); // We have passed all of the checks, start checking the temp updateTemperatureWarning(); } Loading Loading @@ -288,7 +313,7 @@ public class PowerUI extends SystemUI { logTemperatureStats(); mHandler.postDelayed(this::updateTemperatureWarning, TEMPERATURE_INTERVAL); mHandler.postDelayed(mUpdateTempCallback, TEMPERATURE_INTERVAL); } private void logAtTemperatureThreshold(float temp) { Loading Loading
packages/SystemUI/src/com/android/systemui/power/PowerUI.java +26 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.database.ContentObserver; import android.os.BatteryManager; Loading Loading @@ -56,6 +58,7 @@ public class PowerUI extends SystemUI { private PowerManager mPowerManager; private HardwarePropertiesManager mHardwarePropertiesManager; private WarningsUI mWarnings; private final Configuration mLastConfiguration = new Configuration(); private int mBatteryLevel = 100; private int mBatteryStatus = BatteryManager.BATTERY_STATUS_UNKNOWN; private int mPlugType = 0; Loading @@ -71,6 +74,11 @@ public class PowerUI extends SystemUI { private int mNumTemps; private long mNextLogTime; // We create a method reference here so that we are guaranteed that we can remove a callback // by using the same instance (method references are not guaranteed to be the same object // each time they are created). private final Runnable mUpdateTempCallback = this::updateTemperatureWarning; public void start() { mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); mHardwarePropertiesManager = (HardwarePropertiesManager) Loading @@ -80,6 +88,7 @@ public class PowerUI extends SystemUI { mContext, (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE), getComponent(StatusBar.class)); mLastConfiguration.setTo(mContext.getResources().getConfiguration()); ContentObserver obs = new ContentObserver(mHandler) { @Override Loading @@ -101,6 +110,16 @@ public class PowerUI extends SystemUI { initTemperatureWarning(); } @Override protected void onConfigurationChanged(Configuration newConfig) { final int mask = ActivityInfo.CONFIG_MCC | ActivityInfo.CONFIG_MNC; // Safe to modify mLastConfiguration here as it's only updated by the main thread (here). if ((mLastConfiguration.updateFrom(newConfig) & mask) != 0) { mHandler.post(this::initTemperatureWarning); } } void updateBatteryWarningLevels() { int critLevel = mContext.getResources().getInteger( com.android.internal.R.integer.config_criticalBatteryWarningLevel); Loading Loading @@ -255,8 +274,14 @@ public class PowerUI extends SystemUI { } mThresholdTemp = throttlingTemps[0]; } setNextLogTime(); // This initialization method may be called on a configuration change. Only one set of // ongoing callbacks should be occurring, so remove any now. updateTemperatureWarning will // schedule an ongoing callback. mHandler.removeCallbacks(mUpdateTempCallback); // We have passed all of the checks, start checking the temp updateTemperatureWarning(); } Loading Loading @@ -288,7 +313,7 @@ public class PowerUI extends SystemUI { logTemperatureStats(); mHandler.postDelayed(this::updateTemperatureWarning, TEMPERATURE_INTERVAL); mHandler.postDelayed(mUpdateTempCallback, TEMPERATURE_INTERVAL); } private void logAtTemperatureThreshold(float temp) { Loading