Merge "Rewriting phone constants for mainline"

This commit is contained in:
Daniel Bright
2020-03-02 20:31:24 +00:00
committed by Gerrit Code Review
9 changed files with 105 additions and 24 deletions

View File

@@ -9439,6 +9439,8 @@ package android.telephony {
field public static final String ACTION_CARRIER_SIGNAL_REQUEST_NETWORK_FAILED = "com.android.internal.telephony.CARRIER_SIGNAL_REQUEST_NETWORK_FAILED"; field public static final String ACTION_CARRIER_SIGNAL_REQUEST_NETWORK_FAILED = "com.android.internal.telephony.CARRIER_SIGNAL_REQUEST_NETWORK_FAILED";
field public static final String ACTION_CARRIER_SIGNAL_RESET = "com.android.internal.telephony.CARRIER_SIGNAL_RESET"; field public static final String ACTION_CARRIER_SIGNAL_RESET = "com.android.internal.telephony.CARRIER_SIGNAL_RESET";
field public static final String ACTION_EMERGENCY_ASSISTANCE = "android.telephony.action.EMERGENCY_ASSISTANCE"; 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_SERVICE_PROVIDERS_UPDATED = "android.telephony.action.SERVICE_PROVIDERS_UPDATED"; field public static final String ACTION_SERVICE_PROVIDERS_UPDATED = "android.telephony.action.SERVICE_PROVIDERS_UPDATED";
field public static final String ACTION_SIM_APPLICATION_STATE_CHANGED = "android.telephony.action.SIM_APPLICATION_STATE_CHANGED"; 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_CARD_STATE_CHANGED = "android.telephony.action.SIM_CARD_STATE_CHANGED";
@@ -9475,6 +9477,8 @@ package android.telephony {
field public static final String EXTRA_ERROR_CODE = "errorCode"; field public static final String EXTRA_ERROR_CODE = "errorCode";
field public static final String EXTRA_PCO_ID = "pcoId"; field public static final String EXTRA_PCO_ID = "pcoId";
field public static final String EXTRA_PCO_VALUE = "pcoValue"; field public static final String EXTRA_PCO_VALUE = "pcoValue";
field public static final String EXTRA_PHONE_IN_ECM_STATE = "android.telephony.extra.PHONE_IN_ECM_STATE";
field public static final String EXTRA_PHONE_IN_EMERGENCY_CALL = "android.telephony.extra.PHONE_IN_EMERGENCY_CALL";
field public static final String EXTRA_PLMN = "android.telephony.extra.PLMN"; field public static final String EXTRA_PLMN = "android.telephony.extra.PLMN";
field public static final String EXTRA_REDIRECTION_URL = "redirectionUrl"; field public static final String EXTRA_REDIRECTION_URL = "redirectionUrl";
field public static final String EXTRA_SHOW_PLMN = "android.telephony.extra.SHOW_PLMN"; field public static final String EXTRA_SHOW_PLMN = "android.telephony.extra.SHOW_PLMN";

View File

@@ -30,8 +30,6 @@ import android.telephony.TelephonyManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import com.android.internal.telephony.PhoneConstants;
/** /**
* This util class provides common logic for carrier actions * This util class provides common logic for carrier actions
*/ */
@@ -103,7 +101,7 @@ public class CarrierActionUtils {
} }
private static void onDisableAllMeteredApns(Intent intent, Context context) { private static void onDisableAllMeteredApns(Intent intent, Context context) {
int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
SubscriptionManager.getDefaultVoiceSubscriptionId()); SubscriptionManager.getDefaultVoiceSubscriptionId());
logd("onDisableAllMeteredApns subId: " + subId); logd("onDisableAllMeteredApns subId: " + subId);
final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class); final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class);
@@ -111,7 +109,7 @@ public class CarrierActionUtils {
} }
private static void onEnableAllMeteredApns(Intent intent, Context context) { private static void onEnableAllMeteredApns(Intent intent, Context context) {
int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
SubscriptionManager.getDefaultVoiceSubscriptionId()); SubscriptionManager.getDefaultVoiceSubscriptionId());
logd("onEnableAllMeteredApns subId: " + subId); logd("onEnableAllMeteredApns subId: " + subId);
final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class); final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class);
@@ -135,7 +133,7 @@ public class CarrierActionUtils {
} }
private static void onRegisterDefaultNetworkAvail(Intent intent, Context context) { private static void onRegisterDefaultNetworkAvail(Intent intent, Context context) {
int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
SubscriptionManager.getDefaultVoiceSubscriptionId()); SubscriptionManager.getDefaultVoiceSubscriptionId());
logd("onRegisterDefaultNetworkAvail subId: " + subId); logd("onRegisterDefaultNetworkAvail subId: " + subId);
final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class); final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class);
@@ -143,7 +141,7 @@ public class CarrierActionUtils {
} }
private static void onDeregisterDefaultNetworkAvail(Intent intent, Context context) { private static void onDeregisterDefaultNetworkAvail(Intent intent, Context context) {
int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
SubscriptionManager.getDefaultVoiceSubscriptionId()); SubscriptionManager.getDefaultVoiceSubscriptionId());
logd("onDeregisterDefaultNetworkAvail subId: " + subId); logd("onDeregisterDefaultNetworkAvail subId: " + subId);
final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class); final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class);
@@ -151,7 +149,7 @@ public class CarrierActionUtils {
} }
private static void onDisableRadio(Intent intent, Context context) { private static void onDisableRadio(Intent intent, Context context) {
int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
SubscriptionManager.getDefaultVoiceSubscriptionId()); SubscriptionManager.getDefaultVoiceSubscriptionId());
logd("onDisableRadio subId: " + subId); logd("onDisableRadio subId: " + subId);
final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class); final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class);
@@ -159,7 +157,7 @@ public class CarrierActionUtils {
} }
private static void onEnableRadio(Intent intent, Context context) { private static void onEnableRadio(Intent intent, Context context) {
int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
SubscriptionManager.getDefaultVoiceSubscriptionId()); SubscriptionManager.getDefaultVoiceSubscriptionId());
logd("onEnableRadio subId: " + subId); logd("onEnableRadio subId: " + subId);
final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class); final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class);
@@ -202,7 +200,7 @@ public class CarrierActionUtils {
} }
private static void onResetAllCarrierActions(Intent intent, Context context) { private static void onResetAllCarrierActions(Intent intent, Context context) {
int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, int subId = intent.getIntExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX,
SubscriptionManager.getDefaultVoiceSubscriptionId()); SubscriptionManager.getDefaultVoiceSubscriptionId());
logd("onResetAllCarrierActions subId: " + subId); logd("onResetAllCarrierActions subId: " + subId);
final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class); final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class);

