Merge "Introduce CarrierConfigChangeListener API to monitor CC change"
diff --git a/Android.bp b/Android.bp
index 0c9b82e..62d2632 100644
--- a/Android.bp
+++ b/Android.bp
@@ -506,7 +506,7 @@
"--hide Todo " +
"--hide Typo " +
"--hide UnavailableSymbol " +
- "--manifest $(location core/res/AndroidManifest.xml) "
+ "--manifest $(location :frameworks-base-core-AndroidManifest.xml) "
packages_to_document = [
"android",
@@ -543,7 +543,7 @@
sdk_version: "none",
system_modules: "none",
java_version: "1.8",
- arg_files: ["core/res/AndroidManifest.xml"],
+ arg_files: [":frameworks-base-core-AndroidManifest.xml"],
aidl: {
local_include_dirs: [
"media/aidl",
@@ -619,12 +619,3 @@
"ProtoLibraries.bp",
"TestProtoLibraries.bp",
]
-
-java_api_contribution {
- name: "api-stubs-docs-non-updatable-public-stubs",
- api_surface: "public",
- api_file: "core/api/current.txt",
- visibility: [
- "//build/orchestrator/apis",
- ],
-}
diff --git a/StubLibraries.bp b/StubLibraries.bp
index 38413c2..b005591 100644
--- a/StubLibraries.bp
+++ b/StubLibraries.bp
@@ -36,8 +36,8 @@
args: metalava_framework_docs_args,
check_api: {
current: {
- api_file: "core/api/current.txt",
- removed_api_file: "core/api/removed.txt",
+ api_file: ":non-updatable-current.txt",
+ removed_api_file: ":non-updatable-removed.txt",
},
last_released: {
api_file: ":android-non-updatable.api.public.latest",
@@ -88,8 +88,8 @@
args: metalava_framework_docs_args + priv_apps,
check_api: {
current: {
- api_file: "core/api/system-current.txt",
- removed_api_file: "core/api/system-removed.txt",
+ api_file: ":non-updatable-system-current.txt",
+ removed_api_file: ":non-updatable-system-removed.txt",
},
last_released: {
api_file: ":android-non-updatable.api.system.latest",
@@ -99,7 +99,7 @@
api_lint: {
enabled: true,
new_since: ":android.api.system.latest",
- baseline_file: "core/api/system-lint-baseline.txt",
+ baseline_file: ":non-updatable-system-lint-baseline.txt",
},
},
dists: [
@@ -127,12 +127,12 @@
args: metalava_framework_docs_args + test + priv_apps_in_stubs,
check_api: {
current: {
- api_file: "core/api/test-current.txt",
- removed_api_file: "core/api/test-removed.txt",
+ api_file: ":non-updatable-test-current.txt",
+ removed_api_file: ":non-updatable-test-removed.txt",
},
api_lint: {
enabled: true,
- baseline_file: "core/api/test-lint-baseline.txt",
+ baseline_file: ":non-updatable-test-lint-baseline.txt",
},
},
dists: [
@@ -172,8 +172,8 @@
args: metalava_framework_docs_args + priv_apps_in_stubs + module_libs,
check_api: {
current: {
- api_file: "core/api/module-lib-current.txt",
- removed_api_file: "core/api/module-lib-removed.txt",
+ api_file: ":non-updatable-module-lib-current.txt",
+ removed_api_file: ":non-updatable-module-lib-removed.txt",
},
last_released: {
api_file: ":android-non-updatable.api.module-lib.latest",
@@ -183,7 +183,7 @@
api_lint: {
enabled: true,
new_since: ":android.api.module-lib.latest",
- baseline_file: "core/api/module-lib-lint-baseline.txt",
+ baseline_file: ":non-updatable-module-lib-lint-baseline.txt",
},
},
dists: [
@@ -364,15 +364,15 @@
java_library {
name: "android_system_server_stubs_current",
- defaults: ["android_stubs_dists_default"],
+ defaults: [
+ "android.jar_defaults",
+ "android_stubs_dists_default",
+ ],
srcs: [":services-non-updatable-stubs"],
installable: false,
static_libs: [
"android_module_lib_stubs_current",
],
- sdk_version: "none",
- system_modules: "none",
- java_version: "1.8",
dist: {
dir: "apistubs/android/system-server",
},
@@ -575,20 +575,7 @@
droidstubs {
name: "hwbinder-stubs-docs",
- srcs: [
- "core/java/android/os/HidlSupport.java",
- "core/java/android/os/HidlMemory.java",
- "core/java/android/os/HwBinder.java",
- "core/java/android/os/HwBlob.java",
- "core/java/android/os/HwParcel.java",
- "core/java/android/os/IHwBinder.java",
- "core/java/android/os/IHwInterface.java",
- "core/java/android/os/DeadObjectException.java",
- "core/java/android/os/DeadSystemException.java",
- "core/java/android/os/NativeHandle.java",
- "core/java/android/os/RemoteException.java",
- "core/java/android/util/AndroidException.java",
- ],
+ srcs: [":hwbinder-stubs-srcs"],
libs: ["framework-annotations-lib"],
installable: false,
sdk_version: "core_platform",
@@ -610,12 +597,3 @@
],
visibility: ["//visibility:public"],
}
-
-java_api_contribution {
- name: "frameworks-base-core-api-module-lib-stubs",
- api_surface: "module-lib",
- api_file: "core/api/module-lib-current.txt",
- visibility: [
- "//build/orchestrator/apis",
- ],
-}
diff --git a/api/Android.bp b/api/Android.bp
index a2b8038..4cb52bc 100644
--- a/api/Android.bp
+++ b/api/Android.bp
@@ -31,10 +31,12 @@
"blueprint",
"soong",
"soong-android",
+ "soong-bp2build",
"soong-genrule",
"soong-java",
],
srcs: ["api.go"],
+ testSrcs: ["api_test.go"],
pluginFor: ["soong_build"],
}
@@ -255,3 +257,15 @@
out: ["combined-removed-dex.txt"],
cmd: "$(location gen_combined_removed_dex.sh) $(location metalava) $(genDir) $(in) > $(out)",
}
+
+java_genrule {
+ name: "api_fingerprint",
+ srcs: [
+ ":frameworks-base-api-current.txt",
+ ":frameworks-base-api-system-current.txt",
+ ":frameworks-base-api-module-lib-current.txt",
+ ":frameworks-base-api-system-server-current.txt",
+ ],
+ out: ["api_fingerprint.txt"],
+ cmd: "cat $(in) | md5sum | cut -d' ' -f1 > $(out)",
+}
diff --git a/api/api.go b/api/api.go
index 077ab96..25d9728 100644
--- a/api/api.go
+++ b/api/api.go
@@ -20,6 +20,7 @@
"github.com/google/blueprint/proptools"
"android/soong/android"
+ "android/soong/bazel"
"android/soong/genrule"
"android/soong/java"
)
@@ -30,6 +31,7 @@
const virtualization = "framework-virtualization"
var core_libraries_modules = []string{art, conscrypt, i18n}
+
// List of modules that are not yet updatable, and hence they can still compile
// against hidden APIs. These modules are filtered out when building the
// updatable-framework-module-impl (because updatable-framework-module-impl is
@@ -59,6 +61,7 @@
type CombinedApis struct {
android.ModuleBase
+ android.BazelModuleBase
properties CombinedApisProperties
}
@@ -99,6 +102,19 @@
Visibility []string
}
+type Bazel_module struct {
+ Bp2build_available *bool
+}
+type bazelProperties struct {
+ *Bazel_module
+}
+
+var bp2buildNotAvailable = bazelProperties{
+ &Bazel_module{
+ Bp2build_available: proptools.BoolPtr(false),
+ },
+}
+
// Struct to pass parameters for the various merged [current|removed].txt file modules we create.
type MergedTxtDefinition struct {
// "current.txt" or "removed.txt"
@@ -144,7 +160,7 @@
},
}
props.Visibility = []string{"//visibility:public"}
- ctx.CreateModule(genrule.GenRuleFactory, &props)
+ ctx.CreateModule(genrule.GenRuleFactory, &props, &bp2buildNotAvailable)
}
func createMergedAnnotationsFilegroups(ctx android.LoadHookContext, modules, system_server_modules []string) {
@@ -174,7 +190,7 @@
props := fgProps{}
props.Name = proptools.StringPtr(i.name)
props.Srcs = createSrcs(i.modules, i.tag)
- ctx.CreateModule(android.FileGroupFactory, &props)
+ ctx.CreateModule(android.FileGroupFactory, &props, &bp2buildNotAvailable)
}
}
@@ -223,7 +239,7 @@
props.Tools = []string{"api_versions_trimmer"}
props.Cmd = proptools.StringPtr("$(location api_versions_trimmer) $(out) $(in)")
props.Dists = []android.Dist{{Targets: []string{"sdk"}}}
- ctx.CreateModule(genrule.GenRuleFactory, &props)
+ ctx.CreateModule(genrule.GenRuleFactory, &props, &bp2buildNotAvailable)
}
}
@@ -315,7 +331,7 @@
props.Name = proptools.StringPtr("all-modules-public-stubs-source")
props.Srcs = createSrcs(modules, "{.public.stubs.source}")
props.Visibility = []string{"//frameworks/base"}
- ctx.CreateModule(android.FileGroupFactory, &props)
+ ctx.CreateModule(android.FileGroupFactory, &props, &bp2buildNotAvailable)
}
func createMergedTxts(ctx android.LoadHookContext, bootclasspath, system_server_classpath []string) {
@@ -389,9 +405,57 @@
module.AddProperties(&module.properties)
android.InitAndroidModule(module)
android.AddLoadHook(module, func(ctx android.LoadHookContext) { module.createInternalModules(ctx) })
+ android.InitBazelModule(module)
return module
}
+type bazelCombinedApisAttributes struct {
+ Scope bazel.StringAttribute
+ Base bazel.LabelAttribute
+ Deps bazel.LabelListAttribute
+}
+
+// combined_apis bp2build converter
+func (a *CombinedApis) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
+ basePrefix := "non-updatable"
+ scopeNames := []string{"public", "system", "module-lib", "system-server"}
+ scopeToSuffix := map[string]string{
+ "public": "-current.txt",
+ "system": "-system-current.txt",
+ "module-lib": "-module-lib-current.txt",
+ "system-server": "-system-server-current.txt",
+ }
+
+ for _, scopeName := range scopeNames{
+ suffix := scopeToSuffix[scopeName]
+ name := a.Name() + suffix
+
+ var scope bazel.StringAttribute
+ scope.SetValue(scopeName)
+
+ var base bazel.LabelAttribute
+ base.SetValue(android.BazelLabelForModuleDepSingle(ctx, basePrefix+suffix))
+
+ var deps bazel.LabelListAttribute
+ classpath := a.properties.Bootclasspath
+ if scopeName == "system-server" {
+ classpath = a.properties.System_server_classpath
+ }
+ deps = bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, classpath))
+
+ attrs := bazelCombinedApisAttributes{
+ Scope: scope,
+ Base: base,
+ Deps: deps,
+ }
+ props := bazel.BazelTargetModuleProperties{
+ Rule_class: "merged_txts",
+ Bzl_load_location: "//build/bazel/rules/java:merged_txts.bzl",
+ }
+ ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, &attrs)
+ }
+}
+
// Various utility methods below.
// Creates an array of ":<m><tag>" for each m in <modules>.
diff --git a/api/api_test.go b/api/api_test.go
new file mode 100644
index 0000000..15b695c
--- /dev/null
+++ b/api/api_test.go
@@ -0,0 +1,68 @@
+// Copyright (C) 2023 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package api
+
+import (
+ "testing"
+
+ "android/soong/android"
+ "android/soong/bp2build"
+)
+
+func runCombinedApisTestCaseWithRegistrationCtxFunc(t *testing.T, tc bp2build.Bp2buildTestCase, registrationCtxFunc func(ctx android.RegistrationContext)) {
+ t.Helper()
+ (&tc).ModuleTypeUnderTest = "combined_apis"
+ (&tc).ModuleTypeUnderTestFactory = combinedApisModuleFactory
+ bp2build.RunBp2BuildTestCase(t, registrationCtxFunc, tc)
+}
+
+func runCombinedApisTestCase(t *testing.T, tc bp2build.Bp2buildTestCase) {
+ t.Helper()
+ runCombinedApisTestCaseWithRegistrationCtxFunc(t, tc, func(ctx android.RegistrationContext) {})
+}
+
+func TestCombinedApisGeneral(t *testing.T) {
+ runCombinedApisTestCase(t, bp2build.Bp2buildTestCase{
+ Description: "combined_apis, general case",
+ Blueprint: `combined_apis {
+ name: "foo",
+ bootclasspath: ["bcp"],
+ system_server_classpath: ["ssc"],
+}
+`,
+ ExpectedBazelTargets: []string{
+ bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-current.txt", bp2build.AttrNameToString{
+ "scope": `"public"`,
+ "base": `":non-updatable-current.txt__BP2BUILD__MISSING__DEP"`,
+ "deps": `[":bcp__BP2BUILD__MISSING__DEP"]`,
+ }),
+ bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-system-current.txt", bp2build.AttrNameToString{
+ "scope": `"system"`,
+ "base": `":non-updatable-system-current.txt__BP2BUILD__MISSING__DEP"`,
+ "deps": `[":bcp__BP2BUILD__MISSING__DEP"]`,
+ }),
+ bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-module-lib-current.txt", bp2build.AttrNameToString{
+ "scope": `"module-lib"`,
+ "base": `":non-updatable-module-lib-current.txt__BP2BUILD__MISSING__DEP"`,
+ "deps": `[":bcp__BP2BUILD__MISSING__DEP"]`,
+ }),
+ bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-system-server-current.txt", bp2build.AttrNameToString{
+ "scope": `"system-server"`,
+ "base": `":non-updatable-system-server-current.txt__BP2BUILD__MISSING__DEP"`,
+ "deps": `[":ssc__BP2BUILD__MISSING__DEP"]`,
+ }),
+ },
+ })
+}
diff --git a/core/api/Android.bp b/core/api/Android.bp
index 114a957..71a2ca2 100644
--- a/core/api/Android.bp
+++ b/core/api/Android.bp
@@ -13,7 +13,10 @@
// limitations under the License.
package {
- default_visibility: ["//visibility:private"],
+ default_visibility: [
+ "//frameworks/base",
+ "//frameworks/base/api",
+ ],
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "frameworks_base_license"
@@ -27,31 +30,33 @@
filegroup {
name: "non-updatable-current.txt",
srcs: ["current.txt"],
- visibility: ["//frameworks/base/api"],
}
filegroup {
name: "non-updatable-removed.txt",
srcs: ["removed.txt"],
- visibility: ["//frameworks/base/api"],
}
filegroup {
name: "non-updatable-system-current.txt",
srcs: ["system-current.txt"],
- visibility: ["//frameworks/base/api"],
}
filegroup {
name: "non-updatable-system-removed.txt",
srcs: ["system-removed.txt"],
- visibility: ["//frameworks/base/api"],
+}
+
+filegroup {
+ name: "non-updatable-system-lint-baseline.txt",
+ srcs: ["system-lint-baseline.txt"],
}
filegroup {
name: "non-updatable-module-lib-current.txt",
srcs: ["module-lib-current.txt"],
visibility: [
+ "//frameworks/base",
"//frameworks/base/api",
"//cts/tests/signature/api",
],
@@ -61,7 +66,46 @@
name: "non-updatable-module-lib-removed.txt",
srcs: ["module-lib-removed.txt"],
visibility: [
+ "//frameworks/base",
"//frameworks/base/api",
"//cts/tests/signature/api",
],
}
+
+filegroup {
+ name: "non-updatable-module-lib-lint-baseline.txt",
+ srcs: ["module-lib-lint-baseline.txt"],
+}
+
+filegroup {
+ name: "non-updatable-test-current.txt",
+ srcs: ["test-current.txt"],
+}
+
+filegroup {
+ name: "non-updatable-test-removed.txt",
+ srcs: ["test-removed.txt"],
+}
+
+filegroup {
+ name: "non-updatable-test-lint-baseline.txt",
+ srcs: ["test-lint-baseline.txt"],
+}
+
+java_api_contribution {
+ name: "api-stubs-docs-non-updatable-public-stubs",
+ api_surface: "public",
+ api_file: "current.txt",
+ visibility: [
+ "//build/orchestrator/apis",
+ ],
+}
+
+java_api_contribution {
+ name: "frameworks-base-core-api-module-lib-stubs",
+ api_surface: "module-lib",
+ api_file: "module-lib-current.txt",
+ visibility: [
+ "//build/orchestrator/apis",
+ ],
+}
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index a640ffd..89cae4b 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -13283,7 +13283,7 @@
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 @@
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;
diff --git a/core/java/Android.bp b/core/java/Android.bp
index 3921408..7df3d1e 100644
--- a/core/java/Android.bp
+++ b/core/java/Android.bp
@@ -293,6 +293,28 @@
],
}
+filegroup {
+ name: "hwbinder-stubs-srcs",
+ srcs: [
+ "android/os/HidlSupport.java",
+ "android/os/HidlMemory.java",
+ "android/os/HwBinder.java",
+ "android/os/HwBlob.java",
+ "android/os/HwParcel.java",
+ "android/os/IHwBinder.java",
+ "android/os/IHwInterface.java",
+ "android/os/DeadObjectException.java",
+ "android/os/DeadSystemException.java",
+ "android/os/NativeHandle.java",
+ "android/os/RemoteException.java",
+ "android/util/AndroidException.java",
+ ],
+ visibility: [
+ "//frameworks/base",
+ "//frameworks/base/api",
+ ],
+}
+
cc_defaults {
name: "incremental_default",
cflags: [
diff --git a/core/java/android/content/pm/TEST_MAPPING b/core/java/android/content/pm/TEST_MAPPING
index d4a24af..a7cc5de 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 ea8d380..656cd99 100644
--- a/core/java/android/nfc/NfcAdapter.java
+++ b/core/java/android/nfc/NfcAdapter.java
@@ -26,6 +26,8 @@
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;
@@ -417,6 +419,7 @@
static boolean sIsInitialized = false;
static boolean sHasNfcFeature;
static boolean sHasBeamFeature;
+ static boolean sHasCeFeature;
// Final after first constructor, except for
// attemptDeadServiceRecovery() when NFC crashes - we accept a best effort
@@ -614,11 +617,13 @@
pm = context.getPackageManager();
sHasNfcFeature = pm.hasSystemFeature(PackageManager.FEATURE_NFC);
sHasBeamFeature = pm.hasSystemFeature(PackageManager.FEATURE_NFC_BEAM);
- boolean hasHceFeature =
+ sHasCeFeature =
pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)
- || pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION_NFCF);
+ || pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION_NFCF)
+ || pm.hasSystemFeature(PackageManager.FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC)
+ || pm.hasSystemFeature(PackageManager.FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE);
/* is this device meant to have NFC */
- if (!sHasNfcFeature && !hasHceFeature) {
+ if (!sHasNfcFeature && !sHasCeFeature) {
Log.v(TAG, "this device does not have NFC support");
throw new UnsupportedOperationException();
}
@@ -641,7 +646,7 @@
throw new UnsupportedOperationException();
}
}
- if (hasHceFeature) {
+ if (sHasCeFeature) {
try {
sNfcFCardEmulationService = sService.getNfcFCardEmulationInterface();
} catch (RemoteException e) {
@@ -1575,11 +1580,17 @@
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 +1618,25 @@
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);
}
@@ -1821,7 +1849,7 @@
@SystemApi
@RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
public boolean enableSecureNfc(boolean enable) {
- if (!sHasNfcFeature) {
+ if (!sHasNfcFeature && !sHasCeFeature) {
throw new UnsupportedOperationException();
}
try {
@@ -1846,10 +1874,13 @@
* Checks if the device supports Secure NFC functionality.
*
* @return True if device supports Secure NFC, false otherwise
- * @throws UnsupportedOperationException if FEATURE_NFC is unavailable.
+ * @throws UnsupportedOperationException if FEATURE_NFC,
+ * FEATURE_NFC_HOST_CARD_EMULATION, FEATURE_NFC_HOST_CARD_EMULATION_NFCF,
+ * FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC and FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE
+ * are unavailable
*/
public boolean isSecureNfcSupported() {
- if (!sHasNfcFeature) {
+ if (!sHasNfcFeature && !sHasCeFeature) {
throw new UnsupportedOperationException();
}
try {
@@ -1875,11 +1906,14 @@
* such as their relative positioning on the device.
*
* @return Information on the nfc antenna(s) on the device.
- * @throws UnsupportedOperationException if FEATURE_NFC is unavailable.
+ * @throws UnsupportedOperationException if FEATURE_NFC,
+ * FEATURE_NFC_HOST_CARD_EMULATION, FEATURE_NFC_HOST_CARD_EMULATION_NFCF,
+ * FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC and FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE
+ * are unavailable
*/
@Nullable
public NfcAntennaInfo getNfcAntennaInfo() {
- if (!sHasNfcFeature) {
+ if (!sHasNfcFeature && !sHasCeFeature) {
throw new UnsupportedOperationException();
}
try {
@@ -1904,12 +1938,15 @@
* Checks Secure NFC feature is enabled.
*
* @return True if Secure NFC is enabled, false otherwise
- * @throws UnsupportedOperationException if FEATURE_NFC is unavailable.
+ * @throws UnsupportedOperationException if FEATURE_NFC,
+ * FEATURE_NFC_HOST_CARD_EMULATION, FEATURE_NFC_HOST_CARD_EMULATION_NFCF,
+ * FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC and FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE
+ * are unavailable
* @throws UnsupportedOperationException if device doesn't support
* Secure NFC functionality. {@link #isSecureNfcSupported}
*/
public boolean isSecureNfcEnabled() {
- if (!sHasNfcFeature) {
+ if (!sHasNfcFeature && !sHasCeFeature) {
throw new UnsupportedOperationException();
}
try {
@@ -2256,14 +2293,17 @@
* always on.
* @param value if true the NFCC will be kept on (with no RF enabled if NFC adapter is
* disabled), if false the NFCC will follow completely the Nfc adapter state.
- * @throws UnsupportedOperationException if FEATURE_NFC is unavailable.
+ * @throws UnsupportedOperationException if FEATURE_NFC,
+ * FEATURE_NFC_HOST_CARD_EMULATION, FEATURE_NFC_HOST_CARD_EMULATION_NFCF,
+ * FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC and FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE
+ * are unavailable
* @return void
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON)
public boolean setControllerAlwaysOn(boolean value) {
- if (!sHasNfcFeature) {
+ if (!sHasNfcFeature && !sHasCeFeature) {
throw new UnsupportedOperationException();
}
try {
@@ -2288,7 +2328,10 @@
* Checks NFC controller always on feature is enabled.
*
* @return True if NFC controller always on is enabled, false otherwise
- * @throws UnsupportedOperationException if FEATURE_NFC is unavailable.
+ * @throws UnsupportedOperationException if FEATURE_NFC,
+ * FEATURE_NFC_HOST_CARD_EMULATION, FEATURE_NFC_HOST_CARD_EMULATION_NFCF,
+ * FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC and FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE
+ * are unavailable
* @hide
*/
@SystemApi
@@ -2316,13 +2359,16 @@
* Checks if the device supports NFC controller always on functionality.
*
* @return True if device supports NFC controller always on, false otherwise
- * @throws UnsupportedOperationException if FEATURE_NFC is unavailable.
+ * @throws UnsupportedOperationException if FEATURE_NFC,
+ * FEATURE_NFC_HOST_CARD_EMULATION, FEATURE_NFC_HOST_CARD_EMULATION_NFCF,
+ * FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC and FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE
+ * are unavailable
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON)
public boolean isControllerAlwaysOnSupported() {
- if (!sHasNfcFeature) {
+ if (!sHasNfcFeature && !sHasCeFeature) {
throw new UnsupportedOperationException();
}
try {
diff --git a/core/java/com/android/internal/infra/AbstractMultiplePendingRequestsRemoteService.java b/core/java/com/android/internal/infra/AbstractMultiplePendingRequestsRemoteService.java
index 6c01780..2a9025d 100644
--- a/core/java/com/android/internal/infra/AbstractMultiplePendingRequestsRemoteService.java
+++ b/core/java/com/android/internal/infra/AbstractMultiplePendingRequestsRemoteService.java
@@ -61,7 +61,7 @@
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 f725b37..491e040 100644
--- a/core/java/com/android/internal/infra/AbstractRemoteService.java
+++ b/core/java/com/android/internal/infra/AbstractRemoteService.java
@@ -98,7 +98,7 @@
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 @@
mCancelled = true;
}
+ S service = mWeakService.get();
+ if (service != null) {
+ service.finishRequest(this);
+ }
+
onCancel();
return true;
}
diff --git a/core/jni/android_view_InputEventSender.cpp b/core/jni/android_view_InputEventSender.cpp
index 4bc567a..ad54004 100644
--- a/core/jni/android_view_InputEventSender.cpp
+++ b/core/jni/android_view_InputEventSender.cpp
@@ -20,20 +20,21 @@
#include <android_runtime/AndroidRuntime.h>
#include <input/InputTransport.h>
+#include <inttypes.h>
#include <log/log.h>
#include <nativehelper/JNIHelp.h>
#include <nativehelper/ScopedLocalRef.h>
#include <utils/Looper.h>
+
+#include <optional>
+#include <unordered_map>
+
#include "android_os_MessageQueue.h"
#include "android_view_InputChannel.h"
#include "android_view_KeyEvent.h"
#include "android_view_MotionEvent.h"
#include "core_jni_helpers.h"
-#include <inttypes.h>
-#include <unordered_map>
-
-
using android::base::Result;
namespace android {
@@ -67,7 +68,7 @@
jobject mSenderWeakGlobal;
InputPublisher mInputPublisher;
sp<MessageQueue> mMessageQueue;
- std::unordered_map<uint32_t, uint32_t> mPublishedSeqMap;
+ std::unordered_map<uint32_t, std::optional<uint32_t>> mPublishedSeqMap;
uint32_t mNextPublishedSeq;
@@ -165,8 +166,14 @@
getInputChannelName().c_str(), status);
return status;
}
+ // mPublishedSeqMap tracks all sequences published from this sender. Only the last
+ // sequence number is used to signal this motion event is finished.
+ if (i == event->getHistorySize()) {
+ mPublishedSeqMap.emplace(publishedSeq, seq);
+ } else {
+ mPublishedSeqMap.emplace(publishedSeq, std::nullopt);
+ }
}
- mPublishedSeqMap.emplace(publishedSeq, seq);
return OK;
}
@@ -277,8 +284,16 @@
// does something wrong and sends bad data. Just ignore and process other events.
return true;
}
- const uint32_t seq = it->second;
+
+ const std::optional<uint32_t> seqOptional = it->second;
mPublishedSeqMap.erase(it);
+ // If this optional does not have a value, it means we are processing an event that had history
+ // and was split. There are more events coming, so we can't call 'dispatchInputEventFinished'
+ // yet. The final split event will have a valid sequence number.
+ if (!seqOptional.has_value()) {
+ return true;
+ }
+ const uint32_t seq = seqOptional.value();
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Received finished signal, seq=%u, handled=%s, pendingEvents=%zu.",
diff --git a/core/res/Android.bp b/core/res/Android.bp
index 93ce783..42c95d6 100644
--- a/core/res/Android.bp
+++ b/core/res/Android.bp
@@ -172,3 +172,12 @@
" > $(out)",
tools: ["xmllint"],
}
+
+filegroup {
+ name: "frameworks-base-core-AndroidManifest.xml",
+ srcs: ["AndroidManifest.xml"],
+ visibility: [
+ "//frameworks/base",
+ "//frameworks/base/api",
+ ],
+}
diff --git a/core/tests/coretests/src/android/content/pm/TEST_MAPPING b/core/tests/coretests/src/android/content/pm/TEST_MAPPING
index 15e04d1..978d80c 100644
--- a/core/tests/coretests/src/android/content/pm/TEST_MAPPING
+++ b/core/tests/coretests/src/android/content/pm/TEST_MAPPING
@@ -1,5 +1,5 @@
{
- "presubmit-large": [
+ "presubmit": [
{
"name": "FrameworksCoreTests",
"options": [
diff --git a/core/tests/coretests/src/android/view/OWNERS b/core/tests/coretests/src/android/view/OWNERS
index a142e27..2ca9994 100644
--- a/core/tests/coretests/src/android/view/OWNERS
+++ b/core/tests/coretests/src/android/view/OWNERS
@@ -1,4 +1,5 @@
# Accessibility
+per-file AccessibilityInteractionControllerTest.java = file:/services/accessibility/OWNERS
per-file WindowInfoTest.java = file:/services/accessibility/OWNERS
# Input
diff --git a/graphics/java/android/graphics/ColorSpace.java b/graphics/java/android/graphics/ColorSpace.java
index ca3c847..6e60e9e 100644
--- a/graphics/java/android/graphics/ColorSpace.java
+++ b/graphics/java/android/graphics/ColorSpace.java
@@ -170,7 +170,7 @@
/**
* Standard CIE 1931 2° illuminant D65, encoded in xyY.
* This illuminant has a color temperature of 6504K. This illuminant
- * is commonly used in RGB color spaces such as sRGB, BT.209, etc.
+ * is commonly used in RGB color spaces such as sRGB, BT.709, etc.
*/
public static final float[] ILLUMINANT_D65 = { 0.31271f, 0.32902f };
/**
@@ -832,8 +832,8 @@
public enum Model {
/**
* The RGB model is a color model with 3 components that
- * refer to the three additive primiaries: red, green
- * andd blue.
+ * refer to the three additive primaries: red, green
+ * and blue.
*/
RGB(3),
/**
@@ -2405,7 +2405,7 @@
* does not need to be specified and is assumed to be 1.0. Only the xy components
* are required.</p>
*
- * <p class="note">The ID, areturned by {@link #getId()}, of an object created by
+ * <p class="note">The ID, as returned by {@link #getId()}, of an object created by
* this constructor is always {@link #MIN_ID}.</p>
*
* @param name Name of the color space, cannot be null, its length must be >= 1
@@ -3832,7 +3832,7 @@
*
* <p>We can only connect color spaces if they use the same profile
* connection space. We assume the connection space is always
- * CIE XYZ but we maye need to perform a chromatic adaptation to
+ * CIE XYZ but we maybe need to perform a chromatic adaptation to
* match the white points. If an adaptation is needed, we use the
* CIE standard illuminant D50. The unmatched color space is adapted
* using the von Kries transform and the {@link Adaptation#BRADFORD}
diff --git a/libs/hwui/jni/fonts/Font.cpp b/libs/hwui/jni/fonts/Font.cpp
index 09be630..d78df3d 100644
--- a/libs/hwui/jni/fonts/Font.cpp
+++ b/libs/hwui/jni/fonts/Font.cpp
@@ -105,8 +105,9 @@
std::move(data), std::string_view(fontPath.c_str(), fontPath.size()),
fontPtr, fontSize, ttcIndex, builder->axes);
if (minikinFont == nullptr) {
- jniThrowException(env, "java/lang/IllegalArgumentException",
- "Failed to create internal object. maybe invalid font data.");
+ jniThrowExceptionFmt(env, "java/lang/IllegalArgumentException",
+ "Failed to create internal object. maybe invalid font data. filePath %s",
+ fontPath.c_str());
return 0;
}
uint32_t localeListId = minikin::registerLocaleList(langTagStr.c_str());
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
index c8187b8..8b2eebe 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
@@ -208,7 +208,7 @@
synchronized (mProfileLock) {
if (profile instanceof A2dpProfile || profile instanceof HeadsetProfile
- || profile instanceof HearingAidProfile) {
+ || profile instanceof HearingAidProfile || profile instanceof LeAudioProfile) {
setProfileConnectedStatus(profile.getProfileId(), false);
switch (newProfileState) {
case BluetoothProfile.STATE_CONNECTED:
@@ -226,7 +226,20 @@
case BluetoothProfile.STATE_DISCONNECTED:
if (mHandler.hasMessages(profile.getProfileId())) {
mHandler.removeMessages(profile.getProfileId());
- setProfileConnectedStatus(profile.getProfileId(), true);
+ if (profile.getConnectionPolicy(mDevice) >
+ BluetoothProfile.CONNECTION_POLICY_FORBIDDEN) {
+ /*
+ * If we received state DISCONNECTED and previous state was
+ * CONNECTING and connection policy is FORBIDDEN or UNKNOWN
+ * then it's not really a failure to connect.
+ *
+ * Connection profile is considered as failed when connection
+ * policy indicates that profile should be connected
+ * but it got disconnected.
+ */
+ Log.w(TAG, "onProfileStateChanged(): Failed to connect profile");
+ setProfileConnectedStatus(profile.getProfileId(), true);
+ }
}
break;
default:
@@ -1188,6 +1201,13 @@
}
private boolean isProfileConnectedFail() {
+ Log.d(TAG, "anonymizedAddress=" + mDevice.getAnonymizedAddress()
+ + " mIsA2dpProfileConnectedFail=" + mIsA2dpProfileConnectedFail
+ + " mIsHearingAidProfileConnectedFail=" + mIsHearingAidProfileConnectedFail
+ + " mIsLeAudioProfileConnectedFail=" + mIsLeAudioProfileConnectedFail
+ + " mIsHeadsetProfileConnectedFail=" + mIsHeadsetProfileConnectedFail
+ + " isConnectedSapDevice()=" + isConnectedSapDevice());
+
return mIsA2dpProfileConnectedFail || mIsHearingAidProfileConnectedFail
|| (!isConnectedSapDevice() && mIsHeadsetProfileConnectedFail)
|| mIsLeAudioProfileConnectedFail;
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java
index 315ab0a..df3861a 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java
@@ -74,6 +74,8 @@
@Mock
private HearingAidProfile mHearingAidProfile;
@Mock
+ private LeAudioProfile mLeAudioProfile;
+ @Mock
private BluetoothDevice mDevice;
@Mock
private BluetoothDevice mSubDevice;
@@ -92,15 +94,76 @@
mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
when(mDevice.getAddress()).thenReturn(DEVICE_ADDRESS);
when(mHfpProfile.isProfileReady()).thenReturn(true);
+ when(mHfpProfile.getProfileId()).thenReturn(BluetoothProfile.HEADSET);
when(mA2dpProfile.isProfileReady()).thenReturn(true);
+ when(mA2dpProfile.getProfileId()).thenReturn(BluetoothProfile.A2DP);
when(mPanProfile.isProfileReady()).thenReturn(true);
+ when(mPanProfile.getProfileId()).thenReturn(BluetoothProfile.PAN);
when(mHearingAidProfile.isProfileReady()).thenReturn(true);
+ when(mHearingAidProfile.getProfileId()).thenReturn(BluetoothProfile.HEARING_AID);
+ when(mLeAudioProfile.isProfileReady()).thenReturn(true);
+ when(mLeAudioProfile.getProfileId()).thenReturn(BluetoothProfile.LE_AUDIO);
mCachedDevice = spy(new CachedBluetoothDevice(mContext, mProfileManager, mDevice));
mSubCachedDevice = spy(new CachedBluetoothDevice(mContext, mProfileManager, mSubDevice));
doAnswer((invocation) -> mBatteryLevel).when(mCachedDevice).getBatteryLevel();
doAnswer((invocation) -> mBatteryLevel).when(mSubCachedDevice).getBatteryLevel();
}
+ private void testTransitionFromConnectingToDisconnected(
+ LocalBluetoothProfile connectingProfile, LocalBluetoothProfile connectedProfile,
+ int connectionPolicy, String expectedSummary) {
+ // Arrange:
+ // At least one profile has to be connected
+ updateProfileStatus(connectedProfile, BluetoothProfile.STATE_CONNECTED);
+ // Set profile under test to CONNECTING
+ updateProfileStatus(connectingProfile, BluetoothProfile.STATE_CONNECTING);
+ // Set connection policy
+ when(connectingProfile.getConnectionPolicy(mDevice)).thenReturn(connectionPolicy);
+
+ // Act & Assert:
+ // Get the expected connection summary.
+ updateProfileStatus(connectingProfile, BluetoothProfile.STATE_DISCONNECTED);
+ assertThat(mCachedDevice.getConnectionSummary()).isEqualTo(expectedSummary);
+ }
+
+ @Test
+ public void onProfileStateChanged_testConnectingToDisconnected_policyAllowed_problem() {
+ String connectTimeoutString = mContext.getString(R.string.profile_connect_timeout_subtext);
+
+ testTransitionFromConnectingToDisconnected(mA2dpProfile, mLeAudioProfile,
+ BluetoothProfile.CONNECTION_POLICY_ALLOWED, connectTimeoutString);
+ testTransitionFromConnectingToDisconnected(mHearingAidProfile, mLeAudioProfile,
+ BluetoothProfile.CONNECTION_POLICY_ALLOWED, connectTimeoutString);
+ testTransitionFromConnectingToDisconnected(mHfpProfile, mLeAudioProfile,
+ BluetoothProfile.CONNECTION_POLICY_ALLOWED, connectTimeoutString);
+ testTransitionFromConnectingToDisconnected(mLeAudioProfile, mA2dpProfile,
+ BluetoothProfile.CONNECTION_POLICY_ALLOWED, connectTimeoutString);
+ }
+
+ @Test
+ public void onProfileStateChanged_testConnectingToDisconnected_policyForbidden_noProblem() {
+ testTransitionFromConnectingToDisconnected(mA2dpProfile, mLeAudioProfile,
+ BluetoothProfile.CONNECTION_POLICY_FORBIDDEN, null);
+ testTransitionFromConnectingToDisconnected(mHearingAidProfile, mLeAudioProfile,
+ BluetoothProfile.CONNECTION_POLICY_FORBIDDEN, null);
+ testTransitionFromConnectingToDisconnected(mHfpProfile, mLeAudioProfile,
+ BluetoothProfile.CONNECTION_POLICY_FORBIDDEN, null);
+ testTransitionFromConnectingToDisconnected(mLeAudioProfile, mA2dpProfile,
+ BluetoothProfile.CONNECTION_POLICY_FORBIDDEN, null);
+ }
+
+ @Test
+ public void onProfileStateChanged_testConnectingToDisconnected_policyUnknown_noProblem() {
+ testTransitionFromConnectingToDisconnected(mA2dpProfile, mLeAudioProfile,
+ BluetoothProfile.CONNECTION_POLICY_UNKNOWN, null);
+ testTransitionFromConnectingToDisconnected(mHearingAidProfile, mLeAudioProfile,
+ BluetoothProfile.CONNECTION_POLICY_UNKNOWN, null);
+ testTransitionFromConnectingToDisconnected(mHfpProfile, mLeAudioProfile,
+ BluetoothProfile.CONNECTION_POLICY_UNKNOWN, null);
+ testTransitionFromConnectingToDisconnected(mLeAudioProfile, mA2dpProfile,
+ BluetoothProfile.CONNECTION_POLICY_UNKNOWN, null);
+ }
+
@Test
public void getConnectionSummary_testProfilesInactive_returnPairing() {
// Arrange:
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index 7eb2cf7..a69d3f0 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -565,11 +565,10 @@
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/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index e2c4cbd..dcf1906 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -1650,15 +1650,7 @@
mContext, 0, snoozeIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
final Intent viewIntent = buildViewDataUsageIntent(res, policy.template);
- // TODO: Resolve to single code path.
- if (UserManager.isHeadlessSystemUserMode()) {
- builder.setContentIntent(PendingIntent.getActivityAsUser(
- mContext, 0, viewIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE,
- /* options= */ null, UserHandle.CURRENT));
- } else {
- builder.setContentIntent(PendingIntent.getActivity(
- mContext, 0, viewIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
- }
+ setContentIntent(builder, viewIntent);
break;
}
case TYPE_LIMIT: {
@@ -1679,15 +1671,7 @@
builder.setSmallIcon(R.drawable.stat_notify_disabled_data);
final Intent intent = buildNetworkOverLimitIntent(res, policy.template);
- // TODO: Resolve to single code path.
- if (UserManager.isHeadlessSystemUserMode()) {
- builder.setContentIntent(PendingIntent.getActivityAsUser(
- mContext, 0, intent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE,
- /* options= */ null, UserHandle.CURRENT));
- } else {
- builder.setContentIntent(PendingIntent.getActivity(
- mContext, 0, intent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
- }
+ setContentIntent(builder, intent);
break;
}
case TYPE_LIMIT_SNOOZED: {
@@ -1711,15 +1695,7 @@
builder.setChannelId(SystemNotificationChannels.NETWORK_STATUS);
final Intent intent = buildViewDataUsageIntent(res, policy.template);
- // TODO: Resolve to single code path.
- if (UserManager.isHeadlessSystemUserMode()) {
- builder.setContentIntent(PendingIntent.getActivityAsUser(
- mContext, 0, intent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE,
- /* options= */ null, UserHandle.CURRENT));
- } else {
- builder.setContentIntent(PendingIntent.getActivity(
- mContext, 0, intent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
- }
+ setContentIntent(builder, intent);
break;
}
case TYPE_RAPID: {
@@ -1739,15 +1715,7 @@
mContext, 0, snoozeIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
final Intent viewIntent = buildViewDataUsageIntent(res, policy.template);
- // TODO: Resolve to single code path.
- if (UserManager.isHeadlessSystemUserMode()) {
- builder.setContentIntent(PendingIntent.getActivityAsUser(
- mContext, 0, viewIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE,
- /* options= */ null, UserHandle.CURRENT));
- } else {
- builder.setContentIntent(PendingIntent.getActivity(
- mContext, 0, viewIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
- }
+ setContentIntent(builder, viewIntent);
break;
}
default: {
@@ -1765,6 +1733,17 @@
mActiveNotifs.add(notificationId);
}
+ private void setContentIntent(Notification.Builder builder, Intent intent) {
+ if (UserManager.isHeadlessSystemUserMode()) {
+ builder.setContentIntent(PendingIntent.getActivityAsUser(
+ mContext, 0, intent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE,
+ /* options= */ null, UserHandle.CURRENT));
+ } else {
+ builder.setContentIntent(PendingIntent.getActivity(
+ mContext, 0, intent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
+ }
+ }
+
private void cancelNotification(NotificationId notificationId) {
mContext.getSystemService(NotificationManager.class).cancel(notificationId.getTag(),
notificationId.getId());
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index b8486e7..cae0234 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -557,6 +557,8 @@
Drawable mEnterpriseThumbnailDrawable;
+ boolean mPauseSchedulePendingForPip = false;
+
private void updateEnterpriseThumbnailDrawable(Context context) {
DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
mEnterpriseThumbnailDrawable = dpm.getResources().getDrawable(
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 12714ed..14927f9 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -3583,7 +3583,7 @@
null /* launchIntoPipHostActivity */, "enterPictureInPictureMode",
transition);
// Continue the pausing process after entering pip.
- if (r.isState(PAUSING)) {
+ if (r.isState(PAUSING) && r.mPauseSchedulePendingForPip) {
r.getTask().schedulePauseActivity(r, false /* userLeaving */,
false /* pauseImmediately */, true /* autoEnteringPip */, "auto-pip");
}
diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java
index 1a3e7d1..ab979ad 100644
--- a/services/core/java/com/android/server/wm/TaskFragment.java
+++ b/services/core/java/com/android/server/wm/TaskFragment.java
@@ -1619,6 +1619,7 @@
if (prev.attachedToProcess()) {
if (shouldAutoPip) {
+ prev.mPauseSchedulePendingForPip = true;
boolean didAutoPip = mAtmService.enterPictureInPictureMode(
prev, prev.pictureInPictureArgs, false /* fromClient */);
ProtoLog.d(WM_DEBUG_STATES, "Auto-PIP allowed, entering PIP mode "
@@ -1682,6 +1683,7 @@
boolean pauseImmediately, boolean autoEnteringPip, String reason) {
ProtoLog.v(WM_DEBUG_STATES, "Enqueueing pending pause: %s", prev);
try {
+ prev.mPauseSchedulePendingForPip = false;
EventLogTags.writeWmPauseActivity(prev.mUserId, System.identityHashCode(prev),
prev.shortComponentName, "userLeaving=" + userLeaving, reason);
diff --git a/telephony/java/android/service/carrier/CarrierService.java b/telephony/java/android/service/carrier/CarrierService.java
index ae91d4d..1c53148 100644
--- a/telephony/java/android/service/carrier/CarrierService.java
+++ b/telephony/java/android/service/carrier/CarrierService.java
@@ -28,8 +28,6 @@
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 @@
@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/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index fc7298e..5ad5001 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -8574,6 +8574,16 @@
public static final String KEY_VONR_ENABLED_BOOL = "vonr_enabled_bool";
/**
+ * Boolean indicating the default VoNR user preference setting.
+ * If true, the VoNR setting will be enabled. If false, it will be disabled initially.
+ *
+ * Enabled by default.
+ *
+ * @hide
+ */
+ public static final String KEY_VONR_ON_BY_DEFAULT_BOOL = "vonr_on_by_default_bool";
+
+ /**
* Determine whether unthrottle data retry when tracking area code (TAC/LAC) from cell changes
*
* @hide
@@ -9254,6 +9264,7 @@
sDefaults.putBoolean(KEY_UNTHROTTLE_DATA_RETRY_WHEN_TAC_CHANGES_BOOL, false);
sDefaults.putBoolean(KEY_VONR_SETTING_VISIBILITY_BOOL, true);
sDefaults.putBoolean(KEY_VONR_ENABLED_BOOL, false);
+ sDefaults.putBoolean(KEY_VONR_ON_BY_DEFAULT_BOOL, true);
sDefaults.putStringArray(KEY_IWLAN_HANDOVER_POLICY_STRING_ARRAY, new String[]{
"source=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN, "
+ "target=GERAN|UTRAN|EUTRAN|NGRAN|IWLAN, type=allowed"});
diff --git a/telephony/java/android/telephony/SubscriptionInfo.java b/telephony/java/android/telephony/SubscriptionInfo.java
index e055f63..2ddc98a 100644
--- a/telephony/java/android/telephony/SubscriptionInfo.java
+++ b/telephony/java/android/telephony/SubscriptionInfo.java
@@ -649,6 +649,15 @@
}
/**
+ * @return {@code true} if the subscription is from the actively used SIM.
+ *
+ * @hide
+ */
+ public boolean isActive() {
+ return mSimSlotIndex >= 0 || mType == SubscriptionManager.SUBSCRIPTION_TYPE_REMOTE_SIM;
+ }
+
+ /**
* Used in scenarios where different subscriptions are bundled as a group.
* It's typically a primary and an opportunistic subscription. (see {@link #isOpportunistic()})
* Such that those subscriptions will have some affiliated behaviors such as opportunistic
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index 10032ed..5c1a006 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -155,6 +155,10 @@
private static final String CACHE_KEY_SLOT_INDEX_PROPERTY =
"cache_key.telephony.get_slot_index";
+ /** The IPC cache key shared by all subscription manager service cacheable properties. */
+ private static final String CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY =
+ "cache_key.telephony.subscription_manager_service";
+
/** @hide */
public static final String GET_SIM_SPECIFIC_SETTINGS_METHOD_NAME = "getSimSpecificSettings";
@@ -246,32 +250,72 @@
CACHE_KEY_DEFAULT_SUB_ID_PROPERTY,
INVALID_SUBSCRIPTION_ID);
+ private static VoidPropertyInvalidatedCache<Integer> sGetDefaultSubIdCache =
+ new VoidPropertyInvalidatedCache<>(ISub::getDefaultSubId,
+ CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
+ INVALID_SUBSCRIPTION_ID);
+
private static VoidPropertyInvalidatedCache<Integer> sDefaultDataSubIdCache =
new VoidPropertyInvalidatedCache<>(ISub::getDefaultDataSubId,
CACHE_KEY_DEFAULT_DATA_SUB_ID_PROPERTY,
INVALID_SUBSCRIPTION_ID);
+ private static VoidPropertyInvalidatedCache<Integer> sGetDefaultDataSubIdCache =
+ new VoidPropertyInvalidatedCache<>(ISub::getDefaultDataSubId,
+ CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
+ INVALID_SUBSCRIPTION_ID);
+
private static VoidPropertyInvalidatedCache<Integer> sDefaultSmsSubIdCache =
new VoidPropertyInvalidatedCache<>(ISub::getDefaultSmsSubId,
CACHE_KEY_DEFAULT_SMS_SUB_ID_PROPERTY,
INVALID_SUBSCRIPTION_ID);
+ private static VoidPropertyInvalidatedCache<Integer> sGetDefaultSmsSubIdCache =
+ new VoidPropertyInvalidatedCache<>(ISub::getDefaultSmsSubId,
+ CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
+ INVALID_SUBSCRIPTION_ID);
+
private static VoidPropertyInvalidatedCache<Integer> sActiveDataSubIdCache =
new VoidPropertyInvalidatedCache<>(ISub::getActiveDataSubscriptionId,
CACHE_KEY_ACTIVE_DATA_SUB_ID_PROPERTY,
INVALID_SUBSCRIPTION_ID);
+ private static VoidPropertyInvalidatedCache<Integer> sGetActiveDataSubscriptionIdCache =
+ new VoidPropertyInvalidatedCache<>(ISub::getActiveDataSubscriptionId,
+ CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
+ INVALID_SUBSCRIPTION_ID);
+
private static IntegerPropertyInvalidatedCache<Integer> sSlotIndexCache =
new IntegerPropertyInvalidatedCache<>(ISub::getSlotIndex,
CACHE_KEY_SLOT_INDEX_PROPERTY,
INVALID_SIM_SLOT_INDEX);
+ private static IntegerPropertyInvalidatedCache<Integer> sGetSlotIndexCache =
+ new IntegerPropertyInvalidatedCache<>(ISub::getSlotIndex,
+ CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
+ INVALID_SIM_SLOT_INDEX);
+
+ private static IntegerPropertyInvalidatedCache<Integer> sSubIdCache =
+ new IntegerPropertyInvalidatedCache<>(ISub::getSubId,
+ CACHE_KEY_SLOT_INDEX_PROPERTY,
+ INVALID_SUBSCRIPTION_ID);
+
+ private static IntegerPropertyInvalidatedCache<Integer> sGetSubIdCache =
+ new IntegerPropertyInvalidatedCache<>(ISub::getSubId,
+ CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
+ INVALID_SUBSCRIPTION_ID);
+
/** Cache depends on getDefaultSubId, so we use the defaultSubId cache key */
private static IntegerPropertyInvalidatedCache<Integer> sPhoneIdCache =
new IntegerPropertyInvalidatedCache<>(ISub::getPhoneId,
CACHE_KEY_DEFAULT_SUB_ID_PROPERTY,
INVALID_PHONE_INDEX);
+ private static IntegerPropertyInvalidatedCache<Integer> sGetPhoneIdCache =
+ new IntegerPropertyInvalidatedCache<>(ISub::getPhoneId,
+ CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY,
+ INVALID_PHONE_INDEX);
+
/**
* Generates a content {@link Uri} used to receive updates on simInfo change
* on the given subscriptionId
@@ -1270,6 +1314,8 @@
private final Context mContext;
+ private static boolean sIsSubscriptionManagerServiceEnabled = false;
+
// Cache of Resource that has been created in getResourcesForSubId. Key is a Pair containing
// the Context and subId.
private static final Map<Pair<Context, Integer>, Resources> sResourcesCache =
@@ -1355,6 +1401,19 @@
public SubscriptionManager(Context context) {
if (DBG) logd("SubscriptionManager created");
mContext = context;
+
+ sIsSubscriptionManagerServiceEnabled = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_using_subscription_manager_service);
+ }
+
+ /**
+ * @return {@code true} if the new subscription manager service is used. This is temporary and
+ * will be removed before Android 14 release.
+ *
+ * @hide
+ */
+ public static boolean isSubscriptionManagerServiceEnabled() {
+ return sIsSubscriptionManagerServiceEnabled;
}
private NetworkPolicyManager getNetworkPolicyManager() {
@@ -1635,17 +1694,33 @@
}
/**
- * @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) {
@@ -2114,6 +2189,7 @@
* subscriptionId doesn't have an associated slot index.
*/
public static int getSlotIndex(int subscriptionId) {
+ if (isSubscriptionManagerServiceEnabled()) return sGetSlotIndexCache.query(subscriptionId);
return sSlotIndexCache.query(subscriptionId);
}
@@ -2125,7 +2201,7 @@
*/
@Nullable
public int[] getSubscriptionIds(int slotIndex) {
- return getSubId(slotIndex);
+ return new int[]{getSubscriptionId(slotIndex)};
}
/** @hide */
@@ -2141,7 +2217,7 @@
try {
ISub iSub = TelephonyManager.getSubscriptionService();
if (iSub != null) {
- subId = iSub.getSubId(slotIndex);
+ subId = iSub.getSubIds(slotIndex);
}
} catch (RemoteException ex) {
// ignore it
@@ -2150,9 +2226,27 @@
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;
+ }
+
+ if (isSubscriptionManagerServiceEnabled()) return sGetSubIdCache.query(slotIndex);
+ return sSubIdCache.query(slotIndex);
+ }
+
/** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public static int getPhoneId(int subId) {
+ if (isSubscriptionManagerServiceEnabled()) return sGetPhoneIdCache.query(subId);
return sPhoneIdCache.query(subId);
}
@@ -2174,6 +2268,7 @@
* @return the "system" default subscription id.
*/
public static int getDefaultSubscriptionId() {
+ if (isSubscriptionManagerServiceEnabled()) return sGetDefaultSubIdCache.query(null);
return sDefaultSubIdCache.query(null);
}
@@ -2262,6 +2357,7 @@
* @return the default SMS subscription Id.
*/
public static int getDefaultSmsSubscriptionId() {
+ if (isSubscriptionManagerServiceEnabled()) return sGetDefaultSmsSubIdCache.query(null);
return sDefaultSmsSubIdCache.query(null);
}
@@ -2296,6 +2392,7 @@
* @return the default data subscription Id.
*/
public static int getDefaultDataSubscriptionId() {
+ if (isSubscriptionManagerServiceEnabled()) return sGetDefaultDataSubIdCache.query(null);
return sDefaultDataSubIdCache.query(null);
}
@@ -2404,9 +2501,9 @@
/** @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 +3476,6 @@
/**
* 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.
@@ -3759,6 +3855,9 @@
* SubscriptionManager.INVALID_SUBSCRIPTION_ID if not.
*/
public static int getActiveDataSubscriptionId() {
+ if (isSubscriptionManagerServiceEnabled()) {
+ return sGetActiveDataSubscriptionIdCache.query(null);
+ }
return sActiveDataSubIdCache.query(null);
}
@@ -3802,6 +3901,11 @@
PropertyInvalidatedCache.invalidateCache(CACHE_KEY_SLOT_INDEX_PROPERTY);
}
+ /** @hide */
+ public static void invalidateSubscriptionManagerServiceCaches() {
+ PropertyInvalidatedCache.invalidateCache(CACHE_KEY_SUBSCRIPTION_MANAGER_SERVICE_PROPERTY);
+ }
+
/**
* Allows a test process to disable client-side caching operations.
*
@@ -3813,7 +3917,16 @@
sActiveDataSubIdCache.disableLocal();
sDefaultSmsSubIdCache.disableLocal();
sSlotIndexCache.disableLocal();
+ sSubIdCache.disableLocal();
sPhoneIdCache.disableLocal();
+
+ sGetDefaultSubIdCache.disableLocal();
+ sGetDefaultDataSubIdCache.disableLocal();
+ sGetActiveDataSubscriptionIdCache.disableLocal();
+ sGetDefaultSmsSubIdCache.disableLocal();
+ sGetSlotIndexCache.disableLocal();
+ sGetSubIdCache.disableLocal();
+ sGetPhoneIdCache.disableLocal();
}
/**
@@ -3826,7 +3939,16 @@
sActiveDataSubIdCache.clear();
sDefaultSmsSubIdCache.clear();
sSlotIndexCache.clear();
+ sSubIdCache.clear();
sPhoneIdCache.clear();
+
+ sGetDefaultSubIdCache.clear();
+ sGetDefaultDataSubIdCache.clear();
+ sGetActiveDataSubscriptionIdCache.clear();
+ sGetDefaultSmsSubIdCache.clear();
+ sGetSlotIndexCache.clear();
+ sGetSubIdCache.clear();
+ sGetPhoneIdCache.clear();
}
/**
@@ -4076,6 +4198,26 @@
}
/**
+ * 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 +4297,18 @@
*/
@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 +4333,18 @@
*/
@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 1654848..7a19d36 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -2375,47 +2375,6 @@
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 @@
}
}
- /**
- * @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. */
diff --git a/telephony/java/com/android/internal/telephony/ISub.aidl b/telephony/java/com/android/internal/telephony/ISub.aidl
old mode 100755
new mode 100644
index 0211a7f..5173405
--- a/telephony/java/com/android/internal/telephony/ISub.aidl
+++ b/telephony/java/com/android/internal/telephony/ISub.aidl
@@ -114,14 +114,6 @@
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 @@
int getSlotIndex(int subId);
- int[] getSubId(int slotIndex);
+ int[] getSubIds(int slotIndex);
+
+ int getSubId(int slotIndex);
int getDefaultSubId();
@@ -323,22 +317,20 @@
*
* @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);
}