Introduce Radio Shutdown System APIs for Mainline
Test: built; cts Bug: 145554073 Change-Id: I26f01ea5f7cca88d1c3aeefae96ff3bf11b5138f
This commit is contained in:
@@ -9610,6 +9610,7 @@ package android.telephony {
|
||||
method @Nullable @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public android.telephony.IccOpenLogicalChannelResponse iccOpenLogicalChannelBySlot(int, @Nullable String, int);
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String iccTransmitApduBasicChannelBySlot(int, int, int, int, int, int, @Nullable String);
|
||||
method @Nullable @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String iccTransmitApduLogicalChannelBySlot(int, int, int, int, int, int, int, @Nullable String);
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isAnyRadioPoweredOn();
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isApplicationOnUicc(int);
|
||||
method public boolean isDataConnectivityPossible();
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isDataEnabledForApn(int);
|
||||
@@ -9648,6 +9649,7 @@ package android.telephony {
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSimPowerStateForSlot(int, int);
|
||||
method @Deprecated public void setVisualVoicemailEnabled(android.telecom.PhoneAccountHandle, boolean);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setVoiceActivationState(int);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void shutdownAllRadios();
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean supplyPin(String);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int[] supplyPinReportResult(String);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean supplyPuk(String, String);
|
||||
|
||||
@@ -41,12 +41,12 @@ import android.os.Trace;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.os.Vibrator;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.util.TimingsTraceLog;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.android.internal.telephony.ITelephony;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.RescueParty;
|
||||
import com.android.server.pm.PackageManagerService;
|
||||
@@ -586,19 +586,15 @@ public final class ShutdownThread extends Thread {
|
||||
TimingsTraceLog shutdownTimingsTraceLog = newTimingsLog();
|
||||
boolean radioOff;
|
||||
|
||||
final ITelephony phone =
|
||||
ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
|
||||
TelephonyManager telephonyManager = mContext.getSystemService(
|
||||
TelephonyManager.class);
|
||||
|
||||
try {
|
||||
radioOff = phone == null || !phone.needMobileRadioShutdown();
|
||||
if (!radioOff) {
|
||||
Log.w(TAG, "Turning off cellular radios...");
|
||||
metricStarted(METRIC_RADIO);
|
||||
phone.shutdownMobileRadios();
|
||||
}
|
||||
} catch (RemoteException ex) {
|
||||
Log.e(TAG, "RemoteException during radio shutdown", ex);
|
||||
radioOff = true;
|
||||
radioOff = telephonyManager == null
|
||||
|| !telephonyManager.isAnyRadioPoweredOn();
|
||||
if (!radioOff) {
|
||||
Log.w(TAG, "Turning off cellular radios...");
|
||||
metricStarted(METRIC_RADIO);
|
||||
telephonyManager.shutdownAllRadios();
|
||||
}
|
||||
|
||||
Log.i(TAG, "Waiting for Radio...");
|
||||
@@ -613,12 +609,7 @@ public final class ShutdownThread extends Thread {
|
||||
}
|
||||
|
||||
if (!radioOff) {
|
||||
try {
|
||||
radioOff = !phone.needMobileRadioShutdown();
|
||||
} catch (RemoteException ex) {
|
||||
Log.e(TAG, "RemoteException during radio shutdown", ex);
|
||||
radioOff = true;
|
||||
}
|
||||
radioOff = !telephonyManager.isAnyRadioPoweredOn();
|
||||
if (radioOff) {
|
||||
Log.i(TAG, "Radio turned off.");
|
||||
metricEnded(METRIC_RADIO);
|
||||
|
||||
@@ -8357,6 +8357,44 @@ public class TelephonyManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shut down all the live radios over all the slot index.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
public void shutdownAllRadios() {
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
if (telephony != null) {
|
||||
telephony.shutdownMobileRadios();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelephony#shutdownMobileRadios", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any radio is on over all the slot indexes.
|
||||
*
|
||||
* @return {@code true} if any radio is on over any slot index.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
||||
public boolean isAnyRadioPoweredOn() {
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
if (telephony != null) {
|
||||
return telephony.needMobileRadioShutdown();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelephony#needMobileRadioShutdown", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Radio explicitly powered off (e.g, airplane mode).
|
||||
* @hide
|
||||
|
||||
Reference in New Issue
Block a user