Merge "Updating the APIs for the Callback Mode" into main
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 10206f2..49b711b 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -15426,6 +15426,7 @@
field public static final int EVENT_DATA_CONNECTION_STATE_CHANGED = 7; // 0x7
field @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) public static final int EVENT_DATA_ENABLED_CHANGED = 34; // 0x22
field public static final int EVENT_DISPLAY_INFO_CHANGED = 21; // 0x15
+ field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final int EVENT_EMERGENCY_CALLBACK_MODE_CHANGED = 40; // 0x28
field @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public static final int EVENT_EMERGENCY_NUMBER_LIST_CHANGED = 25; // 0x19
field @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) public static final int EVENT_IMS_CALL_DISCONNECT_CAUSE_CHANGED = 28; // 0x1c
field @RequiresPermission(android.Manifest.permission.READ_CALL_LOG) public static final int EVENT_LEGACY_CALL_STATE_CHANGED = 36; // 0x24
@@ -15463,6 +15464,12 @@
method @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) public void onDataEnabledChanged(boolean, int);
}
+ @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static interface TelephonyCallback.EmergencyCallbackModeListener {
+ method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void onCallbackModeRestarted(int, @NonNull java.time.Duration, int);
+ method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void onCallbackModeStarted(int, @NonNull java.time.Duration, int);
+ method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void onCallbackModeStopped(int, int, int);
+ }
+
public static interface TelephonyCallback.LinkCapacityEstimateChangedListener {
method @RequiresPermission(android.Manifest.permission.READ_PRECISE_PHONE_STATE) public void onLinkCapacityEstimateChanged(@NonNull java.util.List<android.telephony.LinkCapacityEstimate>);
}
@@ -15724,6 +15731,8 @@
field public static final int CELL_BROADCAST_RESULT_SUCCESS = 0; // 0x0
field public static final int CELL_BROADCAST_RESULT_UNKNOWN = -1; // 0xffffffff
field public static final int CELL_BROADCAST_RESULT_UNSUPPORTED = 1; // 0x1
+ field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int EMERGENCY_CALLBACK_MODE_CALL = 1; // 0x1
+ field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int EMERGENCY_CALLBACK_MODE_SMS = 2; // 0x2
field public static final int ENABLE_NR_DUAL_CONNECTIVITY_INVALID_STATE = 4; // 0x4
field public static final int ENABLE_NR_DUAL_CONNECTIVITY_NOT_SUPPORTED = 1; // 0x1
field public static final int ENABLE_NR_DUAL_CONNECTIVITY_RADIO_ERROR = 3; // 0x3
@@ -15781,6 +15790,13 @@
field public static final int SRVCC_STATE_HANDOVER_FAILED = 2; // 0x2
field public static final int SRVCC_STATE_HANDOVER_NONE = -1; // 0xffffffff
field public static final int SRVCC_STATE_HANDOVER_STARTED = 0; // 0x0
+ field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int STOP_REASON_EMERGENCY_SMS_SENT = 4; // 0x4
+ field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int STOP_REASON_NORMAL_SMS_SENT = 2; // 0x2
+ field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int STOP_REASON_OUTGOING_EMERGENCY_CALL_INITIATED = 3; // 0x3
+ field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int STOP_REASON_OUTGOING_NORMAL_CALL_INITIATED = 1; // 0x1
+ field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int STOP_REASON_TIMER_EXPIRED = 5; // 0x5
+ field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int STOP_REASON_UNKNOWN = 0; // 0x0
+ field @FlaggedApi("com.android.internal.telephony.flags.emergency_callback_mode_notification") public static final int STOP_REASON_USER_ACTION = 6; // 0x6
field public static final int THERMAL_MITIGATION_RESULT_INVALID_STATE = 3; // 0x3
field public static final int THERMAL_MITIGATION_RESULT_MODEM_ERROR = 1; // 0x1
field public static final int THERMAL_MITIGATION_RESULT_MODEM_NOT_AVAILABLE = 2; // 0x2
diff --git a/core/java/android/telephony/PhoneStateListener.java b/core/java/android/telephony/PhoneStateListener.java
index 5ac0c50..e8ef9d6 100644
--- a/core/java/android/telephony/PhoneStateListener.java
+++ b/core/java/android/telephony/PhoneStateListener.java
@@ -1671,14 +1671,22 @@
}
/** @hide */
- public final void onCallBackModeStarted(
- @TelephonyManager.EmergencyCallbackModeType int type) {
+ public final void onCallbackModeStarted(
+ @TelephonyManager.EmergencyCallbackModeType int type, long durationMillis,
+ int subId) {
// not support. Can't override. Use TelephonyCallback.
}
/** @hide */
- public final void onCallBackModeStopped(@EmergencyCallbackModeType int type,
- @EmergencyCallbackModeStopReason int reason) {
+ public final void onCallbackModeRestarted(
+ @TelephonyManager.EmergencyCallbackModeType int type, long durationMillis,
+ int subId) {
+ // not support. Can't override. Use TelephonyCallback.
+ }
+
+ /** @hide */
+ public final void onCallbackModeStopped(@EmergencyCallbackModeType int type,
+ @EmergencyCallbackModeStopReason int reason, int subId) {
// not support. Can't override. Use TelephonyCallback.
}
diff --git a/core/java/android/telephony/TelephonyCallback.java b/core/java/android/telephony/TelephonyCallback.java
index c360e64..14d5800 100644
--- a/core/java/android/telephony/TelephonyCallback.java
+++ b/core/java/android/telephony/TelephonyCallback.java
@@ -41,6 +41,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
+import java.time.Duration;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -619,16 +620,20 @@
/**
- * Event for changes to the Emergency callback mode
+ * Event for changes to the emergency callback mode
*
* <p>Requires permission {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE}
*
- * @see EmergencyCallbackModeListener#onCallbackModeStarted(int)
- * @see EmergencyCallbackModeListener#onCallbackModeStopped(int, int)
+ * @see EmergencyCallbackModeListener#onCallbackModeStarted(int, Duration, int)
+ * @see EmergencyCallbackModeListener#onCallbackModeRestarted(int, Duration, int)
+ * @see EmergencyCallbackModeListener#onCallbackModeStopped(int, int, int)
*
* @hide
*/
+
+ @FlaggedApi(Flags.FLAG_EMERGENCY_CALLBACK_MODE_NOTIFICATION)
@RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ @SystemApi
public static final int EVENT_EMERGENCY_CALLBACK_MODE_CHANGED = 40;
/**
@@ -1671,39 +1676,64 @@
}
/**
- * Interface for emergency callback mode listener.
+ * Interface for the emergency callback mode listener.
*
* @hide
*/
+ @FlaggedApi(Flags.FLAG_EMERGENCY_CALLBACK_MODE_NOTIFICATION)
+ @SystemApi
public interface EmergencyCallbackModeListener {
/**
- * Indicates that Callback Mode has been started.
+ * Indicates that emergency callback mode has been started.
* <p>
- * This method will be called when an emergency sms/emergency call is sent
- * and the callback mode is supported by the carrier.
- * If an emergency SMS is transmitted during callback mode for SMS, this API will be called
- * once again with TelephonyManager#EMERGENCY_CALLBACK_MODE_SMS.
+ * This method will be called when an emergency SMS or emergency call is ended and
+ * the emergency callback mode is supported by the carrier.
+ * If the emergency callback mode was started for an emergency call and an emergency SMS is
+ * transmitted during callback mode for SMS then this API will be called once again with
+ * TelephonyManager#EMERGENCY_CALLBACK_MODE_SMS.
*
- * @param type for callback mode entry
+ * @param type for the emergency callback mode entry
* See {@link TelephonyManager.EmergencyCallbackModeType}.
* @see TelephonyManager#EMERGENCY_CALLBACK_MODE_CALL
* @see TelephonyManager#EMERGENCY_CALLBACK_MODE_SMS
+ *
+ * @param timerDuration is the time remaining in the emergency callback mode.
+ * @param subId The subscription ID used to start the emergency callback mode.
*/
@RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
- void onCallBackModeStarted(@TelephonyManager.EmergencyCallbackModeType int type);
+ void onCallbackModeStarted(@TelephonyManager.EmergencyCallbackModeType int type,
+ @NonNull Duration timerDuration, int subId);
/**
- * Indicates that Callback Mode has been stopped.
+ * Indicates that emergency callback mode has been re-started.
* <p>
- * This method will be called when the callback mode timer expires or when
- * a normal call/SMS is sent
+ * This method will be called when an emergency SMS or emergency call is ended
+ * in the emergency callback mode.
+ * This is used to restart the emergency callback mode when it is already in progress.
*
- * @param type for callback mode entry
+ * @param type for the emergency callback mode entry
+ * See {@link TelephonyManager.EmergencyCallbackModeType}.
* @see TelephonyManager#EMERGENCY_CALLBACK_MODE_CALL
* @see TelephonyManager#EMERGENCY_CALLBACK_MODE_SMS
*
- * @param reason for changing callback mode
+ * @param timerDuration is the time remaining in the emergency callback mode.
+ * @param subId The subscription ID used to restart the emergency callback mode.
+ */
+ @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ void onCallbackModeRestarted(@TelephonyManager.EmergencyCallbackModeType int type,
+ @NonNull Duration timerDuration, int subId);
+
+ /**
+ * Indicates that emergency callback mode has been stopped.
+ * <p>
+ * This method will be called when the emergency callback mode timer expires or when
+ * a normal call/SMS is sent
*
+ * @param type for the emergency callback mode entry
+ * @see TelephonyManager#EMERGENCY_CALLBACK_MODE_CALL
+ * @see TelephonyManager#EMERGENCY_CALLBACK_MODE_SMS
+ *
+ * @param reason for changing emergency callback mode
* @see TelephonyManager#STOP_REASON_UNKNOWN
* @see TelephonyManager#STOP_REASON_OUTGOING_NORMAL_CALL_INITIATED
* @see TelephonyManager#STOP_REASON_NORMAL_SMS_SENT
@@ -1711,10 +1741,12 @@
* @see TelephonyManager#STOP_REASON_EMERGENCY_SMS_SENT
* @see TelephonyManager#STOP_REASON_TIMER_EXPIRED
* @see TelephonyManager#STOP_REASON_USER_ACTION
+ *
+ * @param subId is the current subscription used the emergency callback mode.
*/
@RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
- void onCallBackModeStopped(@TelephonyManager.EmergencyCallbackModeType int type,
- @TelephonyManager.EmergencyCallbackModeStopReason int reason);
+ void onCallbackModeStopped(@TelephonyManager.EmergencyCallbackModeType int type,
+ @TelephonyManager.EmergencyCallbackModeStopReason int reason, int subId);
}
/**
@@ -2132,18 +2164,43 @@
mediaQualityStatus)));
}
- public void onCallBackModeStarted(@TelephonyManager.EmergencyCallbackModeType int type) {
+ @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ public void onCallbackModeStarted(@TelephonyManager.EmergencyCallbackModeType int type,
+ long durationMillis, int subId) {
+ if (!Flags.emergencyCallbackModeNotification()) return;
+
EmergencyCallbackModeListener listener =
(EmergencyCallbackModeListener) mTelephonyCallbackWeakRef.get();
Log.d(LOG_TAG, "onCallBackModeStarted:type=" + type + ", listener=" + listener);
if (listener == null) return;
+ final Duration timerDuration = Duration.ofMillis(durationMillis);
Binder.withCleanCallingIdentity(
- () -> mExecutor.execute(() -> listener.onCallBackModeStarted(type)));
+ () -> mExecutor.execute(() -> listener.onCallbackModeStarted(type,
+ timerDuration, subId)));
}
- public void onCallBackModeStopped(@TelephonyManager.EmergencyCallbackModeType int type,
- @TelephonyManager.EmergencyCallbackModeStopReason int reason) {
+ @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ public void onCallbackModeRestarted(@TelephonyManager.EmergencyCallbackModeType int type,
+ long durationMillis, int subId) {
+ if (!Flags.emergencyCallbackModeNotification()) return;
+
+ EmergencyCallbackModeListener listener =
+ (EmergencyCallbackModeListener) mTelephonyCallbackWeakRef.get();
+ Log.d(LOG_TAG, "onCallbackModeRestarted:type=" + type + ", listener=" + listener);
+ if (listener == null) return;
+
+ final Duration timerDuration = Duration.ofMillis(durationMillis);
+ Binder.withCleanCallingIdentity(
+ () -> mExecutor.execute(() -> listener.onCallbackModeRestarted(type,
+ timerDuration, subId)));
+ }
+
+ @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ public void onCallbackModeStopped(@TelephonyManager.EmergencyCallbackModeType int type,
+ @TelephonyManager.EmergencyCallbackModeStopReason int reason, int subId) {
+ if (!Flags.emergencyCallbackModeNotification()) return;
+
EmergencyCallbackModeListener listener =
(EmergencyCallbackModeListener) mTelephonyCallbackWeakRef.get();
Log.d(LOG_TAG, "onCallBackModeStopped:type=" + type
@@ -2151,7 +2208,8 @@
if (listener == null) return;
Binder.withCleanCallingIdentity(
- () -> mExecutor.execute(() -> listener.onCallBackModeStopped(type, reason)));
+ () -> mExecutor.execute(() -> listener.onCallbackModeStopped(type, reason,
+ subId)));
}
public void onCarrierRoamingNtnModeChanged(boolean active) {
diff --git a/core/java/android/telephony/TelephonyRegistryManager.java b/core/java/android/telephony/TelephonyRegistryManager.java
index 10f03c1..3c7e924 100644
--- a/core/java/android/telephony/TelephonyRegistryManager.java
+++ b/core/java/android/telephony/TelephonyRegistryManager.java
@@ -115,7 +115,6 @@
ICarrierConfigChangeListener>
mCarrierConfigChangeListenerMap = new ConcurrentHashMap<>();
-
/** @hide **/
public TelephonyRegistryManager(@NonNull Context context) {
mContext = context;
@@ -1721,13 +1720,36 @@
* @param subId Sender subscription ID.
* @param type for callback mode entry.
* See {@link TelephonyManager.EmergencyCallbackModeType}.
+ * @param durationMillis is the number of milliseconds remaining in the emergency callback
+ * mode.
* @hide
*/
- public void notifyCallBackModeStarted(int phoneId, int subId,
- @TelephonyManager.EmergencyCallbackModeType int type) {
+ public void notifyCallbackModeStarted(int phoneId, int subId,
+ @TelephonyManager.EmergencyCallbackModeType int type, long durationMillis) {
try {
- Log.d(TAG, "notifyCallBackModeStarted:type=" + type);
- sRegistry.notifyCallbackModeStarted(phoneId, subId, type);
+ Log.d(TAG, "notifyCallbackModeStarted:type=" + type);
+ sRegistry.notifyCallbackModeStarted(phoneId, subId, type, durationMillis);
+ } catch (RemoteException ex) {
+ // system process is dead
+ throw ex.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Notify Callback Mode has been restarted.
+ * @param phoneId Sender phone ID.
+ * @param subId Sender subscription ID.
+ * @param type for callback mode entry.
+ * See {@link TelephonyManager.EmergencyCallbackModeType}.
+ * @param durationMillis is the number of milliseconds remaining in the emergency callback
+ * mode.
+ * @hide
+ */
+ public void notifyCallbackModeRestarted(int phoneId, int subId,
+ @TelephonyManager.EmergencyCallbackModeType int type, long durationMillis) {
+ try {
+ Log.d(TAG, "notifyCallbackModeRestarted:type=" + type);
+ sRegistry.notifyCallbackModeRestarted(phoneId, subId, type, durationMillis);
} catch (RemoteException ex) {
// system process is dead
throw ex.rethrowFromSystemServer();
diff --git a/core/java/com/android/internal/telephony/IPhoneStateListener.aidl b/core/java/com/android/internal/telephony/IPhoneStateListener.aidl
index f177e14..81b885a 100644
--- a/core/java/com/android/internal/telephony/IPhoneStateListener.aidl
+++ b/core/java/com/android/internal/telephony/IPhoneStateListener.aidl
@@ -78,8 +78,9 @@
void onAllowedNetworkTypesChanged(in int reason, in long allowedNetworkType);
void onLinkCapacityEstimateChanged(in List<LinkCapacityEstimate> linkCapacityEstimateList);
void onMediaQualityStatusChanged(in MediaQualityStatus mediaQualityStatus);
- void onCallBackModeStarted(int type);
- void onCallBackModeStopped(int type, int reason);
+ void onCallbackModeStarted(int type, long durationMillis, int subId);
+ void onCallbackModeRestarted(int type, long durationMillis, int subId);
+ void onCallbackModeStopped(int type, int reason, int subId);
void onSimultaneousCallingStateChanged(in int[] subIds);
void onCarrierRoamingNtnModeChanged(in boolean active);
void onCarrierRoamingNtnEligibleStateChanged(in boolean eligible);
diff --git a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl
index e500a37a..f836cf2 100644
--- a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl
+++ b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl
@@ -118,7 +118,8 @@
void removeCarrierConfigChangeListener(ICarrierConfigChangeListener listener, String pkg);
void notifyCarrierConfigChanged(int phoneId, int subId, int carrierId, int specificCarrierId);
- void notifyCallbackModeStarted(int phoneId, int subId, int type);
+ void notifyCallbackModeStarted(int phoneId, int subId, int type, long durationMillis);
+ void notifyCallbackModeRestarted(int phoneId, int subId, int type, long durationMillis);
void notifyCallbackModeStopped(int phoneId, int subId, int type, int reason);
void notifyCarrierRoamingNtnModeChanged(int subId, in boolean active);
void notifyCarrierRoamingNtnEligibleStateChanged(int subId, in boolean eligible);
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index 7442277..39ac515 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -422,9 +422,9 @@
private int[] mSimultaneousCellularCallingSubIds = {};
private int[] mECBMReason;
- private boolean[] mECBMStarted;
+ private long[] mECBMDuration;
private int[] mSCBMReason;
- private boolean[] mSCBMStarted;
+ private long[] mSCBMDuration;
private boolean[] mCarrierRoamingNtnMode = null;
private boolean[] mCarrierRoamingNtnEligible = null;
@@ -724,9 +724,9 @@
mAllowedNetworkTypeReason = copyOf(mAllowedNetworkTypeReason, mNumPhones);
mAllowedNetworkTypeValue = copyOf(mAllowedNetworkTypeValue, mNumPhones);
mECBMReason = copyOf(mECBMReason, mNumPhones);
- mECBMStarted = copyOf(mECBMStarted, mNumPhones);
+ mECBMDuration = copyOf(mECBMDuration, mNumPhones);
mSCBMReason = copyOf(mSCBMReason, mNumPhones);
- mSCBMStarted = copyOf(mSCBMStarted, mNumPhones);
+ mSCBMDuration = copyOf(mSCBMDuration, mNumPhones);
mCarrierRoamingNtnMode = copyOf(mCarrierRoamingNtnMode, mNumPhones);
mCarrierRoamingNtnEligible = copyOf(mCarrierRoamingNtnEligible, mNumPhones);
// ds -> ss switch.
@@ -784,9 +784,9 @@
mCarrierPrivilegeStates.add(i, new Pair<>(Collections.emptyList(), new int[0]));
mCarrierServiceStates.add(i, new Pair<>(null, Process.INVALID_UID));
mECBMReason[i] = TelephonyManager.STOP_REASON_UNKNOWN;
- mECBMStarted[i] = false;
+ mECBMDuration[i] = 0;
mSCBMReason[i] = TelephonyManager.STOP_REASON_UNKNOWN;
- mSCBMStarted[i] = false;
+ mSCBMDuration[i] = 0;
mCarrierRoamingNtnMode[i] = false;
mCarrierRoamingNtnEligible[i] = false;
}
@@ -859,9 +859,9 @@
mCarrierPrivilegeStates = new ArrayList<>();
mCarrierServiceStates = new ArrayList<>();
mECBMReason = new int[numPhones];
- mECBMStarted = new boolean[numPhones];
+ mECBMDuration = new long[numPhones];
mSCBMReason = new int[numPhones];
- mSCBMStarted = new boolean[numPhones];
+ mSCBMDuration = new long[numPhones];
mCarrierRoamingNtnMode = new boolean[numPhones];
mCarrierRoamingNtnEligible = new boolean[numPhones];
@@ -904,9 +904,9 @@
mCarrierPrivilegeStates.add(i, new Pair<>(Collections.emptyList(), new int[0]));
mCarrierServiceStates.add(i, new Pair<>(null, Process.INVALID_UID));
mECBMReason[i] = TelephonyManager.STOP_REASON_UNKNOWN;
- mECBMStarted[i] = false;
+ mECBMDuration[i] = 0;
mSCBMReason[i] = TelephonyManager.STOP_REASON_UNKNOWN;
- mSCBMStarted[i] = false;
+ mSCBMDuration[i] = 0;
mCarrierRoamingNtnMode[i] = false;
mCarrierRoamingNtnEligible[i] = false;
}
@@ -1493,24 +1493,24 @@
}
if (events.contains(TelephonyCallback.EVENT_EMERGENCY_CALLBACK_MODE_CHANGED)) {
try {
- boolean ecbmStarted = mECBMStarted[r.phoneId];
- if (ecbmStarted) {
- r.callback.onCallBackModeStarted(
- TelephonyManager.EMERGENCY_CALLBACK_MODE_CALL);
- } else {
- r.callback.onCallBackModeStopped(
+ if (mECBMDuration[r.phoneId] != 0) {
+ r.callback.onCallbackModeStarted(
TelephonyManager.EMERGENCY_CALLBACK_MODE_CALL,
- mECBMReason[r.phoneId]);
+ mECBMDuration[r.phoneId], r.subId);
+ } else {
+ r.callback.onCallbackModeStopped(
+ TelephonyManager.EMERGENCY_CALLBACK_MODE_CALL,
+ mECBMReason[r.phoneId], r.subId);
}
- boolean scbmStarted = mSCBMStarted[r.phoneId];
- if (scbmStarted) {
- r.callback.onCallBackModeStarted(
- TelephonyManager.EMERGENCY_CALLBACK_MODE_SMS);
- } else {
- r.callback.onCallBackModeStopped(
+ if (mSCBMReason[r.phoneId] != 0) {
+ r.callback.onCallbackModeStarted(
TelephonyManager.EMERGENCY_CALLBACK_MODE_SMS,
- mSCBMReason[r.phoneId]);
+ mSCBMDuration[r.phoneId], r.subId);
+ } else {
+ r.callback.onCallbackModeStopped(
+ TelephonyManager.EMERGENCY_CALLBACK_MODE_SMS,
+ mSCBMReason[r.phoneId], r.subId);
}
} catch (RemoteException ex) {
remove(r.binder);
@@ -3457,10 +3457,9 @@
}
@Override
- public void notifyCallbackModeStarted(int phoneId, int subId, int type) {
- if (!checkNotifyPermission("notifyCallbackModeStarted()")) {
- return;
- }
+ public void notifyCallbackModeStarted(int phoneId, int subId, int type, long durationMillis) {
+ if (!checkNotifyPermission("notifyCallbackModeStarted()")) return;
+
if (VDBG) {
log("notifyCallbackModeStarted: phoneId=" + phoneId + ", subId=" + subId
+ ", type=" + type);
@@ -3468,9 +3467,9 @@
synchronized (mRecords) {
if (validatePhoneId(phoneId)) {
if (type == TelephonyManager.EMERGENCY_CALLBACK_MODE_CALL) {
- mECBMStarted[phoneId] = true;
+ mECBMDuration[phoneId] = durationMillis;
} else if (type == TelephonyManager.EMERGENCY_CALLBACK_MODE_SMS) {
- mSCBMStarted[phoneId] = true;
+ mSCBMDuration[phoneId] = durationMillis;
}
}
for (Record r : mRecords) {
@@ -3478,7 +3477,39 @@
if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_EMERGENCY_CALLBACK_MODE_CHANGED)) {
try {
- r.callback.onCallBackModeStarted(type);
+ r.callback.onCallbackModeStarted(type, durationMillis, subId);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
+ }
+ }
+ }
+ }
+ handleRemoveListLocked();
+ }
+
+ @Override
+ public void notifyCallbackModeRestarted(int phoneId, int subId, int type,
+ long durationMillis) {
+ if (!checkNotifyPermission("notifyCallbackModeRestarted()")) return;
+
+ if (VDBG) {
+ log("notifyCallbackModeRestarted: phoneId=" + phoneId + ", subId=" + subId
+ + ", type=" + type);
+ }
+ synchronized (mRecords) {
+ if (validatePhoneId(phoneId)) {
+ if (type == TelephonyManager.EMERGENCY_CALLBACK_MODE_CALL) {
+ mECBMDuration[phoneId] = durationMillis;
+ } else if (type == TelephonyManager.EMERGENCY_CALLBACK_MODE_SMS) {
+ mSCBMDuration[phoneId] = durationMillis;
+ }
+ }
+ for (Record r : mRecords) {
+ // Send to all listeners regardless of subscription
+ if (r.matchTelephonyCallbackEvent(
+ TelephonyCallback.EVENT_EMERGENCY_CALLBACK_MODE_CHANGED)) {
+ try {
+ r.callback.onCallbackModeRestarted(type, durationMillis, subId);
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
@@ -3490,9 +3521,8 @@
@Override
public void notifyCallbackModeStopped(int phoneId, int subId, int type, int reason) {
- if (!checkNotifyPermission("notifyCallbackModeStopped()")) {
- return;
- }
+ if (!checkNotifyPermission("notifyCallbackModeStopped()")) return;
+
if (VDBG) {
log("notifyCallbackModeStopped: phoneId=" + phoneId + ", subId=" + subId
+ ", type=" + type + ", reason=" + reason);
@@ -3500,11 +3530,11 @@
synchronized (mRecords) {
if (validatePhoneId(phoneId)) {
if (type == TelephonyManager.EMERGENCY_CALLBACK_MODE_CALL) {
- mECBMStarted[phoneId] = false;
mECBMReason[phoneId] = reason;
+ mECBMDuration[phoneId] = 0;
} else if (type == TelephonyManager.EMERGENCY_CALLBACK_MODE_SMS) {
- mSCBMStarted[phoneId] = false;
mSCBMReason[phoneId] = reason;
+ mSCBMDuration[phoneId] = 0;
}
}
for (Record r : mRecords) {
@@ -3512,7 +3542,7 @@
if (r.matchTelephonyCallbackEvent(
TelephonyCallback.EVENT_EMERGENCY_CALLBACK_MODE_CHANGED)) {
try {
- r.callback.onCallBackModeStopped(type, reason);
+ r.callback.onCallbackModeStopped(type, reason, subId);
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
@@ -3662,9 +3692,9 @@
pw.println("mPhysicalChannelConfigs=" + mPhysicalChannelConfigs.get(i));
pw.println("mLinkCapacityEstimateList=" + mLinkCapacityEstimateLists.get(i));
pw.println("mECBMReason=" + mECBMReason[i]);
- pw.println("mECBMStarted=" + mECBMStarted[i]);
+ pw.println("mECBMDuration=" + mECBMDuration[i]);
pw.println("mSCBMReason=" + mSCBMReason[i]);
- pw.println("mSCBMStarted=" + mSCBMStarted[i]);
+ pw.println("mSCBMDuration=" + mSCBMDuration[i]);
pw.println("mCarrierRoamingNtnMode=" + mCarrierRoamingNtnMode[i]);
pw.println("mCarrierRoamingNtnEligible=" + mCarrierRoamingNtnEligible[i]);
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index f01cfc1..fee4587 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -19180,15 +19180,19 @@
public @interface EmergencyCallbackModeType {}
/**
- * The callback mode is due to emergency call.
+ * The emergency callback mode is due to emergency call.
* @hide
*/
+ @FlaggedApi(Flags.FLAG_EMERGENCY_CALLBACK_MODE_NOTIFICATION)
+ @SystemApi
public static final int EMERGENCY_CALLBACK_MODE_CALL = 1;
/**
- * The callback mode is due to emergency SMS.
+ * The emergency callback mode is due to emergency SMS.
* @hide
*/
+ @FlaggedApi(Flags.FLAG_EMERGENCY_CALLBACK_MODE_NOTIFICATION)
+ @SystemApi
public static final int EMERGENCY_CALLBACK_MODE_SMS = 2;
/**
@@ -19209,45 +19213,64 @@
public @interface EmergencyCallbackModeStopReason {}
/**
- * unknown reason.
+ * Indicates that emergency callback mode has been stopped for an unknown reason.
* @hide
*/
+ @FlaggedApi(Flags.FLAG_EMERGENCY_CALLBACK_MODE_NOTIFICATION)
+ @SystemApi
public static final int STOP_REASON_UNKNOWN = 0;
/**
- * The call back mode is exited due to a new normal call is originated.
+ * Indicates that emergency callback mode has been stopped because a new non-emergency call was
+ * initiated.
* @hide
*/
+ @FlaggedApi(Flags.FLAG_EMERGENCY_CALLBACK_MODE_NOTIFICATION)
+ @SystemApi
public static final int STOP_REASON_OUTGOING_NORMAL_CALL_INITIATED = 1;
/**
- * The call back mode is exited due to a new normal SMS is originated.
+ * Indicates that emergency callback mode has been stopped because a new non-emergency SMS was
+ * sent.
* @hide
*/
+ @FlaggedApi(Flags.FLAG_EMERGENCY_CALLBACK_MODE_NOTIFICATION)
+ @SystemApi
public static final int STOP_REASON_NORMAL_SMS_SENT = 2;
/**
- * The call back mode is exited due to a new emergency call is originated.
+ * Indicates that emergency callback mode has been stopped because a new outgoing emergency
+ * call was initiated.
* @hide
*/
+ @FlaggedApi(Flags.FLAG_EMERGENCY_CALLBACK_MODE_NOTIFICATION)
+ @SystemApi
public static final int STOP_REASON_OUTGOING_EMERGENCY_CALL_INITIATED = 3;
/**
- * The call back mode is exited due to a new emergency SMS is originated.
+ * Indicates that emergency callback mode has been stopped because a new emergency SMS was sent.
* @hide
*/
+ @FlaggedApi(Flags.FLAG_EMERGENCY_CALLBACK_MODE_NOTIFICATION)
+ @SystemApi
public static final int STOP_REASON_EMERGENCY_SMS_SENT = 4;
/**
- * The call back mode is exited due to timer expiry.
+ * Indicates that emergency callback mode has been stopped due to the emergency callback mode
+ * timer expiry.
* @hide
*/
+ @FlaggedApi(Flags.FLAG_EMERGENCY_CALLBACK_MODE_NOTIFICATION)
+ @SystemApi
public static final int STOP_REASON_TIMER_EXPIRED = 5;
/**
- * The call back mode is exited due to user action.
+ * Indicates that emergency callback mode has been stopped due to user ending the emergency
+ * mode by clicking the notification.
* @hide
*/
+ @FlaggedApi(Flags.FLAG_EMERGENCY_CALLBACK_MODE_NOTIFICATION)
+ @SystemApi
public static final int STOP_REASON_USER_ACTION = 6;
/**