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

Commit e666a46e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 2f6110f8 400e0443
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -791,11 +791,12 @@ public class BatterySaverStateMachine {
        ensureNotificationChannelExists(manager, DYNAMIC_MODE_NOTIF_CHANNEL_ID,
                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,
                        mContext.getResources().getString(R.string.dynamic_mode_notification_title),
                        R.string.dynamic_mode_notification_summary,
                        Intent.ACTION_POWER_USAGE_SUMMARY));
                        Intent.ACTION_POWER_USAGE_SUMMARY),
                UserHandle.ALL);
    }

    @VisibleForTesting
@@ -806,12 +807,13 @@ public class BatterySaverStateMachine {

        final String percentage = NumberFormat.getPercentInstance()
                .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,
                        mContext.getResources().getString(
                                R.string.battery_saver_charged_notification_title, percentage),
                        R.string.battery_saver_off_notification_summary,
                        Settings.ACTION_BATTERY_SAVER_SETTINGS));
                        Settings.ACTION_BATTERY_SAVER_SETTINGS),
                UserHandle.ALL);
    }

    private void ensureNotificationChannelExists(NotificationManager manager,
@@ -819,6 +821,7 @@ public class BatterySaverStateMachine {
        NotificationChannel channel = new NotificationChannel(
                channelId, mContext.getText(nameId), NotificationManager.IMPORTANCE_DEFAULT);
        channel.setSound(null, null);
        channel.setBlockableSystem(true);
        manager.createNotificationChannel(channel);
    }