From 95fd52b0941c77b13c53ea57503ca854e3d04d5a Mon Sep 17 00:00:00 2001 From: youngtaecha Date: Wed, 1 Dec 2021 13:38:30 +0000 Subject: Disable testing_mode on below conditions. - userbuildmode is true and - allow_testing_mode_on_user_build is false and - testing_mode is true Bug: 205920270 Test: Manual Test: atest CellBroadcastReceiverOemUnitTests Change-Id: Ib4354a69cbdb6912bc5eee866efafba8d9861690 --- .../cellbroadcastreceiver/CellBroadcastReceiver.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java b/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java index e4a114b1f..14ebe3b0c 100644 --- a/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java +++ b/src/com/android/cellbroadcastreceiver/CellBroadcastReceiver.java @@ -275,7 +275,7 @@ public class CellBroadcastReceiver extends BroadcastReceiver { * @param context the context * @param subId subId of the carrier config event */ - private void resetSettingsIfCarrierChanged(Context context, int subId) { + private void resetSettingsAsNeeded(Context context, int subId) { // subId may be -1 if carrier config broadcast is being sent on SIM removal if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { if (getPreviousCarrierIdForDefaultSub() == NO_PREVIOUS_CARRIER_ID) { @@ -318,6 +318,17 @@ public class CellBroadcastReceiver extends BroadcastReceiver { return; } + /** When user_build_mode is true and alow_testing_mode_on_user_build is false + * then testing_mode is not able to be true at all. + */ + Resources res = getResourcesMethod(); + if (!res.getBoolean(R.bool.allow_testing_mode_on_user_build) + && SystemProperties.getInt("ro.debuggable", 0) == 0 + && CellBroadcastReceiver.isTestingMode(context)) { + Log.d(TAG, "it can't be testing_mode at all"); + setTestingMode(false); + } + if (carrierId != previousCarrierId) { saveCarrierIdForDefaultSub(carrierId); startConfigService(context, @@ -445,7 +456,7 @@ public class CellBroadcastReceiver extends BroadcastReceiver { if (isSystemUser()) { Log.d(TAG, "initializeSharedPreference"); - resetSettingsIfCarrierChanged(context, subId); + resetSettingsAsNeeded(context, subId); SharedPreferences sp = getDefaultSharedPreferences(); -- cgit v1.2.3