Merge "Add logic to update the notification whenever the satellite availaibility changes." into main
diff --git a/Telephony.iml b/Telephony.iml
new file mode 100644
index 0000000..d8ee5ed
--- /dev/null
+++ b/Telephony.iml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony">
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/src" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/testapps/EmbmsServiceTestApp/src" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/testapps/EmbmsTestDownloadApp/src" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/testapps/EmbmsTestStreamingApp/src" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/testapps/GbaTestApp/src" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/testapps/ImsTestService/src" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/testapps/SmsManagerTestApp/src" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/testapps/TelephonyManagerTestApp/src" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/testapps/TelephonyRegistryTestApp/src" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/testapps/TestRcsApp/TestApp/src" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/testapps/TestRcsApp/aosp_test_rcsclient/src" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/testapps/TestSatelliteApp/src" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/testapps/TestSliceApp/app/src/main/java" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/tests/src" isTestSource="true" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/utils/satellite/configdatagenerator/src/main/java" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/utils/satellite/configdatagenerator/src/test/java" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/utils/satellite/s2storage/src/readonly/java" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/utils/satellite/s2storage/src/test/java" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/utils/satellite/s2storage/src/testutils/java/com/android/telephony/sats2range/testutils" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/utils/satellite/s2storage/src/write/java" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/utils/satellite/tools/src/main/java" isTestSource="false" />
+ <sourceFolder url="file:///usr/local/google/home/donaldahn/source/2408_main/packages/services/Telephony/utils/satellite/tools/src/test/java" isTestSource="false" />
+ </content>
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="framework_srcjars" />
+ <orderEntry type="module" module-name="core" />
+ <orderEntry type="module" module-name="ims" />
+ <orderEntry type="module" module-name="telecomm" />
+ <orderEntry type="module" module-name="telephony" />
+ <orderEntry type="module" module-name="frameworks_telephony" />
+ <orderEntry type="module" module-name="dependencies" />
+ <orderEntry type="inheritedJdk" />
+ </component>
+</module>
diff --git a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
index a47691e..1c27994 100644
--- a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
+++ b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
@@ -180,7 +180,8 @@
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 NOTIFICATION_TAG = "SatelliteAccessController";
+ private static final String AVAILABLE_NOTIFICATION_TAG = "available_notification_tag";
+ private static final String UNAVAILABLE_NOTIFICATION_TAG = "unavailable_notification_tag";
private static final int NOTIFICATION_ID = 1;
private static final String NOTIFICATION_CHANNEL = "satelliteChannel";
private static final String NOTIFICATION_CHANNEL_ID = "satellite";
@@ -1447,44 +1448,41 @@
}
if (mSatelliteDisallowedReasons.isEmpty()) {
- if (!hasAlreadyNotified(KEY_AVAILABLE_NOTIFICATION_SHOWN, 0)) {
+ mNotificationManager.cancel(UNAVAILABLE_NOTIFICATION_TAG, NOTIFICATION_ID);
+ if (!hasAlreadyNotified(KEY_AVAILABLE_NOTIFICATION_SHOWN)) {
mNotificationManager.notifyAsUser(
- NOTIFICATION_TAG,
+ AVAILABLE_NOTIFICATION_TAG,
NOTIFICATION_ID,
mSatelliteAvailableNotification,
UserHandle.ALL
);
- markAsNotified(KEY_AVAILABLE_NOTIFICATION_SHOWN, 0);
+ markAsNotified(KEY_AVAILABLE_NOTIFICATION_SHOWN, true);
+ markAsNotified(KEY_UNAVAILABLE_NOTIFICATION_SHOWN, false);
}
} else {
+ mNotificationManager.cancel(AVAILABLE_NOTIFICATION_TAG, NOTIFICATION_ID);
for (Integer reason : mSatelliteDisallowedReasons) {
- if (!hasAlreadyNotified(KEY_UNAVAILABLE_NOTIFICATION_SHOWN, reason)) {
+ if (!hasAlreadyNotified(KEY_UNAVAILABLE_NOTIFICATION_SHOWN)) {
mNotificationManager.notifyAsUser(
- NOTIFICATION_TAG,
+ UNAVAILABLE_NOTIFICATION_TAG,
NOTIFICATION_ID,
mSatelliteUnAvailableNotifications.get(reason),
UserHandle.ALL
);
- markAsNotified(KEY_UNAVAILABLE_NOTIFICATION_SHOWN, reason);
+ markAsNotified(KEY_UNAVAILABLE_NOTIFICATION_SHOWN, true);
+ markAsNotified(KEY_AVAILABLE_NOTIFICATION_SHOWN, false);
break;
}
}
}
}
- private boolean hasAlreadyNotified(String key, int reason) {
- Set<String> reasons = mSharedPreferences.getStringSet(key, new HashSet<>());
- return reasons.contains(String.valueOf(reason));
+ private boolean hasAlreadyNotified(String key) {
+ return mSharedPreferences.getBoolean(key, false);
}
- 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();
- }
+ private void markAsNotified(String key, boolean notified) {
+ mSharedPreferences.edit().putBoolean(key, notified).apply();
}
/**