Merge "refactor radioPowerstate"
am: 354fc35005
Change-Id: I964beaa764a9c49b462167a9192ac03d3049d0a9
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package android.telephony;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.UnsupportedAppUsage;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -281,6 +282,15 @@ public class PhoneStateListener {
|
||||
*/
|
||||
public static final int LISTEN_PHONE_CAPABILITY_CHANGE = 0x00200000;
|
||||
|
||||
/**
|
||||
* Listen for changes to the radio power state.
|
||||
*
|
||||
* @see #onRadioPowerStateChanged
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final int LISTEN_RADIO_POWER_STATE_CHANGED = 0x00400000;
|
||||
|
||||
/*
|
||||
* Subscription used to listen to the phone state changes
|
||||
* @hide
|
||||
@@ -407,6 +417,9 @@ public class PhoneStateListener {
|
||||
PhoneStateListener.this.onPhoneCapabilityChanged(
|
||||
(PhoneCapability) msg.obj);
|
||||
break;
|
||||
case LISTEN_RADIO_POWER_STATE_CHANGED:
|
||||
PhoneStateListener.this.onRadioPowerStateChanged((int) msg.obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -646,6 +659,18 @@ public class PhoneStateListener {
|
||||
// default implementation empty
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback invoked when modem radio power state changes. Requires
|
||||
* the READ_PRIVILEGED_PHONE_STATE permission.
|
||||
* @param state the modem radio power state
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public void onRadioPowerStateChanged(@TelephonyManager.RadioPowerState int state) {
|
||||
// default implementation empty
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Callback invoked when telephony has received notice from a carrier
|
||||
* app that a network action that could result in connectivity loss
|
||||
@@ -777,6 +802,10 @@ public class PhoneStateListener {
|
||||
public void onPhoneCapabilityChanged(PhoneCapability capability) {
|
||||
send(LISTEN_PHONE_CAPABILITY_CHANGE, 0, 0, capability);
|
||||
}
|
||||
|
||||
public void onRadioPowerStateChanged(@TelephonyManager.RadioPowerState int state) {
|
||||
send(LISTEN_RADIO_POWER_STATE_CHANGED, 0, 0, state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6855,6 +6855,60 @@ public class TelephonyManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef(prefix = {"RADIO_POWER_"},
|
||||
value = {RADIO_POWER_OFF,
|
||||
RADIO_POWER_ON,
|
||||
RADIO_POWER_UNAVAILABLE,
|
||||
})
|
||||
public @interface RadioPowerState {}
|
||||
|
||||
/**
|
||||
* Radio explicitly powered off (e.g, airplane mode).
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final int RADIO_POWER_OFF = 0;
|
||||
|
||||
/**
|
||||
* Radio power is on.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final int RADIO_POWER_ON = 1;
|
||||
|
||||
/**
|
||||
* Radio power unavailable (eg, modem resetting or not booted).
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final int RADIO_POWER_UNAVAILABLE = 2;
|
||||
|
||||
/**
|
||||
* @return current modem radio state.
|
||||
*
|
||||
* <p>Requires permission: {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE} or
|
||||
* {@link android.Manifest.permission#READ_PHONE_STATE} or that the calling
|
||||
* app has carrier privileges (see {@link #hasCarrierPrivileges}).
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(anyOf = {android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
|
||||
android.Manifest.permission.READ_PHONE_STATE})
|
||||
public @RadioPowerState int getRadioPowerState() {
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
if (telephony != null) {
|
||||
return telephony.getRadioPowerState(getSlotIndex(), mContext.getOpPackageName());
|
||||
}
|
||||
} catch (RemoteException ex) {
|
||||
// This could happen if binder process crashes.
|
||||
}
|
||||
return RADIO_POWER_UNAVAILABLE;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
@SuppressLint("Doclava125")
|
||||
|
||||
@@ -52,5 +52,6 @@ oneway interface IPhoneStateListener {
|
||||
void onCarrierNetworkChange(in boolean active);
|
||||
void onUserMobileDataStateChanged(in boolean enabled);
|
||||
void onPhoneCapabilityChanged(in PhoneCapability capability);
|
||||
void onRadioPowerStateChanged(in int state);
|
||||
}
|
||||
|
||||
|
||||
@@ -1484,4 +1484,10 @@ interface ITelephony {
|
||||
* Return the network selection mode on the subscription with id {@code subId}.
|
||||
*/
|
||||
int getNetworkSelectionMode(int subId);
|
||||
|
||||
/**
|
||||
* Return the modem radio power state for slot index.
|
||||
*
|
||||
*/
|
||||
int getRadioPowerState(int slotIdex, String callingPackage);
|
||||
}
|
||||
|
||||
@@ -79,4 +79,5 @@ interface ITelephonyRegistry {
|
||||
void notifyCarrierNetworkChange(in boolean active);
|
||||
void notifyUserMobileDataStateChangedForPhoneId(in int phoneId, in int subId, in boolean state);
|
||||
void notifyPhoneCapabilityChanged(in PhoneCapability capability);
|
||||
void notifyRadioPowerStateChanged(in int state);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user