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

Commit bd1b6540 authored by William Escande's avatar William Escande
Browse files

AutoOnFeature: Remove popup action

Flag: com.android.bluetooth.flags.auto_on_feature
Bug: 323060869
Test: Manual Trigger the AutoOnFeature notification and look at it
Change-Id: Ib3d1ffacae1fe456af2909eb278d02e0435a5d3b
parent da649ada
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -110,7 +110,6 @@
             android:permission="android.permission.BLUETOOTH_PRIVILEGED">
            <intent-filter>
                <action android:name="android.bluetooth.notification.action.SEND_TOGGLE_NOTIFICATION"/>
                <action android:name="android.bluetooth.notification.action.AUTO_ON_USER_ACTION"/>
            </intent-filter>
        </service>

+0 −1
Original line number Diff line number Diff line
@@ -258,6 +258,5 @@
    <string name="bluetooth_and_wifi_stays_on_message">Your device remembers to keep Wi-Fi and Bluetooth on in airplane mode. Turn off Wi-Fi and Bluetooth if you don\'t want them to stay on.</string>
    <string name="bluetooth_enabled_auto_on_title">Bluetooth turned back on</string>
    <string name="bluetooth_enabled_auto_on_message">You can change this anytime in Settings</string>
    <string name="bluetooth_disable_auto_on">Stop automatic turn on</string>
    <string name="bluetooth_notification_group">Bluetooth automatic state change</string>
</resources>
+0 −33
Original line number Diff line number Diff line
@@ -23,9 +23,7 @@ import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.bluetooth.BluetoothManager;
import android.content.Intent;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.IBinder;
import android.provider.Settings;
@@ -61,9 +59,6 @@ public class NotificationHelperService extends Service {
    private static final String NOTIFICATION_EXTRA =
            "android.bluetooth.notification.extra.NOTIFICATION_REASON";

    private static final String AUTO_ON_USER_ACTION =
            "android.bluetooth.notification.action.AUTO_ON_USER_ACTION";

    private static final Map<String, Pair<Integer /* titleId */, Integer /* messageId */>>
            NOTIFICATION_MAP =
                    Map.of(
@@ -95,9 +90,6 @@ public class NotificationHelperService extends Service {
            case NOTIFICATION_ACTION -> {
                sendToggleNotification(intent.getStringExtra(NOTIFICATION_EXTRA));
            }
            case AUTO_ON_USER_ACTION -> {
                autoOnUserAction();
            }
        }
        return Service.START_NOT_STICKY;
    }
@@ -161,23 +153,6 @@ public class NotificationHelperService extends Service {
                            PendingIntent.FLAG_UPDATE_CURRENT,
                            new Intent("android.settings.BLUETOOTH_DASHBOARD_SETTINGS"),
                            PendingIntent.FLAG_IMMUTABLE));

            Intent baseIntent =
                    new Intent()
                            .setAction(AUTO_ON_USER_ACTION)
                            .setClass(this, NotificationHelperService.class);
            PendingIntent disablePendingIntent =
                    PendingIntent.getService(
                            this,
                            0,
                            new Intent(baseIntent),
                            PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_ONE_SHOT);
            builder.addAction(
                    new Notification.Action.Builder(
                                    Icon.createWithResource(this, R.drawable.ic_bluetooth_settings),
                                    getString(R.string.bluetooth_disable_auto_on),
                                    disablePendingIntent)
                            .build());
        }

        notificationManager.notify(
@@ -217,12 +192,4 @@ public class NotificationHelperService extends Service {
                        + (" savedDate=" + savedDate));
        return true;
    }

    /** Process the tap on the Auto On popup action, that will disable the feature */
    private void autoOnUserAction() {
        getSystemService(BluetoothManager.class).getAdapter().setAutoOnEnabled(false);
        String tag = NOTIFICATION_TAG + "/" + AUTO_ON_BT_ENABLED_NOTIFICATION;
        getSystemService(NotificationManager.class)
                .cancel(tag, SystemMessage.ID.NOTE_BT_APM_NOTIFICATION_VALUE);
    }
}