From e5b7ec0100d9224a8d1a201135cca52000bcc7a3 Mon Sep 17 00:00:00 2001 From: paulhu Date: Mon, 13 Jan 2020 14:19:19 +0800 Subject: [PATCH] Replace SystemNotificationChannels on Tethering Tethering used SystemNotificationChannels for showing notification before. But SystemNotificationChannels is used for system package only, tethering package is not able to use it now. Thus, replace it with tethering own notification channel. Bug: 122085773 Test: atest TetheringTests Change-Id: I854a102795c19351a4137360414926c461cc604c --- packages/Tethering/res/values/strings.xml | 21 +++++++++++++++++-- .../connectivity/tethering/Tethering.java | 13 ++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/packages/Tethering/res/values/strings.xml b/packages/Tethering/res/values/strings.xml index ca866a946ea26..792bce9fc334c 100644 --- a/packages/Tethering/res/values/strings.xml +++ b/packages/Tethering/res/values/strings.xml @@ -1,4 +1,18 @@ + @@ -9,8 +23,11 @@ - + Tethering is disabled - + Contact your admin for details + + + Hotspot & tethering status \ No newline at end of file diff --git a/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java b/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java index 2119791a26027..da1103153f6b4 100644 --- a/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java +++ b/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java @@ -50,6 +50,7 @@ import static android.telephony.CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANG import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; import android.app.Notification; +import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.bluetooth.BluetoothAdapter; @@ -107,7 +108,6 @@ import androidx.annotation.Nullable; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.messages.nano.SystemMessageProto.SystemMessage; -import com.android.internal.notification.SystemNotificationChannels; import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.MessageUtils; import com.android.internal.util.State; @@ -692,6 +692,12 @@ public class Tethering { if (notificationManager == null) { return; } + final NotificationChannel channel = new NotificationChannel( + "TETHERING_STATUS", + mContext.getResources().getString(R.string.notification_channel_tethering_status), + NotificationManager.IMPORTANCE_LOW); + notificationManager.createNotificationChannel(channel); + int icon = 0; switch(id) { case SystemMessage.NOTE_TETHER_USB: @@ -735,12 +741,11 @@ public class Tethering { } if (mTetheredNotificationBuilder == null) { - mTetheredNotificationBuilder = new Notification.Builder(mContext, - SystemNotificationChannels.NETWORK_STATUS); + mTetheredNotificationBuilder = new Notification.Builder(mContext, channel.getId()); mTetheredNotificationBuilder.setWhen(0) .setOngoing(true) .setColor(mContext.getColor( - com.android.internal.R.color.system_notification_accent_color)) + android.R.color.system_notification_accent_color)) .setVisibility(Notification.VISIBILITY_PUBLIC) .setCategory(Notification.CATEGORY_STATUS); }