From ef53f427f669d6b6b628eb9b0bff1785cdd59551 Mon Sep 17 00:00:00 2001 From: Sarah Chin Date: Mon, 14 Nov 2022 15:10:54 -0800 Subject: [PATCH] Allow user to disable network boost notification CarrierDefaultApp notification channels are not able to be disabled by default. Allow the network boost channel notifications to be blockable so user can disable them without affecting other notificatons in CarrierDefaultApp. Test: manual test Bug: 258266536 Change-Id: I8907205e905b9fbdab3193f1816074b9ed62e785 --- packages/CarrierDefaultApp/res/values/strings.xml | 2 +- .../SlicePurchaseBroadcastReceiver.java | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/CarrierDefaultApp/res/values/strings.xml b/packages/CarrierDefaultApp/res/values/strings.xml index 8a19709589fd4..3dcdf00ca8f5c 100644 --- a/packages/CarrierDefaultApp/res/values/strings.xml +++ b/packages/CarrierDefaultApp/res/values/strings.xml @@ -15,7 +15,7 @@ Continue anyway via browser - Network Boost + Network boost %s recommends a data boost diff --git a/packages/CarrierDefaultApp/src/com/android/carrierdefaultapp/SlicePurchaseBroadcastReceiver.java b/packages/CarrierDefaultApp/src/com/android/carrierdefaultapp/SlicePurchaseBroadcastReceiver.java index dd7b218959bf4..b322b8bd95bb2 100644 --- a/packages/CarrierDefaultApp/src/com/android/carrierdefaultapp/SlicePurchaseBroadcastReceiver.java +++ b/packages/CarrierDefaultApp/src/com/android/carrierdefaultapp/SlicePurchaseBroadcastReceiver.java @@ -240,11 +240,15 @@ public class SlicePurchaseBroadcastReceiver extends BroadcastReceiver{ return; } - context.getSystemService(NotificationManager.class).createNotificationChannel( - new NotificationChannel(NETWORK_BOOST_NOTIFICATION_CHANNEL_ID, - context.getResources().getString( - R.string.network_boost_notification_channel), - NotificationManager.IMPORTANCE_DEFAULT)); + NotificationChannel channel = new NotificationChannel( + NETWORK_BOOST_NOTIFICATION_CHANNEL_ID, + context.getResources().getString(R.string.network_boost_notification_channel), + NotificationManager.IMPORTANCE_DEFAULT); + // CarrierDefaultApp notifications are unblockable by default. Make this channel blockable + // to allow users to disable notifications posted to this channel without affecting other + // notifications in this application. + channel.setBlockable(true); + context.getSystemService(NotificationManager.class).createNotificationChannel(channel); Notification notification = new Notification.Builder(context, NETWORK_BOOST_NOTIFICATION_CHANNEL_ID)