diff options
author | Jordan Liu <jminjie@google.com> | 2021-10-19 18:43:09 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-10-19 18:43:09 +0000 |
commit | bc0e217c23d9a83c782b1f0b7ca8766eed7a98bf (patch) | |
tree | ade47f7a6e0add5c1c3bcd31f2776457ce2b33ee /src | |
parent | 9e3cede5cf230d9306312d3d40921668582b3272 (diff) | |
parent | ea4c284bed1aea3f8dba4c0cdfb5e7d508ebe0ed (diff) | |
download | Stk-bc0e217c23d9a83c782b1f0b7ca8766eed7a98bf.tar.gz |
Merge "Remove unnecessary content title from notifications" am: cead072ccc am: ea4c284bed
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Stk/+/1450515
Change-Id: If191d9a8d138a7a28c59eba9ac0d4386ee82f9bb
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/stk/StkAppService.java | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java index 46fc55a..7a9fe18 100644 --- a/src/com/android/stk/StkAppService.java +++ b/src/com/android/stk/StkAppService.java @@ -1676,17 +1676,10 @@ public class StkAppService extends Service implements Runnable { private void launchNotificationOnKeyguard(int slotId, String message) { Notification.Builder builder = new Notification.Builder(this, STK_NOTIFICATION_CHANNEL_ID); + setNotificationTitle(slotId, builder); builder.setStyle(new Notification.BigTextStyle(builder).bigText(message)); builder.setContentText(message); - - Menu menu = getMainMenu(slotId); - if (menu == null || TextUtils.isEmpty(menu.title)) { - builder.setContentTitle(""); - } else { - builder.setContentTitle(menu.title); - } - builder.setSmallIcon(R.drawable.stat_notify_sim_toolkit); builder.setOngoing(true); builder.setOnlyAlertOnce(true); @@ -2147,12 +2140,7 @@ public class StkAppService extends Service implements Runnable { createAllChannels(); final Notification.Builder notificationBuilder = new Notification.Builder( StkAppService.this, STK_NOTIFICATION_CHANNEL_ID); - if (mStkContext[slotId].mMainCmd != null && - mStkContext[slotId].mMainCmd.getMenu() != null) { - notificationBuilder.setContentTitle(mStkContext[slotId].mMainCmd.getMenu().title); - } else { - notificationBuilder.setContentTitle(""); - } + setNotificationTitle(slotId, notificationBuilder); notificationBuilder .setSmallIcon(R.drawable.stat_notify_sim_toolkit); notificationBuilder.setContentIntent(pendingIntent); @@ -2181,6 +2169,30 @@ public class StkAppService extends Service implements Runnable { } } + private void setNotificationTitle(int slotId, Notification.Builder builder) { + Menu menu = getMainMenu(slotId); + if (menu == null || TextUtils.isEmpty(menu.title) + || TextUtils.equals(menu.title, getResources().getString(R.string.app_name))) { + // No need to set a content title in the content area if no title (alpha identifier + // of SET-UP MENU command) is available for the specified slot or the title is same + // as the application label. + return; + } + + for (int index = 0; index < mSimCount; index++) { + if (index != slotId) { + Menu otherMenu = getMainMenu(index); + if (otherMenu != null && !TextUtils.equals(menu.title, otherMenu.title)) { + // Set the title (alpha identifier of SET-UP MENU command) as the content title + // to differentiate it from other main menu with different alpha identifier + // (including null) is available. + builder.setContentTitle(menu.title); + return; + } + } + } + } + /** Creates the notification channel and registers it with NotificationManager. * If a channel with the same ID is already registered, NotificationManager will * ignore this call. |