summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2017-05-22 18:16:15 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-05-22 18:16:16 +0000
commit1685eaeb50984f31a1bf94b16f8245aacc428d40 (patch)
tree209677db584e0d16a4dfa4d816be554d6d73cb92
parent1172a0112f3641d1a73681fe6a0bdeef3455bc6c (diff)
parent55bcb0813f9a41d7542bde40b69cd6d00ee17df7 (diff)
downloadandroid_packages_services_Telecomm-1685eaeb50984f31a1bf94b16f8245aacc428d40.tar.gz
android_packages_services_Telecomm-1685eaeb50984f31a1bf94b16f8245aacc428d40.tar.bz2
android_packages_services_Telecomm-1685eaeb50984f31a1bf94b16f8245aacc428d40.zip
Merge "Update notification channels on locale change." into oc-dev
-rw-r--r--src/com/android/server/telecom/ui/NotificationChannelManager.java33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/com/android/server/telecom/ui/NotificationChannelManager.java b/src/com/android/server/telecom/ui/NotificationChannelManager.java
index 7b64e311..46b6c282 100644
--- a/src/com/android/server/telecom/ui/NotificationChannelManager.java
+++ b/src/com/android/server/telecom/ui/NotificationChannelManager.java
@@ -18,9 +18,13 @@ package com.android.server.telecom.ui;
import android.app.NotificationChannel;
import android.app.NotificationManager;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.media.AudioAttributes;
import android.net.Uri;
+import android.telecom.Log;
import com.android.server.telecom.R;
@@ -33,18 +37,29 @@ public class NotificationChannelManager {
public static final String CHANNEL_ID_MISSED_CALLS = "TelecomMissedCalls";
public static final String CHANNEL_ID_INCOMING_CALLS = "TelecomIncomingCalls";
+ private BroadcastReceiver mLocaleChangeReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.i(this, "Locale change; recreating channels.");
+ createOrUpdateAll(context);
+ }
+ };
+
public void createChannels(Context context) {
- maybeCreateChannel(context, CHANNEL_ID_MISSED_CALLS);
- maybeCreateChannel(context, CHANNEL_ID_INCOMING_CALLS);
+ context.registerReceiver(mLocaleChangeReceiver,
+ new IntentFilter(Intent.ACTION_LOCALE_CHANGED));
+
+ createOrUpdateAll(context);
}
- private void maybeCreateChannel(Context context, String channelId) {
- NotificationChannel channel = getNotificationManager(context).getNotificationChannel(
- channelId);
- if (channel == null) {
- channel = createChannel(context, channelId);
- getNotificationManager(context).createNotificationChannel(channel);
- }
+ private void createOrUpdateAll(Context context) {
+ createOrUpdateChannel(context, CHANNEL_ID_MISSED_CALLS);
+ createOrUpdateChannel(context, CHANNEL_ID_INCOMING_CALLS);
+ }
+
+ private void createOrUpdateChannel(Context context, String channelId) {
+ NotificationChannel channel = createChannel(context, channelId);
+ getNotificationManager(context).createNotificationChannel(channel);
}
private NotificationChannel createChannel(Context context, String channelId) {