Reset telephony stack during Reset Mobile Network flow

This CL introduces two more steps to restart Phone process and RILD
during the Reset mobile network flow by the help of the
TelephonyContentProvider which has been used by Pixel Adaptive
Connectivity Services ("SCONE") for a while.

The additional reset options can resolve issues like resources leak
and internal state stuck, effectively recover telephony stack into
fresh state.

The reset options are performed in the background and have no impact
on UX of the reset flow.

Bug: 271921464
Test: ResetNetworkOperationBuilderTest
Test: Feature test with both flag on and off
Change-Id: If09d20d79e908dd43f3f654fb7cca7f713b7f03a
This commit is contained in:
Rambo Wang
2024-01-04 04:33:23 +00:00
parent 4f06db7bf8
commit 4c384506d5
6 changed files with 126 additions and 1 deletions

View File

@@ -33,6 +33,8 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.ResetNetworkRequest;
import com.android.settings.network.apn.ApnSettings;
@@ -50,6 +52,13 @@ public class ResetNetworkOperationBuilder {
private static final boolean DRY_RUN = false;
// TelephonyContentProvider method to restart phone process
@VisibleForTesting
static final String METHOD_RESTART_PHONE_PROCESS = "restartPhoneProcess";
// TelephonyContentProvider method to restart RILD
@VisibleForTesting
static final String METHOD_RESTART_RILD = "restartRild";
private Context mContext;
private List<Runnable> mResetSequence = new ArrayList<Runnable>();
@@ -229,16 +238,56 @@ public class ResetNetworkOperationBuilder {
// Reset IMS for all slots
for (int slotIndex = 0; slotIndex < tm.getActiveModemCount(); slotIndex++) {
tm.resetIms(slotIndex);
Log.i(TAG, "IMS was reset for slot " + slotIndex);
}
} else {
// Reset IMS for the slot specified by the sucriptionId.
final int slotIndex = SubscriptionManager.getSlotIndex(subId);
tm.resetIms(slotIndex);
Log.i(TAG, "IMS was reset for slot " + slotIndex);
}
});
return this;
}
/**
* Append a step to restart phone process by the help of TelephonyContentProvider.
* It's a no-op if TelephonyContentProvider doesn't exist.
* @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);
}
return this;
}
/**
* Append a step to restart RILD by the help of TelephonyContentProvider.
* It's a no-op if TelephonyContentProvider doesn't exist.
* @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);
}
return this;
}
/**
* Construct a Runnable containing all operations appended.
* @return Runnable
@@ -262,4 +311,14 @@ public class ResetNetworkOperationBuilder {
};
mResetSequence.add(runnable);
}
/**
* @return the authority of the telephony content provider that support methods
* resetPhoneProcess and resetRild.
*/
@VisibleForTesting
String getResetTelephonyContentProviderAuthority() {
return mContext.getResources().getString(
R.string.reset_telephony_stack_content_provider_authority);
}
}