Loading packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java +10 −15 Original line number Diff line number Diff line Loading @@ -120,7 +120,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { "PNW.autoSaverNoThanks"; private static final String ACTION_ENABLE_SEVERE_BATTERY_DIALOG = "PNW.enableSevereDialog"; private static final String EXTRA_SCHEDULED_BY_PERCENTAGE = "extra_scheduled_by_percentage"; public static final String BATTERY_SAVER_SCHEDULE_SCREEN_INTENT_ACTION = "com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS"; Loading Loading @@ -264,6 +265,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { if (showSevereLowBatteryDialog()) { mBroadcastSender.sendBroadcast(new Intent(ACTION_ENABLE_SEVERE_BATTERY_DIALOG) .setPackage(mContext.getPackageName()) .putExtra(EXTRA_SCHEDULED_BY_PERCENTAGE, isScheduledByPercentage()) .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND)); // Reset the state once dialog been enabled Loading @@ -271,7 +273,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { mPlaySound = false; return; } if (!showLowBatteryNotification()) { if (isScheduledByPercentage()) { return; } Loading Loading @@ -327,26 +329,19 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { } /** * Disable low battery warning notification if battery saver schedule mode set as * "Based on percentage". * Checking battery saver schedule mode is set as "Based on percentage" or not. * * return {@code false} if scheduled by percentage. * return {@code true} if scheduled by percentage. */ private boolean showLowBatteryNotification() { private boolean isScheduledByPercentage() { final ContentResolver resolver = mContext.getContentResolver(); final int mode = Settings.Global.getInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE, PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE); // Return true if battery saver schedule mode will not trigger by percentage. if (mode != PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE) { return true; } // Return true if battery saver mode trigger percentage is less than 0, which means it is // Return false if battery saver mode trigger percentage is less than 0, which means it is // set as "Based on routine" mode, otherwise it will be "Based on percentage" mode. final int threshold = Settings.Global.getInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0); return threshold <= 0; return mode == PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE && Settings.Global.getInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0) > 0; } private void showAutoSaverSuggestionNotification() { Loading Loading
packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java +10 −15 Original line number Diff line number Diff line Loading @@ -120,7 +120,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { "PNW.autoSaverNoThanks"; private static final String ACTION_ENABLE_SEVERE_BATTERY_DIALOG = "PNW.enableSevereDialog"; private static final String EXTRA_SCHEDULED_BY_PERCENTAGE = "extra_scheduled_by_percentage"; public static final String BATTERY_SAVER_SCHEDULE_SCREEN_INTENT_ACTION = "com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS"; Loading Loading @@ -264,6 +265,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { if (showSevereLowBatteryDialog()) { mBroadcastSender.sendBroadcast(new Intent(ACTION_ENABLE_SEVERE_BATTERY_DIALOG) .setPackage(mContext.getPackageName()) .putExtra(EXTRA_SCHEDULED_BY_PERCENTAGE, isScheduledByPercentage()) .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND)); // Reset the state once dialog been enabled Loading @@ -271,7 +273,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { mPlaySound = false; return; } if (!showLowBatteryNotification()) { if (isScheduledByPercentage()) { return; } Loading Loading @@ -327,26 +329,19 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { } /** * Disable low battery warning notification if battery saver schedule mode set as * "Based on percentage". * Checking battery saver schedule mode is set as "Based on percentage" or not. * * return {@code false} if scheduled by percentage. * return {@code true} if scheduled by percentage. */ private boolean showLowBatteryNotification() { private boolean isScheduledByPercentage() { final ContentResolver resolver = mContext.getContentResolver(); final int mode = Settings.Global.getInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE, PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE); // Return true if battery saver schedule mode will not trigger by percentage. if (mode != PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE) { return true; } // Return true if battery saver mode trigger percentage is less than 0, which means it is // Return false if battery saver mode trigger percentage is less than 0, which means it is // set as "Based on routine" mode, otherwise it will be "Based on percentage" mode. final int threshold = Settings.Global.getInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0); return threshold <= 0; return mode == PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE && Settings.Global.getInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0) > 0; } private void showAutoSaverSuggestionNotification() { Loading