Loading core/java/android/app/NotificationManager.java +13 −0 Original line number Diff line number Diff line Loading @@ -446,6 +446,19 @@ public class NotificationManager } } /** * @hide */ public void createNotificationChannelsForPackage(String pkg, @NonNull List<NotificationChannel> channels) { INotificationManager service = getService(); try { service.createNotificationChannels(pkg, new ParceledListSlice(channels)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Returns the notification channel settings for a given channel id. */ Loading core/java/com/android/internal/notification/SystemNotificationChannels.java 0 → 100644 +136 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.android.internal.notification; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.Context; import android.provider.Settings; import com.android.internal.R; import java.util.ArrayList; import java.util.Arrays; import java.util.List; // Manages the NotificationChannels used by the frameworks itself. public class SystemNotificationChannels { public static String VIRTUAL_KEYBOARD = "VIRTUAL_KEYBOARD"; public static String PHYSICAL_KEYBOARD = "PHYSICAL_KEYBOARD"; public static String SECURITY = "SECURITY"; public static String CAR_MODE = "CAR_MODE"; public static String ACCOUNT = "ACCOUNT"; public static String DEVELOPER = "DEVELOPER"; public static String UPDATES = "UPDATES"; public static String NETWORK_STATUS = "NETWORK_STATUS"; public static String NETWORK_ALERTS = "NETWORK_ALERTS"; public static String VPN = "VPN"; public static String DEVICE_ADMIN = "DEVICE_ADMIN"; public static String ALERTS = "ALERTS"; public static String RETAIL_MODE = "RETAIL_MODE"; public static String USB = "USB"; public static void createAll(Context context) { final NotificationManager nm = context.getSystemService(NotificationManager.class); List<NotificationChannel> channelsList = new ArrayList<NotificationChannel>(); channelsList.add(new NotificationChannel( VIRTUAL_KEYBOARD, context.getString(R.string.notification_channel_virtual_keyboard), NotificationManager.IMPORTANCE_LOW)); final NotificationChannel physicalKeyboardChannel = new NotificationChannel( PHYSICAL_KEYBOARD, context.getString(R.string.notification_channel_physical_keyboard), NotificationManager.IMPORTANCE_DEFAULT); physicalKeyboardChannel.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, Notification.AUDIO_ATTRIBUTES_DEFAULT); channelsList.add(physicalKeyboardChannel); channelsList.add(new NotificationChannel( SECURITY, context.getString(R.string.notification_channel_security), NotificationManager.IMPORTANCE_LOW)); channelsList.add(new NotificationChannel( CAR_MODE, context.getString(R.string.notification_channel_car_mode), NotificationManager.IMPORTANCE_LOW)); channelsList.add(new NotificationChannel( DEVELOPER, context.getString(R.string.notification_channel_developer), NotificationManager.IMPORTANCE_LOW)); channelsList.add(new NotificationChannel( UPDATES, context.getString(R.string.notification_channel_updates), NotificationManager.IMPORTANCE_LOW)); channelsList.add(new NotificationChannel( NETWORK_STATUS, context.getString(R.string.notification_channel_network_status), NotificationManager.IMPORTANCE_LOW)); final NotificationChannel networkAlertsChannel = new NotificationChannel( NETWORK_ALERTS, context.getString(R.string.notification_channel_network_alerts), NotificationManager.IMPORTANCE_HIGH); networkAlertsChannel.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, Notification.AUDIO_ATTRIBUTES_DEFAULT); channelsList.add(networkAlertsChannel); channelsList.add(new NotificationChannel( VPN, context.getString(R.string.notification_channel_vpn), NotificationManager.IMPORTANCE_LOW)); channelsList.add(new NotificationChannel( DEVICE_ADMIN, context.getString(R.string.notification_channel_device_admin), NotificationManager.IMPORTANCE_LOW)); final NotificationChannel alertsChannel = new NotificationChannel( ALERTS, context.getString(R.string.notification_channel_alerts), NotificationManager.IMPORTANCE_DEFAULT); alertsChannel.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, Notification.AUDIO_ATTRIBUTES_DEFAULT); channelsList.add(alertsChannel); channelsList.add(new NotificationChannel( RETAIL_MODE, context.getString(R.string.notification_channel_retail_mode), NotificationManager.IMPORTANCE_LOW)); channelsList.add(new NotificationChannel( USB, context.getString(R.string.notification_channel_usb), NotificationManager.IMPORTANCE_MIN)); nm.createNotificationChannels(channelsList); createAccountChannelForPackage(context.getPackageName(), context); } public static void createAccountChannelForPackage(String pkg, Context context) { final NotificationManager nm = context.getSystemService(NotificationManager.class); nm.createNotificationChannelsForPackage(pkg, Arrays.asList(new NotificationChannel( ACCOUNT, context.getString(R.string.notification_channel_account), NotificationManager.IMPORTANCE_LOW))); } private SystemNotificationChannels() {} } core/res/res/values/strings.xml +42 −0 Original line number Diff line number Diff line Loading @@ -587,6 +587,48 @@ <!-- Text shown in place of notification contents when the notification is hidden by policy on a secure lockscreen --> <string name="notification_hidden_by_policy_text">Contents hidden by policy</string> <!-- Text shown when viewing channel settings for notifications related to the virtual keyboard --> <string name="notification_channel_virtual_keyboard">Virtual keyboard</string> <!-- Text shown when viewing channel settings for notifications related to the hardware keyboard --> <string name="notification_channel_physical_keyboard">Physical keyboard</string> <!-- Text shown when viewing channel settings for notifications related to security --> <string name="notification_channel_security">Security</string> <!-- Text shown when viewing channel settings for notifications related to car mode --> <string name="notification_channel_car_mode">Car mode</string> <!-- Text shown when viewing channel settings for notifications related to account status --> <string name="notification_channel_account">Account status</string> <!-- Text shown when viewing channel settings for notifications related to developers --> <string name="notification_channel_developer">Developer messages</string> <!-- Text shown when viewing channel settings for notifications related to system updates --> <string name="notification_channel_updates">Updates</string> <!-- Text shown when viewing channel settings for notifications related to network status --> <string name="notification_channel_network_status">Network status</string> <!-- Text shown when viewing channel settings for notifications related to network alerts --> <string name="notification_channel_network_alerts">Network alerts</string> <!-- Text shown when viewing channel settings for notifications related to vpn status --> <string name="notification_channel_vpn">VPN status</string> <!-- Text shown when viewing channel settings for notifications related to remote device administration --> <string name="notification_channel_device_admin">Device administration</string> <!-- Text shown when viewing channel settings for notifications related to important alerts --> <string name="notification_channel_alerts">Alerts</string> <!-- Text shown when viewing channel settings for notifications related to being in retail mode --> <string name="notification_channel_retail_mode">Retail demo</string> <!-- Text shown when viewing channel settings for notifications related to a usb connection --> <string name="notification_channel_usb">USB connection</string> <!-- Displayed to the user to tell them that they have started up the phone in "safe mode" --> <string name="safeMode">Safe mode</string> Loading core/res/res/values/symbols.xml +17 −0 Original line number Diff line number Diff line Loading @@ -2887,4 +2887,21 @@ <!-- Colon separated list of package names that should be granted Notification Listener access --> <java-symbol type="string" name="config_defaultListenerAccessPackages" /> <!-- system notification channels --> <java-symbol type="string" name="notification_channel_virtual_keyboard" /> <java-symbol type="string" name="notification_channel_physical_keyboard" /> <java-symbol type="string" name="notification_channel_security" /> <java-symbol type="string" name="notification_channel_car_mode" /> <java-symbol type="string" name="notification_channel_account" /> <java-symbol type="string" name="notification_channel_developer" /> <java-symbol type="string" name="notification_channel_updates" /> <java-symbol type="string" name="notification_channel_network_status" /> <java-symbol type="string" name="notification_channel_network_alerts" /> <java-symbol type="string" name="notification_channel_vpn" /> <java-symbol type="string" name="notification_channel_device_admin" /> <java-symbol type="string" name="notification_channel_alerts" /> <java-symbol type="string" name="notification_channel_retail_mode" /> <java-symbol type="string" name="notification_channel_usb" /> </resources> services/core/java/com/android/server/InputMethodManagerService.java +9 −7 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import com.android.internal.inputmethod.InputMethodSubtypeSwitchingController; import com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem; import com.android.internal.inputmethod.InputMethodUtils; import com.android.internal.inputmethod.InputMethodUtils.InputMethodSettings; import com.android.internal.notification.SystemNotificationChannels; import com.android.internal.os.HandlerCaller; import com.android.internal.os.SomeArgs; import com.android.internal.os.TransferPipe; Loading Loading @@ -1262,7 +1263,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub Bundle extras = new Bundle(); extras.putBoolean(Notification.EXTRA_ALLOW_DURING_SETUP, true); mImeSwitcherNotification = new Notification.Builder(mContext) mImeSwitcherNotification = new Notification.Builder(mContext, SystemNotificationChannels.VIRTUAL_KEYBOARD) .setSmallIcon(com.android.internal.R.drawable.ic_notification_ime_default) .setWhen(0) .setOngoing(true) Loading Loading
core/java/android/app/NotificationManager.java +13 −0 Original line number Diff line number Diff line Loading @@ -446,6 +446,19 @@ public class NotificationManager } } /** * @hide */ public void createNotificationChannelsForPackage(String pkg, @NonNull List<NotificationChannel> channels) { INotificationManager service = getService(); try { service.createNotificationChannels(pkg, new ParceledListSlice(channels)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Returns the notification channel settings for a given channel id. */ Loading
core/java/com/android/internal/notification/SystemNotificationChannels.java 0 → 100644 +136 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.android.internal.notification; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.Context; import android.provider.Settings; import com.android.internal.R; import java.util.ArrayList; import java.util.Arrays; import java.util.List; // Manages the NotificationChannels used by the frameworks itself. public class SystemNotificationChannels { public static String VIRTUAL_KEYBOARD = "VIRTUAL_KEYBOARD"; public static String PHYSICAL_KEYBOARD = "PHYSICAL_KEYBOARD"; public static String SECURITY = "SECURITY"; public static String CAR_MODE = "CAR_MODE"; public static String ACCOUNT = "ACCOUNT"; public static String DEVELOPER = "DEVELOPER"; public static String UPDATES = "UPDATES"; public static String NETWORK_STATUS = "NETWORK_STATUS"; public static String NETWORK_ALERTS = "NETWORK_ALERTS"; public static String VPN = "VPN"; public static String DEVICE_ADMIN = "DEVICE_ADMIN"; public static String ALERTS = "ALERTS"; public static String RETAIL_MODE = "RETAIL_MODE"; public static String USB = "USB"; public static void createAll(Context context) { final NotificationManager nm = context.getSystemService(NotificationManager.class); List<NotificationChannel> channelsList = new ArrayList<NotificationChannel>(); channelsList.add(new NotificationChannel( VIRTUAL_KEYBOARD, context.getString(R.string.notification_channel_virtual_keyboard), NotificationManager.IMPORTANCE_LOW)); final NotificationChannel physicalKeyboardChannel = new NotificationChannel( PHYSICAL_KEYBOARD, context.getString(R.string.notification_channel_physical_keyboard), NotificationManager.IMPORTANCE_DEFAULT); physicalKeyboardChannel.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, Notification.AUDIO_ATTRIBUTES_DEFAULT); channelsList.add(physicalKeyboardChannel); channelsList.add(new NotificationChannel( SECURITY, context.getString(R.string.notification_channel_security), NotificationManager.IMPORTANCE_LOW)); channelsList.add(new NotificationChannel( CAR_MODE, context.getString(R.string.notification_channel_car_mode), NotificationManager.IMPORTANCE_LOW)); channelsList.add(new NotificationChannel( DEVELOPER, context.getString(R.string.notification_channel_developer), NotificationManager.IMPORTANCE_LOW)); channelsList.add(new NotificationChannel( UPDATES, context.getString(R.string.notification_channel_updates), NotificationManager.IMPORTANCE_LOW)); channelsList.add(new NotificationChannel( NETWORK_STATUS, context.getString(R.string.notification_channel_network_status), NotificationManager.IMPORTANCE_LOW)); final NotificationChannel networkAlertsChannel = new NotificationChannel( NETWORK_ALERTS, context.getString(R.string.notification_channel_network_alerts), NotificationManager.IMPORTANCE_HIGH); networkAlertsChannel.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, Notification.AUDIO_ATTRIBUTES_DEFAULT); channelsList.add(networkAlertsChannel); channelsList.add(new NotificationChannel( VPN, context.getString(R.string.notification_channel_vpn), NotificationManager.IMPORTANCE_LOW)); channelsList.add(new NotificationChannel( DEVICE_ADMIN, context.getString(R.string.notification_channel_device_admin), NotificationManager.IMPORTANCE_LOW)); final NotificationChannel alertsChannel = new NotificationChannel( ALERTS, context.getString(R.string.notification_channel_alerts), NotificationManager.IMPORTANCE_DEFAULT); alertsChannel.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, Notification.AUDIO_ATTRIBUTES_DEFAULT); channelsList.add(alertsChannel); channelsList.add(new NotificationChannel( RETAIL_MODE, context.getString(R.string.notification_channel_retail_mode), NotificationManager.IMPORTANCE_LOW)); channelsList.add(new NotificationChannel( USB, context.getString(R.string.notification_channel_usb), NotificationManager.IMPORTANCE_MIN)); nm.createNotificationChannels(channelsList); createAccountChannelForPackage(context.getPackageName(), context); } public static void createAccountChannelForPackage(String pkg, Context context) { final NotificationManager nm = context.getSystemService(NotificationManager.class); nm.createNotificationChannelsForPackage(pkg, Arrays.asList(new NotificationChannel( ACCOUNT, context.getString(R.string.notification_channel_account), NotificationManager.IMPORTANCE_LOW))); } private SystemNotificationChannels() {} }
core/res/res/values/strings.xml +42 −0 Original line number Diff line number Diff line Loading @@ -587,6 +587,48 @@ <!-- Text shown in place of notification contents when the notification is hidden by policy on a secure lockscreen --> <string name="notification_hidden_by_policy_text">Contents hidden by policy</string> <!-- Text shown when viewing channel settings for notifications related to the virtual keyboard --> <string name="notification_channel_virtual_keyboard">Virtual keyboard</string> <!-- Text shown when viewing channel settings for notifications related to the hardware keyboard --> <string name="notification_channel_physical_keyboard">Physical keyboard</string> <!-- Text shown when viewing channel settings for notifications related to security --> <string name="notification_channel_security">Security</string> <!-- Text shown when viewing channel settings for notifications related to car mode --> <string name="notification_channel_car_mode">Car mode</string> <!-- Text shown when viewing channel settings for notifications related to account status --> <string name="notification_channel_account">Account status</string> <!-- Text shown when viewing channel settings for notifications related to developers --> <string name="notification_channel_developer">Developer messages</string> <!-- Text shown when viewing channel settings for notifications related to system updates --> <string name="notification_channel_updates">Updates</string> <!-- Text shown when viewing channel settings for notifications related to network status --> <string name="notification_channel_network_status">Network status</string> <!-- Text shown when viewing channel settings for notifications related to network alerts --> <string name="notification_channel_network_alerts">Network alerts</string> <!-- Text shown when viewing channel settings for notifications related to vpn status --> <string name="notification_channel_vpn">VPN status</string> <!-- Text shown when viewing channel settings for notifications related to remote device administration --> <string name="notification_channel_device_admin">Device administration</string> <!-- Text shown when viewing channel settings for notifications related to important alerts --> <string name="notification_channel_alerts">Alerts</string> <!-- Text shown when viewing channel settings for notifications related to being in retail mode --> <string name="notification_channel_retail_mode">Retail demo</string> <!-- Text shown when viewing channel settings for notifications related to a usb connection --> <string name="notification_channel_usb">USB connection</string> <!-- Displayed to the user to tell them that they have started up the phone in "safe mode" --> <string name="safeMode">Safe mode</string> Loading
core/res/res/values/symbols.xml +17 −0 Original line number Diff line number Diff line Loading @@ -2887,4 +2887,21 @@ <!-- Colon separated list of package names that should be granted Notification Listener access --> <java-symbol type="string" name="config_defaultListenerAccessPackages" /> <!-- system notification channels --> <java-symbol type="string" name="notification_channel_virtual_keyboard" /> <java-symbol type="string" name="notification_channel_physical_keyboard" /> <java-symbol type="string" name="notification_channel_security" /> <java-symbol type="string" name="notification_channel_car_mode" /> <java-symbol type="string" name="notification_channel_account" /> <java-symbol type="string" name="notification_channel_developer" /> <java-symbol type="string" name="notification_channel_updates" /> <java-symbol type="string" name="notification_channel_network_status" /> <java-symbol type="string" name="notification_channel_network_alerts" /> <java-symbol type="string" name="notification_channel_vpn" /> <java-symbol type="string" name="notification_channel_device_admin" /> <java-symbol type="string" name="notification_channel_alerts" /> <java-symbol type="string" name="notification_channel_retail_mode" /> <java-symbol type="string" name="notification_channel_usb" /> </resources>
services/core/java/com/android/server/InputMethodManagerService.java +9 −7 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import com.android.internal.inputmethod.InputMethodSubtypeSwitchingController; import com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem; import com.android.internal.inputmethod.InputMethodUtils; import com.android.internal.inputmethod.InputMethodUtils.InputMethodSettings; import com.android.internal.notification.SystemNotificationChannels; import com.android.internal.os.HandlerCaller; import com.android.internal.os.SomeArgs; import com.android.internal.os.TransferPipe; Loading Loading @@ -1262,7 +1263,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub Bundle extras = new Bundle(); extras.putBoolean(Notification.EXTRA_ALLOW_DURING_SETUP, true); mImeSwitcherNotification = new Notification.Builder(mContext) mImeSwitcherNotification = new Notification.Builder(mContext, SystemNotificationChannels.VIRTUAL_KEYBOARD) .setSmallIcon(com.android.internal.R.drawable.ic_notification_ime_default) .setWhen(0) .setOngoing(true) Loading