Loading src/java/com/android/internal/telephony/configupdate/TelephonyConfigUpdateInstallReceiver.java +34 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import com.android.server.updates.ConfigUpdateInstallReceiver; import libcore.io.IoUtils; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.util.Iterator; Loading Loading @@ -293,4 +294,37 @@ public class TelephonyConfigUpdateInstallReceiver extends ConfigUpdateInstallRec Log.d(TAG, "source file is not exist, no file to copy"); return false; } /** * This API should be used by only CTS/unit tests to reset the telephony configs set through * config updater */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public boolean cleanUpTelephonyConfigs() { Log.d(TAG, "cleanTelephonyConfigs: resetting the telephony configs"); try { // metadata/version File updateMetadataDir = new File(updateDir, UPDATE_METADATA_PATH); writeUpdate( updateMetadataDir, updateVersion, new ByteArrayInputStream(Integer.toString(-1).getBytes())); // new_telephony_config.pb writeUpdate(updateDir, updateContent, new ByteArrayInputStream(new byte[] {})); // valid_telephony_config.pb File validConfigContentPath = new File(updateDir, VALID_CONFIG_CONTENT_PATH); writeUpdate(updateDir, validConfigContentPath, new ByteArrayInputStream(new byte[] {})); } catch (IOException e) { Log.e(TAG, "Failed to clean telephony config files: " + e); return false; } Log.d(TAG, "cleanTelephonyConfigs: resetting the config parser"); synchronized (getInstance().mConfigParserLock) { getInstance().mConfigParser = null; } return true; } } src/java/com/android/internal/telephony/satellite/SatelliteConfig.java +28 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.internal.telephony.satellite; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.os.FileUtils; import android.util.ArraySet; import android.util.Log; Loading Loading @@ -287,6 +288,33 @@ public class SatelliteConfig { return targetSatelliteFilePath.toFile(); } /** * This method cleans the Satellite Config OTA resources and it should be used only in CTS/Unit * tests */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public void cleanOtaResources(@Nullable Context context) { if (context == null) { Log.d(TAG, "cleanOtaResources : context is null"); return; } try { File satelliteFileDir = context.getDir(SATELLITE_DIR_NAME, Context.MODE_PRIVATE); if (!satelliteFileDir.exists()) { Log.d( TAG, "cleanOtaResources: " + SATELLITE_DIR_NAME + " does not exist. No need to clean."); return; } Log.d(TAG, "cleanOtaResources: Deleting contents under " + SATELLITE_DIR_NAME); FileUtils.deleteContents(satelliteFileDir); } catch (Exception e) { Log.e(TAG, "cleanOtaResources error : " + e); } } /** * @return {@code true} if the SatS2File is already existed and {@code false} otherwise. */ Loading src/java/com/android/internal/telephony/satellite/SatelliteController.java +9 −0 Original line number Diff line number Diff line Loading @@ -1050,6 +1050,15 @@ public class SatelliteController extends Handler { return satelliteConfigParser.getConfig(); } /** * This API should be used by only CTS/unit tests to reset the telephony configs set through * config updater */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public void cleanUpTelephonyConfigs() { TelephonyConfigUpdateInstallReceiver.getInstance().cleanUpTelephonyConfigs(); } /** * Get SatelliteConfigParser from TelephonyConfigUpdateInstallReceiver */ Loading Loading
src/java/com/android/internal/telephony/configupdate/TelephonyConfigUpdateInstallReceiver.java +34 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import com.android.server.updates.ConfigUpdateInstallReceiver; import libcore.io.IoUtils; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.util.Iterator; Loading Loading @@ -293,4 +294,37 @@ public class TelephonyConfigUpdateInstallReceiver extends ConfigUpdateInstallRec Log.d(TAG, "source file is not exist, no file to copy"); return false; } /** * This API should be used by only CTS/unit tests to reset the telephony configs set through * config updater */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public boolean cleanUpTelephonyConfigs() { Log.d(TAG, "cleanTelephonyConfigs: resetting the telephony configs"); try { // metadata/version File updateMetadataDir = new File(updateDir, UPDATE_METADATA_PATH); writeUpdate( updateMetadataDir, updateVersion, new ByteArrayInputStream(Integer.toString(-1).getBytes())); // new_telephony_config.pb writeUpdate(updateDir, updateContent, new ByteArrayInputStream(new byte[] {})); // valid_telephony_config.pb File validConfigContentPath = new File(updateDir, VALID_CONFIG_CONTENT_PATH); writeUpdate(updateDir, validConfigContentPath, new ByteArrayInputStream(new byte[] {})); } catch (IOException e) { Log.e(TAG, "Failed to clean telephony config files: " + e); return false; } Log.d(TAG, "cleanTelephonyConfigs: resetting the config parser"); synchronized (getInstance().mConfigParserLock) { getInstance().mConfigParser = null; } return true; } }
src/java/com/android/internal/telephony/satellite/SatelliteConfig.java +28 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.internal.telephony.satellite; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.os.FileUtils; import android.util.ArraySet; import android.util.Log; Loading Loading @@ -287,6 +288,33 @@ public class SatelliteConfig { return targetSatelliteFilePath.toFile(); } /** * This method cleans the Satellite Config OTA resources and it should be used only in CTS/Unit * tests */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public void cleanOtaResources(@Nullable Context context) { if (context == null) { Log.d(TAG, "cleanOtaResources : context is null"); return; } try { File satelliteFileDir = context.getDir(SATELLITE_DIR_NAME, Context.MODE_PRIVATE); if (!satelliteFileDir.exists()) { Log.d( TAG, "cleanOtaResources: " + SATELLITE_DIR_NAME + " does not exist. No need to clean."); return; } Log.d(TAG, "cleanOtaResources: Deleting contents under " + SATELLITE_DIR_NAME); FileUtils.deleteContents(satelliteFileDir); } catch (Exception e) { Log.e(TAG, "cleanOtaResources error : " + e); } } /** * @return {@code true} if the SatS2File is already existed and {@code false} otherwise. */ Loading
src/java/com/android/internal/telephony/satellite/SatelliteController.java +9 −0 Original line number Diff line number Diff line Loading @@ -1050,6 +1050,15 @@ public class SatelliteController extends Handler { return satelliteConfigParser.getConfig(); } /** * This API should be used by only CTS/unit tests to reset the telephony configs set through * config updater */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public void cleanUpTelephonyConfigs() { TelephonyConfigUpdateInstallReceiver.getInstance().cleanUpTelephonyConfigs(); } /** * Get SatelliteConfigParser from TelephonyConfigUpdateInstallReceiver */ Loading