Merge "Fix crash when using SatelliteSOSMessageRecommender without satellite feature" into main
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5c8504a..1190d38 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -596,7 +596,8 @@
<receiver
android:name=".security.SafetySourceReceiver"
- android:exported="false">
+ android:exported="false"
+ androidprv:systemUserOnly="true">
<intent-filter>
<action android:name="android.safetycenter.action.REFRESH_SAFETY_SOURCES"/>
</intent-filter>
diff --git a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
index 45cd611..0a7fd6c 100644
--- a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
+++ b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
@@ -360,19 +360,21 @@
Path pathSatelliteS2CellFile = satelliteConfig.getSatelliteS2CellFile(context);
mSatelliteS2CellFile = pathSatelliteS2CellFile.toFile();
if (mSatelliteS2CellFile != null && !mSatelliteS2CellFile.exists()) {
- loge("The satellite S2 cell file " + mSatelliteS2CellFile.getName()
+ loge("The satellite S2 cell file " + mSatelliteS2CellFile.getAbsolutePath()
+ " does not exist");
mSatelliteS2CellFile = null;
+ } else {
+ logd("S2 cell file from ConfigUpdater:" + mSatelliteS2CellFile.getAbsolutePath());
}
}
if (mSatelliteS2CellFile == null) {
- logd("Check mSatelliteS2CellFile from CarrierConfig");
+ logd("Check mSatelliteS2CellFile from device overlay config");
String satelliteS2CellFileName = getSatelliteS2CellFileFromOverlayConfig(context);
mSatelliteS2CellFile = TextUtils.isEmpty(satelliteS2CellFileName)
? null : new File(satelliteS2CellFileName);
if (mSatelliteS2CellFile != null && !mSatelliteS2CellFile.exists()) {
- loge("The satellite S2 cell file " + mSatelliteS2CellFile.getName()
+ loge("The satellite S2 cell file " + mSatelliteS2CellFile.getAbsolutePath()
+ " does not exist");
mSatelliteS2CellFile = null;
}
@@ -385,18 +387,23 @@
if (satelliteConfig != null
&& !satelliteConfig.getDeviceSatelliteCountryCodes().isEmpty()) {
- logd("update mSatelliteCountryCodes by ConfigUpdater");
mSatelliteCountryCodes = satelliteConfig.getDeviceSatelliteCountryCodes();
+ logd("update mSatelliteCountryCodes by ConfigUpdater: "
+ + String.join(",", mSatelliteCountryCodes));
} else {
mSatelliteCountryCodes = getSatelliteCountryCodesFromOverlayConfig(context);
}
if (satelliteConfig != null && satelliteConfig.isSatelliteDataForAllowedRegion() != null) {
- logd("update mIsSatelliteAllowAccessControl by ConfigUpdater");
mIsSatelliteAllowAccessControl = satelliteConfig.isSatelliteDataForAllowedRegion();
+ logd("update mIsSatelliteAllowAccessControl by ConfigUpdater: "
+ + mIsSatelliteAllowAccessControl);
} else {
mIsSatelliteAllowAccessControl = getSatelliteAccessAllowFromOverlayConfig(context);
}
+
+ // Clean up resources so that the new config data will be used when receiving new requests
+ cleanupOnDeviceAccessControllerResources();
}
private void loadOverlayConfigs(@NonNull Context context) {
diff --git a/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java b/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java
index 045cc1d..b5c0c0b 100644
--- a/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java
+++ b/tests/src/com/android/phone/satellite/accesscontrol/SatelliteAccessControllerTest.java
@@ -84,7 +84,6 @@
import java.io.File;
import java.lang.reflect.Field;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -573,7 +572,7 @@
assertNull(spyConfigParserNull.getConfig());
- // Verify the case when the configParser is exist but empty.
+ // Verify the case when the configParser exist but empty.
SatelliteConfigParser spyConfigParserEmpty =
spy(new SatelliteConfigParser("test".getBytes()));
doReturn(spyConfigParserEmpty).when(mMockSatelliteController).getSatelliteConfigParser();
@@ -582,23 +581,28 @@
assertNull(spyConfigParserEmpty.getConfig());
- // Verify the case when the configParser is exist and valid data
+ // Verify the case when the configParser exists and has valid data
SatelliteConfig mockSatelliteConfig = mock(SatelliteConfig.class);
- final String filePath = "/data/user_de/0/com.android.phone/app_satellite/s2_cell_file";
- Path targetSatS2FilePath = Paths.get(filePath);
+ Path mockTargetSatS2FilePath = mock(Path.class);
+ File mockS2CellFile = mock(File.class);
+ doReturn(mockS2CellFile).when(mockTargetSatS2FilePath).toFile();
+ doReturn(true).when(mockS2CellFile).exists();
doReturn(false).when(mockSatelliteConfig).isFileExist(any());
- doReturn(targetSatS2FilePath).when(mockSatelliteConfig)
+ doReturn(mockTargetSatS2FilePath).when(mockSatelliteConfig)
.copySatS2FileToPhoneDirectory(any(), any());
doReturn(Arrays.asList("US")).when(mockSatelliteConfig).getDeviceSatelliteCountryCodes();
doReturn(false).when(mockSatelliteConfig).isSatelliteDataForAllowedRegion();
- doReturn(targetSatS2FilePath).when(mockSatelliteConfig).getSatelliteS2CellFile(any());
+ doReturn(mockTargetSatS2FilePath).when(mockSatelliteConfig).getSatelliteS2CellFile(any());
doReturn(mockSatelliteConfig).when(mMockSatelliteController).getSatelliteConfig();
+ mSatelliteAccessControllerUT.setSatelliteOnDeviceAccessController(
+ mMockSatelliteOnDeviceAccessController);
sendConfigUpdateChangedEvent(mMockContext);
- verify(mockSatelliteConfig, times(0)).getDeviceSatelliteCountryCodes();
- verify(mockSatelliteConfig, times(0)).isSatelliteDataForAllowedRegion();
+ verify(mockSatelliteConfig, times(2)).getDeviceSatelliteCountryCodes();
+ verify(mockSatelliteConfig, times(2)).isSatelliteDataForAllowedRegion();
verify(mockSatelliteConfig, times(2)).getSatelliteS2CellFile(any());
+ assertTrue(mSatelliteAccessControllerUT.isSatelliteOnDeviceAccessControllerReset());
}
private void sendConfigUpdateChangedEvent(Context context) {