View File

@@ -15,6 +15,7 @@
*/ */
package com.android.carrierdefaultapp; package com.android.carrierdefaultapp;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Matchers.eq; import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
@@ -26,11 +27,10 @@ import android.app.PendingIntent;
import android.content.Intent; import android.content.Intent;
import android.os.PersistableBundle; import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager; import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.test.InstrumentationTestCase; import android.test.InstrumentationTestCase;
import com.android.internal.telephony.PhoneConstants;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -69,6 +69,7 @@ public class CarrierDefaultReceiverTest extends InstrumentationTestCase {
mContext.injectSystemService(NotificationManager.class, mNotificationMgr); mContext.injectSystemService(NotificationManager.class, mNotificationMgr);
mContext.injectSystemService(TelephonyManager.class, mTelephonyMgr); mContext.injectSystemService(TelephonyManager.class, mTelephonyMgr);
mContext.injectSystemService(CarrierConfigManager.class, mCarrierConfigMgr); mContext.injectSystemService(CarrierConfigManager.class, mCarrierConfigMgr);
doReturn(mTelephonyMgr).when(mTelephonyMgr).createForSubscriptionId(anyInt());
mReceiver = new CarrierDefaultBroadcastReceiver(); mReceiver = new CarrierDefaultBroadcastReceiver();
} }
@@ -88,7 +89,7 @@ public class CarrierDefaultReceiverTest extends InstrumentationTestCase {
doReturn(b).when(mCarrierConfigMgr).getConfig(); doReturn(b).when(mCarrierConfigMgr).getConfig();
Intent intent = new Intent(TelephonyManager.ACTION_CARRIER_SIGNAL_REDIRECTED); Intent intent = new Intent(TelephonyManager.ACTION_CARRIER_SIGNAL_REDIRECTED);
intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
mReceiver.onReceive(mContext, intent); mReceiver.onReceive(mContext, intent);
mContext.waitForMs(100); mContext.waitForMs(100);

View File

@@ -55,7 +55,6 @@ import android.service.dreams.IDreamManager;
import android.telephony.PhoneStateListener; import android.telephony.PhoneStateListener;
import android.telephony.ServiceState; import android.telephony.ServiceState;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.ArraySet; import android.util.ArraySet;
import android.util.FeatureFlagUtils; import android.util.FeatureFlagUtils;
import android.util.Log; import android.util.Log;
@@ -1394,8 +1393,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
} else if (TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED.equals(action)) { } else if (TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED.equals(action)) {
// Airplane mode can be changed after ECM exits if airplane toggle button // Airplane mode can be changed after ECM exits if airplane toggle button
// is pressed during ECM mode // is pressed during ECM mode
if (!(intent.getBooleanExtra("PHONE_IN_ECM_STATE", false)) && if (!(intent.getBooleanExtra(TelephonyManager.EXTRA_PHONE_IN_ECM_STATE, false))
mIsWaitingForEcmExit) { && mIsWaitingForEcmExit) {
mIsWaitingForEcmExit = false; mIsWaitingForEcmExit = false;
changeAirplaneModeSystemSetting(true); changeAirplaneModeSystemSetting(true);
} }

View File

@@ -30,12 +30,12 @@ import android.telephony.CellSignalStrength;
import android.telephony.ServiceState; import android.telephony.ServiceState;
import android.telephony.SignalStrength; import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner; import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper; import android.testing.TestableLooper.RunWithLooper;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents; import com.android.internal.telephony.TelephonyIntents;
import com.android.settingslib.graph.SignalDrawable; import com.android.settingslib.graph.SignalDrawable;
import com.android.settingslib.net.DataUsageController; import com.android.settingslib.net.DataUsageController;
@@ -418,7 +418,7 @@ public class NetworkControllerSignalTest extends NetworkControllerBaseTest {
intent.putExtra(TelephonyIntents.EXTRA_SHOW_PLMN, showPlmn); intent.putExtra(TelephonyIntents.EXTRA_SHOW_PLMN, showPlmn);
intent.putExtra(TelephonyIntents.EXTRA_PLMN, plmn); intent.putExtra(TelephonyIntents.EXTRA_PLMN, plmn);
intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mSubId); SubscriptionManager.putSubscriptionIdExtra(intent, mSubId);
return intent; return intent;
} }

