summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/system-current.txt5
-rw-r--r--core/java/android/content/pm/TEST_MAPPING42
-rw-r--r--core/java/android/nfc/NfcAdapter.java25
-rw-r--r--core/java/com/android/internal/infra/AbstractMultiplePendingRequestsRemoteService.java2
-rw-r--r--core/java/com/android/internal/infra/AbstractRemoteService.java7
-rw-r--r--core/java/com/android/internal/protolog/BaseProtoLogImpl.java12
-rw-r--r--core/java/com/android/internal/protolog/ProtoLogImpl.java12
-rw-r--r--core/res/res/values/strings.xml5
-rw-r--r--core/res/res/values/symbols.xml2
-rw-r--r--services/core/java/com/android/server/TelephonyRegistry.java9
-rw-r--r--telephony/common/com/android/internal/telephony/util/TelephonyUtils.java2
-rw-r--r--telephony/java/android/service/carrier/CarrierService.java9
-rw-r--r--telephony/java/android/telephony/SubscriptionManager.java100
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java99
-rw-r--r--[-rwxr-xr-x]telephony/java/com/android/internal/telephony/ISub.aidl20
-rw-r--r--tests/Internal/src/com/android/internal/protolog/ProtoLogImplTest.java2
-rw-r--r--tools/codegen/Android.bp2
-rw-r--r--tools/codegen/BUILD.bazel21
-rw-r--r--tools/codegen/manifest.txt1
19 files changed, 180 insertions, 197 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 03c8f8fc6891..89cae4bd55e4 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -13283,7 +13283,7 @@ package android.telephony {
method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int[] getCompleteActiveSubscriptionIdList();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getEnabledSubscriptionId(int);
method @NonNull public static android.content.res.Resources getResourcesForSubId(@NonNull android.content.Context, int);
- method @Nullable @RequiresPermission(android.Manifest.permission.MANAGE_SUBSCRIPTION_USER_ASSOCIATION) public android.os.UserHandle getUserHandle(int);
+ method @Nullable @RequiresPermission(android.Manifest.permission.MANAGE_SUBSCRIPTION_USER_ASSOCIATION) public android.os.UserHandle getSubscriptionUserHandle(int);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isSubscriptionEnabled(int);
method public void requestEmbeddedSubscriptionInfoListRefresh();
method public void requestEmbeddedSubscriptionInfoListRefresh(int);
@@ -13293,8 +13293,8 @@ package android.telephony {
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDefaultVoiceSubscriptionId(int);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setPreferredDataSubscriptionId(int, boolean, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setSubscriptionEnabled(int, boolean);
+ method @RequiresPermission(android.Manifest.permission.MANAGE_SUBSCRIPTION_USER_ASSOCIATION) public void setSubscriptionUserHandle(int, @Nullable android.os.UserHandle);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setUiccApplicationsEnabled(int, boolean);
- method @RequiresPermission(android.Manifest.permission.MANAGE_SUBSCRIPTION_USER_ASSOCIATION) public void setUserHandle(int, @Nullable android.os.UserHandle);
field @RequiresPermission(android.Manifest.permission.MANAGE_SUBSCRIPTION_PLANS) public static final String ACTION_SUBSCRIPTION_PLANS_CHANGED = "android.telephony.action.SUBSCRIPTION_PLANS_CHANGED";
field @NonNull public static final android.net.Uri ADVANCED_CALLING_ENABLED_CONTENT_URI;
field @NonNull public static final android.net.Uri CROSS_SIM_ENABLED_CONTENT_URI;
@@ -13624,6 +13624,7 @@ package android.telephony {
field public static final int INVALID_EMERGENCY_NUMBER_DB_VERSION = -1; // 0xffffffff
field public static final int KEY_TYPE_EPDG = 1; // 0x1
field public static final int KEY_TYPE_WLAN = 2; // 0x2
+ field public static final int MOBILE_DATA_POLICY_AUTO_DATA_SWITCH = 3; // 0x3
field public static final int MOBILE_DATA_POLICY_DATA_ON_NON_DEFAULT_DURING_VOICE_CALL = 1; // 0x1
field public static final int MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED = 2; // 0x2
field public static final int NR_DUAL_CONNECTIVITY_DISABLE = 2; // 0x2
diff --git a/core/java/android/content/pm/TEST_MAPPING b/core/java/android/content/pm/TEST_MAPPING
index d4a24af61c9f..a7cc5de2e735 100644
--- a/core/java/android/content/pm/TEST_MAPPING
+++ b/core/java/android/content/pm/TEST_MAPPING
@@ -28,6 +28,9 @@
"path": "cts/hostsidetests/os/test_mappings/packagemanager"
},
{
+ "path": "cts/hostsidetests/appsearch"
+ },
+ {
"path": "system/apex/tests"
},
{
@@ -46,6 +49,12 @@
"name": "ApkVerityTest"
},
{
+ "name": "CtsSilentUpdateHostTestCases"
+ },
+ {
+ "name": "CtsSuspendAppsTestCases"
+ },
+ {
"name": "CtsIncrementalInstallHostTestCases",
"options": [
{
@@ -81,39 +90,6 @@
]
},
{
- "name": "CtsAppSearchHostTestCases",
- "options": [
- {
- "exclude-annotation": "androidx.test.filters.FlakyTest"
- },
- {
- "exclude-annotation": "org.junit.Ignore"
- }
- ]
- },
- {
- "name": "CtsSilentUpdateHostTestCases",
- "options": [
- {
- "exclude-annotation": "androidx.test.filters.FlakyTest"
- },
- {
- "exclude-annotation": "org.junit.Ignore"
- }
- ]
- },
- {
- "name": "CtsSuspendAppsTestCases",
- "options": [
- {
- "exclude-annotation": "androidx.test.filters.FlakyTest"
- },
- {
- "exclude-annotation": "org.junit.Ignore"
- }
- ]
- },
- {
"name": "CtsSuspendAppsPermissionTestCases",
"options": [
{
diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java
index ea8d38013edb..1bb44af81cec 100644
--- a/core/java/android/nfc/NfcAdapter.java
+++ b/core/java/android/nfc/NfcAdapter.java
@@ -26,6 +26,8 @@ import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
import android.annotation.UserIdInt;
import android.app.Activity;
+import android.app.ActivityThread;
+import android.app.OnActivityPausedListener;
import android.app.PendingIntent;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
@@ -1575,11 +1577,17 @@ public final class NfcAdapter {
if (activity == null || intent == null) {
throw new NullPointerException();
}
+ if (!activity.isResumed()) {
+ throw new IllegalStateException("Foreground dispatch can only be enabled " +
+ "when your activity is resumed");
+ }
try {
TechListParcel parcel = null;
if (techLists != null && techLists.length > 0) {
parcel = new TechListParcel(techLists);
}
+ ActivityThread.currentActivityThread().registerOnActivityPausedListener(activity,
+ mForegroundDispatchListener);
sService.setForegroundDispatch(intent, filters, parcel);
} catch (RemoteException e) {
attemptDeadServiceRecovery(e);
@@ -1607,8 +1615,25 @@ public final class NfcAdapter {
throw new UnsupportedOperationException();
}
}
+ ActivityThread.currentActivityThread().unregisterOnActivityPausedListener(activity,
+ mForegroundDispatchListener);
+ disableForegroundDispatchInternal(activity, false);
+ }
+
+ OnActivityPausedListener mForegroundDispatchListener = new OnActivityPausedListener() {
+ @Override
+ public void onPaused(Activity activity) {
+ disableForegroundDispatchInternal(activity, true);
+ }
+ };
+
+ void disableForegroundDispatchInternal(Activity activity, boolean force) {
try {
sService.setForegroundDispatch(null, null, null);
+ if (!force && !activity.isResumed()) {
+ throw new IllegalStateException("You must disable foreground dispatching " +
+ "while your activity is still resumed");
+ }
} catch (RemoteException e) {
attemptDeadServiceRecovery(e);
}
diff --git a/core/java/com/android/internal/infra/AbstractMultiplePendingRequestsRemoteService.java b/core/java/com/android/internal/infra/AbstractMultiplePendingRequestsRemoteService.java
index 6c01780dac76..2a9025d35339 100644
--- a/core/java/com/android/internal/infra/AbstractMultiplePendingRequestsRemoteService.java
+++ b/core/java/com/android/internal/infra/AbstractMultiplePendingRequestsRemoteService.java
@@ -61,7 +61,7 @@ public abstract class AbstractMultiplePendingRequestsRemoteService<S
final int size = mPendingRequests.size();
if (mVerbose) Slog.v(mTag, "Sending " + size + " pending requests");
for (int i = 0; i < size; i++) {
- mPendingRequests.get(i).run();
+ handlePendingRequest(mPendingRequests.get(i));
}
mPendingRequests.clear();
}
diff --git a/core/java/com/android/internal/infra/AbstractRemoteService.java b/core/java/com/android/internal/infra/AbstractRemoteService.java
index f725b37acde7..491e04016ff5 100644
--- a/core/java/com/android/internal/infra/AbstractRemoteService.java
+++ b/core/java/com/android/internal/infra/AbstractRemoteService.java
@@ -98,7 +98,7 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
private long mNextUnbind;
/** Requests that have been scheduled, but that are not finished yet */
- private final ArrayList<BasePendingRequest<S, I>> mUnfinishedRequests = new ArrayList<>();
+ protected final ArrayList<BasePendingRequest<S, I>> mUnfinishedRequests = new ArrayList<>();
/**
* Callback called when the service dies.
@@ -622,6 +622,11 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
mCancelled = true;
}
+ S service = mWeakService.get();
+ if (service != null) {
+ service.finishRequest(this);
+ }
+
onCancel();
return true;
}
diff --git a/core/java/com/android/internal/protolog/BaseProtoLogImpl.java b/core/java/com/android/internal/protolog/BaseProtoLogImpl.java
index 4d1234f9006a..ac9188a0debc 100644
--- a/core/java/com/android/internal/protolog/BaseProtoLogImpl.java
+++ b/core/java/com/android/internal/protolog/BaseProtoLogImpl.java
@@ -72,11 +72,13 @@ public class BaseProtoLogImpl {
private static final String TAG = "ProtoLog";
private static final long MAGIC_NUMBER_VALUE = ((long) MAGIC_NUMBER_H << 32) | MAGIC_NUMBER_L;
static final String PROTOLOG_VERSION = "1.0.0";
+ private static final int DEFAULT_PER_CHUNK_SIZE = 0;
private final File mLogFile;
private final String mViewerConfigFilename;
private final TraceBuffer mBuffer;
protected final ProtoLogViewerConfigReader mViewerConfig;
+ private final int mPerChunkSize;
private boolean mProtoLogEnabled;
private boolean mProtoLogEnabledLockFree;
@@ -156,7 +158,7 @@ public class BaseProtoLogImpl {
return;
}
try {
- ProtoOutputStream os = new ProtoOutputStream();
+ ProtoOutputStream os = new ProtoOutputStream(mPerChunkSize);
long token = os.start(LOG);
os.write(MESSAGE_HASH, messageHash);
os.write(ELAPSED_REALTIME_NANOS, SystemClock.elapsedRealtimeNanos());
@@ -215,10 +217,16 @@ public class BaseProtoLogImpl {
public BaseProtoLogImpl(File file, String viewerConfigFilename, int bufferCapacity,
ProtoLogViewerConfigReader viewerConfig) {
+ this(file, viewerConfigFilename, bufferCapacity, viewerConfig, DEFAULT_PER_CHUNK_SIZE);
+ }
+
+ public BaseProtoLogImpl(File file, String viewerConfigFilename, int bufferCapacity,
+ ProtoLogViewerConfigReader viewerConfig, int perChunkSize) {
mLogFile = file;
mBuffer = new TraceBuffer(bufferCapacity);
mViewerConfigFilename = viewerConfigFilename;
mViewerConfig = viewerConfig;
+ mPerChunkSize = perChunkSize;
}
/**
@@ -364,7 +372,7 @@ public class BaseProtoLogImpl {
try {
long offset =
(System.currentTimeMillis() - (SystemClock.elapsedRealtimeNanos() / 1000000));
- ProtoOutputStream proto = new ProtoOutputStream();
+ ProtoOutputStream proto = new ProtoOutputStream(mPerChunkSize);
proto.write(MAGIC_NUMBER, MAGIC_NUMBER_VALUE);
proto.write(VERSION, PROTOLOG_VERSION);
proto.write(REAL_TIME_TO_ELAPSED_TIME_OFFSET_MILLIS, offset);
diff --git a/core/java/com/android/internal/protolog/ProtoLogImpl.java b/core/java/com/android/internal/protolog/ProtoLogImpl.java
index 353c6c083d9d..527cfddf6d8e 100644
--- a/core/java/com/android/internal/protolog/ProtoLogImpl.java
+++ b/core/java/com/android/internal/protolog/ProtoLogImpl.java
@@ -30,6 +30,7 @@ public class ProtoLogImpl extends BaseProtoLogImpl {
private static final int BUFFER_CAPACITY = 1024 * 1024;
private static final String LOG_FILENAME = "/data/misc/wmtrace/wm_log.winscope";
private static final String VIEWER_CONFIG_FILENAME = "/system/etc/protolog.conf.json.gz";
+ private static final int PER_CHUNK_SIZE = 1024;
private static ProtoLogImpl sServiceInstance = null;
@@ -94,7 +95,10 @@ public class ProtoLogImpl extends BaseProtoLogImpl {
public static synchronized ProtoLogImpl getSingleInstance() {
if (sServiceInstance == null) {
sServiceInstance = new ProtoLogImpl(
- new File(LOG_FILENAME), BUFFER_CAPACITY, new ProtoLogViewerConfigReader());
+ new File(LOG_FILENAME)
+ , BUFFER_CAPACITY
+ , new ProtoLogViewerConfigReader()
+ , PER_CHUNK_SIZE);
}
return sServiceInstance;
}
@@ -105,8 +109,8 @@ public class ProtoLogImpl extends BaseProtoLogImpl {
}
public ProtoLogImpl(File logFile, int bufferCapacity,
- ProtoLogViewerConfigReader viewConfigReader) {
- super(logFile, VIEWER_CONFIG_FILENAME, bufferCapacity, viewConfigReader);
- }
+ ProtoLogViewerConfigReader viewConfigReader, int perChunkSize) {
+ super(logFile, VIEWER_CONFIG_FILENAME, bufferCapacity, viewConfigReader, perChunkSize);
+ }
}
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 73c201c5bf9d..8764906c66cf 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -202,6 +202,11 @@
<!-- Displayed to tell the user that they cannot change the caller ID setting. -->
<string name="CLIRPermanent">You can\'t change the caller ID setting.</string>
+ <!-- Notification title to tell the user that auto data switch has occurred. [CHAR LIMIT=NOTIF_TITLE] -->
+ <string name="auto_data_switch_title">Switched data to <xliff:g id="carrierDisplay" example="Verizon">%s</xliff:g></string>
+ <!-- Notification content to tell the user that auto data switch can be disabled at settings. [CHAR LIMIT=NOTIF_BODY] -->
+ <string name="auto_data_switch_content">You can change this anytime in Settings</string>
+
<!-- Notification title to tell the user that data service is blocked by access control. [CHAR LIMIT=NOTIF_TITLE] -->
<string name="RestrictedOnDataTitle">No mobile data service</string>
<!-- Notification title to tell the user that emergency calling is blocked by access control. [CHAR LIMIT=NOTIF_TITLE] -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index fa1150cb3674..8477afa0f7fa 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -598,6 +598,8 @@
<java-symbol type="string" name="RestrictedOnEmergencyTitle" />
<java-symbol type="string" name="RestrictedOnNormalTitle" />
<java-symbol type="string" name="RestrictedStateContent" />
+ <java-symbol type="string" name="auto_data_switch_title" />
+ <java-symbol type="string" name="auto_data_switch_content" />
<java-symbol type="string" name="RestrictedStateContentMsimTemplate" />
<java-symbol type="string" name="notification_channel_network_alert" />
<java-symbol type="string" name="notification_channel_call_forward" />
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index 2652ebec5255..ca86021cd629 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -558,11 +558,10 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
if (VDBG) log("MSG_USER_SWITCHED userId=" + msg.arg1);
int numPhones = getTelephonyManager().getActiveModemCount();
for (int phoneId = 0; phoneId < numPhones; phoneId++) {
- int[] subIds = SubscriptionManager.getSubId(phoneId);
- int subId =
- (subIds != null) && (subIds.length > 0)
- ? subIds[0]
- : SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
+ int subId = SubscriptionManager.getSubscriptionId(phoneId);
+ if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+ subId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
+ }
TelephonyRegistry.this.notifyCellLocationForSubscriber(
subId, mCellIdentity[phoneId], true /* hasUserSwitched */);
}
diff --git a/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java b/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java
index 5179babbd31d..76d2b7d8fce5 100644
--- a/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java
+++ b/telephony/common/com/android/internal/telephony/util/TelephonyUtils.java
@@ -206,6 +206,8 @@ public final class TelephonyUtils {
return "DATA_ON_NON_DEFAULT_DURING_VOICE_CALL";
case TelephonyManager.MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED:
return "MMS_ALWAYS_ALLOWED";
+ case TelephonyManager.MOBILE_DATA_POLICY_AUTO_DATA_SWITCH:
+ return "AUTO_DATA_SWITCH";
default:
return "UNKNOWN(" + mobileDataPolicy + ")";
}
diff --git a/telephony/java/android/service/carrier/CarrierService.java b/telephony/java/android/service/carrier/CarrierService.java
index ae91d4d9b595..1c531486f3b1 100644
--- a/telephony/java/android/service/carrier/CarrierService.java
+++ b/telephony/java/android/service/carrier/CarrierService.java
@@ -28,8 +28,6 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyRegistryManager;
import android.util.Log;
-import com.android.internal.util.ArrayUtils;
-
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -237,12 +235,7 @@ public abstract class CarrierService extends Service {
@Override
public void getCarrierConfig(int phoneId, CarrierIdentifier id, ResultReceiver result) {
try {
- int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
- int[] subIds = SubscriptionManager.getSubId(phoneId);
- if (!ArrayUtils.isEmpty(subIds)) {
- // There should be at most one active subscription mapping to the phoneId.
- subId = subIds[0];
- }
+ int subId = SubscriptionManager.getSubscriptionId(phoneId);
Bundle data = new Bundle();
data.putParcelable(KEY_CONFIG_BUNDLE, CarrierService.this.onLoadConfig(subId, id));
result.send(RESULT_OK, data);
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index 10032ed54d60..682bd9cb868e 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -266,6 +266,11 @@ public class SubscriptionManager {
CACHE_KEY_SLOT_INDEX_PROPERTY,
INVALID_SIM_SLOT_INDEX);
+ private static IntegerPropertyInvalidatedCache<Integer> sSubIdCache =
+ new IntegerPropertyInvalidatedCache<>(ISub::getSubId,
+ CACHE_KEY_SLOT_INDEX_PROPERTY,
+ INVALID_SUBSCRIPTION_ID);
+
/** Cache depends on getDefaultSubId, so we use the defaultSubId cache key */
private static IntegerPropertyInvalidatedCache<Integer> sPhoneIdCache =
new IntegerPropertyInvalidatedCache<>(ISub::getPhoneId,
@@ -1635,17 +1640,33 @@ public class SubscriptionManager {
}
/**
- * @return List of all SubscriptionInfo records in database,
- * include those that were inserted before, maybe empty but not null.
+ * Get all subscription info records from SIMs that are inserted now or were inserted before.
+ *
+ * <p>
+ * If the caller does not have {@link Manifest.permission#READ_PHONE_NUMBERS} permission,
+ * {@link SubscriptionInfo#getNumber()} will return empty string.
+ * If the caller does not have {@link Manifest.permission#USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER},
+ * {@link SubscriptionInfo#getIccId()} and {@link SubscriptionInfo#getCardString()} will return
+ * empty string, and {@link SubscriptionInfo#getGroupUuid()} will return {@code null}.
+ *
+ * <p>
+ * The carrier app will always have full {@link SubscriptionInfo} for the subscriptions
+ * that it has carrier privilege.
+ *
+ * @return List of all {@link SubscriptionInfo} records from SIMs that are inserted or
+ * inserted before. Sorted by {@link SubscriptionInfo#getSimSlotIndex()}, then
+ * {@link SubscriptionInfo#getSubscriptionId()}.
+ *
* @hide
*/
+ @RequiresPermission(anyOf = {
+ Manifest.permission.READ_PHONE_STATE,
+ Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
+ "carrier privileges",
+ })
@NonNull
- @UnsupportedAppUsage
public List<SubscriptionInfo> getAllSubscriptionInfoList() {
- if (VDBG) logd("[getAllSubscriptionInfoList]+");
-
List<SubscriptionInfo> result = null;
-
try {
ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
@@ -2125,7 +2146,7 @@ public class SubscriptionManager {
*/
@Nullable
public int[] getSubscriptionIds(int slotIndex) {
- return getSubId(slotIndex);
+ return new int[]{getSubscriptionId(slotIndex)};
}
/** @hide */
@@ -2141,7 +2162,7 @@ public class SubscriptionManager {
try {
ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
- subId = iSub.getSubId(slotIndex);
+ subId = iSub.getSubIds(slotIndex);
}
} catch (RemoteException ex) {
// ignore it
@@ -2150,6 +2171,22 @@ public class SubscriptionManager {
return subId;
}
+ /**
+ * Get the subscription id for specified slot index.
+ *
+ * @param slotIndex Logical SIM slot index.
+ * @return The subscription id. {@link #INVALID_SUBSCRIPTION_ID} if SIM is absent.
+ *
+ * @hide
+ */
+ public static int getSubscriptionId(int slotIndex) {
+ if (!isValidSlotIndex(slotIndex)) {
+ return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+ }
+
+ return sSubIdCache.query(slotIndex);
+ }
+
/** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public static int getPhoneId(int subId) {
@@ -2404,9 +2441,9 @@ public class SubscriptionManager {
/** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public static void putPhoneIdAndSubIdExtra(Intent intent, int phoneId) {
- int[] subIds = SubscriptionManager.getSubId(phoneId);
- if (subIds != null && subIds.length > 0) {
- putPhoneIdAndSubIdExtra(intent, phoneId, subIds[0]);
+ int subId = SubscriptionManager.getSubscriptionId(phoneId);
+ if (isValidSubscriptionId(subId)) {
+ putPhoneIdAndSubIdExtra(intent, phoneId, subId);
} else {
logd("putPhoneIdAndSubIdExtra: no valid subs");
intent.putExtra(PhoneConstants.PHONE_KEY, phoneId);
@@ -3379,7 +3416,6 @@ public class SubscriptionManager {
/**
* Get subscriptionInfo list of subscriptions that are in the same group of given subId.
- * See {@link #createSubscriptionGroup(List)} for more details.
*
* Caller must have {@link android.Manifest.permission#READ_PHONE_STATE}
* or carrier privilege permission on the subscription.
@@ -4076,6 +4112,26 @@ public class SubscriptionManager {
}
/**
+ * Convert phone number source to string.
+ *
+ * @param source The phone name source.
+ *
+ * @return The phone name source in string format.
+ *
+ * @hide
+ */
+ @NonNull
+ public static String phoneNumberSourceToString(@PhoneNumberSource int source) {
+ switch (source) {
+ case SubscriptionManager.PHONE_NUMBER_SOURCE_UICC: return "UICC";
+ case SubscriptionManager.PHONE_NUMBER_SOURCE_CARRIER: return "CARRIER";
+ case SubscriptionManager.PHONE_NUMBER_SOURCE_IMS: return "IMS";
+ default:
+ return "UNKNOWN(" + source + ")";
+ }
+ }
+
+ /**
* Convert display name source to string.
*
* @param source The display name source.
@@ -4155,18 +4211,18 @@ public class SubscriptionManager {
*/
@SystemApi
@RequiresPermission(Manifest.permission.MANAGE_SUBSCRIPTION_USER_ASSOCIATION)
- public void setUserHandle(int subscriptionId, @Nullable UserHandle userHandle) {
+ public void setSubscriptionUserHandle(int subscriptionId, @Nullable UserHandle userHandle) {
if (!isValidSubscriptionId(subscriptionId)) {
- throw new IllegalArgumentException("[setUserHandle]: Invalid subscriptionId: "
- + subscriptionId);
+ throw new IllegalArgumentException("[setSubscriptionUserHandle]: "
+ + "Invalid subscriptionId: " + subscriptionId);
}
try {
ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
- iSub.setUserHandle(userHandle, subscriptionId, mContext.getOpPackageName());
+ iSub.setSubscriptionUserHandle(userHandle, subscriptionId);
} else {
- throw new IllegalStateException("[setUserHandle]: "
+ throw new IllegalStateException("[setSubscriptionUserHandle]: "
+ "subscription service unavailable");
}
} catch (RemoteException ex) {
@@ -4191,18 +4247,18 @@ public class SubscriptionManager {
*/
@SystemApi
@RequiresPermission(Manifest.permission.MANAGE_SUBSCRIPTION_USER_ASSOCIATION)
- public @Nullable UserHandle getUserHandle(int subscriptionId) {
+ public @Nullable UserHandle getSubscriptionUserHandle(int subscriptionId) {
if (!isValidSubscriptionId(subscriptionId)) {
- throw new IllegalArgumentException("[getUserHandle]: Invalid subscriptionId: "
- + subscriptionId);
+ throw new IllegalArgumentException("[getSubscriptionUserHandle]: "
+ + "Invalid subscriptionId: " + subscriptionId);
}
try {
ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
- return iSub.getUserHandle(subscriptionId, mContext.getOpPackageName());
+ return iSub.getSubscriptionUserHandle(subscriptionId);
} else {
- throw new IllegalStateException("[getUserHandle]: "
+ throw new IllegalStateException("[getSubscriptionUserHandle]: "
+ "subscription service unavailable");
}
} catch (RemoteException ex) {
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 3b376fb4c605..7a19d36ba743 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -2375,47 +2375,6 @@ public class TelephonyManager {
return getNaiBySubscriberId(getSubId());
}
- /**
- * Returns the NAI. Return null if NAI is not available.
- *
- * <p>Starting with API level 29, persistent device identifiers are guarded behind additional
- * restrictions, and apps are recommended to use resettable identifiers (see <a
- * href="/training/articles/user-data-ids">Best practices for unique identifiers</a>). This
- * method can be invoked if one of the following requirements is met:
- * <ul>
- * <li>If the calling app has been granted the READ_PRIVILEGED_PHONE_STATE permission; this
- * is a privileged permission that can only be granted to apps preloaded on the device.
- * <li>If the calling app is the device owner of a fully-managed device, a profile
- * owner of an organization-owned device, or their delegates (see {@link
- * android.app.admin.DevicePolicyManager#getEnrollmentSpecificId()}).
- * <li>If the calling app has carrier privileges (see {@link #hasCarrierPrivileges}).
- * <li>If the calling app is the default SMS role holder (see {@link
- * RoleManager#isRoleHeld(String)}).
- * </ul>
- *
- * <p>If the calling app does not meet one of these requirements then this method will behave
- * as follows:
- *
- * <ul>
- * <li>If the calling app's target SDK is API level 28 or lower and the app has the
- * READ_PHONE_STATE permission then null is returned.</li>
- * <li>If the calling app's target SDK is API level 28 or lower and the app does not have
- * the READ_PHONE_STATE permission, or if the calling app is targeting API level 29 or
- * higher, then a SecurityException is thrown.</li>
- * </ul>
- *
- * @param slotIndex of which Nai is returned
- */
- /** {@hide}*/
- @UnsupportedAppUsage
- public String getNai(int slotIndex) {
- int[] subId = SubscriptionManager.getSubId(slotIndex);
- if (subId == null) {
- return null;
- }
- return getNaiBySubscriberId(subId[0]);
- }
-
private String getNaiBySubscriberId(int subId) {
try {
IPhoneSubInfo info = getSubscriberInfoService();
@@ -6130,46 +6089,6 @@ public class TelephonyManager {
}
}
- /**
- * @hide
- */
- @UnsupportedAppUsage
- private IPhoneSubInfo getSubscriberInfo() {
- return getSubscriberInfoService();
- }
-
- /**
- * Returns the Telephony call state for calls on a specific SIM slot.
- * <p>
- * Note: This method considers ONLY telephony/mobile calls, where {@link #getCallState()}
- * considers the state of calls from other {@link android.telecom.ConnectionService}
- * implementations.
- * <p>
- * Requires Permission:
- * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} for applications
- * targeting API level 31+ or that the calling application has carrier privileges
- * (see {@link #hasCarrierPrivileges()}).
- *
- * @param slotIndex the SIM slot index to check call state for.
- * @hide
- */
- @RequiresPermission(value = android.Manifest.permission.READ_PHONE_STATE, conditional = true)
- public @CallState int getCallStateForSlot(int slotIndex) {
- try {
- int[] subId = SubscriptionManager.getSubId(slotIndex);
- ITelephony telephony = getITelephony();
- if (telephony == null || subId == null || subId.length == 0) {
- return CALL_STATE_IDLE;
- }
- return telephony.getCallStateForSubscription(subId[0], mContext.getPackageName(),
- mContext.getAttributionTag());
- } catch (RemoteException | NullPointerException ex) {
- // the phone process is restarting.
- return CALL_STATE_IDLE;
- }
- }
-
-
/** Data connection activity: No traffic. */
public static final int DATA_ACTIVITY_NONE = 0x00000000;
/** Data connection activity: Currently receiving IP PPP traffic. */
@@ -15401,11 +15320,29 @@ public class TelephonyManager {
public static final int MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED = 2;
/**
+ * Allow switching mobile data to the non-default SIM if the non-default SIM has better
+ * availability.
+ *
+ * This is used for temporarily allowing data on the non-default data SIM when on-default SIM
+ * has better availability on DSDS devices, where better availability means strong
+ * signal/connectivity.
+ * If this policy is enabled, data will be temporarily enabled on the non-default data SIM,
+ * including during any voice calls(equivalent to enabling
+ * {@link #MOBILE_DATA_POLICY_DATA_ON_NON_DEFAULT_DURING_VOICE_CALL}).
+ *
+ * This policy can be enabled and disabled via {@link #setMobileDataPolicyEnabled}.
+ * @hide
+ */
+ @SystemApi
+ public static final int MOBILE_DATA_POLICY_AUTO_DATA_SWITCH = 3;
+
+ /**
* @hide
*/
@IntDef(prefix = { "MOBILE_DATA_POLICY_" }, value = {
MOBILE_DATA_POLICY_DATA_ON_NON_DEFAULT_DURING_VOICE_CALL,
MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED,
+ MOBILE_DATA_POLICY_AUTO_DATA_SWITCH,
})
@Retention(RetentionPolicy.SOURCE)
public @interface MobileDataPolicy { }
diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl
index 0211a7f5c5c5..5173405ac17d 100755..100644
--- a/telephony/java/com/android/internal/telephony/ISub.aidl
+++ b/telephony/java/com/android/internal/telephony/ISub.aidl
@@ -114,14 +114,6 @@ interface ISub {
oneway void requestEmbeddedSubscriptionInfoListRefresh(int cardId);
/**
- * Add a new SubscriptionInfo to subinfo database if needed
- * @param iccId the IccId of the SIM card
- * @param slotIndex the slot which the SIM is inserted
- * @return the URL of the newly created row or the updated row
- */
- int addSubInfoRecord(String iccId, int slotIndex);
-
- /**
* Add a new subscription info record, if needed
* @param uniqueId This is the unique identifier for the subscription within the specific
* subscription type.
@@ -244,7 +236,9 @@ interface ISub {
int getSlotIndex(int subId);
- int[] getSubId(int slotIndex);
+ int[] getSubIds(int slotIndex);
+
+ int getSubId(int slotIndex);
int getDefaultSubId();
@@ -323,22 +317,20 @@ interface ISub {
*
* @param userHandle the user handle for this subscription
* @param subId the unique SubscriptionInfo index in database
- * @param callingPackage The package making the IPC.
*
* @throws SecurityException if doesn't have MANAGE_SUBSCRIPTION_USER_ASSOCIATION
* @throws IllegalArgumentException if subId is invalid.
*/
- int setUserHandle(in UserHandle userHandle, int subId, String callingPackage);
+ int setSubscriptionUserHandle(in UserHandle userHandle, int subId);
/**
* Get UserHandle for this subscription
*
* @param subId the unique SubscriptionInfo index in database
- * @param callingPackage the package making the IPC
* @return userHandle associated with this subscription.
*
- * @throws SecurityException if doesn't have SMANAGE_SUBSCRIPTION_USER_ASSOCIATION
+ * @throws SecurityException if doesn't have MANAGE_SUBSCRIPTION_USER_ASSOCIATION
* @throws IllegalArgumentException if subId is invalid.
*/
- UserHandle getUserHandle(int subId, String callingPackage);
+ UserHandle getSubscriptionUserHandle(int subId);
}
diff --git a/tests/Internal/src/com/android/internal/protolog/ProtoLogImplTest.java b/tests/Internal/src/com/android/internal/protolog/ProtoLogImplTest.java
index 3db011683a86..fdd919412e55 100644
--- a/tests/Internal/src/com/android/internal/protolog/ProtoLogImplTest.java
+++ b/tests/Internal/src/com/android/internal/protolog/ProtoLogImplTest.java
@@ -86,7 +86,7 @@ public class ProtoLogImplTest {
mFile = testContext.getFileStreamPath("tracing_test.dat");
//noinspection ResultOfMethodCallIgnored
mFile.delete();
- mProtoLog = new ProtoLogImpl(mFile, 1024 * 1024, mReader);
+ mProtoLog = new ProtoLogImpl(mFile, 1024 * 1024, mReader, 1024);
}
@After
diff --git a/tools/codegen/Android.bp b/tools/codegen/Android.bp
index e53ba3e18a86..a1df878df12e 100644
--- a/tools/codegen/Android.bp
+++ b/tools/codegen/Android.bp
@@ -9,7 +9,7 @@ package {
java_binary_host {
name: "codegen_cli",
- manifest: "manifest.txt",
+ main_class: "com.android.codegen.MainKt",
srcs: [
"src/**/*.kt",
],
diff --git a/tools/codegen/BUILD.bazel b/tools/codegen/BUILD.bazel
deleted file mode 100644
index c14046d674dc..000000000000
--- a/tools/codegen/BUILD.bazel
+++ /dev/null
@@ -1,21 +0,0 @@
-# TODO(b/245731902): auto-generate these with bp2build.
-load("@rules_kotlin//kotlin:jvm_library.bzl", "kt_jvm_library")
-
-java_binary(
- name = "codegen_cli",
- main_class = "com.android.codegen.MainKt",
- runtime_deps = [
- ":codegen_cli_kt_lib",
- ],
-)
-
-kt_jvm_library(
- name = "codegen_cli_kt_lib",
- srcs = glob(["src/**/*.kt"]),
- deps = ["//external/javaparser"],
-)
-
-kt_jvm_library(
- name = "codegen-version-info",
- srcs = glob(["src/**/SharedConstants.kt"]),
-)
diff --git a/tools/codegen/manifest.txt b/tools/codegen/manifest.txt
deleted file mode 100644
index 6e1018ba6b55..000000000000
--- a/tools/codegen/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Main-class: com.android.codegen.MainKt