From 98920c3714be9b5b4872c28081ab319d7a1e6a0e Mon Sep 17 00:00:00 2001 From: Rambo Wang Date: Tue, 11 Jun 2024 17:23:20 +0000 Subject: [PATCH] eSIM profile is not erased during Reset mobile network settings flow The CL fixes the bug that eSIM profile is not erased even if user choose to erase eSIM during Reset Mobile Network Settings flow. The issue was introduced when adding background operations to restart Phone process and RILD. Restart Phone process performed earlier. It may interrup the previous reset operations (e.g. eSIM erasing). The fix here is to arrange reset Phone and RILD in the end of the flow, only performed after all other reset operations. Bug: 345854350 Test: atest ResetNetworkOperationBuilderTest Test: Manual regression test Change-Id: If2bd492d417a07a7056bf9fd0d051f8811ba6369 --- .../android/settings/ResetNetworkRequest.java | 1 + .../network/ResetNetworkOperationBuilder.java | 46 +++++++++++-------- .../ResetNetworkOperationBuilderTest.java | 8 ++-- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/com/android/settings/ResetNetworkRequest.java b/src/com/android/settings/ResetNetworkRequest.java index 4be8b3206a6..7632ea01d71 100644 --- a/src/com/android/settings/ResetNetworkRequest.java +++ b/src/com/android/settings/ResetNetworkRequest.java @@ -270,6 +270,7 @@ public class ResetNetworkRequest { if ((mResetOptions & RESET_IMS_STACK) != 0) { builder.resetIms(mSubscriptionIdToResetIms); } + // Reset phone process and RILD may impact above components, keep them at the end if ((mResetOptions & RESET_PHONE_PROCESS) != 0) { builder.restartPhoneProcess(); } diff --git a/src/com/android/settings/network/ResetNetworkOperationBuilder.java b/src/com/android/settings/network/ResetNetworkOperationBuilder.java index 4067fba5892..6f36074d145 100644 --- a/src/com/android/settings/network/ResetNetworkOperationBuilder.java +++ b/src/com/android/settings/network/ResetNetworkOperationBuilder.java @@ -256,16 +256,19 @@ public class ResetNetworkOperationBuilder { * @return this */ public ResetNetworkOperationBuilder restartPhoneProcess() { - try { - mContext.getContentResolver().call( - getResetTelephonyContentProviderAuthority(), - METHOD_RESTART_PHONE_PROCESS, - /* arg= */ null, - /* extras= */ null); - Log.i(TAG, "Phone process was restarted."); - } catch (IllegalArgumentException iae) { - Log.w(TAG, "Fail to restart phone process: " + iae); - } + Runnable runnable = () -> { + try { + mContext.getContentResolver().call( + getResetTelephonyContentProviderAuthority(), + METHOD_RESTART_PHONE_PROCESS, + /* arg= */ null, + /* extras= */ null); + Log.i(TAG, "Phone process was restarted."); + } catch (IllegalArgumentException iae) { + Log.w(TAG, "Fail to restart phone process: " + iae); + } + }; + mResetSequence.add(runnable); return this; } @@ -275,16 +278,19 @@ public class ResetNetworkOperationBuilder { * @return this */ public ResetNetworkOperationBuilder restartRild() { - try { - mContext.getContentResolver().call( - getResetTelephonyContentProviderAuthority(), - METHOD_RESTART_RILD, - /* arg= */ null, - /* extras= */ null); - Log.i(TAG, "RILD was restarted."); - } catch (IllegalArgumentException iae) { - Log.w(TAG, "Fail to restart RILD: " + iae); - } + Runnable runnable = () -> { + try { + mContext.getContentResolver().call( + getResetTelephonyContentProviderAuthority(), + METHOD_RESTART_RILD, + /* arg= */ null, + /* extras= */ null); + Log.i(TAG, "RILD was restarted."); + } catch (IllegalArgumentException iae) { + Log.w(TAG, "Fail to restart RILD: " + iae); + } + }; + mResetSequence.add(runnable); return this; } diff --git a/tests/unit/src/com/android/settings/network/ResetNetworkOperationBuilderTest.java b/tests/unit/src/com/android/settings/network/ResetNetworkOperationBuilderTest.java index 6213f8eeb33..5f544064924 100644 --- a/tests/unit/src/com/android/settings/network/ResetNetworkOperationBuilderTest.java +++ b/tests/unit/src/com/android/settings/network/ResetNetworkOperationBuilderTest.java @@ -188,7 +188,7 @@ public class ResetNetworkOperationBuilderTest { doThrow(new IllegalArgumentException()).when(mContentProvider).call( anyString(), anyString(), anyString(), any()); - mBuilder.restartPhoneProcess(); + mBuilder.restartPhoneProcess().build().run(); } @Test @@ -196,12 +196,12 @@ public class ResetNetworkOperationBuilderTest { doThrow(new IllegalArgumentException()).when(mContentProvider).call( anyString(), anyString(), anyString(), any()); - mBuilder.restartRild(); + mBuilder.restartRild().build().run(); } @Test public void restartPhoneProcess_withTelephonyContentProvider_shouldCallRestartPhoneProcess() { - mBuilder.restartPhoneProcess(); + mBuilder.restartPhoneProcess().build().run(); verify(mContentProvider).call( eq(mBuilder.getResetTelephonyContentProviderAuthority()), @@ -212,7 +212,7 @@ public class ResetNetworkOperationBuilderTest { @Test public void restartRild_withTelephonyContentProvider_shouldCallRestartRild() { - mBuilder.restartRild(); + mBuilder.restartRild().build().run(); verify(mContentProvider).call( eq(mBuilder.getResetTelephonyContentProviderAuthority()),