Channels for Frameworks notifications

Adapts all notifications used by system services to use channels.
Channels are initialized by SystemServer after the NotificationService
has started.

Test: runtest systemui-notification
Change-Id: I25c45293b786adb57787aeab4c2613c9d7c89dab
This commit is contained in:
Geoffrey Pitsch
2017-02-15 09:35:38 -05:00
parent 37bb686bb7
commit 9b561aa6f8

View File

@@ -32,6 +32,7 @@ import android.widget.Toast;
import com.android.internal.R; import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.notification.SystemNotificationChannels;
import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET; import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET;
import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR; import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
@@ -187,7 +188,9 @@ public class NetworkNotificationManager {
return; return;
} }
Notification.Builder builder = new Notification.Builder(mContext) final String channelId = highPriority ? SystemNotificationChannels.NETWORK_ALERTS :
SystemNotificationChannels.NETWORK_STATUS;
Notification.Builder builder = new Notification.Builder(mContext, channelId)
.setWhen(System.currentTimeMillis()) .setWhen(System.currentTimeMillis())
.setShowWhen(notifyType == NotificationType.NETWORK_SWITCH) .setShowWhen(notifyType == NotificationType.NETWORK_SWITCH)
.setSmallIcon(icon) .setSmallIcon(icon)
@@ -198,10 +201,6 @@ public class NetworkNotificationManager {
.setContentTitle(title) .setContentTitle(title)
.setContentIntent(intent) .setContentIntent(intent)
.setLocalOnly(true) .setLocalOnly(true)
.setPriority(highPriority ?
Notification.PRIORITY_HIGH :
Notification.PRIORITY_DEFAULT)
.setDefaults(highPriority ? Notification.DEFAULT_ALL : 0)
.setOnlyAlertOnce(true); .setOnlyAlertOnce(true);
if (notifyType == NotificationType.NETWORK_SWITCH) { if (notifyType == NotificationType.NETWORK_SWITCH) {