View File

@@ -746,8 +746,8 @@ class LegacyGlobalActions implements DialogInterface.OnDismissListener, DialogIn
} else if (TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED.equals(action)) { } else if (TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED.equals(action)) {
// Airplane mode can be changed after ECM exits if airplane toggle button // Airplane mode can be changed after ECM exits if airplane toggle button
// is pressed during ECM mode // is pressed during ECM mode
if (!(intent.getBooleanExtra("PHONE_IN_ECM_STATE", false)) && if (!(intent.getBooleanExtra(TelephonyManager.EXTRA_PHONE_IN_ECM_STATE, false))
mIsWaitingForEcmExit) { && mIsWaitingForEcmExit) {
mIsWaitingForEcmExit = false; mIsWaitingForEcmExit = false;
changeAirplaneModeSystemSetting(true); changeAirplaneModeSystemSetting(true);
} }

View File

@@ -2144,10 +2144,9 @@ public class SubscriptionManager {
@UnsupportedAppUsage @UnsupportedAppUsage
public static void putPhoneIdAndSubIdExtra(Intent intent, int phoneId, int subId) { public static void putPhoneIdAndSubIdExtra(Intent intent, int phoneId, int subId) {
if (VDBG) logd("putPhoneIdAndSubIdExtra: phoneId=" + phoneId + " subId=" + subId); if (VDBG) logd("putPhoneIdAndSubIdExtra: phoneId=" + phoneId + " subId=" + subId);
intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
intent.putExtra(EXTRA_SUBSCRIPTION_INDEX, subId);
intent.putExtra(EXTRA_SLOT_INDEX, phoneId); intent.putExtra(EXTRA_SLOT_INDEX, phoneId);
intent.putExtra(PhoneConstants.PHONE_KEY, phoneId); intent.putExtra(PhoneConstants.PHONE_KEY, phoneId);
putSubscriptionIdExtra(intent, subId);
} }
/** /**
@@ -3324,4 +3323,19 @@ public class SubscriptionManager {
} }
return SubscriptionManager.INVALID_SUBSCRIPTION_ID; return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
} }
/**
* Helper method that puts a subscription id on an intent with the constants:
* PhoneConstant.SUBSCRIPTION_KEY and SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX.
* Both constants are used to support backwards compatibility. Once we know we got all places,
* we can remove PhoneConstants.SUBSCRIPTION_KEY.
* @param intent Intent to put sub id on.
* @param subId SubscriptionId to put on intent.
*
* @hide
*/
public static void putSubscriptionIdExtra(Intent intent, int subId) {
intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
}
} }

