From 142eae07765dcc2c3574974dd36b2c35ea399ed5 Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Fri, 13 Dec 2019 19:29:20 -0800 Subject: [PATCH] Move emergency callback related intents to TelephonyManager This CL also renames to have android.telephony prefix for one of the intents used internally. Also suppresses the lint errors for keeping android.intent.* which is needed for app compatiblily as 3rd party may have hardcoded in their manifest. Bug: 146240041 Test: Build Change-Id: Ib3e786b73af614d5ef0d8cf3e5a6642273060f68 --- api/system-current.txt | 3 + .../globalactions/GlobalActionsDialog.java | 7 +-- .../systemui/qs/tiles/AirplaneModeTile.java | 4 +- .../server/policy/LegacyGlobalActions.java | 7 +-- .../android/telephony/TelephonyManager.java | 58 ++++++++++++++++++- .../internal/telephony/TelephonyIntents.java | 7 ++- 6 files changed, 71 insertions(+), 15 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index b2bf2c603eb7f..dd7f57512a83d 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9801,7 +9801,10 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) public void updateTestOtaEmergencyNumberDbFilePath(@NonNull String); field @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final String ACTION_ANOMALY_REPORTED = "android.telephony.action.ANOMALY_REPORTED"; field public static final String ACTION_EMERGENCY_ASSISTANCE = "android.telephony.action.EMERGENCY_ASSISTANCE"; + field public static final String ACTION_EMERGENCY_CALLBACK_MODE_CHANGED = "android.intent.action.EMERGENCY_CALLBACK_MODE_CHANGED"; + field public static final String ACTION_EMERGENCY_CALL_STATE_CHANGED = "android.intent.action.EMERGENCY_CALL_STATE_CHANGED"; field public static final String ACTION_NETWORK_SET_TIME = "android.telephony.action.NETWORK_SET_TIME"; + field public static final String ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS = "android.telephony.action.SHOW_NOTICE_ECM_BLOCK_OTHERS"; field public static final String ACTION_SIM_APPLICATION_STATE_CHANGED = "android.telephony.action.SIM_APPLICATION_STATE_CHANGED"; field public static final String ACTION_SIM_CARD_STATE_CHANGED = "android.telephony.action.SIM_CARD_STATE_CHANGED"; field public static final String ACTION_SIM_SLOT_STATUS_CHANGED = "android.telephony.action.SIM_SLOT_STATUS_CHANGED"; diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java index ef853e65c4a2f..3ccad64d76dc1 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java @@ -81,7 +81,6 @@ import com.android.internal.colorextraction.drawable.ScrimDrawable; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.statusbar.IStatusBarService; -import com.android.internal.telephony.TelephonyIntents; import com.android.internal.util.EmergencyAffordanceManager; import com.android.internal.util.ScreenRecordHelper; import com.android.internal.util.ScreenshotHelper; @@ -190,7 +189,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); filter.addAction(Intent.ACTION_SCREEN_OFF); - filter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); + filter.addAction(TelephonyManager.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); mBroadcastDispatcher.registerReceiver(mBroadcastReceiver, filter); ConnectivityManager cm = (ConnectivityManager) @@ -314,7 +313,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, mIsWaitingForEcmExit = true; // Launch ECM exit dialog Intent ecmDialogIntent = - new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null); + new Intent(TelephonyManager.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null); ecmDialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(ecmDialogIntent); } else { @@ -1420,7 +1419,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener, if (!SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS.equals(reason)) { mHandler.sendMessage(mHandler.obtainMessage(MESSAGE_DISMISS, reason)); } - } else if (TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED.equals(action)) { + } else if (TelephonyManager.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED.equals(action)) { // Airplane mode can be changed after ECM exits if airplane toggle button // is pressed during ECM mode if (!(intent.getBooleanExtra("PHONE_IN_ECM_STATE", false)) && diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java index 4afcf013507da..5e297e21686b9 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java @@ -26,11 +26,11 @@ import android.provider.Settings; import android.provider.Settings.Global; import android.service.quicksettings.Tile; import android.sysprop.TelephonyProperties; +import android.telephony.TelephonyManager; import android.widget.Switch; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; -import com.android.internal.telephony.TelephonyIntents; import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.plugins.ActivityStarter; @@ -76,7 +76,7 @@ public class AirplaneModeTile extends QSTileImpl { MetricsLogger.action(mContext, getMetricsCategory(), !airplaneModeEnabled); if (!airplaneModeEnabled && TelephonyProperties.in_ecm_mode().orElse(false)) { mActivityStarter.postStartActivityDismissingKeyguard( - new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS), 0); + new Intent(TelephonyManager.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS), 0); return; } setEnabled(!airplaneModeEnabled); diff --git a/services/core/java/com/android/server/policy/LegacyGlobalActions.java b/services/core/java/com/android/server/policy/LegacyGlobalActions.java index c779ebf4a9952..52714933c8e23 100644 --- a/services/core/java/com/android/server/policy/LegacyGlobalActions.java +++ b/services/core/java/com/android/server/policy/LegacyGlobalActions.java @@ -62,7 +62,6 @@ import com.android.internal.globalactions.SinglePressAction; import com.android.internal.globalactions.ToggleAction; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; -import com.android.internal.telephony.TelephonyIntents; import com.android.internal.util.EmergencyAffordanceManager; import com.android.internal.widget.LockPatternUtils; import com.android.server.policy.WindowManagerPolicy.WindowManagerFuncs; @@ -133,7 +132,7 @@ class LegacyGlobalActions implements DialogInterface.OnDismissListener, DialogIn IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); filter.addAction(Intent.ACTION_SCREEN_OFF); - filter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); + filter.addAction(TelephonyManager.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); context.registerReceiver(mBroadcastReceiver, filter); ConnectivityManager cm = (ConnectivityManager) @@ -231,7 +230,7 @@ class LegacyGlobalActions implements DialogInterface.OnDismissListener, DialogIn mIsWaitingForEcmExit = true; // Launch ECM exit dialog Intent ecmDialogIntent = - new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null); + new Intent(TelephonyManager.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null); ecmDialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(ecmDialogIntent); } else { @@ -741,7 +740,7 @@ class LegacyGlobalActions implements DialogInterface.OnDismissListener, DialogIn if (!PhoneWindowManager.SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS.equals(reason)) { mHandler.sendEmptyMessage(MESSAGE_DISMISS); } - } else if (TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED.equals(action)) { + } else if (TelephonyManager.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED.equals(action)) { // Airplane mode can be changed after ECM exits if airplane toggle button // is pressed during ECM mode if (!(intent.getBooleanExtra("PHONE_IN_ECM_STATE", false)) && diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 2082795b76e0c..a2ed733e121e9 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -1475,14 +1475,68 @@ public class TelephonyManager { *

