Merge "Showing battery saver notifications in secondary profiles." into qt-dev

This commit is contained in:
TreeHugger Robot
2019-05-24 23:45:57 +00:00
committed by Android (Google) Code Review

View File

@@ -791,11 +791,12 @@ public class BatterySaverStateMachine {
ensureNotificationChannelExists(manager, DYNAMIC_MODE_NOTIF_CHANNEL_ID, ensureNotificationChannelExists(manager, DYNAMIC_MODE_NOTIF_CHANNEL_ID,
R.string.dynamic_mode_notification_channel_name); R.string.dynamic_mode_notification_channel_name);
manager.notify(DYNAMIC_MODE_NOTIFICATION_ID, manager.notifyAsUser(TAG, DYNAMIC_MODE_NOTIFICATION_ID,
buildNotification(DYNAMIC_MODE_NOTIF_CHANNEL_ID, buildNotification(DYNAMIC_MODE_NOTIF_CHANNEL_ID,
mContext.getResources().getString(R.string.dynamic_mode_notification_title), mContext.getResources().getString(R.string.dynamic_mode_notification_title),
R.string.dynamic_mode_notification_summary, R.string.dynamic_mode_notification_summary,
Intent.ACTION_POWER_USAGE_SUMMARY)); Intent.ACTION_POWER_USAGE_SUMMARY),
UserHandle.ALL);
} }
@VisibleForTesting @VisibleForTesting
@@ -806,12 +807,13 @@ public class BatterySaverStateMachine {
final String percentage = NumberFormat.getPercentInstance() final String percentage = NumberFormat.getPercentInstance()
.format((double) mBatteryLevel / 100.0); .format((double) mBatteryLevel / 100.0);
manager.notify(STICKY_AUTO_DISABLED_NOTIFICATION_ID, manager.notifyAsUser(TAG, STICKY_AUTO_DISABLED_NOTIFICATION_ID,
buildNotification(BATTERY_SAVER_NOTIF_CHANNEL_ID, buildNotification(BATTERY_SAVER_NOTIF_CHANNEL_ID,
mContext.getResources().getString( mContext.getResources().getString(
R.string.battery_saver_charged_notification_title, percentage), R.string.battery_saver_charged_notification_title, percentage),
R.string.battery_saver_off_notification_summary, R.string.battery_saver_off_notification_summary,
Settings.ACTION_BATTERY_SAVER_SETTINGS)); Settings.ACTION_BATTERY_SAVER_SETTINGS),
UserHandle.ALL);
} }
private void ensureNotificationChannelExists(NotificationManager manager, private void ensureNotificationChannelExists(NotificationManager manager,
@@ -819,6 +821,7 @@ public class BatterySaverStateMachine {
NotificationChannel channel = new NotificationChannel( NotificationChannel channel = new NotificationChannel(
channelId, mContext.getText(nameId), NotificationManager.IMPORTANCE_DEFAULT); channelId, mContext.getText(nameId), NotificationManager.IMPORTANCE_DEFAULT);
channel.setSound(null, null); channel.setSound(null, null);
channel.setBlockableSystem(true);
manager.createNotificationChannel(channel); manager.createNotificationChannel(channel);
} }