Merge cherrypicks of ['googleplex-android-review.googlesource.com/30579907'] into 25Q1-release.
Change-Id: Ia1c26f8af71eaf2142fe0c685d2428e0be246c23
diff --git a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
index f17377c..251ba65 100644
--- a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
+++ b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
@@ -184,8 +184,7 @@
private static final String KEY_AVAILABLE_NOTIFICATION_SHOWN = "available_notification_shown";
private static final String KEY_UNAVAILABLE_NOTIFICATION_SHOWN =
"unavailable_notification_shown";
- private static final String AVAILABLE_NOTIFICATION_TAG = "available_notification_tag";
- private static final String UNAVAILABLE_NOTIFICATION_TAG = "unavailable_notification_tag";
+ private static final String NOTIFICATION_TAG = "SatelliteAccessController";
private static final int NOTIFICATION_ID = 1;
private static final String NOTIFICATION_CHANNEL = "satelliteChannel";
private static final String NOTIFICATION_CHANNEL_ID = "satellite";
@@ -1454,41 +1453,44 @@
}
if (mSatelliteDisallowedReasons.isEmpty()) {
- mNotificationManager.cancel(UNAVAILABLE_NOTIFICATION_TAG, NOTIFICATION_ID);
- if (!hasAlreadyNotified(KEY_AVAILABLE_NOTIFICATION_SHOWN)) {
+ if (!hasAlreadyNotified(KEY_AVAILABLE_NOTIFICATION_SHOWN, 0)) {
mNotificationManager.notifyAsUser(
- AVAILABLE_NOTIFICATION_TAG,
+ NOTIFICATION_TAG,
NOTIFICATION_ID,
mSatelliteAvailableNotification,
UserHandle.ALL
);
- markAsNotified(KEY_AVAILABLE_NOTIFICATION_SHOWN, true);
- markAsNotified(KEY_UNAVAILABLE_NOTIFICATION_SHOWN, false);
+ markAsNotified(KEY_AVAILABLE_NOTIFICATION_SHOWN, 0);
}
} else {
- mNotificationManager.cancel(AVAILABLE_NOTIFICATION_TAG, NOTIFICATION_ID);
for (Integer reason : mSatelliteDisallowedReasons) {
- if (!hasAlreadyNotified(KEY_UNAVAILABLE_NOTIFICATION_SHOWN)) {
+ if (!hasAlreadyNotified(KEY_UNAVAILABLE_NOTIFICATION_SHOWN, reason)) {
mNotificationManager.notifyAsUser(
- UNAVAILABLE_NOTIFICATION_TAG,
+ NOTIFICATION_TAG,
NOTIFICATION_ID,
mSatelliteUnAvailableNotifications.get(reason),
UserHandle.ALL
);
- markAsNotified(KEY_UNAVAILABLE_NOTIFICATION_SHOWN, true);
- markAsNotified(KEY_AVAILABLE_NOTIFICATION_SHOWN, false);
+ markAsNotified(KEY_UNAVAILABLE_NOTIFICATION_SHOWN, reason);
break;
}
}
}
}
- private boolean hasAlreadyNotified(String key) {
- return mSharedPreferences.getBoolean(key, false);
+ private boolean hasAlreadyNotified(String key, int reason) {
+ Set<String> reasons = mSharedPreferences.getStringSet(key, new HashSet<>());
+ return reasons.contains(String.valueOf(reason));
}
- private void markAsNotified(String key, boolean notified) {
- mSharedPreferences.edit().putBoolean(key, notified).apply();
+ private void markAsNotified(String key, int reason) {
+ Set<String> reasons = mSharedPreferences.getStringSet(key, new HashSet<>());
+ if (!reasons.contains(String.valueOf(reason))) {
+ reasons.add(String.valueOf(reason));
+ SharedPreferences.Editor editor = mSharedPreferences.edit();
+ editor.putStringSet(key, reasons);
+ editor.apply();
+ }
}
/**