Fix Settings restart during Reset mobile nework settings flow
This CL avoids restarting Settings in the reset mobile flow when phone process is restarted, by switching the usage of the stable content provider connection to the unstable client. The CL also arranges restarting phone process as the last reset operation in the flow (later than RILD reset) to avoid any reset operation get impacted by phone process restarting. Since the permission to protect the TelephonyContentProvider has been renamed, the CL also renames the requsted permision. Bug: 347047105 Test: atest ResetNetworkOperationBuilderTest Test: Reset mobile network feature test Flag: EXEMPT resource update with minor refactoring Change-Id: I7bfa79bc9d7451a4a03269704b0009a3730e287f
This commit is contained in:
@@ -16,20 +16,16 @@
|
||||
|
||||
package com.android.settings.network;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.anyInt;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkPolicyManager;
|
||||
@@ -67,7 +63,7 @@ public class ResetNetworkOperationBuilderTest {
|
||||
@Mock
|
||||
private NetworkPolicyManager mNetworkPolicyManager;
|
||||
@Mock
|
||||
private ContentProvider mContentProvider;;
|
||||
private ContentProviderClient mContentProviderClient;
|
||||
|
||||
|
||||
private Context mContext;
|
||||
@@ -77,9 +73,8 @@ public class ResetNetworkOperationBuilderTest {
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
doReturn(ContentResolver.wrap(mContentProvider)).when(mContext).getContentResolver();
|
||||
|
||||
mBuilder = spy(new ResetNetworkOperationBuilder(mContext));
|
||||
doReturn(mContentProviderClient).when(mBuilder).getUnstableTelephonyContentProviderClient();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -184,38 +179,38 @@ public class ResetNetworkOperationBuilderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restartPhoneProcess_withoutTelephonyContentProvider_shouldNotCrash() {
|
||||
doThrow(new IllegalArgumentException()).when(mContentProvider).call(
|
||||
anyString(), anyString(), anyString(), any());
|
||||
public void restartPhoneProcess_withoutTelephonyContentProvider_shouldNotCrash()
|
||||
throws Exception {
|
||||
doReturn(null).when(mBuilder).getUnstableTelephonyContentProviderClient();
|
||||
|
||||
mBuilder.restartPhoneProcess().build().run();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restartRild_withoutTelephonyContentProvider_shouldNotCrash() {
|
||||
doThrow(new IllegalArgumentException()).when(mContentProvider).call(
|
||||
anyString(), anyString(), anyString(), any());
|
||||
public void restartRild_withoutTelephonyContentProvider_shouldNotCrash()
|
||||
throws Exception {
|
||||
doReturn(null).when(mBuilder).getUnstableTelephonyContentProviderClient();
|
||||
|
||||
mBuilder.restartRild().build().run();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restartPhoneProcess_withTelephonyContentProvider_shouldCallRestartPhoneProcess() {
|
||||
public void restartPhoneProcess_withTelephonyContentProvider_shouldCallRestartPhoneProcess()
|
||||
throws Exception {
|
||||
mBuilder.restartPhoneProcess().build().run();
|
||||
|
||||
verify(mContentProvider).call(
|
||||
eq(mBuilder.getResetTelephonyContentProviderAuthority()),
|
||||
verify(mContentProviderClient).call(
|
||||
eq(ResetNetworkOperationBuilder.METHOD_RESTART_PHONE_PROCESS),
|
||||
isNull(),
|
||||
isNull());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void restartRild_withTelephonyContentProvider_shouldCallRestartRild() {
|
||||
public void restartRild_withTelephonyContentProvider_shouldCallRestartRild()
|
||||
throws Exception {
|
||||
mBuilder.restartRild().build().run();
|
||||
|
||||
verify(mContentProvider).call(
|
||||
eq(mBuilder.getResetTelephonyContentProviderAuthority()),
|
||||
verify(mContentProviderClient).call(
|
||||
eq(ResetNetworkOperationBuilder.METHOD_RESTART_RILD),
|
||||
isNull(),
|
||||
isNull());
|
||||
|
Reference in New Issue
Block a user