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

Commit 6b816e25 authored by Aayush Gupta's avatar Aayush Gupta
Browse files

Merge remote-tracking branch 'origin/lineage-18.1' into v1-r

parents d105f30b a7e586e2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -133,4 +133,7 @@

    <!-- Notify use that they are in Lock-to-app (for devices without navbar)-->
    <string name="screen_pinning_toast_no_navbar">To unpin this screen, touch &amp; hold Back button</string>

    <!-- Channel name for Battery notifications -->
    <string name="battery_notification_channel_tv">Battery warning</string>
</resources>
+18 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.power;

import android.app.KeyguardManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
@@ -27,6 +28,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.media.AudioAttributes;
import android.net.Uri;
import android.os.Bundle;
@@ -80,6 +82,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
    private static final String TAG = PowerUI.TAG + ".Notification";
    private static final boolean DEBUG = PowerUI.DEBUG;

    private static final String BATTERY_NOTIF_CHANNEL_ID_TV = "powernotifications.battery.tv";

    private static final String TAG_BATTERY = "low_battery";
    private static final String TAG_TEMPERATURE = "high_temp";
    private static final String TAG_AUTO_SAVER = "auto_saver";
@@ -167,6 +171,13 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
        mKeyguard = mContext.getSystemService(KeyguardManager.class);
        mReceiver.init();
        mActivityStarter = activityStarter;

        if (isTv()) {
            // TV-specific notification channel
            mNoMan.createNotificationChannel(new NotificationChannel(BATTERY_NOTIF_CHANNEL_ID_TV,
                    mContext.getString(R.string.battery_notification_channel_tv),
                    NotificationManager.IMPORTANCE_HIGH));
        }
    }

    @Override
@@ -234,6 +245,10 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
        }
    }

    private boolean isTv() {
        return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK);
    }

    private void showInvalidChargerNotification() {
        final Notification.Builder nb =
                new Notification.Builder(mContext, NotificationChannels.ALERTS)
@@ -277,7 +292,9 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
                        .setOnlyAlertOnce(true)
                        .setDeleteIntent(pendingBroadcast(ACTION_DISMISSED_WARNING))
                        .setStyle(new Notification.BigTextStyle().bigText(contentText))
                        .setVisibility(Notification.VISIBILITY_PUBLIC);
                        .setVisibility(Notification.VISIBILITY_PUBLIC)
                        .extend(new Notification.TvExtender()
                                .setChannelId(BATTERY_NOTIF_CHANNEL_ID_TV));
        if (hasBatterySettings()) {
            nb.setContentIntent(pendingBroadcast(ACTION_SHOW_BATTERY_SETTINGS));
        }