View File

@@ -1529,6 +1529,40 @@ public class TelephonyManager {
public static final String EXTRA_SIM_COMBINATION_NAMES = public static final String EXTRA_SIM_COMBINATION_NAMES =
"android.telephony.extra.SIM_COMBINATION_NAMES"; "android.telephony.extra.SIM_COMBINATION_NAMES";
/**
* <p>Broadcast Action: The emergency callback mode is changed.
* <ul>
* <li><em>EXTRA_PHONE_IN_ECM_STATE</em> - A boolean value,true=phone in ECM,
* false=ECM off</li>
* </ul>
* <p class="note">
* You can <em>not</em> 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()}.
*
* <p class="note">This is a protected intent that can only be sent by the system.
*
* @see #EXTRA_PHONE_IN_ECM_STATE
*
* @hide
*/
@SystemApi
@SuppressLint("ActionValue")
public static final String ACTION_EMERGENCY_CALLBACK_MODE_CHANGED =
"android.intent.action.EMERGENCY_CALLBACK_MODE_CHANGED";
/**
* Extra included in {@link #ACTION_EMERGENCY_CALLBACK_MODE_CHANGED}.
* Indicates whether the phone is in an emergency phone state.
*
* @hide
*/
@SystemApi
public static final String EXTRA_PHONE_IN_ECM_STATE =
"android.telephony.extra.PHONE_IN_ECM_STATE";
/** /**
* <p>Broadcast Action: when data connections get redirected with validation failure. * <p>Broadcast Action: when data connections get redirected with validation failure.
* intended for sim/account status checks and only sent to the specified carrier app * intended for sim/account status checks and only sent to the specified carrier app
@@ -1716,6 +1750,40 @@ public class TelephonyManager {
@SuppressLint("ActionValue") @SuppressLint("ActionValue")
public static final String EXTRA_DEFAULT_NETWORK_AVAILABLE = "defaultNetworkAvailable"; public static final String EXTRA_DEFAULT_NETWORK_AVAILABLE = "defaultNetworkAvailable";
/**
* <p>Broadcast Action: The emergency call state is changed.
* <ul>
* <li><em>EXTRA_PHONE_IN_EMERGENCY_CALL</em> - A boolean value, true if phone in emergency
* call, false otherwise</li>
* </ul>
* <p class="note">
* You can <em>not</em> 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()}.
*
* <p class="note">This is a protected intent that can only be sent by the system.
*
* @see #EXTRA_PHONE_IN_EMERGENCY_CALL
*
* @hide
*/
@SystemApi
@SuppressLint("ActionValue")
public static final String ACTION_EMERGENCY_CALL_STATE_CHANGED =
"android.intent.action.EMERGENCY_CALL_STATE_CHANGED";
/**
* Extra included in {@link #ACTION_EMERGENCY_CALL_STATE_CHANGED}.
* It indicates whether the phone is making an emergency call.
*
* @hide
*/
@SystemApi
public static final String EXTRA_PHONE_IN_EMERGENCY_CALL =
"android.telephony.extra.PHONE_IN_EMERGENCY_CALL";
// //
// //
// Device Info // Device Info

View File

@@ -104,9 +104,6 @@ public class PhoneConstants {
public static final String DATA_APN_TYPE_KEY = "apnType"; public static final String DATA_APN_TYPE_KEY = "apnType";
public static final String DATA_APN_KEY = "apn"; public static final String DATA_APN_KEY = "apn";
public static final String PHONE_IN_ECM_STATE = "phoneinECMState";
public static final String PHONE_IN_EMERGENCY_CALL = "phoneInEmergencyCall";
/** /**
* Return codes for supplyPinReturnResult and * Return codes for supplyPinReturnResult and
* supplyPukReturnResult APIs * supplyPukReturnResult APIs