* Requires the READ_PHONE_STATE permission. * - *

This is a protected intent that can only be sent - * by the system. + *

This is a protected intent that can only be sent by the system. * * @hide */ @SystemApi public static final String ACTION_NETWORK_SET_TIME = "android.telephony.action.NETWORK_SET_TIME"; + /** + *

Broadcast Action: The emergency callback mode is changed. + *

+ *

+ * You can not receive this through components declared + * in manifests, only by explicitly registering for it with + * {@link android.content.Context#registerReceiver(android.content.BroadcastReceiver, + * android.content.IntentFilter) Context.registerReceiver()}. + * + *

This is a protected intent that can only be sent by the system. + * + * @hide + */ + @SystemApi + @SuppressLint("ActionValue") + public static final String ACTION_EMERGENCY_CALLBACK_MODE_CHANGED + = "android.intent.action.EMERGENCY_CALLBACK_MODE_CHANGED"; + + /** + *

Broadcast Action: The emergency call state is changed. + *

+ *

+ * You can not receive this through components declared + * in manifests, only by explicitly registering for it with + * {@link android.content.Context#registerReceiver(android.content.BroadcastReceiver, + * android.content.IntentFilter) Context.registerReceiver()}. + * + *

This is a protected intent that can only be sent by the system. + * + * @hide + */ + @SystemApi + @SuppressLint("ActionValue") + public static final String ACTION_EMERGENCY_CALL_STATE_CHANGED + = "android.intent.action.EMERGENCY_CALL_STATE_CHANGED"; + + /** + *

Broadcast Action: It indicates the Emergency callback mode blocks datacall/sms + *

. + * This is to pop up a notice to show user that the phone is in emergency callback mode + * and data calls and outgoing sms are blocked. + * + *

This is a protected intent that can only be sent by the system. + * + * @hide + */ + @SystemApi + public static final String ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS + = "android.telephony.action.SHOW_NOTICE_ECM_BLOCK_OTHERS"; + // // // Device Info diff --git a/telephony/java/com/android/internal/telephony/TelephonyIntents.java b/telephony/java/com/android/internal/telephony/TelephonyIntents.java index 8e1a78c56e0ab..024b6403bf755 100644 --- a/telephony/java/com/android/internal/telephony/TelephonyIntents.java +++ b/telephony/java/com/android/internal/telephony/TelephonyIntents.java @@ -18,6 +18,7 @@ package com.android.internal.telephony; import android.content.Intent; import android.telephony.SubscriptionManager; +import android.telephony.TelephonyManager; /** * The intents that the telephony services broadcast. @@ -99,7 +100,7 @@ public class TelephonyIntents { * by the system. */ public static final String ACTION_EMERGENCY_CALLBACK_MODE_CHANGED - = "android.intent.action.EMERGENCY_CALLBACK_MODE_CHANGED"; + = TelephonyManager.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED; /** *

Broadcast Action: The emergency call state is changed. @@ -120,7 +121,7 @@ public class TelephonyIntents { * by the system. */ public static final String ACTION_EMERGENCY_CALL_STATE_CHANGED - = "android.intent.action.EMERGENCY_CALL_STATE_CHANGED"; + = TelephonyManager.ACTION_EMERGENCY_CALL_STATE_CHANGED; /** * Broadcast Action: The phone's signal strength has changed. The intent will have the @@ -234,7 +235,7 @@ public class TelephonyIntents { * by the system. */ public static final String ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS - = "com.android.internal.intent.action.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS"; + = TelephonyManager.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS; /** *

Broadcast Action: Indicates that the action is forbidden by network.