Merge "Daggerify and Dumpify LockscreenWallpaper"
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..03af56d
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,13 @@
+BasedOnStyle: Google
+
+AccessModifierOffset: -4
+AlignOperands: false
+AllowShortFunctionsOnASingleLine: Inline
+AlwaysBreakBeforeMultilineStrings: false
+ColumnLimit: 100
+CommentPragmas: NOLINT:.*
+ConstructorInitializerIndentWidth: 6
+ContinuationIndentWidth: 8
+IndentWidth: 4
+PenaltyBreakBeforeFirstCallParameter: 100000
+SpacesBeforeTrailingComments: 1
diff --git a/Android.bp b/Android.bp
index 04b4e6e..21552695 100644
--- a/Android.bp
+++ b/Android.bp
@@ -200,32 +200,9 @@
}
filegroup {
- name: "framework-wifi-sources",
- srcs: [
- "wifi/java/**/*.java",
- "wifi/java/**/*.aidl",
- ],
- exclude_srcs: [
- ":framework-wifi-non-updatable-sources"
- ],
- path: "wifi/java",
-}
-
-filegroup {
- name: "framework-wifi-non-updatable-sources",
- srcs: [
- // TODO(b/146011398) package android.net.wifi is now split amongst 2 jars: framework.jar and
- // framework-wifi.jar. This is not a good idea, should move WifiNetworkScoreCache
- // to a separate package.
- "wifi/java/android/net/wifi/WifiNetworkScoreCache.java"
- ],
-}
-
-filegroup {
name: "framework-non-updatable-sources",
srcs: [
// Java/AIDL sources under frameworks/base
- ":framework-appsearch-sources",
":framework-blobstore-sources",
":framework-core-sources",
":framework-drm-sources",
@@ -245,7 +222,7 @@
":framework-telecomm-sources",
":framework-telephony-common-sources",
":framework-telephony-sources",
- ":framework-wifi-sources",
+ ":framework-wifi-annotations",
":framework-wifi-non-updatable-sources",
":PacProcessor-aidl-sources",
":ProxyHandler-aidl-sources",
@@ -284,8 +261,11 @@
filegroup {
name: "framework-updatable-sources",
srcs: [
+ ":framework-appsearch-sources",
":framework-sdkext-sources",
+ ":framework-statsd-sources",
":updatable-media-srcs",
+ ":framework-wifi-updatable-sources",
]
}
@@ -371,6 +351,9 @@
"com.android.sysprop.apex",
"PlatformProperties",
],
+ aidl: {
+ include_dirs: ["system/connectivity/wificond/aidl"],
+ },
sdk_version: "core_platform",
installable: false,
}
@@ -418,7 +401,7 @@
filegroup {
name: "framework-jarjar-rules",
- srcs: ["jarjar_rules_hidl.txt"],
+ srcs: ["framework-jarjar-rules.txt"],
}
filegroup {
@@ -443,6 +426,12 @@
name: "framework-minus-apex",
defaults: ["framework-defaults"],
srcs: [":framework-non-updatable-sources"],
+ libs: [
+ "framework-appsearch-stubs",
+ // TODO(b/146167933): Use framework-statsd-stubs
+ "framework-statsd",
+ "framework-wifi-stubs",
+ ],
installable: true,
javac_shard_size: 150,
required: [
@@ -478,7 +467,13 @@
installable: false, // this lib is a build-only library
static_libs: [
"framework-minus-apex",
- // TODO(jiyong): add stubs for APEXes here
+ "framework-appsearch", // TODO(b/146218515): should be framework-appsearch-stubs
+ "framework-sdkext-stubs-systemapi",
+ // TODO(b/146167933): Use framework-statsd-stubs instead.
+ "framework-statsd",
+ // TODO(b/140299412): should be framework-wifi-stubs
+ "framework-wifi",
+ // TODO(jiyong): add more stubs for APEXes here
],
sdk_version: "core_platform",
apex_available: ["//apex_available:platform"],
@@ -804,8 +799,8 @@
filegroup {
name: "incremental_aidl",
srcs: [
+ "core/java/android/os/incremental/IIncrementalManagerNative.aidl",
"core/java/android/os/incremental/IIncrementalManager.aidl",
- "core/java/android/os/incremental/IIncrementalServiceProxy.aidl",
"core/java/android/os/incremental/IncrementalDataLoaderParamsParcel.aidl",
"core/java/android/os/incremental/IncrementalFileSystemControlParcel.aidl",
"core/java/android/os/incremental/NamedParcelFileDescriptor.aidl",
@@ -1172,7 +1167,7 @@
arg_files: [
"core/res/AndroidManifest.xml",
],
- args: metalava_framework_docs_args + " --show-annotation android.annotation.SystemApi ",
+ args: metalava_framework_docs_args + " --show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.PRIVILEGED_APPS,process=android.annotation.SystemApi.Process.ALL\\) ",
write_sdk_values: true,
}
@@ -1483,7 +1478,7 @@
merge_annotations_dirs: [
"metalava-manual",
],
- args: " --show-annotation android.annotation.SystemApi",
+ args: " --show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.PRIVILEGED_APPS,process=android.annotation.SystemApi.Process.ALL\\)",
}
java_library_static {
@@ -1505,7 +1500,7 @@
removed_dex_api_filename: "removed-dex.txt",
args: metalava_framework_docs_args +
" --show-unannotated " +
- " --show-annotation android.annotation.SystemApi " +
+ " --show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.PRIVILEGED_APPS,process=android.annotation.SystemApi.Process.ALL\\) " +
" --show-annotation android.annotation.TestApi ",
}
@@ -1524,7 +1519,7 @@
" --hide ReferencesHidden " +
" --hide UnhiddenSystemApi " +
" --show-unannotated " +
- " --show-annotation android.annotation.SystemApi " +
+ " --show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.PRIVILEGED_APPS,process=android.annotation.SystemApi.Process.ALL\\) " +
" --show-annotation android.annotation.TestApi ",
}
@@ -1568,7 +1563,7 @@
arg_files: [
"core/res/AndroidManifest.xml",
],
- args: metalava_framework_docs_args + " --show-annotation android.annotation.SystemApi",
+ args: metalava_framework_docs_args + " --show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.PRIVILEGED_APPS,process=android.annotation.SystemApi.Process.ALL\\)",
check_api: {
current: {
api_file: "api/system-current.txt",
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 8fac394..f94de29 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -256,6 +256,7 @@
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/ext.jar)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/telephony/java/com/google/android/mms)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/*-service.jar)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/service-statsd.jar)
# ******************************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST ABOVE THIS BANNER
# ******************************************************************
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index 6831117..78e72bf 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -1,3 +1,13 @@
+[Builtin Hooks]
+clang_format = true
+
+[Builtin Hooks Options]
+# Only turn on clang-format check for the following subfolders.
+clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp
+ cmds/hid/
+ cmds/input/
+ libs/input/
+
[Hook Scripts]
checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
diff --git a/apct-tests/perftests/core/src/android/wm/InternalWindowOperationPerfTest.java b/apct-tests/perftests/core/src/android/wm/InternalWindowOperationPerfTest.java
index c096cd2..4ed3b4e 100644
--- a/apct-tests/perftests/core/src/android/wm/InternalWindowOperationPerfTest.java
+++ b/apct-tests/perftests/core/src/android/wm/InternalWindowOperationPerfTest.java
@@ -95,7 +95,7 @@
mTraceMarkParser.forAllSlices((key, slices) -> {
for (TraceMarkSlice slice : slices) {
- state.addExtraResult(key, (long) (slice.getDurarionInSeconds() * NANOS_PER_S));
+ state.addExtraResult(key, (long) (slice.getDurationInSeconds() * NANOS_PER_S));
}
});
diff --git a/apct-tests/perftests/utils/src/android/perftests/utils/ManualBenchmarkState.java b/apct-tests/perftests/utils/src/android/perftests/utils/ManualBenchmarkState.java
index b075239..fe2b1f6 100644
--- a/apct-tests/perftests/utils/src/android/perftests/utils/ManualBenchmarkState.java
+++ b/apct-tests/perftests/utils/src/android/perftests/utils/ManualBenchmarkState.java
@@ -23,11 +23,15 @@
import android.util.ArrayMap;
import android.util.Log;
+import com.android.internal.util.ArrayUtils;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import java.util.concurrent.TimeUnit;
/**
@@ -140,6 +144,8 @@
/** @see #addExtraResult(String, long) */
private ArrayMap<String, ArrayList<Long>> mExtraResults;
+ private final List<Long> mTmpDurations = Arrays.asList(0L);
+
// Statistics. These values will be filled when the benchmark has finished.
// The computation needs double precision, but long int is fine for final reporting.
private Stats mStats;
@@ -188,14 +194,25 @@
if (duration < 0) {
throw new RuntimeException("duration is negative: " + duration);
}
+ mTmpDurations.set(0, duration);
+ return keepRunning(mTmpDurations);
+ }
+
+ /**
+ * Similar to the {@link #keepRunning(long)} but accepts a list of durations
+ */
+ public boolean keepRunning(List<Long> durations) {
switch (mState) {
case NOT_STARTED:
mState = WARMUP;
mWarmupStartTime = System.nanoTime();
return true;
case WARMUP: {
+ if (ArrayUtils.isEmpty(durations)) {
+ return true;
+ }
final long timeSinceStartingWarmup = System.nanoTime() - mWarmupStartTime;
- ++mWarmupIterations;
+ mWarmupIterations += durations.size();
if (mWarmupIterations >= WARMUP_MIN_ITERATIONS
&& timeSinceStartingWarmup >= mWarmupDurationNs) {
beginBenchmark(timeSinceStartingWarmup, mWarmupIterations);
@@ -203,7 +220,10 @@
return true;
}
case RUNNING: {
- mResults.add(duration);
+ if (ArrayUtils.isEmpty(durations)) {
+ return true;
+ }
+ mResults.addAll(durations);
final boolean keepRunning = mResults.size() < mMaxIterations;
if (!keepRunning) {
mStats = new Stats(mResults);
diff --git a/apct-tests/perftests/utils/src/android/perftests/utils/TraceMarkParser.java b/apct-tests/perftests/utils/src/android/perftests/utils/TraceMarkParser.java
index 1afed3a..b15b6f6 100644
--- a/apct-tests/perftests/utils/src/android/perftests/utils/TraceMarkParser.java
+++ b/apct-tests/perftests/utils/src/android/perftests/utils/TraceMarkParser.java
@@ -40,6 +40,8 @@
private final Predicate<TraceMarkLine> mTraceLineFilter;
+ private static final long MICROS_PER_SECOND = 1000L * 1000L;
+
public TraceMarkParser(Predicate<TraceMarkLine> traceLineFilter) {
mTraceLineFilter = traceLineFilter;
}
@@ -116,13 +118,19 @@
}
}
+ public void reset() {
+ mSlicesMap.clear();
+ mDepthMap.clear();
+ mPendingStarts.clear();
+ }
+
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
forAllSlices((key, slices) -> {
double totalMs = 0;
for (TraceMarkSlice s : slices) {
- totalMs += s.getDurarionInSeconds() * 1000;
+ totalMs += s.getDurationInSeconds() * 1000;
}
sb.append(key).append(" count=").append(slices.size()).append(" avg=")
.append(totalMs / slices.size()).append("ms\n");
@@ -134,6 +142,10 @@
return sb.toString();
}
+ static double microsecondToSeconds(long ms) {
+ return (ms * 1.0d) / MICROS_PER_SECOND;
+ }
+
public static class TraceMarkSlice {
public final TraceMarkLine begin;
public final TraceMarkLine end;
@@ -143,7 +155,11 @@
this.end = end;
}
- public double getDurarionInSeconds() {
+ public double getDurationInSeconds() {
+ return microsecondToSeconds(end.timestamp - begin.timestamp);
+ }
+
+ public long getDurationInMicroseconds() {
return end.timestamp - begin.timestamp;
}
}
@@ -164,7 +180,7 @@
static final char SYNC_END = 'E';
public final String taskPid;
- public final double timestamp;
+ public final long timestamp; // in microseconds
public final String name;
public final boolean isAsync;
public final boolean isBegin;
@@ -179,7 +195,7 @@
if (timeBegin < 0) {
throw new IllegalArgumentException("Timestamp start not found");
}
- timestamp = Double.parseDouble(rawLine.substring(timeBegin, timeEnd));
+ timestamp = parseMicroseconds(rawLine.substring(timeBegin, timeEnd));
isAsync = type == ASYNC_START || type == ASYNC_FINISH;
isBegin = type == ASYNC_START || type == SYNC_BEGIN;
@@ -223,9 +239,29 @@
return null;
}
+ /**
+ * Parse the timestamp from atrace output, the format will be like:
+ * 84962.920719 where the decimal part will be always exactly 6 digits.
+ * ^^^^^ ^^^^^^
+ * | |
+ * sec microsec
+ */
+ static long parseMicroseconds(String line) {
+ int end = line.length();
+ long t = 0;
+ for (int i = 0; i < end; i++) {
+ char c = line.charAt(i);
+ if (c >= '0' && c <= '9') {
+ t = t * 10 + (c - '0');
+ }
+ }
+ return t;
+ }
+
@Override
public String toString() {
- return "TraceMarkLine{pid=" + taskPid + " time=" + timestamp + " name=" + name
+ return "TraceMarkLine{pid=" + taskPid + " time="
+ + microsecondToSeconds(timestamp) + " name=" + name
+ " async=" + isAsync + " begin=" + isBegin + "}";
}
}
diff --git a/apex/Android.bp b/apex/Android.bp
new file mode 100644
index 0000000..56f7db2
--- /dev/null
+++ b/apex/Android.bp
@@ -0,0 +1,42 @@
+// Copyright (C) 2019 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.
+
+mainline_stubs_args =
+ "--error UnhiddenSystemApi " +
+ "--hide BroadcastBehavior " +
+ "--hide DeprecationMismatch " +
+ "--hide HiddenSuperclass " +
+ "--hide HiddenTypedefConstant " +
+ "--hide HiddenTypeParameter " +
+ "--hide MissingPermission " +
+ "--hide RequiresPermission " +
+ "--hide SdkConstant " +
+ "--hide Todo " +
+ "--hide Typo " +
+ "--hide UnavailableSymbol "
+
+// TODO: remove this server classes are cleaned up.
+mainline_stubs_args += "--hide-package com.android.server "
+
+stubs_defaults {
+ name: "framework-module-stubs-defaults-publicapi",
+ args: mainline_stubs_args,
+ installable: false,
+}
+
+stubs_defaults {
+ name: "framework-module-stubs-defaults-systemapi",
+ args: mainline_stubs_args + " --show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.PRIVILEGED_APPS,process=android.annotation.SystemApi.Process.ALL\\) ",
+ installable: false,
+}
diff --git a/apex/appsearch/Android.bp b/apex/appsearch/Android.bp
index bcdcc7d..b014fdc 100644
--- a/apex/appsearch/Android.bp
+++ b/apex/appsearch/Android.bp
@@ -14,9 +14,11 @@
apex {
name: "com.android.appsearch",
-
manifest: "apex_manifest.json",
-
+ java_libs: [
+ "framework-appsearch",
+ "service-appsearch",
+ ],
key: "com.android.appsearch.key",
certificate: ":com.android.appsearch.certificate",
}
diff --git a/apex/appsearch/framework/Android.bp b/apex/appsearch/framework/Android.bp
index 0a65f73..3dc5a2c 100644
--- a/apex/appsearch/framework/Android.bp
+++ b/apex/appsearch/framework/Android.bp
@@ -23,17 +23,52 @@
java_library {
name: "framework-appsearch",
- installable: false,
- sdk_version: "core_platform",
- srcs: [
- ":framework-appsearch-sources",
- ],
- aidl: {
- export_include_dirs: [
- "java",
- ],
- },
+ installable: true,
+ sdk_version: "core_platform", // TODO(b/146218515) should be core_current
+ srcs: [":framework-appsearch-sources"],
libs: [
- "framework-minus-apex",
+ "framework-minus-apex", // TODO(b/146218515) should be framework-system-stubs
],
}
+
+metalava_appsearch_docs_args =
+ "--hide-package com.android.server " +
+ "--error UnhiddenSystemApi " +
+ "--hide RequiresPermission " +
+ "--hide MissingPermission " +
+ "--hide BroadcastBehavior " +
+ "--hide HiddenSuperclass " +
+ "--hide DeprecationMismatch " +
+ "--hide UnavailableSymbol " +
+ "--hide SdkConstant " +
+ "--hide HiddenTypeParameter " +
+ "--hide Todo --hide Typo " +
+ "--hide HiddenTypedefConstant " +
+ "--show-annotation android.annotation.SystemApi "
+
+droidstubs {
+ name: "framework-appsearch-stubs-srcs",
+ srcs: [
+ ":framework-annotations",
+ ":framework-appsearch-sources",
+ ],
+ aidl: {
+ include_dirs: ["frameworks/base/core/java"],
+ },
+ args: metalava_appsearch_docs_args,
+ sdk_version: "core_current",
+ libs: ["android_system_stubs_current"],
+}
+
+java_library {
+ name: "framework-appsearch-stubs",
+ srcs: [":framework-appsearch-stubs-srcs"],
+ aidl: {
+ export_include_dirs: [
+ "java",
+ ],
+ },
+ sdk_version: "core_current",
+ libs: ["android_system_stubs_current"],
+ installable: false,
+}
diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchManagerFrameworkInitializer.java b/apex/appsearch/framework/java/android/app/appsearch/AppSearchManagerFrameworkInitializer.java
index fcebe3d..02cc967 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchManagerFrameworkInitializer.java
+++ b/apex/appsearch/framework/java/android/app/appsearch/AppSearchManagerFrameworkInitializer.java
@@ -15,19 +15,25 @@
*/
package android.app.appsearch;
+import android.annotation.SystemApi;
import android.app.SystemServiceRegistry;
import android.content.Context;
/**
- * This is where the AppSearchManagerService wrapper is registered.
+ * Class holding initialization code for the AppSearch module.
*
- * TODO(b/142567528): add comments when implement this class
* @hide
*/
+@SystemApi
public class AppSearchManagerFrameworkInitializer {
+ private AppSearchManagerFrameworkInitializer() {}
/**
- * TODO(b/142567528): add comments when implement this class
+ * Called by {@link SystemServiceRegistry}'s static initializer and registers all AppSearch
+ * services to {@link Context}, so that {@link Context#getSystemService} can return them.
+ *
+ * @throws IllegalStateException if this is called from anywhere besides
+ * {@link SystemServiceRegistry}
*/
public static void initialize() {
SystemServiceRegistry.registerStaticService(
diff --git a/apex/sdkext/Android.bp b/apex/sdkext/Android.bp
index aaf25b1..5369a96 100644
--- a/apex/sdkext/Android.bp
+++ b/apex/sdkext/Android.bp
@@ -12,6 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+package {
+ default_visibility: [":__subpackages__"],
+}
+
apex {
name: "com.android.sdkext",
manifest: "manifest.json",
@@ -19,12 +23,18 @@
java_libs: [ "framework-sdkext" ],
prebuilts: [
"com.android.sdkext.ldconfig",
+ "cur_sdkinfo",
"derive_sdk.rc",
],
key: "com.android.sdkext.key",
certificate: ":com.android.sdkext.certificate",
}
+sdk {
+ name: "sdkext-sdk",
+ java_libs: [ "framework-sdkext-stubs-systemapi" ],
+}
+
apex_key {
name: "com.android.sdkext.key",
public_key: "com.android.sdkext.avbpubkey",
@@ -42,3 +52,33 @@
filename: "ld.config.txt",
installable: false,
}
+
+python_binary_host {
+ name: "gen_sdkinfo",
+ srcs: [
+ "sdk.proto",
+ "gen_sdkinfo.py",
+ ],
+ proto: {
+ canonical_path_from_root: false,
+ },
+ version: {
+ py3: {
+ embedded_launcher: true,
+ },
+ },
+}
+
+gensrcs {
+ name: "cur_sdkinfo_src",
+ srcs: [""],
+ tools: [ "gen_sdkinfo" ],
+ cmd: "$(location) -v 0 -o $(out)",
+}
+
+prebuilt_etc {
+ name: "cur_sdkinfo",
+ src: ":cur_sdkinfo_src",
+ filename: "sdkinfo.binarypb",
+ installable: false,
+}
diff --git a/apex/sdkext/framework/Android.bp b/apex/sdkext/framework/Android.bp
index b17f0f8..a50dc3d 100644
--- a/apex/sdkext/framework/Android.bp
+++ b/apex/sdkext/framework/Android.bp
@@ -12,12 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+package {
+ default_visibility: [ ":__pkg__" ]
+}
+
filegroup {
name: "framework-sdkext-sources",
srcs: [
"java/**/*.java",
],
path: "java",
+ visibility: [ "//frameworks/base:__pkg__" ] // For the "global" stubs.
}
java_library {
@@ -27,4 +32,40 @@
libs: [ "framework-annotations-lib" ],
permitted_packages: [ "android.os.ext" ],
installable: true,
+ visibility: [ "//frameworks/base/apex/sdkext:__pkg__" ],
+}
+
+droidstubs {
+ name: "framework-sdkext-droidstubs-publicapi",
+ defaults: [
+ "framework-sdkext-stubs-defaults",
+ "framework-module-stubs-defaults-publicapi",
+ ]
+}
+
+droidstubs {
+ name: "framework-sdkext-droidstubs-systemapi",
+ defaults: [
+ "framework-sdkext-stubs-defaults",
+ "framework-module-stubs-defaults-systemapi",
+ ]
+}
+
+stubs_defaults {
+ name: "framework-sdkext-stubs-defaults",
+ srcs: [
+ ":framework-sdkext-sources",
+ ":framework-annotations",
+ ],
+ sdk_version: "system_current",
+}
+
+java_library {
+ name: "framework-sdkext-stubs-systemapi",
+ srcs: [":framework-sdkext-droidstubs-systemapi"],
+ sdk_version: "system_current",
+ visibility: [
+ "//frameworks/base:__pkg__", // Framework
+ "//frameworks/base/apex/sdkext:__pkg__", // sdkext SDK
+ ]
}
diff --git a/apex/sdkext/framework/java/android/os/ext/SdkExtensions.java b/apex/sdkext/framework/java/android/os/ext/SdkExtensions.java
index d3b9397..a8a7eff 100644
--- a/apex/sdkext/framework/java/android/os/ext/SdkExtensions.java
+++ b/apex/sdkext/framework/java/android/os/ext/SdkExtensions.java
@@ -60,7 +60,7 @@
*/
public static int getExtensionVersion(@SdkVersion int sdk) {
if (sdk < VERSION_CODES.R) {
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException(String.valueOf(sdk) + " does not have extensions");
}
return R_EXTENSION_INT;
}
diff --git a/apex/sdkext/gen_sdkinfo.py b/apex/sdkext/gen_sdkinfo.py
new file mode 100644
index 0000000..5af478b
--- /dev/null
+++ b/apex/sdkext/gen_sdkinfo.py
@@ -0,0 +1,19 @@
+import sdk_pb2
+import sys
+
+if __name__ == '__main__':
+ argv = sys.argv[1:]
+ if not len(argv) == 4 or sorted([argv[0], argv[2]]) != ['-o', '-v']:
+ print('usage: gen_sdkinfo -v <version> -o <output-file>')
+ sys.exit(1)
+
+ for i in range(len(argv)):
+ if sys.argv[i] == '-o':
+ filename = sys.argv[i+1]
+ if sys.argv[i] == '-v':
+ version = int(sys.argv[i+1])
+
+ proto = sdk_pb2.SdkVersion()
+ proto.version = version
+ with open(filename, 'wb') as f:
+ f.write(proto.SerializeToString())
diff --git a/apex/sdkext/sdk.proto b/apex/sdkext/sdk.proto
new file mode 100644
index 0000000..d15b935
--- /dev/null
+++ b/apex/sdkext/sdk.proto
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+syntax = "proto3";
+package com.android.sdkext.proto;
+
+option java_outer_classname = "SdkProto";
+option optimize_for = LITE_RUNTIME;
+
+message SdkVersion {
+ int32 version = 1;
+}
diff --git a/apex/statsd/Android.bp b/apex/statsd/Android.bp
index 8327f31..09ca1d2 100644
--- a/apex/statsd/Android.bp
+++ b/apex/statsd/Android.bp
@@ -16,15 +16,16 @@
name: "com.android.os.statsd",
defaults: ["com.android.os.statsd-defaults"],
manifest: "apex_manifest.json",
-
-
}
apex_defaults {
// libc.so and libcutils.so are included in the apex
// native_shared_libs: ["libc", "libcutils"],
// binaries: ["vold"],
- // java_libs: ["core-all"],
+ java_libs: [
+ "framework-statsd",
+ "service-statsd",
+ ],
// prebuilts: ["my_prebuilt"],
name: "com.android.os.statsd-defaults",
key: "com.android.os.statsd.key",
diff --git a/apex/statsd/aidl/android/os/IStatsManager.aidl b/apex/statsd/aidl/android/os/IStatsd.aidl
similarity index 99%
rename from apex/statsd/aidl/android/os/IStatsManager.aidl
rename to apex/statsd/aidl/android/os/IStatsd.aidl
index cc62f07..cffc6ce 100644
--- a/apex/statsd/aidl/android/os/IStatsManager.aidl
+++ b/apex/statsd/aidl/android/os/IStatsd.aidl
@@ -24,7 +24,7 @@
* Binder interface to communicate with the statistics management service.
* {@hide}
*/
-interface IStatsManager {
+interface IStatsd {
/**
* Tell the stats daemon that the android system server is up and running.
*/
diff --git a/apex/statsd/framework/Android.bp b/apex/statsd/framework/Android.bp
new file mode 100644
index 0000000..37b07a6
--- /dev/null
+++ b/apex/statsd/framework/Android.bp
@@ -0,0 +1,67 @@
+// Copyright (C) 2019 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.
+
+filegroup {
+ name: "framework-statsd-sources",
+ srcs: [
+ "java/**/*.java",
+ ],
+ path: "java",
+}
+
+java_library {
+ name: "framework-statsd",
+ installable: true,
+ // TODO(b/146209659): Use system_current instead.
+ sdk_version: "core_platform",
+ srcs: [
+ ":framework-statsd-sources",
+ ],
+ permitted_packages: [
+ "android.app",
+ "android.util",
+ ],
+ libs: [
+ "framework-annotations-lib",
+ // TODO(b/146230220): Use framework-system-stubs instead.
+ "android_system_stubs_current",
+ ],
+ // TODO:(b/146210774): Add apex_available field.
+}
+
+droidstubs {
+ name: "framework-statsd-stubs-docs",
+ defaults: [
+ "framework-module-stubs-defaults-publicapi"
+ ],
+ srcs: [
+ ":framework-statsd-sources",
+ ],
+ libs: [
+ "framework-all",
+ ],
+ sdk_version: "core_platform",
+}
+
+// TODO(b/146167933): Use these stubs in frameworks/base/Android.bp
+java_library {
+ name: "framework-statsd-stubs",
+ srcs: [
+ ":framework-statsd-stubs-docs",
+ ],
+ libs: [
+ "framework-all",
+ ],
+ sdk_version: "core_platform",
+}
diff --git a/core/java/android/util/StatsEvent.java b/apex/statsd/framework/java/android/util/StatsEvent.java
similarity index 100%
rename from core/java/android/util/StatsEvent.java
rename to apex/statsd/framework/java/android/util/StatsEvent.java
diff --git a/apex/statsd/service/Android.bp b/apex/statsd/service/Android.bp
index f71d74f..f3a8989 100644
--- a/apex/statsd/service/Android.bp
+++ b/apex/statsd/service/Android.bp
@@ -1,5 +1,5 @@
// Statsd Service jar, which will eventually be put in the statsd mainline apex.
-// service-statsd needs to be added to PRODUCT_SYSTEM_SERVER_JARS.
+// service-statsd needs to be added to PRODUCT_UPDATABLE_SYSTEM_SERVER_JARS.
// This jar will contain StatsCompanionService
java_library {
name: "service-statsd",
@@ -8,9 +8,9 @@
srcs: [
"java/**/*.java",
],
-
+ // TODO: link against the proper stubs (b/146084685).
libs: [
- "framework",
+ "framework-minus-apex",
"services.core",
],
}
diff --git a/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java b/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java
index 6fb3bc4..bc7716e 100644
--- a/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java
+++ b/apex/statsd/service/java/com/android/server/stats/StatsCompanionService.java
@@ -79,7 +79,7 @@
import android.os.IBinder;
import android.os.IPullAtomCallback;
import android.os.IStatsCompanionService;
-import android.os.IStatsManager;
+import android.os.IStatsd;
import android.os.IStoraged;
import android.os.IThermalEventListener;
import android.os.IThermalService;
@@ -268,7 +268,7 @@
private final AlarmManager mAlarmManager;
private final INetworkStatsService mNetworkStatsService;
@GuardedBy("sStatsdLock")
- private static IStatsManager sStatsd;
+ private static IStatsd sStatsd;
private static final Object sStatsdLock = new Object();
private final OnAlarmListener mAnomalyAlarmListener = new AnomalyAlarmListener();
@@ -2743,8 +2743,8 @@
* Note: This should only be called from sayHiToStatsd. All other clients should use the cached
* sStatsd with a null check.
*/
- private static IStatsManager fetchStatsdService() {
- return IStatsManager.Stub.asInterface(ServiceManager.getService("stats"));
+ private static IStatsd fetchStatsdService() {
+ return IStatsd.Stub.asInterface(ServiceManager.getService("stats"));
}
public static final class Lifecycle extends SystemService {
diff --git a/api/current.txt b/api/current.txt
index c4fa0ab..4708616 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -6732,6 +6732,7 @@
method @Deprecated @Nullable public String getApplicationRestrictionsManagingPackage(@NonNull android.content.ComponentName);
method public boolean getAutoTime(@NonNull android.content.ComponentName);
method @Deprecated public boolean getAutoTimeRequired();
+ method public boolean getAutoTimeZone(@NonNull android.content.ComponentName);
method @NonNull public java.util.List<android.os.UserHandle> getBindDeviceAdminTargetUsers(@NonNull android.content.ComponentName);
method public boolean getBluetoothContactSharingDisabled(@NonNull android.content.ComponentName);
method public boolean getCameraDisabled(@Nullable android.content.ComponentName);
@@ -6739,6 +6740,7 @@
method @Nullable public java.util.Set<java.lang.String> getCrossProfileCalendarPackages(@NonNull android.content.ComponentName);
method public boolean getCrossProfileCallerIdDisabled(@NonNull android.content.ComponentName);
method public boolean getCrossProfileContactsSearchDisabled(@NonNull android.content.ComponentName);
+ method @NonNull public java.util.Set<java.lang.String> getCrossProfilePackages(@NonNull android.content.ComponentName);
method @NonNull public java.util.List<java.lang.String> getCrossProfileWidgetProviders(@NonNull android.content.ComponentName);
method public int getCurrentFailedPasswordAttempts();
method @Nullable public java.util.List<java.lang.String> getDelegatePackages(@NonNull android.content.ComponentName, @NonNull String);
@@ -6849,6 +6851,7 @@
method @Deprecated public void setApplicationRestrictionsManagingPackage(@NonNull android.content.ComponentName, @Nullable String) throws android.content.pm.PackageManager.NameNotFoundException;
method public void setAutoTime(@NonNull android.content.ComponentName, boolean);
method @Deprecated public void setAutoTimeRequired(@NonNull android.content.ComponentName, boolean);
+ method public void setAutoTimeZone(@NonNull android.content.ComponentName, boolean);
method public void setBackupServiceEnabled(@NonNull android.content.ComponentName, boolean);
method public void setBluetoothContactSharingDisabled(@NonNull android.content.ComponentName, boolean);
method public void setCameraDisabled(@NonNull android.content.ComponentName, boolean);
@@ -6856,6 +6859,7 @@
method public void setCrossProfileCalendarPackages(@NonNull android.content.ComponentName, @Nullable java.util.Set<java.lang.String>);
method public void setCrossProfileCallerIdDisabled(@NonNull android.content.ComponentName, boolean);
method public void setCrossProfileContactsSearchDisabled(@NonNull android.content.ComponentName, boolean);
+ method public void setCrossProfilePackages(@NonNull android.content.ComponentName, @NonNull java.util.Set<java.lang.String>);
method public void setDefaultSmsApplication(@NonNull android.content.ComponentName, @NonNull String);
method public void setDelegatedScopes(@NonNull android.content.ComponentName, @NonNull String, @NonNull java.util.List<java.lang.String>);
method public void setDeviceOwnerLockScreenInfo(@NonNull android.content.ComponentName, CharSequence);
@@ -16776,16 +16780,29 @@
package android.hardware.biometrics {
public class BiometricManager {
- method @RequiresPermission(android.Manifest.permission.USE_BIOMETRIC) public int canAuthenticate();
+ method @Deprecated @RequiresPermission(android.Manifest.permission.USE_BIOMETRIC) public int canAuthenticate();
+ method @RequiresPermission(android.Manifest.permission.USE_BIOMETRIC) public int canAuthenticate(int);
field public static final int BIOMETRIC_ERROR_HW_UNAVAILABLE = 1; // 0x1
field public static final int BIOMETRIC_ERROR_NONE_ENROLLED = 11; // 0xb
field public static final int BIOMETRIC_ERROR_NO_HARDWARE = 12; // 0xc
field public static final int BIOMETRIC_SUCCESS = 0; // 0x0
}
+ public static interface BiometricManager.Authenticators {
+ field public static final int BIOMETRIC_STRONG = 15; // 0xf
+ field public static final int BIOMETRIC_WEAK = 255; // 0xff
+ field public static final int DEVICE_CREDENTIAL = 32768; // 0x8000
+ }
+
public class BiometricPrompt {
method @RequiresPermission(android.Manifest.permission.USE_BIOMETRIC) public void authenticate(@NonNull android.hardware.biometrics.BiometricPrompt.CryptoObject, @NonNull android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull android.hardware.biometrics.BiometricPrompt.AuthenticationCallback);
method @RequiresPermission(android.Manifest.permission.USE_BIOMETRIC) public void authenticate(@NonNull android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull android.hardware.biometrics.BiometricPrompt.AuthenticationCallback);
+ method @Nullable public int getAllowedAuthenticators();
+ method @Nullable public CharSequence getDescription();
+ method @Nullable public CharSequence getNegativeButtonText();
+ method @Nullable public CharSequence getSubtitle();
+ method @NonNull public CharSequence getTitle();
+ method public boolean isConfirmationRequired();
field public static final int BIOMETRIC_ACQUIRED_GOOD = 0; // 0x0
field public static final int BIOMETRIC_ACQUIRED_IMAGER_DIRTY = 3; // 0x3
field public static final int BIOMETRIC_ACQUIRED_INSUFFICIENT = 2; // 0x2
@@ -16821,9 +16838,10 @@
public static class BiometricPrompt.Builder {
ctor public BiometricPrompt.Builder(android.content.Context);
method @NonNull public android.hardware.biometrics.BiometricPrompt build();
+ method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setAllowedAuthenticators(int);
method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setConfirmationRequired(boolean);
method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setDescription(@NonNull CharSequence);
- method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setDeviceCredentialAllowed(boolean);
+ method @Deprecated @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setDeviceCredentialAllowed(boolean);
method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setNegativeButton(@NonNull CharSequence, @NonNull java.util.concurrent.Executor, @NonNull android.content.DialogInterface.OnClickListener);
method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setSubtitle(@NonNull CharSequence);
method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setTitle(@NonNull CharSequence);
@@ -17228,6 +17246,7 @@
field public static final int REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR = 1; // 0x1
field public static final int REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME = 12; // 0xc
field public static final int REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING = 10; // 0xa
+ field public static final int REQUEST_AVAILABLE_CAPABILITIES_OFFLINE_PROCESSING = 15; // 0xf
field public static final int REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING = 4; // 0x4
field public static final int REQUEST_AVAILABLE_CAPABILITIES_RAW = 3; // 0x3
field public static final int REQUEST_AVAILABLE_CAPABILITIES_READ_SENSOR_SETTINGS = 5; // 0x5
@@ -25641,10 +25660,10 @@
}
public static interface MediaParser.OutputConsumer {
- method public void onFormat(int, @NonNull android.media.MediaFormat);
method public void onSampleCompleted(int, long, int, int, int, @Nullable android.media.MediaCodec.CryptoInfo);
method public void onSampleData(int, @NonNull android.media.MediaParser.InputReader) throws java.io.IOException, java.lang.InterruptedException;
method public void onSeekMap(@NonNull android.media.MediaParser.SeekMap);
+ method public void onTrackData(int, @NonNull android.media.MediaParser.TrackData);
method public void onTracksFound(int);
}
@@ -25665,6 +25684,11 @@
method public void seekToPosition(long);
}
+ public static final class MediaParser.TrackData {
+ field @Nullable public final android.media.DrmInitData drmInitData;
+ field @NonNull public final android.media.MediaFormat mediaFormat;
+ }
+
public static final class MediaParser.UnrecognizedInputFormatException extends java.io.IOException {
}
@@ -35005,6 +35029,7 @@
method public void dump(@NonNull java.io.FileDescriptor, @Nullable String[]) throws android.os.RemoteException;
method public void dumpAsync(@NonNull java.io.FileDescriptor, @Nullable String[]) throws android.os.RemoteException;
method @Nullable public String getInterfaceDescriptor() throws android.os.RemoteException;
+ method public static int getSuggestedMaxIpcSizeBytes();
method public boolean isBinderAlive();
method public void linkToDeath(@NonNull android.os.IBinder.DeathRecipient, int) throws android.os.RemoteException;
method public boolean pingBinder();
@@ -35201,6 +35226,7 @@
method public void readMap(@NonNull java.util.Map, @Nullable ClassLoader);
method @Nullable public <T extends android.os.Parcelable> T readParcelable(@Nullable ClassLoader);
method @Nullable public android.os.Parcelable[] readParcelableArray(@Nullable ClassLoader);
+ method @Nullable public android.os.Parcelable.Creator<?> readParcelableCreator(@Nullable ClassLoader);
method @NonNull public <T extends android.os.Parcelable> java.util.List<T> readParcelableList(@NonNull java.util.List<T>, @Nullable ClassLoader);
method @Nullable public android.os.PersistableBundle readPersistableBundle();
method @Nullable public android.os.PersistableBundle readPersistableBundle(@Nullable ClassLoader);
@@ -35248,6 +35274,7 @@
method public void writeNoException();
method public void writeParcelable(@Nullable android.os.Parcelable, int);
method public <T extends android.os.Parcelable> void writeParcelableArray(@Nullable T[], int);
+ method public void writeParcelableCreator(@NonNull android.os.Parcelable);
method public <T extends android.os.Parcelable> void writeParcelableList(@Nullable java.util.List<T>, int);
method public void writePersistableBundle(@Nullable android.os.PersistableBundle);
method public void writeSerializable(@Nullable java.io.Serializable);
@@ -38375,11 +38402,11 @@
protected static interface ContactsContract.RawContactsColumns {
field public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
field public static final String AGGREGATION_MODE = "aggregation_mode";
- field public static final String BACKUP_ID = "backup_id";
+ field @Deprecated public static final String BACKUP_ID = "backup_id";
field public static final String CONTACT_ID = "contact_id";
field public static final String DATA_SET = "data_set";
field public static final String DELETED = "deleted";
- field public static final String METADATA_DIRTY = "metadata_dirty";
+ field @Deprecated public static final String METADATA_DIRTY = "metadata_dirty";
field public static final String RAW_CONTACT_IS_READ_ONLY = "raw_contact_is_read_only";
field public static final String RAW_CONTACT_IS_USER_PROFILE = "raw_contact_is_user_profile";
}
@@ -38686,6 +38713,10 @@
public final class MediaStore {
ctor public MediaStore();
+ method @NonNull public static android.app.PendingIntent createDeleteRequest(@NonNull android.content.ContentResolver, @NonNull java.util.Collection<android.net.Uri>);
+ method @NonNull public static android.app.PendingIntent createFavoriteRequest(@NonNull android.content.ContentResolver, @NonNull java.util.Collection<android.net.Uri>, boolean);
+ method @NonNull public static android.app.PendingIntent createTrashRequest(@NonNull android.content.ContentResolver, @NonNull java.util.Collection<android.net.Uri>, boolean);
+ method @NonNull public static android.app.PendingIntent createWriteRequest(@NonNull android.content.ContentResolver, @NonNull java.util.Collection<android.net.Uri>);
method @Nullable public static android.net.Uri getDocumentUri(@NonNull android.content.Context, @NonNull android.net.Uri);
method @NonNull public static java.util.Set<java.lang.String> getExternalVolumeNames(@NonNull android.content.Context);
method public static android.net.Uri getMediaScannerUri();
@@ -38696,9 +38727,6 @@
method @NonNull public static String getVolumeName(@NonNull android.net.Uri);
method @Deprecated @NonNull public static android.net.Uri setIncludePending(@NonNull android.net.Uri);
method @NonNull public static android.net.Uri setRequireOriginal(@NonNull android.net.Uri);
- method public static void trash(@NonNull android.content.Context, @NonNull android.net.Uri);
- method public static void trash(@NonNull android.content.Context, @NonNull android.net.Uri, long);
- method public static void untrash(@NonNull android.content.Context, @NonNull android.net.Uri);
field public static final String ACTION_IMAGE_CAPTURE = "android.media.action.IMAGE_CAPTURE";
field public static final String ACTION_IMAGE_CAPTURE_SECURE = "android.media.action.IMAGE_CAPTURE_SECURE";
field public static final String ACTION_REVIEW = "android.provider.action.REVIEW";
@@ -44577,6 +44605,7 @@
method public void notifyConfigChangedForSubId(int);
field public static final String ACTION_CARRIER_CONFIG_CHANGED = "android.telephony.action.CARRIER_CONFIG_CHANGED";
field public static final int DATA_CYCLE_THRESHOLD_DISABLED = -2; // 0xfffffffe
+ field public static final int DATA_CYCLE_USE_PLATFORM_DEFAULT = -1; // 0xffffffff
field public static final String EXTRA_SLOT_INDEX = "android.telephony.extra.SLOT_INDEX";
field public static final String EXTRA_SUBSCRIPTION_INDEX = "android.telephony.extra.SUBSCRIPTION_INDEX";
field public static final String KEY_5G_NR_SSRSRP_THRESHOLDS_INT_ARRAY = "5g_nr_ssrsrp_thresholds_int_array";
@@ -44636,11 +44665,16 @@
field public static final String KEY_CI_ACTION_ON_SYS_UPDATE_EXTRA_STRING = "ci_action_on_sys_update_extra_string";
field public static final String KEY_CI_ACTION_ON_SYS_UPDATE_EXTRA_VAL_STRING = "ci_action_on_sys_update_extra_val_string";
field public static final String KEY_CI_ACTION_ON_SYS_UPDATE_INTENT_STRING = "ci_action_on_sys_update_intent_string";
- field public static final String KEY_CONFIG_IMS_PACKAGE_OVERRIDE_STRING = "config_ims_package_override_string";
+ field public static final String KEY_CONFIG_IMS_MMTEL_PACKAGE_OVERRIDE_STRING = "config_ims_mmtel_package_override_string";
+ field @Deprecated public static final String KEY_CONFIG_IMS_PACKAGE_OVERRIDE_STRING = "config_ims_package_override_string";
+ field public static final String KEY_CONFIG_IMS_RCS_PACKAGE_OVERRIDE_STRING = "config_ims_rcs_package_override_string";
field public static final String KEY_CONFIG_PLANS_PACKAGE_OVERRIDE_STRING = "config_plans_package_override_string";
field public static final String KEY_CONFIG_TELEPHONY_USE_OWN_NUMBER_FOR_VOICEMAIL_BOOL = "config_telephony_use_own_number_for_voicemail_bool";
field public static final String KEY_CSP_ENABLED_BOOL = "csp_enabled_bool";
+ field public static final String KEY_DATA_LIMIT_NOTIFICATION_BOOL = "data_limit_notification_bool";
field public static final String KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG = "data_limit_threshold_bytes_long";
+ field public static final String KEY_DATA_RAPID_NOTIFICATION_BOOL = "data_rapid_notification_bool";
+ field public static final String KEY_DATA_WARNING_NOTIFICATION_BOOL = "data_warning_notification_bool";
field public static final String KEY_DATA_WARNING_THRESHOLD_BYTES_LONG = "data_warning_threshold_bytes_long";
field public static final String KEY_DEFAULT_SIM_CALL_MANAGER_STRING = "default_sim_call_manager_string";
field public static final String KEY_DEFAULT_VM_NUMBER_ROAMING_AND_IMS_UNREGISTERED_STRING = "default_vm_number_roaming_and_ims_unregistered_string";
@@ -45200,6 +45234,7 @@
method public void onDataConnectionStateChanged(int);
method public void onDataConnectionStateChanged(int, int);
method public void onMessageWaitingIndicatorChanged(boolean);
+ method @RequiresPermission("android.permission.MODIFY_PHONE_STATE") public void onPreciseDataConnectionStateChanged(@NonNull android.telephony.PreciseDataConnectionState);
method public void onServiceStateChanged(android.telephony.ServiceState);
method @Deprecated public void onSignalStrengthChanged(int);
method public void onSignalStrengthsChanged(android.telephony.SignalStrength);
@@ -45214,12 +45249,23 @@
field public static final int LISTEN_EMERGENCY_NUMBER_LIST = 16777216; // 0x1000000
field public static final int LISTEN_MESSAGE_WAITING_INDICATOR = 4; // 0x4
field public static final int LISTEN_NONE = 0; // 0x0
+ field @RequiresPermission("android.permission.MODIFY_PHONE_STATE") public static final int LISTEN_PRECISE_DATA_CONNECTION_STATE = 4096; // 0x1000
field public static final int LISTEN_SERVICE_STATE = 1; // 0x1
field @Deprecated public static final int LISTEN_SIGNAL_STRENGTH = 2; // 0x2
field public static final int LISTEN_SIGNAL_STRENGTHS = 256; // 0x100
field public static final int LISTEN_USER_MOBILE_DATA_STATE = 524288; // 0x80000
}
+ public final class PreciseDataConnectionState implements android.os.Parcelable {
+ method public int describeContents();
+ method public int getLastCauseCode();
+ method @Nullable public android.net.LinkProperties getLinkProperties();
+ method public int getNetworkType();
+ method public int getState();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.telephony.PreciseDataConnectionState> CREATOR;
+ }
+
public final class RadioAccessSpecifier implements android.os.Parcelable {
ctor public RadioAccessSpecifier(int, int[], int[]);
method public int describeContents();
@@ -45600,6 +45646,7 @@
method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public boolean doesSwitchMultiSimConfigTriggerReboot();
method public int getActiveModemCount();
method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public java.util.List<android.telephony.CellInfo> getAllCellInfo();
+ method @NonNull public static int[] getAllNetworkTypes();
method public int getCallState();
method public int getCardIdForDefaultEuicc();
method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) @WorkerThread public android.os.PersistableBundle getCarrierConfig();
@@ -45731,6 +45778,7 @@
field public static final int DATA_CONNECTED = 2; // 0x2
field public static final int DATA_CONNECTING = 1; // 0x1
field public static final int DATA_DISCONNECTED = 0; // 0x0
+ field public static final int DATA_DISCONNECTING = 4; // 0x4
field public static final int DATA_SUSPENDED = 3; // 0x3
field public static final int DATA_UNKNOWN = -1; // 0xffffffff
field public static final String EXTRA_CALL_VOICEMAIL_INTENT = "android.telephony.extra.CALL_VOICEMAIL_INTENT";
@@ -47282,7 +47330,7 @@
field public static final long WEEK_IN_MILLIS = 604800000L; // 0x240c8400L
field public static final String YEAR_FORMAT = "%Y";
field public static final String YEAR_FORMAT_TWO_DIGITS = "%g";
- field public static final long YEAR_IN_MILLIS = 31449600000L; // 0x7528ad000L
+ field @Deprecated public static final long YEAR_IN_MILLIS = 31449600000L; // 0x7528ad000L
field @Deprecated public static final int[] sameMonthTable;
field @Deprecated public static final int[] sameYearTable;
}
@@ -48721,6 +48769,13 @@
ctor public Base64OutputStream(java.io.OutputStream, int);
}
+ public final class CloseGuard {
+ ctor public CloseGuard();
+ method public void close();
+ method public void open(@NonNull String);
+ method public void warnIfOpen();
+ }
+
@Deprecated public final class Config {
field @Deprecated public static final boolean DEBUG = false;
field @Deprecated public static final boolean LOGD = true;
@@ -51050,6 +51105,9 @@
method public boolean dispatchUnhandledMove(android.view.View, int);
method protected void dispatchVisibilityChanged(@NonNull android.view.View, int);
method public void dispatchWindowFocusChanged(boolean);
+ method public void dispatchWindowInsetsAnimationFinished(@NonNull android.view.WindowInsetsAnimationCallback.InsetsAnimation);
+ method @NonNull public android.view.WindowInsets dispatchWindowInsetsAnimationProgress(@NonNull android.view.WindowInsets);
+ method @NonNull public android.view.WindowInsetsAnimationCallback.AnimationBounds dispatchWindowInsetsAnimationStarted(@NonNull android.view.WindowInsetsAnimationCallback.InsetsAnimation, @NonNull android.view.WindowInsetsAnimationCallback.AnimationBounds);
method public void dispatchWindowSystemUiVisiblityChanged(int);
method public void dispatchWindowVisibilityChanged(int);
method @CallSuper public void draw(android.graphics.Canvas);
@@ -51230,6 +51288,7 @@
method @android.view.ViewDebug.ExportedProperty(category="layout") public final int getWidth();
method protected int getWindowAttachCount();
method public android.view.WindowId getWindowId();
+ method @Nullable public android.view.WindowInsetsController getWindowInsetsController();
method public int getWindowSystemUiVisibility();
method public android.os.IBinder getWindowToken();
method public int getWindowVisibility();
@@ -51568,6 +51627,7 @@
method public void setVisibility(int);
method @Deprecated public void setWillNotCacheDrawing(boolean);
method public void setWillNotDraw(boolean);
+ method public void setWindowInsetsAnimationCallback(@Nullable android.view.WindowInsetsAnimationCallback);
method public void setX(float);
method public void setY(float);
method public void setZ(float);
@@ -52454,6 +52514,7 @@
method public android.transition.Transition getExitTransition();
method protected final int getFeatures();
method protected final int getForcedWindowFlags();
+ method @Nullable public android.view.WindowInsetsController getInsetsController();
method @NonNull public abstract android.view.LayoutInflater getLayoutInflater();
method protected final int getLocalFeatures();
method public android.media.session.MediaController getMediaController();
@@ -52669,7 +52730,9 @@
method @NonNull public android.view.WindowInsets consumeStableInsets();
method @NonNull public android.view.WindowInsets consumeSystemWindowInsets();
method @Nullable public android.view.DisplayCutout getDisplayCutout();
+ method @NonNull public android.graphics.Insets getInsets(int);
method @NonNull public android.graphics.Insets getMandatorySystemGestureInsets();
+ method @NonNull public android.graphics.Insets getMaxInsets(int) throws java.lang.IllegalArgumentException;
method public int getStableInsetBottom();
method public int getStableInsetLeft();
method public int getStableInsetRight();
@@ -52688,6 +52751,7 @@
method @NonNull public android.view.WindowInsets inset(@IntRange(from=0) int, @IntRange(from=0) int, @IntRange(from=0) int, @IntRange(from=0) int);
method public boolean isConsumed();
method public boolean isRound();
+ method public boolean isVisible(int);
method @Deprecated @NonNull public android.view.WindowInsets replaceSystemWindowInsets(int, int, int, int);
method @Deprecated @NonNull public android.view.WindowInsets replaceSystemWindowInsets(android.graphics.Rect);
}
@@ -52697,11 +52761,76 @@
ctor public WindowInsets.Builder(@NonNull android.view.WindowInsets);
method @NonNull public android.view.WindowInsets build();
method @NonNull public android.view.WindowInsets.Builder setDisplayCutout(@Nullable android.view.DisplayCutout);
+ method @NonNull public android.view.WindowInsets.Builder setInsets(int, @NonNull android.graphics.Insets);
method @NonNull public android.view.WindowInsets.Builder setMandatorySystemGestureInsets(@NonNull android.graphics.Insets);
+ method @NonNull public android.view.WindowInsets.Builder setMaxInsets(int, @NonNull android.graphics.Insets) throws java.lang.IllegalArgumentException;
method @NonNull public android.view.WindowInsets.Builder setStableInsets(@NonNull android.graphics.Insets);
method @NonNull public android.view.WindowInsets.Builder setSystemGestureInsets(@NonNull android.graphics.Insets);
method @NonNull public android.view.WindowInsets.Builder setSystemWindowInsets(@NonNull android.graphics.Insets);
method @NonNull public android.view.WindowInsets.Builder setTappableElementInsets(@NonNull android.graphics.Insets);
+ method @NonNull public android.view.WindowInsets.Builder setVisible(int, boolean);
+ }
+
+ public static final class WindowInsets.Type {
+ method public static int all();
+ method public static int captionBar();
+ method public static int ime();
+ method public static int mandatorySystemGestures();
+ method public static int navigationBars();
+ method public static int statusBars();
+ method public static int systemBars();
+ method public static int systemGestures();
+ method public static int tappableElement();
+ method public static int windowDecor();
+ }
+
+ public interface WindowInsetsAnimationCallback {
+ method public default void onFinished(@NonNull android.view.WindowInsetsAnimationCallback.InsetsAnimation);
+ method @NonNull public android.view.WindowInsets onProgress(@NonNull android.view.WindowInsets);
+ method @NonNull public default android.view.WindowInsetsAnimationCallback.AnimationBounds onStarted(@NonNull android.view.WindowInsetsAnimationCallback.InsetsAnimation, @NonNull android.view.WindowInsetsAnimationCallback.AnimationBounds);
+ }
+
+ public static final class WindowInsetsAnimationCallback.AnimationBounds {
+ ctor public WindowInsetsAnimationCallback.AnimationBounds(@NonNull android.graphics.Insets, @NonNull android.graphics.Insets);
+ method @NonNull public android.graphics.Insets getLowerBound();
+ method @NonNull public android.graphics.Insets getUpperBound();
+ method @NonNull public android.view.WindowInsetsAnimationCallback.AnimationBounds inset(@NonNull android.graphics.Insets);
+ }
+
+ public static final class WindowInsetsAnimationCallback.InsetsAnimation {
+ ctor public WindowInsetsAnimationCallback.InsetsAnimation(int, @Nullable android.view.animation.Interpolator, long);
+ method public long getDurationMillis();
+ method @FloatRange(from=0.0f, to=1.0f) public float getFraction();
+ method public float getInterpolatedFraction();
+ method @Nullable public android.view.animation.Interpolator getInterpolator();
+ method public int getTypeMask();
+ method public void setDuration(long);
+ method public void setFraction(@FloatRange(from=0.0f, to=1.0f) float);
+ }
+
+ public interface WindowInsetsAnimationControlListener {
+ method public void onCancelled();
+ method public void onReady(@NonNull android.view.WindowInsetsAnimationController, int);
+ }
+
+ public interface WindowInsetsAnimationController {
+ method public void finish(boolean);
+ method @FloatRange(from=0.0f, to=1.0f) public float getCurrentFraction();
+ method @NonNull public android.graphics.Insets getCurrentInsets();
+ method @NonNull public android.graphics.Insets getHiddenStateInsets();
+ method @NonNull public android.graphics.Insets getShownStateInsets();
+ method public int getTypes();
+ method public void setInsetsAndAlpha(@Nullable android.graphics.Insets, @FloatRange(from=0.0f, to=1.0f) float, @FloatRange(from=0.0f, to=1.0f) float);
+ }
+
+ public interface WindowInsetsController {
+ method public default void controlInputMethodAnimation(long, @NonNull android.view.WindowInsetsAnimationControlListener);
+ method public default void hideInputMethod();
+ method public void setSystemBarsAppearance(int);
+ method public void setSystemBarsBehavior(int);
+ method public default void showInputMethod();
+ field public static final int APPEARANCE_LIGHT_NAVIGATION_BARS = 16; // 0x10
+ field public static final int APPEARANCE_LIGHT_STATUS_BARS = 8; // 0x8
}
public interface WindowManager extends android.view.ViewManager {
diff --git a/api/removed.txt b/api/removed.txt
index 1a2f434..4e8e325 100644
--- a/api/removed.txt
+++ b/api/removed.txt
@@ -441,6 +441,9 @@
method @Deprecated public static boolean getIncludePending(@NonNull android.net.Uri);
method @Deprecated @NonNull public static android.provider.MediaStore.PendingSession openPending(@NonNull android.content.Context, @NonNull android.net.Uri);
method @Deprecated @NonNull public static android.net.Uri setIncludeTrashed(@NonNull android.net.Uri);
+ method @Deprecated public static void trash(@NonNull android.content.Context, @NonNull android.net.Uri);
+ method @Deprecated public static void trash(@NonNull android.content.Context, @NonNull android.net.Uri, long);
+ method @Deprecated public static void untrash(@NonNull android.content.Context, @NonNull android.net.Uri);
}
public static interface MediaStore.Audio.AudioColumns extends android.provider.MediaStore.MediaColumns {
diff --git a/api/system-current.txt b/api/system-current.txt
old mode 100644
new mode 100755
index e04a391..b14bf34
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -546,10 +546,12 @@
method public final android.os.IBinder onBind(android.content.Intent);
method @Deprecated public void onGetInstantAppIntentFilter(@Nullable int[], @NonNull String, @NonNull android.app.InstantAppResolverService.InstantAppResolutionCallback);
method @Deprecated public void onGetInstantAppIntentFilter(@NonNull android.content.Intent, @Nullable int[], @NonNull String, @NonNull android.app.InstantAppResolverService.InstantAppResolutionCallback);
- method public void onGetInstantAppIntentFilter(@NonNull android.content.Intent, @Nullable int[], @NonNull android.os.UserHandle, @NonNull String, @NonNull android.app.InstantAppResolverService.InstantAppResolutionCallback);
+ method @Deprecated public void onGetInstantAppIntentFilter(@NonNull android.content.Intent, @Nullable int[], @NonNull android.os.UserHandle, @NonNull String, @NonNull android.app.InstantAppResolverService.InstantAppResolutionCallback);
+ method public void onGetInstantAppIntentFilter(@NonNull android.content.pm.InstantAppRequestInfo, @NonNull android.app.InstantAppResolverService.InstantAppResolutionCallback);
method @Deprecated public void onGetInstantAppResolveInfo(@Nullable int[], @NonNull String, @NonNull android.app.InstantAppResolverService.InstantAppResolutionCallback);
method @Deprecated public void onGetInstantAppResolveInfo(@NonNull android.content.Intent, @Nullable int[], @NonNull String, @NonNull android.app.InstantAppResolverService.InstantAppResolutionCallback);
- method public void onGetInstantAppResolveInfo(@NonNull android.content.Intent, @Nullable int[], @NonNull android.os.UserHandle, @NonNull String, @NonNull android.app.InstantAppResolverService.InstantAppResolutionCallback);
+ method @Deprecated public void onGetInstantAppResolveInfo(@NonNull android.content.Intent, @Nullable int[], @NonNull android.os.UserHandle, @NonNull String, @NonNull android.app.InstantAppResolverService.InstantAppResolutionCallback);
+ method public void onGetInstantAppResolveInfo(@NonNull android.content.pm.InstantAppRequestInfo, @NonNull android.app.InstantAppResolverService.InstantAppResolutionCallback);
}
public static final class InstantAppResolverService.InstantAppResolutionCallback {
@@ -809,6 +811,14 @@
}
+package android.app.appsearch {
+
+ public class AppSearchManagerFrameworkInitializer {
+ method public static void initialize();
+ }
+
+}
+
package android.app.assist {
public static class AssistStructure.ViewNode {
@@ -1305,6 +1315,7 @@
method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public int getAppStandbyBucket(String);
method @RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS) public java.util.Map<java.lang.String,java.lang.Integer> getAppStandbyBuckets();
method public int getUsageSource();
+ method @RequiresPermission(android.Manifest.permission.BIND_CARRIER_SERVICES) public void onCarrierPrivilegedAppsChanged();
method @RequiresPermission(allOf={android.Manifest.permission.SUSPEND_APPS, android.Manifest.permission.OBSERVE_APP_USAGE}) public void registerAppUsageLimitObserver(int, @NonNull String[], @NonNull java.time.Duration, @NonNull java.time.Duration, @Nullable android.app.PendingIntent);
method @RequiresPermission(android.Manifest.permission.OBSERVE_APP_USAGE) public void registerAppUsageObserver(int, @NonNull String[], long, @NonNull java.util.concurrent.TimeUnit, @NonNull android.app.PendingIntent);
method @RequiresPermission(android.Manifest.permission.OBSERVE_APP_USAGE) public void registerUsageSessionObserver(int, @NonNull String[], @NonNull java.time.Duration, @NonNull java.time.Duration, @NonNull android.app.PendingIntent, @Nullable android.app.PendingIntent);
@@ -1349,6 +1360,14 @@
field public static final int OPTIONAL_CODECS_SUPPORT_UNKNOWN = -1; // 0xffffffff
}
+ public final class BluetoothA2dpSink implements android.bluetooth.BluetoothProfile {
+ method public void finalize();
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public int getConnectionPolicy(@Nullable android.bluetooth.BluetoothDevice);
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isAudioPlaying(@Nullable android.bluetooth.BluetoothDevice);
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean setConnectionPolicy(@Nullable android.bluetooth.BluetoothDevice, int);
+ field @RequiresPermission(android.Manifest.permission.BLUETOOTH) public static final String ACTION_CONNECTION_STATE_CHANGED = "android.bluetooth.a2dp-sink.profile.action.CONNECTION_STATE_CHANGED";
+ }
+
public final class BluetoothAdapter {
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean addOnMetadataChangedListener(@NonNull android.bluetooth.BluetoothDevice, @NonNull java.util.concurrent.Executor, @NonNull android.bluetooth.BluetoothAdapter.OnMetadataChangedListener);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean connectAllEnabledProfiles(@NonNull android.bluetooth.BluetoothDevice);
@@ -1423,15 +1442,24 @@
public final class BluetoothDevice implements android.os.Parcelable {
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean cancelBondProcess();
+ method public boolean cancelPairing();
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public int getBatteryLevel();
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public int getMessageAccessPermission();
method @Nullable @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public byte[] getMetadata(int);
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public int getPhonebookAccessPermission();
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public int getSimAccessPermission();
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isBondingInitiatedLocally();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isConnected();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isEncrypted();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean isInSilenceMode();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean removeBond();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean setAlias(@NonNull String);
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setMessageAccessPermission(int);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setMetadata(int, @NonNull byte[]);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setPhonebookAccessPermission(int);
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean setPin(@Nullable String);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setSilenceMode(boolean);
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setSimAccessPermission(int);
field public static final int ACCESS_ALLOWED = 1; // 0x1
field public static final int ACCESS_REJECTED = 2; // 0x2
field public static final int ACCESS_UNKNOWN = 0; // 0x0
@@ -1466,7 +1494,9 @@
}
public final class BluetoothHearingAid implements android.bluetooth.BluetoothProfile {
+ method @NonNull @RequiresPermission(android.Manifest.permission.BLUETOOTH) public java.util.List<android.bluetooth.BluetoothDevice> getActiveDevices();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public int getConnectionPolicy(@NonNull android.bluetooth.BluetoothDevice);
+ method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public long getHiSyncId(@Nullable android.bluetooth.BluetoothDevice);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean setConnectionPolicy(@NonNull android.bluetooth.BluetoothDevice, int);
}
@@ -1485,6 +1515,11 @@
field public static final int REMOTE_PANU_ROLE = 2; // 0x2
}
+ public class BluetoothPbap implements android.bluetooth.BluetoothProfile {
+ method public int getConnectionState(@Nullable android.bluetooth.BluetoothDevice);
+ field public static final String ACTION_CONNECTION_STATE_CHANGED = "android.bluetooth.pbap.profile.action.CONNECTION_STATE_CHANGED";
+ }
+
public interface BluetoothProfile {
field public static final int CONNECTION_POLICY_ALLOWED = 100; // 0x64
field public static final int CONNECTION_POLICY_FORBIDDEN = 0; // 0x0
@@ -1616,6 +1651,7 @@
field public static final String STATS_MANAGER = "stats";
field public static final String STATUS_BAR_SERVICE = "statusbar";
field public static final String SYSTEM_UPDATE_SERVICE = "system_update";
+ field public static final String TELEPHONY_IMS_SERVICE = "telephony_ims";
field public static final String TELEPHONY_REGISTRY_SERVICE = "telephony_registry";
field public static final String VR_SERVICE = "vrmanager";
field @Deprecated public static final String WIFI_RTT_SERVICE = "rttmanager";
@@ -1902,6 +1938,18 @@
field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.InstantAppIntentFilter> CREATOR;
}
+ public final class InstantAppRequestInfo implements android.os.Parcelable {
+ ctor public InstantAppRequestInfo(@NonNull android.content.Intent, @Nullable int[], @NonNull android.os.UserHandle, boolean, @NonNull String);
+ method public int describeContents();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.InstantAppRequestInfo> CREATOR;
+ field @Nullable public final int[] hostDigestPrefix;
+ field @NonNull public final android.content.Intent intent;
+ field public final boolean isRequesterInstantApp;
+ field @NonNull public final String token;
+ field @NonNull public final android.os.UserHandle userHandle;
+ }
+
public final class InstantAppResolveInfo implements android.os.Parcelable {
ctor public InstantAppResolveInfo(@NonNull android.content.pm.InstantAppResolveInfo.InstantAppDigest, @Nullable String, @Nullable java.util.List<android.content.pm.InstantAppIntentFilter>, int);
ctor public InstantAppResolveInfo(@NonNull android.content.pm.InstantAppResolveInfo.InstantAppDigest, @Nullable String, @Nullable java.util.List<android.content.pm.InstantAppIntentFilter>, long, @Nullable android.os.Bundle);
@@ -2265,6 +2313,15 @@
}
+package android.hardware.biometrics {
+
+ public static interface BiometricManager.Authenticators {
+ field public static final int BIOMETRIC_CONVENIENCE = 4095; // 0xfff
+ field public static final int EMPTY_SET = 0; // 0x0
+ }
+
+}
+
package android.hardware.camera2 {
public abstract class CameraDevice implements java.lang.AutoCloseable {
@@ -3410,6 +3467,14 @@
field public static final int STATUS_OK = 0; // 0x0
}
+ public static final class SoundTrigger.ModelParamRange implements android.os.Parcelable {
+ method public int describeContents();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.hardware.soundtrigger.SoundTrigger.ModelParamRange> CREATOR;
+ field public final int end;
+ field public final int start;
+ }
+
public static final class SoundTrigger.ModuleProperties implements android.os.Parcelable {
method public int describeContents();
method public void writeToParcel(android.os.Parcel, int);
@@ -4138,18 +4203,20 @@
package android.media.session {
public final class MediaSessionManager {
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void registerCallback(@NonNull java.util.concurrent.Executor, @NonNull android.media.session.MediaSessionManager.Callback);
+ method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void addOnMediaKeyEventDispatchedListener(@NonNull java.util.concurrent.Executor, @NonNull android.media.session.MediaSessionManager.OnMediaKeyEventDispatchedListener);
+ method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void addOnMediaKeyEventSessionChangedListener(@NonNull java.util.concurrent.Executor, @NonNull android.media.session.MediaSessionManager.OnMediaKeyEventSessionChangedListener);
+ method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void removeOnMediaKeyEventDispatchedListener(@NonNull android.media.session.MediaSessionManager.OnMediaKeyEventDispatchedListener);
+ method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void removeOnMediaKeyEventSessionChangedListener(@NonNull android.media.session.MediaSessionManager.OnMediaKeyEventSessionChangedListener);
method @RequiresPermission(android.Manifest.permission.SET_MEDIA_KEY_LISTENER) public void setOnMediaKeyListener(android.media.session.MediaSessionManager.OnMediaKeyListener, @Nullable android.os.Handler);
method @RequiresPermission(android.Manifest.permission.SET_VOLUME_KEY_LONG_PRESS_LISTENER) public void setOnVolumeKeyLongPressListener(android.media.session.MediaSessionManager.OnVolumeKeyLongPressListener, @Nullable android.os.Handler);
- method @RequiresPermission(android.Manifest.permission.MEDIA_CONTENT_CONTROL) public void unregisterCallback(@NonNull android.media.session.MediaSessionManager.Callback);
}
- public abstract static class MediaSessionManager.Callback {
- ctor public MediaSessionManager.Callback();
- method public abstract void onAddressedPlayerChanged(android.media.session.MediaSession.Token);
- method public abstract void onAddressedPlayerChanged(android.content.ComponentName);
- method public abstract void onMediaKeyEventDispatched(android.view.KeyEvent, android.media.session.MediaSession.Token);
- method public abstract void onMediaKeyEventDispatched(android.view.KeyEvent, android.content.ComponentName);
+ public static interface MediaSessionManager.OnMediaKeyEventDispatchedListener {
+ method public default void onMediaKeyEventDispatched(@NonNull android.view.KeyEvent, @NonNull String, @NonNull android.media.session.MediaSession.Token);
+ }
+
+ public static interface MediaSessionManager.OnMediaKeyEventSessionChangedListener {
+ method public default void onMediaKeyEventSessionChanged(@NonNull String, @Nullable android.media.session.MediaSession.Token);
}
public static interface MediaSessionManager.OnMediaKeyListener {
@@ -4199,8 +4266,11 @@
method @Nullable @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER) public android.media.soundtrigger.SoundTriggerDetector createSoundTriggerDetector(java.util.UUID, @NonNull android.media.soundtrigger.SoundTriggerDetector.Callback, @Nullable android.os.Handler);
method @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER) public void deleteModel(java.util.UUID);
method public int getDetectionServiceOperationsTimeout();
- method @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER) public android.media.soundtrigger.SoundTriggerManager.Model getModel(java.util.UUID);
+ method @Nullable @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER) public android.media.soundtrigger.SoundTriggerManager.Model getModel(java.util.UUID);
method @Nullable @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER) public android.hardware.soundtrigger.SoundTrigger.ModuleProperties getModuleProperties();
+ method @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER) public int getParameter(@NonNull java.util.UUID, int) throws java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException;
+ method @Nullable @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER) public android.hardware.soundtrigger.SoundTrigger.ModelParamRange queryParameter(@Nullable java.util.UUID, int);
+ method @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER) public int setParameter(@Nullable java.util.UUID, int, int) throws java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException;
method @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER) public void updateModel(android.media.soundtrigger.SoundTriggerManager.Model);
}
@@ -4357,6 +4427,7 @@
method @Nullable public String onHardwareRemoved(android.media.tv.TvInputHardwareInfo);
method @Nullable public android.media.tv.TvInputInfo onHdmiDeviceAdded(android.hardware.hdmi.HdmiDeviceInfo);
method @Nullable public String onHdmiDeviceRemoved(android.hardware.hdmi.HdmiDeviceInfo);
+ method public void onHdmiDeviceUpdated(@NonNull android.hardware.hdmi.HdmiDeviceInfo);
}
public abstract static class TvInputService.RecordingSession {
@@ -4499,6 +4570,14 @@
method public void onUpstreamChanged(@Nullable android.net.Network);
}
+ public class InvalidPacketException extends java.lang.Exception {
+ ctor public InvalidPacketException(int);
+ field public static final int ERROR_INVALID_IP_ADDRESS = -21; // 0xffffffeb
+ field public static final int ERROR_INVALID_LENGTH = -23; // 0xffffffe9
+ field public static final int ERROR_INVALID_PORT = -22; // 0xffffffea
+ field public final int error;
+ }
+
public final class IpConfiguration implements android.os.Parcelable {
ctor public IpConfiguration();
ctor public IpConfiguration(@NonNull android.net.IpConfiguration);
@@ -4549,6 +4628,15 @@
method @NonNull @RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS) public android.net.IpSecTransform buildTunnelModeTransform(@NonNull java.net.InetAddress, @NonNull android.net.IpSecManager.SecurityParameterIndex) throws java.io.IOException, android.net.IpSecManager.ResourceUnavailableException, android.net.IpSecManager.SpiUnavailableException;
}
+ public class KeepalivePacketData {
+ ctor protected KeepalivePacketData(@NonNull java.net.InetAddress, int, @NonNull java.net.InetAddress, int, @NonNull byte[]) throws android.net.InvalidPacketException;
+ method @NonNull public byte[] getPacket();
+ field @NonNull public final java.net.InetAddress dstAddress;
+ field public final int dstPort;
+ field @NonNull public final java.net.InetAddress srcAddress;
+ field public final int srcPort;
+ }
+
public class LinkAddress implements android.os.Parcelable {
ctor public LinkAddress(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int, int, int);
ctor public LinkAddress(@NonNull java.net.InetAddress, @IntRange(from=0, to=128) int);
@@ -4828,7 +4916,7 @@
method @NonNull public java.util.List<android.net.LinkAddress> getInternalAddresses();
method @NonNull public java.util.List<java.net.InetAddress> getInternalDhcpServers();
method @NonNull public java.util.List<java.net.InetAddress> getInternalDnsServers();
- method @NonNull public java.util.List<android.net.LinkAddress> getInternalSubnets();
+ method @NonNull public java.util.List<android.net.IpPrefix> getInternalSubnets();
method @NonNull public java.util.List<android.net.ipsec.ike.IkeTrafficSelector> getOutboundTrafficSelectors();
}
@@ -4897,6 +4985,7 @@
public final class IkeSessionConfiguration {
ctor public IkeSessionConfiguration();
method @NonNull public String getRemoteApplicationVersion();
+ method @NonNull public java.util.List<byte[]> getRemoteVendorIDs();
method public boolean isIkeExtensionEnabled(int);
field public static final int EXTENSION_TYPE_FRAGMENTATION = 1; // 0x1
field public static final int EXTENSION_TYPE_MOBIKE = 2; // 0x2
@@ -4916,9 +5005,9 @@
ctor public IkeSessionParams.Builder();
method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder addSaProposal(@NonNull android.net.ipsec.ike.IkeSaProposal);
method @NonNull public android.net.ipsec.ike.IkeSessionParams build();
- method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setAuthDigitalSignature(@NonNull java.security.cert.X509Certificate, @NonNull java.security.cert.X509Certificate, @NonNull java.security.PrivateKey);
- method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setAuthDigitalSignature(@NonNull java.security.cert.X509Certificate, @NonNull java.security.cert.X509Certificate, @NonNull java.util.List<java.security.cert.X509Certificate>, @NonNull java.security.PrivateKey);
- method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setAuthEap(@NonNull java.security.cert.X509Certificate, @NonNull android.net.eap.EapSessionConfig);
+ method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setAuthDigitalSignature(@Nullable java.security.cert.X509Certificate, @NonNull java.security.cert.X509Certificate, @NonNull java.security.PrivateKey);
+ method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setAuthDigitalSignature(@Nullable java.security.cert.X509Certificate, @NonNull java.security.cert.X509Certificate, @NonNull java.util.List<java.security.cert.X509Certificate>, @NonNull java.security.PrivateKey);
+ method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setAuthEap(@Nullable java.security.cert.X509Certificate, @NonNull android.net.eap.EapSessionConfig);
method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setAuthPsk(@NonNull byte[]);
method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setLocalIdentification(@NonNull android.net.ipsec.ike.IkeIdentification);
method @NonNull public android.net.ipsec.ike.IkeSessionParams.Builder setRemoteIdentification(@NonNull android.net.ipsec.ike.IkeIdentification);
@@ -4936,7 +5025,7 @@
}
public static class IkeSessionParams.IkeAuthDigitalSignRemoteConfig extends android.net.ipsec.ike.IkeSessionParams.IkeAuthConfig {
- method @NonNull public java.security.cert.X509Certificate getRemoteCaCert();
+ method @Nullable public java.security.cert.X509Certificate getRemoteCaCert();
}
public static class IkeSessionParams.IkeAuthEapConfig extends android.net.ipsec.ike.IkeSessionParams.IkeAuthConfig {
@@ -5000,12 +5089,10 @@
ctor public TunnelModeChildSessionParams.Builder();
method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInboundTrafficSelectors(@NonNull android.net.ipsec.ike.IkeTrafficSelector);
method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalAddressRequest(int);
- method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalAddressRequest(@NonNull java.net.InetAddress, int);
+ method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalAddressRequest(@NonNull java.net.Inet4Address);
+ method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalAddressRequest(@NonNull java.net.Inet6Address, int);
method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalDhcpServerRequest(int);
- method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalDhcpServerRequest(@NonNull java.net.InetAddress);
method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalDnsServerRequest(int);
- method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalDnsServerRequest(@NonNull java.net.InetAddress);
- method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addInternalSubnetRequest(int);
method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addOutboundTrafficSelectors(@NonNull android.net.ipsec.ike.IkeTrafficSelector);
method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams.Builder addSaProposal(@NonNull android.net.ipsec.ike.ChildSaProposal);
method @NonNull public android.net.ipsec.ike.TunnelModeChildSessionParams build();
@@ -5029,9 +5116,6 @@
public static interface TunnelModeChildSessionParams.ConfigRequestIpv4Netmask extends android.net.ipsec.ike.TunnelModeChildSessionParams.ConfigRequest {
}
- public static interface TunnelModeChildSessionParams.ConfigRequestIpv4Subnet extends android.net.ipsec.ike.TunnelModeChildSessionParams.ConfigRequest {
- }
-
public static interface TunnelModeChildSessionParams.ConfigRequestIpv6Address extends android.net.ipsec.ike.TunnelModeChildSessionParams.ConfigRequest {
method @Nullable public java.net.Inet6Address getAddress();
method public int getPrefixLength();
@@ -5041,9 +5125,6 @@
method @Nullable public java.net.Inet6Address getAddress();
}
- public static interface TunnelModeChildSessionParams.ConfigRequestIpv6Subnet extends android.net.ipsec.ike.TunnelModeChildSessionParams.ConfigRequest {
- }
-
}
package android.net.ipsec.ike.exceptions {
@@ -5648,7 +5729,6 @@
method public boolean isApMacRandomizationSupported();
method public boolean isConnectedMacRandomizationSupported();
method @Deprecated public boolean isDeviceToDeviceRttSupported();
- method public boolean isDualBandSupported();
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public boolean isDualModeSupported();
method public boolean isPortableHotspotSupported();
method @RequiresPermission(android.Manifest.permission.ACCESS_WIFI_STATE) public boolean isWifiApEnabled();
@@ -5661,10 +5741,10 @@
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void registerTrafficStateCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.WifiManager.TrafficStateCallback);
method @RequiresPermission(android.Manifest.permission.WIFI_UPDATE_USABILITY_STATS_SCORE) public void removeOnWifiUsabilityStatsListener(@NonNull android.net.wifi.WifiManager.OnWifiUsabilityStatsListener);
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void restoreBackupData(@NonNull byte[]);
- method @Nullable @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void restoreSoftApBackupData(@NonNull byte[]);
+ method @Nullable @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public android.net.wifi.SoftApConfiguration restoreSoftApBackupData(@NonNull byte[]);
method @Deprecated @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public void restoreSupplicantBackupData(@NonNull byte[], @NonNull byte[]);
method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public byte[] retrieveBackupData();
- method @Nullable @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public byte[] retrieveSoftApBackupData();
+ method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public byte[] retrieveSoftApBackupData();
method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD, android.Manifest.permission.NETWORK_STACK}) public void save(@NonNull android.net.wifi.WifiConfiguration, @Nullable android.net.wifi.WifiManager.ActionListener);
method @RequiresPermission(android.Manifest.permission.WIFI_SET_DEVICE_MOBILITY_STATE) public void setDeviceMobilityState(int);
method @RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS) public boolean setSoftApConfiguration(@NonNull android.net.wifi.SoftApConfiguration);
@@ -6204,6 +6284,27 @@
method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteWifiScanStoppedFromSource(@NonNull android.os.WorkSource);
method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteWifiState(int, @Nullable String);
method @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public void noteWifiSupplicantStateChanged(int, boolean);
+ field public static final int WIFI_STATE_OFF = 0; // 0x0
+ field public static final int WIFI_STATE_OFF_SCANNING = 1; // 0x1
+ field public static final int WIFI_STATE_ON_CONNECTED_P2P = 5; // 0x5
+ field public static final int WIFI_STATE_ON_CONNECTED_STA = 4; // 0x4
+ field public static final int WIFI_STATE_ON_CONNECTED_STA_P2P = 6; // 0x6
+ field public static final int WIFI_STATE_ON_DISCONNECTED = 3; // 0x3
+ field public static final int WIFI_STATE_ON_NO_NETWORKS = 2; // 0x2
+ field public static final int WIFI_STATE_SOFT_AP = 7; // 0x7
+ field public static final int WIFI_SUPPL_STATE_ASSOCIATED = 7; // 0x7
+ field public static final int WIFI_SUPPL_STATE_ASSOCIATING = 6; // 0x6
+ field public static final int WIFI_SUPPL_STATE_AUTHENTICATING = 5; // 0x5
+ field public static final int WIFI_SUPPL_STATE_COMPLETED = 10; // 0xa
+ field public static final int WIFI_SUPPL_STATE_DISCONNECTED = 1; // 0x1
+ field public static final int WIFI_SUPPL_STATE_DORMANT = 11; // 0xb
+ field public static final int WIFI_SUPPL_STATE_FOUR_WAY_HANDSHAKE = 8; // 0x8
+ field public static final int WIFI_SUPPL_STATE_GROUP_HANDSHAKE = 9; // 0x9
+ field public static final int WIFI_SUPPL_STATE_INACTIVE = 3; // 0x3
+ field public static final int WIFI_SUPPL_STATE_INTERFACE_DISABLED = 2; // 0x2
+ field public static final int WIFI_SUPPL_STATE_INVALID = 0; // 0x0
+ field public static final int WIFI_SUPPL_STATE_SCANNING = 4; // 0x4
+ field public static final int WIFI_SUPPL_STATE_UNINITIALIZED = 12; // 0xc
}
public class Binder implements android.os.IBinder {
@@ -6595,6 +6696,21 @@
field public static final int STATUS_WAITING_REBOOT = 5; // 0x5
}
+ public class TelephonyServiceManager {
+ method @NonNull public android.os.TelephonyServiceManager.ServiceRegisterer getTelephonyServiceRegisterer();
+ }
+
+ public static class TelephonyServiceManager.ServiceNotFoundException extends java.lang.Exception {
+ ctor public TelephonyServiceManager.ServiceNotFoundException(@NonNull String);
+ }
+
+ public final class TelephonyServiceManager.ServiceRegisterer {
+ method @Nullable public android.os.IBinder get();
+ method @NonNull public android.os.IBinder getOrThrow() throws android.os.TelephonyServiceManager.ServiceNotFoundException;
+ method public void register(@NonNull android.os.IBinder);
+ method @Nullable public android.os.IBinder tryGet();
+ }
+
public class UpdateEngine {
ctor public UpdateEngine();
method public void applyPayload(String, long, long, String[]);
@@ -7019,34 +7135,34 @@
field public static final int STATUS_NOT_BLOCKED = 0; // 0x0
}
- public static final class ContactsContract.MetadataSync implements android.provider.BaseColumns android.provider.ContactsContract.MetadataSyncColumns {
- field public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_metadata";
- field public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact_metadata";
- field public static final android.net.Uri CONTENT_URI;
- field public static final String METADATA_AUTHORITY = "com.android.contacts.metadata";
- field public static final android.net.Uri METADATA_AUTHORITY_URI;
+ @Deprecated public static final class ContactsContract.MetadataSync implements android.provider.BaseColumns android.provider.ContactsContract.MetadataSyncColumns {
+ field @Deprecated public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_metadata";
+ field @Deprecated public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact_metadata";
+ field @Deprecated public static final android.net.Uri CONTENT_URI;
+ field @Deprecated public static final String METADATA_AUTHORITY = "com.android.contacts.metadata";
+ field @Deprecated public static final android.net.Uri METADATA_AUTHORITY_URI;
}
- protected static interface ContactsContract.MetadataSyncColumns {
- field public static final String ACCOUNT_NAME = "account_name";
- field public static final String ACCOUNT_TYPE = "account_type";
- field public static final String DATA = "data";
- field public static final String DATA_SET = "data_set";
- field public static final String DELETED = "deleted";
- field public static final String RAW_CONTACT_BACKUP_ID = "raw_contact_backup_id";
+ @Deprecated protected static interface ContactsContract.MetadataSyncColumns {
+ field @Deprecated public static final String ACCOUNT_NAME = "account_name";
+ field @Deprecated public static final String ACCOUNT_TYPE = "account_type";
+ field @Deprecated public static final String DATA = "data";
+ field @Deprecated public static final String DATA_SET = "data_set";
+ field @Deprecated public static final String DELETED = "deleted";
+ field @Deprecated public static final String RAW_CONTACT_BACKUP_ID = "raw_contact_backup_id";
}
- public static final class ContactsContract.MetadataSyncState implements android.provider.BaseColumns android.provider.ContactsContract.MetadataSyncStateColumns {
- field public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_metadata_sync_state";
- field public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact_metadata_sync_state";
- field public static final android.net.Uri CONTENT_URI;
+ @Deprecated public static final class ContactsContract.MetadataSyncState implements android.provider.BaseColumns android.provider.ContactsContract.MetadataSyncStateColumns {
+ field @Deprecated public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_metadata_sync_state";
+ field @Deprecated public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact_metadata_sync_state";
+ field @Deprecated public static final android.net.Uri CONTENT_URI;
}
- protected static interface ContactsContract.MetadataSyncStateColumns {
- field public static final String ACCOUNT_NAME = "account_name";
- field public static final String ACCOUNT_TYPE = "account_type";
- field public static final String DATA_SET = "data_set";
- field public static final String STATE = "state";
+ @Deprecated protected static interface ContactsContract.MetadataSyncStateColumns {
+ field @Deprecated public static final String ACCOUNT_NAME = "account_name";
+ field @Deprecated public static final String ACCOUNT_TYPE = "account_type";
+ field @Deprecated public static final String DATA_SET = "data_set";
+ field @Deprecated public static final String STATE = "state";
}
public final class DeviceConfig {
@@ -7060,13 +7176,14 @@
method @RequiresPermission(android.Manifest.permission.READ_DEVICE_CONFIG) public static String getString(@NonNull String, @NonNull String, @Nullable String);
method public static void removeOnPropertiesChangedListener(@NonNull android.provider.DeviceConfig.OnPropertiesChangedListener);
method @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static void resetToDefaults(int, @Nullable String);
- method @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static boolean setProperties(@NonNull android.provider.DeviceConfig.Properties);
+ method @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static boolean setProperties(@NonNull android.provider.DeviceConfig.Properties) throws android.provider.DeviceConfig.BadConfigException;
method @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static boolean setProperty(@NonNull String, @NonNull String, @Nullable String, boolean);
field public static final String NAMESPACE_ACTIVITY_MANAGER = "activity_manager";
field public static final String NAMESPACE_ACTIVITY_MANAGER_NATIVE_BOOT = "activity_manager_native_boot";
field public static final String NAMESPACE_APP_COMPAT = "app_compat";
field public static final String NAMESPACE_ATTENTION_MANAGER_SERVICE = "attention_manager_service";
field public static final String NAMESPACE_AUTOFILL = "autofill";
+ field public static final String NAMESPACE_BIOMETRICS = "biometrics";
field public static final String NAMESPACE_CONNECTIVITY = "connectivity";
field public static final String NAMESPACE_CONTENT_CAPTURE = "content_capture";
field @Deprecated public static final String NAMESPACE_DEX_BOOT = "dex_boot";
@@ -7092,6 +7209,10 @@
field public static final String NAMESPACE_TEXTCLASSIFIER = "textclassifier";
}
+ public static class DeviceConfig.BadConfigException extends java.lang.Exception {
+ ctor public DeviceConfig.BadConfigException();
+ }
+
public static interface DeviceConfig.OnPropertiesChangedListener {
method public void onPropertiesChanged(@NonNull android.provider.DeviceConfig.Properties);
}
@@ -7106,6 +7227,16 @@
method @Nullable public String getString(@NonNull String, @Nullable String);
}
+ public static final class DeviceConfig.Properties.Builder {
+ ctor public DeviceConfig.Properties.Builder(@NonNull String);
+ method @NonNull public android.provider.DeviceConfig.Properties build();
+ method @NonNull public android.provider.DeviceConfig.Properties.Builder setBoolean(@NonNull String, boolean);
+ method @NonNull public android.provider.DeviceConfig.Properties.Builder setFloat(@NonNull String, float);
+ method @NonNull public android.provider.DeviceConfig.Properties.Builder setInt(@NonNull String, int);
+ method @NonNull public android.provider.DeviceConfig.Properties.Builder setLong(@NonNull String, long);
+ method @NonNull public android.provider.DeviceConfig.Properties.Builder setString(@NonNull String, @Nullable String);
+ }
+
public final class DocumentsContract {
method public static boolean isManageMode(@NonNull android.net.Uri);
method @NonNull public static android.net.Uri setManageMode(@NonNull android.net.Uri);
@@ -7239,6 +7370,7 @@
public final class Settings {
field public static final String ACTION_ACCESSIBILITY_DETAILS_SETTINGS = "android.settings.ACCESSIBILITY_DETAILS_SETTINGS";
+ field public static final String ACTION_BUGREPORT_HANDLER_SETTINGS = "android.settings.BUGREPORT_HANDLER_SETTINGS";
field public static final String ACTION_ENTERPRISE_PRIVACY_SETTINGS = "android.settings.ENTERPRISE_PRIVACY_SETTINGS";
field public static final String ACTION_LOCATION_CONTROLLER_EXTRA_PACKAGE_SETTINGS = "android.settings.LOCATION_CONTROLLER_EXTRA_PACKAGE_SETTINGS";
field public static final String ACTION_MANAGE_APP_OVERLAY_PERMISSION = "android.settings.MANAGE_APP_OVERLAY_PERMISSION";
@@ -7915,6 +8047,7 @@
field public static final String KEY_CONTEXTUAL_ACTIONS = "key_contextual_actions";
field public static final String KEY_IMPORTANCE = "key_importance";
field public static final String KEY_PEOPLE = "key_people";
+ field public static final String KEY_RANKING_SCORE = "key_ranking_score";
field public static final String KEY_SNOOZE_CRITERIA = "key_snooze_criteria";
field public static final String KEY_TEXT_REPLIES = "key_text_replies";
field public static final String KEY_USER_SENTIMENT = "key_user_sentiment";
@@ -9196,7 +9329,6 @@
method public void onOutgoingEmergencyCall(@NonNull android.telephony.emergency.EmergencyNumber);
method public void onOutgoingEmergencySms(@NonNull android.telephony.emergency.EmergencyNumber);
method @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public void onPreciseCallStateChanged(@NonNull android.telephony.PreciseCallState);
- method @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public void onPreciseDataConnectionStateChanged(@NonNull android.telephony.PreciseDataConnectionState);
method public void onRadioPowerStateChanged(int);
method public void onSrvccStateChanged(int);
method public void onVoiceActivationStateChanged(int);
@@ -9206,7 +9338,6 @@
field @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) public static final int LISTEN_OUTGOING_EMERGENCY_CALL = 268435456; // 0x10000000
field @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) public static final int LISTEN_OUTGOING_EMERGENCY_SMS = 536870912; // 0x20000000
field @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public static final int LISTEN_PRECISE_CALL_STATE = 2048; // 0x800
- field @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public static final int LISTEN_PRECISE_DATA_CONNECTION_STATE = 4096; // 0x1000
field public static final int LISTEN_RADIO_POWER_STATE_CHANGED = 8388608; // 0x800000
field @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final int LISTEN_SRVCC_STATE_CHANGED = 16384; // 0x4000
field public static final int LISTEN_VOICE_ACTIVATION_STATE = 131072; // 0x20000
@@ -9232,13 +9363,12 @@
}
public final class PreciseDataConnectionState implements android.os.Parcelable {
- method public int describeContents();
- method @Nullable public String getDataConnectionApn();
- method public int getDataConnectionApnTypeBitMask();
- method public int getDataConnectionFailCause();
- method public int getDataConnectionState();
- method public void writeToParcel(android.os.Parcel, int);
- field @NonNull public static final android.os.Parcelable.Creator<android.telephony.PreciseDataConnectionState> CREATOR;
+ method @Deprecated @NonNull public String getDataConnectionApn();
+ method @Deprecated public int getDataConnectionApnTypeBitMask();
+ method @Deprecated public int getDataConnectionFailCause();
+ method @Deprecated @Nullable public android.net.LinkProperties getDataConnectionLinkProperties();
+ method @Deprecated public int getDataConnectionNetworkType();
+ method @Deprecated public int getDataConnectionState();
}
public final class PreciseDisconnectCause {
@@ -9482,6 +9612,7 @@
}
public class SubscriptionInfo implements android.os.Parcelable {
+ method public boolean areUiccApplicationsEnabled();
method @Nullable public java.util.List<android.telephony.UiccAccessRule> getAccessRules();
method public int getProfileClass();
method public boolean isGroupDisabled();
@@ -9521,6 +9652,7 @@
public class TelephonyFrameworkInitializer {
method public static void registerServiceWrappers();
+ method public static void setTelephonyServiceManager(@NonNull android.os.TelephonyServiceManager);
}
public final class TelephonyHistogram implements android.os.Parcelable {
@@ -9545,9 +9677,6 @@
public class TelephonyManager {
method @Deprecated @RequiresPermission(android.Manifest.permission.CALL_PHONE) public void call(String, String);
- method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void carrierActionReportDefaultNetworkStatus(int, boolean);
- method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void carrierActionResetAll(int);
- method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void carrierActionSetRadioEnabled(int, boolean);
method public int checkCarrierPrivilegesForPackage(String);
method public int checkCarrierPrivilegesForPackageAnyPhone(String);
method public void dial(String);
@@ -9560,6 +9689,7 @@
method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int);
method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent);
method public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int);
+ method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getCarrierPrivilegeStatus(int);
method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List<java.lang.String> getCarrierPrivilegedPackagesForAllActiveSubscriptions();
method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.CarrierRestrictionRules getCarrierRestrictionRules();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String getCdmaMdn();
@@ -9601,6 +9731,7 @@
method @Nullable @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public android.telephony.IccOpenLogicalChannelResponse iccOpenLogicalChannelBySlot(int, @Nullable String, int);
method @NonNull @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String iccTransmitApduBasicChannelBySlot(int, int, int, int, int, int, @Nullable String);
method @Nullable @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String iccTransmitApduLogicalChannelBySlot(int, int, int, int, int, int, int, @Nullable String);
+ method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isAnyRadioPoweredOn();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isApplicationOnUicc(int);
method public boolean isDataConnectivityPossible();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isDataEnabledForApn(int);
@@ -9619,8 +9750,11 @@
method public boolean needsOtaServiceProvisioning();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void notifyOtaEmergencyNumberDbInstalled();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean rebootRadio();
+ method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void reportDefaultNetworkStatus(boolean);
method @RequiresPermission(allOf={android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.MODIFY_PHONE_STATE}) public void requestCellInfoUpdate(@NonNull android.os.WorkSource, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CellInfoCallback);
+ method public void requestModemActivityInfo(@NonNull android.os.ResultReceiver);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void requestNumberVerification(@NonNull android.telephony.PhoneNumberRange, long, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.NumberVerificationCallback);
+ method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void resetAllCarrierActions();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void resetCarrierKeysForImsiEncryption();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean resetRadioConfig();
method @RequiresPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL) public void resetSettings();
@@ -9634,11 +9768,13 @@
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setOpportunisticNetworkState(boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setPreferredNetworkTypeBitmask(long);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setRadio(boolean);
+ method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setRadioEnabled(boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setRadioPower(boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSimPowerState(int);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSimPowerStateForSlot(int, int);
method @Deprecated public void setVisualVoicemailEnabled(android.telecom.PhoneAccountHandle, boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setVoiceActivationState(int);
+ method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void shutdownAllRadios();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean supplyPin(String);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int[] supplyPinReportResult(String);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean supplyPuk(String, String);
@@ -9648,6 +9784,7 @@
method public void updateServiceLocation();
method @RequiresPermission(android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) public void updateTestOtaEmergencyNumberDbFilePath(@NonNull String);
field @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public static final String ACTION_ANOMALY_REPORTED = "android.telephony.action.ANOMALY_REPORTED";
+ field public static final String ACTION_EMERGENCY_ASSISTANCE = "android.telephony.action.EMERGENCY_ASSISTANCE";
field public static final String ACTION_SIM_APPLICATION_STATE_CHANGED = "android.telephony.action.SIM_APPLICATION_STATE_CHANGED";
field public static final String ACTION_SIM_CARD_STATE_CHANGED = "android.telephony.action.SIM_CARD_STATE_CHANGED";
field public static final String ACTION_SIM_SLOT_STATUS_CHANGED = "android.telephony.action.SIM_SLOT_STATUS_CHANGED";
@@ -10242,6 +10379,11 @@
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.ims.ImsExternalCallState> CREATOR;
}
+ public class ImsManager {
+ method @NonNull public android.telephony.ims.ImsMmTelManager getImsMmTelManager(int);
+ method @NonNull public android.telephony.ims.ImsRcsManager getImsRcsManager(int);
+ }
+
public class ImsMmTelManager implements android.telephony.ims.RegistrationManager {
method @NonNull public static android.telephony.ims.ImsMmTelManager createForSubscriptionId(int);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void getFeatureState(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>) throws android.telephony.ims.ImsException;
@@ -10285,6 +10427,22 @@
ctor @Deprecated public ImsMmTelManager.RegistrationCallback();
}
+ public class ImsRcsManager implements android.telephony.ims.RegistrationManager {
+ method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void getRegistrationState(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>);
+ method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void getRegistrationTransportType(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>);
+ method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isAvailable(int) throws android.telephony.ims.ImsException;
+ method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isCapable(int, int) throws android.telephony.ims.ImsException;
+ method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void registerImsRegistrationCallback(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.ims.RegistrationManager.RegistrationCallback) throws android.telephony.ims.ImsException;
+ method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void registerRcsAvailabilityCallback(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.ims.ImsRcsManager.AvailabilityCallback) throws android.telephony.ims.ImsException;
+ method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void unregisterImsRegistrationCallback(@NonNull android.telephony.ims.RegistrationManager.RegistrationCallback);
+ method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void unregisterRcsAvailabilityCallback(@NonNull android.telephony.ims.ImsRcsManager.AvailabilityCallback) throws android.telephony.ims.ImsException;
+ }
+
+ public static class ImsRcsManager.AvailabilityCallback {
+ ctor public ImsRcsManager.AvailabilityCallback();
+ method public void onAvailabilityChanged(@NonNull android.telephony.ims.feature.RcsFeature.RcsImsCapabilities);
+ }
+
public final class ImsReasonInfo implements android.os.Parcelable {
field public static final String EXTRA_MSG_SERVICE_NOT_AUTHORIZED = "Forbidden. Not Authorized for Service";
}
@@ -10646,9 +10804,22 @@
public class RcsFeature extends android.telephony.ims.feature.ImsFeature {
ctor public RcsFeature();
- method public void changeEnabledCapabilities(android.telephony.ims.feature.CapabilityChangeRequest, android.telephony.ims.feature.ImsFeature.CapabilityCallbackProxy);
+ method public void changeEnabledCapabilities(@NonNull android.telephony.ims.feature.CapabilityChangeRequest, @NonNull android.telephony.ims.feature.ImsFeature.CapabilityCallbackProxy);
+ method public final void notifyCapabilitiesStatusChanged(@NonNull android.telephony.ims.feature.RcsFeature.RcsImsCapabilities);
method public void onFeatureReady();
method public void onFeatureRemoved();
+ method public boolean queryCapabilityConfiguration(int, int);
+ method @NonNull public final android.telephony.ims.feature.RcsFeature.RcsImsCapabilities queryCapabilityStatus();
+ }
+
+ public static class RcsFeature.RcsImsCapabilities extends android.telephony.ims.feature.ImsFeature.Capabilities {
+ ctor public RcsFeature.RcsImsCapabilities(int);
+ method public void addCapabilities(int);
+ method public boolean isCapable(int);
+ method public void removeCapabilities(int);
+ field public static final int CAPABILITY_TYPE_NONE = 0; // 0x0
+ field public static final int CAPABILITY_TYPE_OPTIONS_UCE = 1; // 0x1
+ field public static final int CAPABILITY_TYPE_PRESENCE_UCE = 2; // 0x2
}
}
diff --git a/api/test-current.txt b/api/test-current.txt
index efb8538..1c6bce0 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -711,6 +711,7 @@
field public static final String POWER_WHITELIST_MANAGER = "power_whitelist";
field public static final String ROLLBACK_SERVICE = "rollback";
field public static final String STATUS_BAR_SERVICE = "statusbar";
+ field public static final String TELEPHONY_IMS_SERVICE = "telephony_ims";
field public static final String TEST_NETWORK_SERVICE = "test_network";
}
@@ -722,6 +723,7 @@
public class Intent implements java.lang.Cloneable android.os.Parcelable {
field @RequiresPermission("android.permission.MANAGE_ROLE_HOLDERS") public static final String ACTION_MANAGE_DEFAULT_APP = "android.intent.action.MANAGE_DEFAULT_APP";
field public static final String ACTION_ROLLBACK_COMMITTED = "android.intent.action.ROLLBACK_COMMITTED";
+ field public static final String EXTRA_ORIGINATING_UID = "android.intent.extra.ORIGINATING_UID";
field public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME";
}
@@ -753,6 +755,7 @@
method public void setEnableRollback(boolean);
method @RequiresPermission("android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS") public void setGrantedRuntimePermissions(String[]);
method @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES) public void setInstallAsApex();
+ method public void setInstallerPackageName(@Nullable String);
method public void setRequestDowngrade(boolean);
method @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES) public void setStaged();
}
@@ -2431,6 +2434,7 @@
method @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static boolean setProperty(@NonNull String, @NonNull String, @Nullable String, boolean);
field public static final String NAMESPACE_ANDROID = "android";
field public static final String NAMESPACE_AUTOFILL = "autofill";
+ field public static final String NAMESPACE_BIOMETRICS = "biometrics";
field public static final String NAMESPACE_CONTENT_CAPTURE = "content_capture";
field public static final String NAMESPACE_PERMISSIONS = "permissions";
field public static final String NAMESPACE_PRIVACY = "privacy";
@@ -2452,6 +2456,16 @@
method @Nullable public String getString(@NonNull String, @Nullable String);
}
+ public static final class DeviceConfig.Properties.Builder {
+ ctor public DeviceConfig.Properties.Builder(@NonNull String);
+ method @NonNull public android.provider.DeviceConfig.Properties build();
+ method @NonNull public android.provider.DeviceConfig.Properties.Builder setBoolean(@NonNull String, boolean);
+ method @NonNull public android.provider.DeviceConfig.Properties.Builder setFloat(@NonNull String, float);
+ method @NonNull public android.provider.DeviceConfig.Properties.Builder setInt(@NonNull String, int);
+ method @NonNull public android.provider.DeviceConfig.Properties.Builder setLong(@NonNull String, long);
+ method @NonNull public android.provider.DeviceConfig.Properties.Builder setString(@NonNull String, @Nullable String);
+ }
+
public final class MediaStore {
method @RequiresPermission(android.Manifest.permission.CLEAR_APP_USER_DATA) public static void deleteContributedMedia(android.content.Context, String, android.os.UserHandle) throws java.io.IOException;
method @RequiresPermission(android.Manifest.permission.CLEAR_APP_USER_DATA) public static long getContributedMediaSize(android.content.Context, String, android.os.UserHandle) throws java.io.IOException;
@@ -2818,6 +2832,7 @@
field @NonNull public static final android.os.Parcelable.Creator<android.service.notification.Adjustment> CREATOR;
field public static final String KEY_CONTEXTUAL_ACTIONS = "key_contextual_actions";
field public static final String KEY_IMPORTANCE = "key_importance";
+ field public static final String KEY_RANKING_SCORE = "key_ranking_score";
field public static final String KEY_SNOOZE_CRITERIA = "key_snooze_criteria";
field public static final String KEY_TEXT_REPLIES = "key_text_replies";
field public static final String KEY_USER_SENTIMENT = "key_user_sentiment";
@@ -3148,6 +3163,10 @@
field @RequiresPermission("android.permission.READ_ACTIVE_EMERGENCY_SESSION") public static final int LISTEN_OUTGOING_EMERGENCY_SMS = 536870912; // 0x20000000
}
+ public final class PreciseDataConnectionState implements android.os.Parcelable {
+ ctor @Deprecated public PreciseDataConnectionState(int, int, int, @NonNull String, @Nullable android.net.LinkProperties, int);
+ }
+
public class ServiceState implements android.os.Parcelable {
method public void addNetworkRegistrationInfo(android.telephony.NetworkRegistrationInfo);
method public void setCdmaSystemAndNetworkId(int, int);
@@ -3414,6 +3433,11 @@
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.ims.ImsExternalCallState> CREATOR;
}
+ public class ImsManager {
+ method @NonNull public android.telephony.ims.ImsMmTelManager getImsMmTelManager(int);
+ method @NonNull public android.telephony.ims.ImsRcsManager getImsRcsManager(int);
+ }
+
public class ImsMmTelManager implements android.telephony.ims.RegistrationManager {
method @NonNull public static android.telephony.ims.ImsMmTelManager createForSubscriptionId(int);
method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public void getFeatureState(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>) throws android.telephony.ims.ImsException;
@@ -3457,6 +3481,22 @@
ctor @Deprecated public ImsMmTelManager.RegistrationCallback();
}
+ public class ImsRcsManager implements android.telephony.ims.RegistrationManager {
+ method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public void getRegistrationState(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>);
+ method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public void getRegistrationTransportType(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>);
+ method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public boolean isAvailable(int) throws android.telephony.ims.ImsException;
+ method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public boolean isCapable(int, int) throws android.telephony.ims.ImsException;
+ method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public void registerImsRegistrationCallback(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.ims.RegistrationManager.RegistrationCallback) throws android.telephony.ims.ImsException;
+ method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public void registerRcsAvailabilityCallback(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.ims.ImsRcsManager.AvailabilityCallback) throws android.telephony.ims.ImsException;
+ method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public void unregisterImsRegistrationCallback(@NonNull android.telephony.ims.RegistrationManager.RegistrationCallback);
+ method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public void unregisterRcsAvailabilityCallback(@NonNull android.telephony.ims.ImsRcsManager.AvailabilityCallback) throws android.telephony.ims.ImsException;
+ }
+
+ public static class ImsRcsManager.AvailabilityCallback {
+ ctor public ImsRcsManager.AvailabilityCallback();
+ method public void onAvailabilityChanged(@NonNull android.telephony.ims.feature.RcsFeature.RcsImsCapabilities);
+ }
+
public class ImsService extends android.app.Service {
ctor public ImsService();
method public android.telephony.ims.feature.MmTelFeature createMmTelFeature(int);
@@ -3814,9 +3854,22 @@
public class RcsFeature extends android.telephony.ims.feature.ImsFeature {
ctor public RcsFeature();
- method public void changeEnabledCapabilities(android.telephony.ims.feature.CapabilityChangeRequest, android.telephony.ims.feature.ImsFeature.CapabilityCallbackProxy);
+ method public void changeEnabledCapabilities(@NonNull android.telephony.ims.feature.CapabilityChangeRequest, @NonNull android.telephony.ims.feature.ImsFeature.CapabilityCallbackProxy);
+ method public final void notifyCapabilitiesStatusChanged(@NonNull android.telephony.ims.feature.RcsFeature.RcsImsCapabilities);
method public void onFeatureReady();
method public void onFeatureRemoved();
+ method public boolean queryCapabilityConfiguration(int, int);
+ method @NonNull public final android.telephony.ims.feature.RcsFeature.RcsImsCapabilities queryCapabilityStatus();
+ }
+
+ public static class RcsFeature.RcsImsCapabilities extends android.telephony.ims.feature.ImsFeature.Capabilities {
+ ctor public RcsFeature.RcsImsCapabilities(int);
+ method public void addCapabilities(int);
+ method public boolean isCapable(int);
+ method public void removeCapabilities(int);
+ field public static final int CAPABILITY_TYPE_NONE = 0; // 0x0
+ field public static final int CAPABILITY_TYPE_OPTIONS_UCE = 1; // 0x1
+ field public static final int CAPABILITY_TYPE_PRESENCE_UCE = 2; // 0x2
}
}
@@ -4422,7 +4475,7 @@
field public static final int ACCESSIBILITY_TITLE_CHANGED = 33554432; // 0x2000000
field public static final int PRIVATE_FLAG_NO_MOVE_ANIMATION = 64; // 0x40
field public CharSequence accessibilityTitle;
- field @android.view.ViewDebug.ExportedProperty(flagMapping={@android.view.ViewDebug.FlagToString(mask=0x1, equals=0x1, name="FAKE_HARDWARE_ACCELERATED"), @android.view.ViewDebug.FlagToString(mask=0x2, equals=0x2, name="FORCE_HARDWARE_ACCELERATED"), @android.view.ViewDebug.FlagToString(mask=0x4, equals=0x4, name="WANTS_OFFSET_NOTIFICATIONS"), @android.view.ViewDebug.FlagToString(mask=0x10, equals=0x10, name="SHOW_FOR_ALL_USERS"), @android.view.ViewDebug.FlagToString(mask=android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION, equals=android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION, name="NO_MOVE_ANIMATION"), @android.view.ViewDebug.FlagToString(mask=0x80, equals=0x80, name="COMPATIBLE_WINDOW"), @android.view.ViewDebug.FlagToString(mask=0x100, equals=0x100, name="SYSTEM_ERROR"), @android.view.ViewDebug.FlagToString(mask=0x400, equals=0x400, name="KEYGUARD"), @android.view.ViewDebug.FlagToString(mask=0x800, equals=0x800, name="DISABLE_WALLPAPER_TOUCH_EVENTS"), @android.view.ViewDebug.FlagToString(mask=0x1000, equals=0x1000, name="FORCE_STATUS_BAR_VISIBLE_TRANSPARENT"), @android.view.ViewDebug.FlagToString(mask=0x2000, equals=0x2000, name="PRESERVE_GEOMETRY"), @android.view.ViewDebug.FlagToString(mask=0x4000, equals=0x4000, name="FORCE_DECOR_VIEW_VISIBILITY"), @android.view.ViewDebug.FlagToString(mask=0x8000, equals=0x8000, name="WILL_NOT_REPLACE_ON_RELAUNCH"), @android.view.ViewDebug.FlagToString(mask=0x10000, equals=0x10000, name="LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME"), @android.view.ViewDebug.FlagToString(mask=0x20000, equals=0x20000, name="FORCE_DRAW_STATUS_BAR_BACKGROUND"), @android.view.ViewDebug.FlagToString(mask=0x40000, equals=0x40000, name="SUSTAINED_PERFORMANCE_MODE"), @android.view.ViewDebug.FlagToString(mask=0x80000, equals=0x80000, name="HIDE_NON_SYSTEM_OVERLAY_WINDOWS"), @android.view.ViewDebug.FlagToString(mask=0x100000, equals=0x100000, name="IS_ROUNDED_CORNERS_OVERLAY"), @android.view.ViewDebug.FlagToString(mask=0x400000, equals=0x400000, name="IS_SCREEN_DECOR"), @android.view.ViewDebug.FlagToString(mask=0x800000, equals=0x800000, name="STATUS_FORCE_SHOW_NAVIGATION"), @android.view.ViewDebug.FlagToString(mask=0x1000000, equals=0x1000000, name="COLOR_SPACE_AGNOSTIC")}) public int privateFlags;
+ field @android.view.ViewDebug.ExportedProperty(flagMapping={@android.view.ViewDebug.FlagToString(mask=0x1, equals=0x1, name="FAKE_HARDWARE_ACCELERATED"), @android.view.ViewDebug.FlagToString(mask=0x2, equals=0x2, name="FORCE_HARDWARE_ACCELERATED"), @android.view.ViewDebug.FlagToString(mask=0x4, equals=0x4, name="WANTS_OFFSET_NOTIFICATIONS"), @android.view.ViewDebug.FlagToString(mask=0x10, equals=0x10, name="SHOW_FOR_ALL_USERS"), @android.view.ViewDebug.FlagToString(mask=android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION, equals=android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION, name="NO_MOVE_ANIMATION"), @android.view.ViewDebug.FlagToString(mask=0x80, equals=0x80, name="COMPATIBLE_WINDOW"), @android.view.ViewDebug.FlagToString(mask=0x100, equals=0x100, name="SYSTEM_ERROR"), @android.view.ViewDebug.FlagToString(mask=0x400, equals=0x400, name="KEYGUARD"), @android.view.ViewDebug.FlagToString(mask=0x800, equals=0x800, name="DISABLE_WALLPAPER_TOUCH_EVENTS"), @android.view.ViewDebug.FlagToString(mask=0x1000, equals=0x1000, name="FORCE_STATUS_BAR_VISIBLE_TRANSPARENT"), @android.view.ViewDebug.FlagToString(mask=0x2000, equals=0x2000, name="PRESERVE_GEOMETRY"), @android.view.ViewDebug.FlagToString(mask=0x4000, equals=0x4000, name="FORCE_DECOR_VIEW_VISIBILITY"), @android.view.ViewDebug.FlagToString(mask=0x8000, equals=0x8000, name="WILL_NOT_REPLACE_ON_RELAUNCH"), @android.view.ViewDebug.FlagToString(mask=0x10000, equals=0x10000, name="LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME"), @android.view.ViewDebug.FlagToString(mask=0x20000, equals=0x20000, name="FORCE_DRAW_STATUS_BAR_BACKGROUND"), @android.view.ViewDebug.FlagToString(mask=0x40000, equals=0x40000, name="SUSTAINED_PERFORMANCE_MODE"), @android.view.ViewDebug.FlagToString(mask=0x80000, equals=0x80000, name="HIDE_NON_SYSTEM_OVERLAY_WINDOWS"), @android.view.ViewDebug.FlagToString(mask=0x100000, equals=0x100000, name="IS_ROUNDED_CORNERS_OVERLAY"), @android.view.ViewDebug.FlagToString(mask=0x400000, equals=0x400000, name="IS_SCREEN_DECOR"), @android.view.ViewDebug.FlagToString(mask=0x800000, equals=0x800000, name="STATUS_FORCE_SHOW_NAVIGATION"), @android.view.ViewDebug.FlagToString(mask=0x1000000, equals=0x1000000, name="COLOR_SPACE_AGNOSTIC"), @android.view.ViewDebug.FlagToString(mask=0x4000000, equals=0x4000000, name="FIT_INSETS_CONTROLLED"), @android.view.ViewDebug.FlagToString(mask=0x8000000, equals=0x8000000, name="ONLY_DRAW_BOTTOM_BAR_BACKGROUND")}) public int privateFlags;
}
public class WindowlessViewRoot {
diff --git a/cmds/hid/jni/Android.bp b/cmds/hid/jni/Android.bp
index 095cfc6..2c07de0 100644
--- a/cmds/hid/jni/Android.bp
+++ b/cmds/hid/jni/Android.bp
@@ -5,6 +5,7 @@
shared_libs: [
"libandroid",
+ "libbase",
"liblog",
"libnativehelper",
],
diff --git a/cmds/hid/jni/com_android_commands_hid_Device.cpp b/cmds/hid/jni/com_android_commands_hid_Device.cpp
index d4fdf85..f56dd6e 100644
--- a/cmds/hid/jni/com_android_commands_hid_Device.cpp
+++ b/cmds/hid/jni/com_android_commands_hid_Device.cpp
@@ -21,17 +21,21 @@
#include <linux/uhid.h>
#include <fcntl.h>
+#include <inttypes.h>
+#include <unistd.h>
#include <cstdio>
#include <cstring>
#include <memory>
-#include <unistd.h>
+#include <android/log.h>
+#include <android/looper.h>
#include <jni.h>
#include <nativehelper/JNIHelp.h>
+#include <nativehelper/ScopedLocalRef.h>
#include <nativehelper/ScopedPrimitiveArray.h>
#include <nativehelper/ScopedUtfChars.h>
-#include <android/looper.h>
-#include <android/log.h>
+
+#include <android-base/stringprintf.h>
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__)
@@ -46,6 +50,7 @@
static struct {
jmethodID onDeviceOpen;
jmethodID onDeviceGetReport;
+ jmethodID onDeviceOutput;
jmethodID onDeviceError;
} gDeviceCallbackClassInfo;
@@ -61,6 +66,26 @@
}
}
+static ScopedLocalRef<jbyteArray> toJbyteArray(JNIEnv* env, const std::vector<uint8_t>& vector) {
+ ScopedLocalRef<jbyteArray> array(env, env->NewByteArray(vector.size()));
+ if (array.get() == nullptr) {
+ jniThrowException(env, "java/lang/OutOfMemoryError", nullptr);
+ return array;
+ }
+ static_assert(sizeof(char) == sizeof(uint8_t));
+ env->SetByteArrayRegion(array.get(), 0, vector.size(),
+ reinterpret_cast<const signed char*>(vector.data()));
+ return array;
+}
+
+static std::string toString(const std::vector<uint8_t>& data) {
+ std::string s = "";
+ for (uint8_t b : data) {
+ s += android::base::StringPrintf("%x ", b);
+ }
+ return s;
+}
+
DeviceCallback::DeviceCallback(JNIEnv* env, jobject callback) :
mCallbackObject(env->NewGlobalRef(callback)) {
env->GetJavaVM(&mJavaVM);
@@ -90,23 +115,30 @@
checkAndClearException(env, "onDeviceGetReport");
}
+void DeviceCallback::onDeviceOutput(const std::vector<uint8_t>& data) {
+ JNIEnv* env = getJNIEnv();
+ env->CallVoidMethod(mCallbackObject, gDeviceCallbackClassInfo.onDeviceOutput,
+ toJbyteArray(env, data).get());
+ checkAndClearException(env, "onDeviceOutput");
+}
+
JNIEnv* DeviceCallback::getJNIEnv() {
JNIEnv* env;
mJavaVM->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
return env;
}
-Device* Device::open(int32_t id, const char* name, int32_t vid, int32_t pid,
- std::vector<uint8_t> descriptor, std::unique_ptr<DeviceCallback> callback) {
-
+std::unique_ptr<Device> Device::open(int32_t id, const char* name, int32_t vid, int32_t pid,
+ const std::vector<uint8_t>& descriptor,
+ std::unique_ptr<DeviceCallback> callback) {
size_t size = descriptor.size();
if (size > HID_MAX_DESCRIPTOR_SIZE) {
LOGE("Received invalid hid report with descriptor size %zu, skipping", size);
return nullptr;
}
- int fd = ::open(UHID_PATH, O_RDWR | O_CLOEXEC);
- if (fd < 0) {
+ android::base::unique_fd fd(::open(UHID_PATH, O_RDWR | O_CLOEXEC));
+ if (!fd.ok()) {
LOGE("Failed to open uhid: %s", strerror(errno));
return nullptr;
}
@@ -114,8 +146,7 @@
struct uhid_event ev = {};
ev.type = UHID_CREATE2;
strlcpy(reinterpret_cast<char*>(ev.u.create2.name), name, sizeof(ev.u.create2.name));
- memcpy(&ev.u.create2.rd_data, descriptor.data(),
- size * sizeof(ev.u.create2.rd_data[0]));
+ memcpy(&ev.u.create2.rd_data, descriptor.data(), size * sizeof(ev.u.create2.rd_data[0]));
ev.u.create2.rd_size = size;
ev.u.create2.bus = BUS_BLUETOOTH;
ev.u.create2.vendor = vid;
@@ -126,7 +157,6 @@
errno = 0;
ssize_t ret = TEMP_FAILURE_RETRY(::write(fd, &ev, sizeof(ev)));
if (ret < 0 || ret != sizeof(ev)) {
- ::close(fd);
LOGE("Failed to create uhid node: %s", strerror(errno));
return nullptr;
}
@@ -134,21 +164,21 @@
// Wait for the device to actually be created.
ret = TEMP_FAILURE_RETRY(::read(fd, &ev, sizeof(ev)));
if (ret < 0 || ev.type != UHID_START) {
- ::close(fd);
LOGE("uhid node failed to start: %s", strerror(errno));
return nullptr;
}
- return new Device(id, fd, std::move(callback));
+ // using 'new' to access non-public constructor
+ return std::unique_ptr<Device>(new Device(id, std::move(fd), std::move(callback)));
}
-Device::Device(int32_t id, int fd, std::unique_ptr<DeviceCallback> callback) :
- mId(id), mFd(fd), mDeviceCallback(std::move(callback)) {
+Device::Device(int32_t id, android::base::unique_fd fd, std::unique_ptr<DeviceCallback> callback)
+ : mId(id), mFd(std::move(fd)), mDeviceCallback(std::move(callback)) {
ALooper* aLooper = ALooper_forThread();
if (aLooper == NULL) {
LOGE("Could not get ALooper, ALooper_forThread returned NULL");
aLooper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
}
- ALooper_addFd(aLooper, fd, 0, ALOOPER_EVENT_INPUT, handleLooperEvents,
+ ALooper_addFd(aLooper, mFd, 0, ALOOPER_EVENT_INPUT, handleLooperEvents,
reinterpret_cast<void*>(this));
}
@@ -162,8 +192,14 @@
struct uhid_event ev = {};
ev.type = UHID_DESTROY;
TEMP_FAILURE_RETRY(::write(mFd, &ev, sizeof(ev)));
- ::close(mFd);
- mFd = -1;
+}
+
+// Send event over the fd.
+static void writeEvent(int fd, struct uhid_event& ev, const char* messageType) {
+ ssize_t ret = TEMP_FAILURE_RETRY(::write(fd, &ev, sizeof(ev)));
+ if (ret < 0 || ret != sizeof(ev)) {
+ LOGE("Failed to send uhid_event %s: %s", messageType, strerror(errno));
+ }
}
void Device::sendReport(const std::vector<uint8_t>& report) const {
@@ -176,10 +212,7 @@
ev.type = UHID_INPUT2;
ev.u.input2.size = report.size();
memcpy(&ev.u.input2.data, report.data(), report.size() * sizeof(ev.u.input2.data[0]));
- ssize_t ret = TEMP_FAILURE_RETRY(::write(mFd, &ev, sizeof(ev)));
- if (ret < 0 || ret != sizeof(ev)) {
- LOGE("Failed to send hid event: %s", strerror(errno));
- }
+ writeEvent(mFd, ev, "UHID_INPUT2");
}
void Device::sendGetFeatureReportReply(uint32_t id, const std::vector<uint8_t>& report) const {
@@ -190,10 +223,7 @@
ev.u.get_report_reply.size = report.size();
memcpy(&ev.u.get_report_reply.data, report.data(),
report.size() * sizeof(ev.u.get_report_reply.data[0]));
- ssize_t ret = TEMP_FAILURE_RETRY(::write(mFd, &ev, sizeof(ev)));
- if (ret < 0 || ret != sizeof(ev)) {
- LOGE("Failed to send hid event (UHID_GET_REPORT_REPLY): %s", strerror(errno));
- }
+ writeEvent(mFd, ev, "UHID_GET_REPORT_REPLY");
}
int Device::handleEvents(int events) {
@@ -210,13 +240,37 @@
return 0;
}
- if (ev.type == UHID_OPEN) {
- mDeviceCallback->onDeviceOpen();
- } else if (ev.type == UHID_GET_REPORT) {
- mDeviceCallback->onDeviceGetReport(ev.u.get_report.id, ev.u.get_report.rnum);
- } else if (ev.type == UHID_SET_REPORT) {
- LOGE("UHID_SET_REPORT is currently not supported");
- return 0;
+ switch (ev.type) {
+ case UHID_OPEN: {
+ mDeviceCallback->onDeviceOpen();
+ break;
+ }
+ case UHID_GET_REPORT: {
+ mDeviceCallback->onDeviceGetReport(ev.u.get_report.id, ev.u.get_report.rnum);
+ break;
+ }
+ case UHID_SET_REPORT: {
+ const struct uhid_set_report_req& set_report = ev.u.set_report;
+ if (set_report.size > UHID_DATA_MAX) {
+ LOGE("SET_REPORT contains too much data: size = %" PRIu16, set_report.size);
+ return 0;
+ }
+
+ std::vector<uint8_t> data(set_report.data, set_report.data + set_report.size);
+ LOGI("Received SET_REPORT: id=%" PRIu32 " rnum=%" PRIu8 " data=%s", set_report.id,
+ set_report.rnum, toString(data).c_str());
+ break;
+ }
+ case UHID_OUTPUT: {
+ struct uhid_output_req& output = ev.u.output;
+ std::vector<uint8_t> data(output.data, output.data + output.size);
+ mDeviceCallback->onDeviceOutput(data);
+ break;
+ }
+ default: {
+ LOGI("Unhandled event type: %" PRIu32, ev.type);
+ break;
+ }
}
return 1;
@@ -250,9 +304,10 @@
std::unique_ptr<uhid::DeviceCallback> cb(new uhid::DeviceCallback(env, callback));
- uhid::Device* d = uhid::Device::open(
- id, reinterpret_cast<const char*>(name.c_str()), vid, pid, desc, std::move(cb));
- return reinterpret_cast<jlong>(d);
+ std::unique_ptr<uhid::Device> d =
+ uhid::Device::open(id, reinterpret_cast<const char*>(name.c_str()), vid, pid, desc,
+ std::move(cb));
+ return reinterpret_cast<jlong>(d.release());
}
static void sendReport(JNIEnv* env, jclass /* clazz */, jlong ptr, jbyteArray rawReport) {
@@ -304,6 +359,8 @@
env->GetMethodID(clazz, "onDeviceOpen", "()V");
uhid::gDeviceCallbackClassInfo.onDeviceGetReport =
env->GetMethodID(clazz, "onDeviceGetReport", "(II)V");
+ uhid::gDeviceCallbackClassInfo.onDeviceOutput =
+ env->GetMethodID(clazz, "onDeviceOutput", "([B)V");
uhid::gDeviceCallbackClassInfo.onDeviceError =
env->GetMethodID(clazz, "onDeviceError", "()V");
if (uhid::gDeviceCallbackClassInfo.onDeviceOpen == NULL ||
diff --git a/cmds/hid/jni/com_android_commands_hid_Device.h b/cmds/hid/jni/com_android_commands_hid_Device.h
index 892c7cd..93ea881 100644
--- a/cmds/hid/jni/com_android_commands_hid_Device.h
+++ b/cmds/hid/jni/com_android_commands_hid_Device.h
@@ -19,6 +19,8 @@
#include <jni.h>
+#include <android-base/unique_fd.h>
+
namespace android {
namespace uhid {
@@ -29,6 +31,7 @@
void onDeviceOpen();
void onDeviceGetReport(uint32_t requestId, uint8_t reportId);
+ void onDeviceOutput(const std::vector<uint8_t>& data);
void onDeviceError();
private:
@@ -39,10 +42,10 @@
class Device {
public:
- static Device* open(int32_t id, const char* name, int32_t vid, int32_t pid,
- std::vector<uint8_t> descriptor, std::unique_ptr<DeviceCallback> callback);
+ static std::unique_ptr<Device> open(int32_t id, const char* name, int32_t vid, int32_t pid,
+ const std::vector<uint8_t>& descriptor,
+ std::unique_ptr<DeviceCallback> callback);
- Device(int32_t id, int fd, std::unique_ptr<DeviceCallback> callback);
~Device();
void sendReport(const std::vector<uint8_t>& report) const;
@@ -52,8 +55,9 @@
int handleEvents(int events);
private:
+ Device(int32_t id, android::base::unique_fd fd, std::unique_ptr<DeviceCallback> callback);
int32_t mId;
- int mFd;
+ android::base::unique_fd mFd;
std::unique_ptr<DeviceCallback> mDeviceCallback;
};
diff --git a/cmds/hid/src/com/android/commands/hid/Device.java b/cmds/hid/src/com/android/commands/hid/Device.java
index 616d411..874604c 100644
--- a/cmds/hid/src/com/android/commands/hid/Device.java
+++ b/cmds/hid/src/com/android/commands/hid/Device.java
@@ -20,13 +20,16 @@
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
-import android.os.MessageQueue;
import android.os.SystemClock;
import android.util.Log;
import android.util.SparseArray;
import com.android.internal.os.SomeArgs;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.Map;
+
public class Device {
private static final String TAG = "HidDevice";
@@ -40,6 +43,7 @@
private final DeviceHandler mHandler;
// mFeatureReports is limited to 256 entries, because the report number is 8-bit
private final SparseArray<byte[]> mFeatureReports;
+ private final Map<ByteBuffer, byte[]> mOutputs;
private long mTimeToSend;
private final Object mCond = new Object();
@@ -55,12 +59,13 @@
private static native void nativeCloseDevice(long ptr);
public Device(int id, String name, int vid, int pid, byte[] descriptor,
- byte[] report, SparseArray<byte[]> featureReports) {
+ byte[] report, SparseArray<byte[]> featureReports, Map<ByteBuffer, byte[]> outputs) {
mId = id;
mThread = new HandlerThread("HidDeviceHandler");
mThread.start();
mHandler = new DeviceHandler(mThread.getLooper());
mFeatureReports = featureReports;
+ mOutputs = outputs;
SomeArgs args = SomeArgs.obtain();
args.argi1 = id;
args.argi2 = vid;
@@ -160,6 +165,11 @@
}
public void onDeviceGetReport(int requestId, int reportId) {
+ if (mFeatureReports == null) {
+ Log.e(TAG, "Received GET_REPORT request for reportId=" + reportId
+ + ", but 'feature_reports' section is not found");
+ return;
+ }
byte[] report = mFeatureReports.get(reportId);
if (report == null) {
@@ -176,6 +186,29 @@
mHandler.sendMessageAtTime(msg, mTimeToSend);
}
+ // native callback
+ public void onDeviceOutput(byte[] data) {
+ if (mOutputs == null) {
+ Log.e(TAG, "Received OUTPUT request, but 'outputs' section is not found");
+ return;
+ }
+ byte[] response = mOutputs.get(ByteBuffer.wrap(data));
+ if (response == null) {
+ Log.i(TAG,
+ "Requested response for output " + Arrays.toString(data) + " is not found");
+ return;
+ }
+
+ Message msg;
+ msg = mHandler.obtainMessage(MSG_SEND_REPORT, response);
+
+ // Message is set to asynchronous so it won't be blocked by synchronization
+ // barrier during UHID_OPEN. This is necessary for drivers that do
+ // UHID_OUTPUT requests during probe, and expect a response right away.
+ msg.setAsynchronous(true);
+ mHandler.sendMessageAtTime(msg, mTimeToSend);
+ }
+
public void onDeviceError() {
Log.e(TAG, "Device error occurred, closing /dev/uhid");
Message msg = mHandler.obtainMessage(MSG_CLOSE_DEVICE);
diff --git a/cmds/hid/src/com/android/commands/hid/Event.java b/cmds/hid/src/com/android/commands/hid/Event.java
index 746e372..62587a7 100644
--- a/cmds/hid/src/com/android/commands/hid/Event.java
+++ b/cmds/hid/src/com/android/commands/hid/Event.java
@@ -21,10 +21,13 @@
import android.util.Log;
import android.util.SparseArray;
-import java.io.InputStreamReader;
import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
public class Event {
private static final String TAG = "HidEvent";
@@ -41,6 +44,7 @@
private int mPid;
private byte[] mReport;
private SparseArray<byte[]> mFeatureReports;
+ private Map<ByteBuffer, byte[]> mOutputs;
private int mDuration;
public int getId() {
@@ -75,6 +79,10 @@
return mFeatureReports;
}
+ public Map<ByteBuffer, byte[]> getOutputs() {
+ return mOutputs;
+ }
+
public int getDuration() {
return mDuration;
}
@@ -88,6 +96,7 @@
+ ", pid=" + mPid
+ ", report=" + Arrays.toString(mReport)
+ ", feature_reports=" + mFeatureReports.toString()
+ + ", outputs=" + mOutputs.toString()
+ ", duration=" + mDuration
+ "}";
}
@@ -123,6 +132,10 @@
mEvent.mFeatureReports = reports;
}
+ public void setOutputs(Map<ByteBuffer, byte[]> outputs) {
+ mEvent.mOutputs = outputs;
+ }
+
public void setVid(int vid) {
mEvent.mVid = vid;
}
@@ -199,6 +212,9 @@
case "feature_reports":
eb.setFeatureReports(readFeatureReports());
break;
+ case "outputs":
+ eb.setOutputs(readOutputs());
+ break;
case "duration":
eb.setDuration(readInt());
break;
@@ -250,7 +266,7 @@
private SparseArray<byte[]> readFeatureReports()
throws IllegalStateException, IOException {
- SparseArray<byte[]> featureReports = new SparseArray();
+ SparseArray<byte[]> featureReports = new SparseArray<>();
try {
mReader.beginArray();
while (mReader.hasNext()) {
@@ -276,17 +292,60 @@
}
}
mReader.endObject();
- if (data != null)
+ if (data != null) {
featureReports.put(id, data);
+ }
}
mReader.endArray();
- } catch (IllegalStateException|NumberFormatException e) {
+ } catch (IllegalStateException | NumberFormatException e) {
consumeRemainingElements();
mReader.endArray();
throw new IllegalStateException("Encountered malformed data.", e);
- } finally {
- return featureReports;
}
+ return featureReports;
+ }
+
+ private Map<ByteBuffer, byte[]> readOutputs()
+ throws IllegalStateException, IOException {
+ Map<ByteBuffer, byte[]> outputs = new HashMap<>();
+
+ try {
+ mReader.beginArray();
+ while (mReader.hasNext()) {
+ byte[] output = null;
+ byte[] response = null;
+ mReader.beginObject();
+ while (mReader.hasNext()) {
+ String name = mReader.nextName();
+ switch (name) {
+ case "description":
+ // Description is only used to keep track of the output responses
+ mReader.nextString();
+ break;
+ case "output":
+ output = readData();
+ break;
+ case "response":
+ response = readData();
+ break;
+ default:
+ consumeRemainingElements();
+ mReader.endObject();
+ throw new IllegalStateException("Invalid key in outputs: " + name);
+ }
+ }
+ mReader.endObject();
+ if (output != null) {
+ outputs.put(ByteBuffer.wrap(output), response);
+ }
+ }
+ mReader.endArray();
+ } catch (IllegalStateException | NumberFormatException e) {
+ consumeRemainingElements();
+ mReader.endArray();
+ throw new IllegalStateException("Encountered malformed data.", e);
+ }
+ return outputs;
}
private void consumeRemainingElements() throws IOException {
@@ -296,10 +355,6 @@
}
}
- private static void error(String msg) {
- error(msg, null);
- }
-
private static void error(String msg, Exception e) {
System.out.println(msg);
Log.e(TAG, msg);
diff --git a/cmds/hid/src/com/android/commands/hid/Hid.java b/cmds/hid/src/com/android/commands/hid/Hid.java
index 54ac1b0..0ee2cc4 100644
--- a/cmds/hid/src/com/android/commands/hid/Hid.java
+++ b/cmds/hid/src/com/android/commands/hid/Hid.java
@@ -16,22 +16,17 @@
package com.android.commands.hid;
-import android.util.JsonReader;
-import android.util.JsonToken;
import android.util.Log;
import android.util.SparseArray;
import libcore.io.IoUtils;
-import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.IOException;
import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
public class Hid {
private static final String TAG = "HID";
@@ -119,7 +114,7 @@
}
int id = e.getId();
Device d = new Device(id, e.getName(), e.getVendorId(), e.getProductId(),
- e.getDescriptor(), e.getReport(), e.getFeatureReports());
+ e.getDescriptor(), e.getReport(), e.getFeatureReports(), e.getOutputs());
mDevices.append(id, d);
}
diff --git a/cmds/incident/main.cpp b/cmds/incident/main.cpp
index 6c3d197..eb2b98a 100644
--- a/cmds/incident/main.cpp
+++ b/cmds/incident/main.cpp
@@ -375,7 +375,7 @@
if (destination == DEST_STDOUT) {
// Call into the service
sp<StatusListener> listener(new StatusListener());
- status = service->reportIncidentToStream(args, listener, writeEnd);
+ status = service->reportIncidentToStream(args, listener, std::move(writeEnd));
if (!status.isOk()) {
fprintf(stderr, "reportIncident returned \"%s\"\n", status.toString8().string());
@@ -388,7 +388,7 @@
} else if (destination == DEST_DUMPSTATE) {
// Call into the service
sp<StatusListener> listener(new StatusListener());
- status = service->reportIncidentToDumpstate(writeEnd, listener);
+ status = service->reportIncidentToDumpstate(std::move(writeEnd), listener);
if (!status.isOk()) {
fprintf(stderr, "reportIncident returned \"%s\"\n", status.toString8().string());
return 1;
diff --git a/cmds/incidentd/src/IncidentService.cpp b/cmds/incidentd/src/IncidentService.cpp
index 999936b..cfd77c2 100644
--- a/cmds/incidentd/src/IncidentService.cpp
+++ b/cmds/incidentd/src/IncidentService.cpp
@@ -279,7 +279,7 @@
Status IncidentService::reportIncidentToStream(const IncidentReportArgs& args,
const sp<IIncidentReportStatusListener>& listener,
- const unique_fd& stream) {
+ unique_fd stream) {
IncidentReportArgs argsCopy(args);
// Streaming reports can not also be broadcast.
@@ -306,7 +306,7 @@
return Status::ok();
}
-Status IncidentService::reportIncidentToDumpstate(const unique_fd& stream,
+Status IncidentService::reportIncidentToDumpstate(unique_fd stream,
const sp<IIncidentReportStatusListener>& listener) {
uid_t caller = IPCThreadState::self()->getCallingUid();
if (caller != AID_ROOT && caller != AID_SHELL) {
diff --git a/cmds/incidentd/src/IncidentService.h b/cmds/incidentd/src/IncidentService.h
index fb013d0..b2c7f23 100644
--- a/cmds/incidentd/src/IncidentService.h
+++ b/cmds/incidentd/src/IncidentService.h
@@ -121,9 +121,9 @@
virtual Status reportIncidentToStream(const IncidentReportArgs& args,
const sp<IIncidentReportStatusListener>& listener,
- const unique_fd& stream);
+ unique_fd stream);
- virtual Status reportIncidentToDumpstate(const unique_fd& stream,
+ virtual Status reportIncidentToDumpstate(unique_fd stream,
const sp<IIncidentReportStatusListener>& listener);
virtual Status systemRunning();
diff --git a/cmds/media/Android.bp b/cmds/media/Android.bp
deleted file mode 100644
index 7879c53..0000000
--- a/cmds/media/Android.bp
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright 2013 The Android Open Source Project
-//
-
-java_binary {
- name: "media",
- wrapper: "media",
- srcs: ["**/*.java"],
-}
diff --git a/cmds/media/MODULE_LICENSE_APACHE2 b/cmds/media/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/cmds/media/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/cmds/media/NOTICE b/cmds/media/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/cmds/media/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, 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.
-
- 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.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/cmds/media/media b/cmds/media/media
deleted file mode 100755
index 00c3915..0000000
--- a/cmds/media/media
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/system/bin/sh
-export CLASSPATH=/system/framework/media.jar
-exec app_process /system/bin com.android.commands.media.Media "$@"
diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp
index 3c5ad42..4d38ba0 100644
--- a/cmds/statsd/src/StatsService.cpp
+++ b/cmds/statsd/src/StatsService.cpp
@@ -272,7 +272,7 @@
}
return NO_ERROR;
}
- default: { return BnStatsManager::onTransact(code, data, reply, flags); }
+ default: { return BnStatsd::onTransact(code, data, reply, flags); }
}
}
@@ -862,13 +862,13 @@
int64_t trainVersion = strtoll(args[2].c_str(), nullptr, 10);
int options = 0;
if (args[3] == "1") {
- options = options | IStatsManager::FLAG_REQUIRE_STAGING;
+ options = options | IStatsd::FLAG_REQUIRE_STAGING;
}
if (args[4] == "1") {
- options = options | IStatsManager::FLAG_ROLLBACK_ENABLED;
+ options = options | IStatsd::FLAG_ROLLBACK_ENABLED;
}
if (args[5] == "1") {
- options = options | IStatsManager::FLAG_REQUIRE_LOW_LATENCY_MONITOR;
+ options = options | IStatsd::FLAG_REQUIRE_LOW_LATENCY_MONITOR;
}
int32_t state = atoi(args[6].c_str());
vector<int64_t> experimentIds;
@@ -1406,9 +1406,9 @@
StorageManager::writeTrainInfo(trainVersionCode, trainNameUtf8, state, experimentIds);
userid_t userId = multiuser_get_user_id(uid);
- bool requiresStaging = options & IStatsManager::FLAG_REQUIRE_STAGING;
- bool rollbackEnabled = options & IStatsManager::FLAG_ROLLBACK_ENABLED;
- bool requiresLowLatencyMonitor = options & IStatsManager::FLAG_REQUIRE_LOW_LATENCY_MONITOR;
+ bool requiresStaging = options & IStatsd::FLAG_REQUIRE_STAGING;
+ bool rollbackEnabled = options & IStatsd::FLAG_ROLLBACK_ENABLED;
+ bool requiresLowLatencyMonitor = options & IStatsd::FLAG_REQUIRE_LOW_LATENCY_MONITOR;
LogEvent event(trainNameUtf8, trainVersionCode, requiresStaging, rollbackEnabled,
requiresLowLatencyMonitor, state, experimentIdsProtoBuffer, userId);
mProcessor->OnLogEvent(&event);
diff --git a/cmds/statsd/src/StatsService.h b/cmds/statsd/src/StatsService.h
index 50b1014..9abf415 100644
--- a/cmds/statsd/src/StatsService.h
+++ b/cmds/statsd/src/StatsService.h
@@ -29,9 +29,9 @@
#include <android/frameworks/stats/1.0/IStats.h>
#include <android/frameworks/stats/1.0/types.h>
-#include <android/os/BnStatsManager.h>
+#include <android/os/BnStatsd.h>
#include <android/os/IStatsCompanionService.h>
-#include <android/os/IStatsManager.h>
+#include <android/os/IStatsd.h>
#include <binder/IResultReceiver.h>
#include <binder/ParcelFileDescriptor.h>
#include <utils/Looper.h>
@@ -52,7 +52,7 @@
using android::hardware::Return;
-class StatsService : public BnStatsManager,
+class StatsService : public BnStatsd,
public IStats,
public IBinder::DeathRecipient {
public:
diff --git a/cmds/svc/src/com/android/commands/svc/DataCommand.java b/cmds/svc/src/com/android/commands/svc/DataCommand.java
index 35510cf..b4dbd1d 100644
--- a/cmds/svc/src/com/android/commands/svc/DataCommand.java
+++ b/cmds/svc/src/com/android/commands/svc/DataCommand.java
@@ -16,12 +16,16 @@
package com.android.commands.svc;
-import android.os.ServiceManager;
-import android.os.RemoteException;
-import android.content.Context;
-import com.android.internal.telephony.ITelephony;
-
+/**
+ * @deprecated Please use adb shell cmd phone data enabled/disable instead.
+ */
+@Deprecated
public class DataCommand extends Svc.Command {
+
+ private static final String DECPRECATED_MESSAGE =
+ "adb shell svc data enable/disable is deprecated;"
+ + "please use adb shell cmd phone data enable/disable instead.";
+
public DataCommand() {
super("data");
}
@@ -33,36 +37,10 @@
public String longHelp() {
return shortHelp() + "\n"
+ "\n"
- + "usage: svc data [enable|disable]\n"
- + " Turn mobile data on or off.\n\n";
+ + DECPRECATED_MESSAGE;
}
public void run(String[] args) {
- boolean validCommand = false;
- if (args.length >= 2) {
- boolean flag = false;
- if ("enable".equals(args[1])) {
- flag = true;
- validCommand = true;
- } else if ("disable".equals(args[1])) {
- flag = false;
- validCommand = true;
- }
- if (validCommand) {
- ITelephony phoneMgr
- = ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE));
- try {
- if (flag) {
- phoneMgr.enableDataConnectivity();
- } else
- phoneMgr.disableDataConnectivity();
- }
- catch (RemoteException e) {
- System.err.println("Mobile data operation failed: " + e);
- }
- return;
- }
- }
- System.err.println(longHelp());
+ System.err.println(DECPRECATED_MESSAGE);
}
}
diff --git a/core/java/android/accessibilityservice/AccessibilityGestureEvent.java b/core/java/android/accessibilityservice/AccessibilityGestureEvent.java
index 8b62e2f..d82b151 100644
--- a/core/java/android/accessibilityservice/AccessibilityGestureEvent.java
+++ b/core/java/android/accessibilityservice/AccessibilityGestureEvent.java
@@ -17,6 +17,8 @@
package android.accessibilityservice;
+import static android.accessibilityservice.AccessibilityService.GESTURE_DOUBLE_TAP;
+import static android.accessibilityservice.AccessibilityService.GESTURE_DOUBLE_TAP_AND_HOLD;
import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_DOWN;
import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_DOWN_AND_LEFT;
import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_DOWN_AND_RIGHT;
@@ -58,6 +60,8 @@
/** @hide */
@IntDef(prefix = { "GESTURE_" }, value = {
+ GESTURE_DOUBLE_TAP,
+ GESTURE_DOUBLE_TAP_AND_HOLD,
GESTURE_SWIPE_UP,
GESTURE_SWIPE_UP_AND_LEFT,
GESTURE_SWIPE_UP_AND_DOWN,
diff --git a/core/java/android/accessibilityservice/AccessibilityService.java b/core/java/android/accessibilityservice/AccessibilityService.java
index 47fdcde..0f619c8 100644
--- a/core/java/android/accessibilityservice/AccessibilityService.java
+++ b/core/java/android/accessibilityservice/AccessibilityService.java
@@ -300,6 +300,18 @@
public static final int GESTURE_SWIPE_DOWN_AND_RIGHT = 16;
/**
+ * The user has performed a double tap gesture on the touch screen.
+ * @hide
+ */
+ public static final int GESTURE_DOUBLE_TAP = 17;
+
+ /**
+ * The user has performed a double tap and hold gesture on the touch screen.
+ * @hide
+ */
+ public static final int GESTURE_DOUBLE_TAP_AND_HOLD = 18;
+
+ /**
* The {@link Intent} that must be declared as handled by the service.
*/
public static final String SERVICE_INTERFACE =
diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java
index f4e465a..0f10c39 100644
--- a/core/java/android/accounts/AccountManager.java
+++ b/core/java/android/accounts/AccountManager.java
@@ -1943,35 +1943,6 @@
}
/**
- * @hide
- * Removes the shared account.
- * @param account the account to remove
- * @param user the user to remove the account from
- * @return
- */
- public boolean removeSharedAccount(final Account account, UserHandle user) {
- try {
- boolean val = mService.removeSharedAccountAsUser(account, user.getIdentifier());
- return val;
- } catch (RemoteException re) {
- throw re.rethrowFromSystemServer();
- }
- }
-
- /**
- * @hide
- * @param user
- * @return
- */
- public Account[] getSharedAccounts(UserHandle user) {
- try {
- return mService.getSharedAccountsAsUser(user.getIdentifier());
- } catch (RemoteException re) {
- throw re.rethrowFromSystemServer();
- }
- }
-
- /**
* Confirms that the user knows the password for an account to make extra
* sure they are the owner of the account. The user-entered password can
* be supplied directly, otherwise the authenticator for this account type
diff --git a/core/java/android/accounts/IAccountManager.aidl b/core/java/android/accounts/IAccountManager.aidl
index 4cf0a20..0127138 100644
--- a/core/java/android/accounts/IAccountManager.aidl
+++ b/core/java/android/accounts/IAccountManager.aidl
@@ -80,14 +80,11 @@
String authTokenType);
/* Shared accounts */
- Account[] getSharedAccountsAsUser(int userId);
- boolean removeSharedAccountAsUser(in Account account, int userId);
void addSharedAccountsFromParentUser(int parentUserId, int userId, String opPackageName);
/* Account renaming. */
void renameAccount(in IAccountManagerResponse response, in Account accountToRename, String newName);
String getPreviousName(in Account account);
- boolean renameSharedAccountAsUser(in Account accountToRename, String newName, int userId);
/* Add account in two steps. */
void startAddAccountSession(in IAccountManagerResponse response, String accountType,
diff --git a/core/java/android/annotation/OWNERS b/core/java/android/annotation/OWNERS
index e07028b..8aceb56 100644
--- a/core/java/android/annotation/OWNERS
+++ b/core/java/android/annotation/OWNERS
@@ -1,2 +1,3 @@
tnorbye@google.com
+aurimas@google.com
per-file UnsupportedAppUsage.java = mathewi@google.com, dbrazdil@google.com, atrost@google.com, andreionea@google.com
diff --git a/core/java/android/annotation/SystemApi.java b/core/java/android/annotation/SystemApi.java
index e96ff01..f589cc5 100644
--- a/core/java/android/annotation/SystemApi.java
+++ b/core/java/android/annotation/SystemApi.java
@@ -41,4 +41,29 @@
@Target({TYPE, FIELD, METHOD, CONSTRUCTOR, ANNOTATION_TYPE, PACKAGE})
@Retention(RetentionPolicy.RUNTIME)
public @interface SystemApi {
+ enum Client {
+ /**
+ * Specifies that the intended clients of a SystemApi are privileged apps.
+ * This is the default value for {@link #client}.
+ */
+ PRIVILEGED_APPS,
+ }
+
+ enum Process {
+ /**
+ * Specifies that the SystemAPI is available in every Java processes.
+ * This is the default value for {@link #process}.
+ */
+ ALL,
+ }
+
+ /**
+ * The intended client of this SystemAPI.
+ */
+ Client client() default android.annotation.SystemApi.Client.PRIVILEGED_APPS;
+
+ /**
+ * The process(es) that this SystemAPI is available
+ */
+ Process process() default android.annotation.SystemApi.Process.ALL;
}
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 577272e..1e3b950 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -766,9 +766,19 @@
private static final String REQUEST_PERMISSIONS_WHO_PREFIX = "@android:requestPermissions:";
private static final String AUTO_FILL_AUTH_WHO_PREFIX = "@android:autoFillAuth:";
-
private static final String KEYBOARD_SHORTCUTS_RECEIVER_PKG_NAME = "com.android.systemui";
+ private static final int LOG_AM_ON_CREATE_CALLED = 30057;
+ private static final int LOG_AM_ON_START_CALLED = 30059;
+ private static final int LOG_AM_ON_RESUME_CALLED = 30022;
+ private static final int LOG_AM_ON_PAUSE_CALLED = 30021;
+ private static final int LOG_AM_ON_STOP_CALLED = 30049;
+ private static final int LOG_AM_ON_RESTART_CALLED = 30058;
+ private static final int LOG_AM_ON_DESTROY_CALLED = 30060;
+ private static final int LOG_AM_ON_ACTIVITY_RESULT_CALLED = 30062;
+ private static final int LOG_AM_ON_TOP_RESUMED_GAINED_CALLED = 30064;
+ private static final int LOG_AM_ON_TOP_RESUMED_LOST_CALLED = 30065;
+
private static class ManagedDialog {
Dialog mDialog;
Bundle mArgs;
@@ -2439,8 +2449,11 @@
* {@link #onProvideKeyboardShortcuts} to retrieve the shortcuts for the foreground activity.
*/
public final void requestShowKeyboardShortcuts() {
+ final ComponentName sysuiComponent = ComponentName.unflattenFromString(
+ getResources().getString(
+ com.android.internal.R.string.config_systemUIServiceComponent));
Intent intent = new Intent(Intent.ACTION_SHOW_KEYBOARD_SHORTCUTS);
- intent.setPackage(KEYBOARD_SHORTCUTS_RECEIVER_PKG_NAME);
+ intent.setPackage(sysuiComponent.getPackageName());
sendBroadcastAsUser(intent, Process.myUserHandle());
}
@@ -2448,8 +2461,11 @@
* Dismiss the Keyboard Shortcuts screen.
*/
public final void dismissKeyboardShortcutsHelper() {
+ final ComponentName sysuiComponent = ComponentName.unflattenFromString(
+ getResources().getString(
+ com.android.internal.R.string.config_systemUIServiceComponent));
Intent intent = new Intent(Intent.ACTION_DISMISS_KEYBOARD_SHORTCUTS);
- intent.setPackage(KEYBOARD_SHORTCUTS_RECEIVER_PKG_NAME);
+ intent.setPackage(sysuiComponent.getPackageName());
sendBroadcastAsUser(intent, Process.myUserHandle());
}
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 590b3db..795f51a 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -4417,4 +4417,18 @@
}
}
}
+
+ /**
+ * Get packages of bugreport-whitelisted apps to handle a bug report.
+ *
+ * @return packages of bugreport-whitelisted apps to handle a bug report.
+ * @hide
+ */
+ public List<String> getBugreportWhitelistedPackages() {
+ try {
+ return getService().getBugreportWhitelistedPackages();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
}
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 49a8e2f3..5cdc505 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -112,6 +112,7 @@
import android.os.StrictMode;
import android.os.SystemClock;
import android.os.SystemProperties;
+import android.os.TelephonyServiceManager;
import android.os.Trace;
import android.os.UserHandle;
import android.permission.IPermissionManager;
@@ -128,6 +129,7 @@
import android.system.ErrnoException;
import android.system.OsConstants;
import android.system.StructStat;
+import android.telephony.TelephonyFrameworkInitializer;
import android.util.AndroidRuntimeException;
import android.util.ArrayMap;
import android.util.DisplayMetrics;
@@ -3415,7 +3417,7 @@
private ContextImpl createBaseContextForActivity(ActivityClientRecord r) {
final int displayId;
try {
- displayId = ActivityTaskManager.getService().getActivityDisplayId(r.token);
+ displayId = ActivityTaskManager.getService().getDisplayId(r.token);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -4405,7 +4407,9 @@
r.newConfig = null;
}
if (localLOGV) Slog.v(TAG, "Resuming " + r + " with isForward=" + isForward);
- WindowManager.LayoutParams l = r.window.getAttributes();
+ ViewRootImpl impl = r.window.getDecorView().getViewRootImpl();
+ WindowManager.LayoutParams l = impl != null
+ ? impl.mWindowAttributes : r.window.getAttributes();
if ((l.softInputMode
& WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION)
!= forwardBit) {
@@ -7395,6 +7399,24 @@
super.remove(path);
}
}
+
+ @Override
+ public void rename(String oldPath, String newPath) throws ErrnoException {
+ try {
+ super.rename(oldPath, newPath);
+ } catch (ErrnoException e) {
+ if (e.errno == OsConstants.EXDEV && oldPath.startsWith("/storage/")) {
+ Log.v(TAG, "Recovering failed rename " + oldPath + " to " + newPath);
+ try {
+ Files.move(new File(oldPath).toPath(), new File(newPath).toPath());
+ } catch (IOException e2) {
+ throw e;
+ }
+ } else {
+ throw e;
+ }
+ }
+ }
}
public static void main(String[] args) {
@@ -7414,6 +7436,9 @@
final File configDir = Environment.getUserConfigDirectory(UserHandle.myUserId());
TrustedCertificateStore.setDefaultUserDirectory(configDir);
+ // Call per-process mainline module initialization.
+ initializeMainlineModules();
+
Process.setArgV0("<pre-initialized>");
Looper.prepareMainLooper();
@@ -7448,6 +7473,14 @@
throw new RuntimeException("Main thread loop unexpectedly exited");
}
+ /**
+ * Call various initializer APIs in mainline modules that need to be called when each process
+ * starts.
+ */
+ public static void initializeMainlineModules() {
+ TelephonyFrameworkInitializer.setTelephonyServiceManager(new TelephonyServiceManager());
+ }
+
private void purgePendingResources() {
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "purgePendingResources");
nPurgePendingResources();
diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl
index aa8a302..112bd30 100644
--- a/core/java/android/app/IActivityManager.aidl
+++ b/core/java/android/app/IActivityManager.aidl
@@ -388,6 +388,7 @@
void requestFullBugReport();
void requestRemoteBugReport();
boolean launchBugReportHandlerApp();
+ List<String> getBugreportWhitelistedPackages();
@UnsupportedAppUsage
Intent getIntentForIntentSender(in IIntentSender sender);
diff --git a/core/java/android/app/IActivityTaskManager.aidl b/core/java/android/app/IActivityTaskManager.aidl
index 37136a1..e2b1b86 100644
--- a/core/java/android/app/IActivityTaskManager.aidl
+++ b/core/java/android/app/IActivityTaskManager.aidl
@@ -164,7 +164,7 @@
boolean convertToTranslucent(in IBinder token, in Bundle options);
void notifyActivityDrawn(in IBinder token);
void reportActivityFullyDrawn(in IBinder token, boolean restoredFromBundle);
- int getActivityDisplayId(in IBinder activityToken);
+ int getDisplayId(in IBinder activityToken);
boolean isImmersive(in IBinder token);
void setImmersive(in IBinder token, boolean immersive);
boolean isTopActivityImmersive();
@@ -405,6 +405,14 @@
void setDisablePreviewScreenshots(IBinder token, boolean disable);
/**
+ * It should only be called from home activity to remove its outdated snapshot. The home
+ * snapshot is used to speed up entering home from screen off. If the content of home activity
+ * is significantly different from before taking the snapshot, then the home activity can use
+ * this method to avoid inconsistent transition.
+ */
+ void invalidateHomeTaskSnapshot(IBinder homeToken);
+
+ /**
* Return the user id of last resumed activity.
*/
int getLastResumedActivityUserId();
diff --git a/core/java/android/app/IInstantAppResolver.aidl b/core/java/android/app/IInstantAppResolver.aidl
index 7318762..8618fbb 100644
--- a/core/java/android/app/IInstantAppResolver.aidl
+++ b/core/java/android/app/IInstantAppResolver.aidl
@@ -16,15 +16,13 @@
package android.app;
-import android.content.Intent;
+import android.content.pm.InstantAppRequestInfo;
import android.os.IRemoteCallback;
/** @hide */
oneway interface IInstantAppResolver {
- void getInstantAppResolveInfoList(in Intent sanitizedIntent, in int[] hostDigestPrefix,
- int userId, String token, int sequence, IRemoteCallback callback);
+ void getInstantAppResolveInfoList(in InstantAppRequestInfo request, int sequence,
+ IRemoteCallback callback);
- void getInstantAppIntentFilterList(in Intent sanitizedIntent, in int[] hostDigestPrefix,
- int userId, String token, IRemoteCallback callback);
-
+ void getInstantAppIntentFilterList(in InstantAppRequestInfo request, IRemoteCallback callback);
}
diff --git a/core/java/android/app/InstantAppResolverService.java b/core/java/android/app/InstantAppResolverService.java
index a7be542..a413c60 100644
--- a/core/java/android/app/InstantAppResolverService.java
+++ b/core/java/android/app/InstantAppResolverService.java
@@ -21,6 +21,7 @@
import android.annotation.SystemApi;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.InstantAppRequestInfo;
import android.content.pm.InstantAppResolveInfo;
import android.os.Build;
import android.os.Bundle;
@@ -59,8 +60,9 @@
* Called to retrieve resolve info for instant applications immediately.
*
* @param digestPrefix The hash prefix of the instant app's domain.
- * @deprecated Should implement {@link #onGetInstantAppResolveInfo(Intent, int[], UserHandle,
- * String, InstantAppResolutionCallback)}.
+ *
+ * @deprecated Should implement {@link #onGetInstantAppResolveInfo(InstantAppRequestInfo,
+ * InstantAppResolutionCallback)}
*/
@Deprecated
public void onGetInstantAppResolveInfo(@Nullable int[] digestPrefix, @NonNull String token,
@@ -73,8 +75,9 @@
* sources.
*
* @param digestPrefix The hash prefix of the instant app's domain.
- * @deprecated Should implement {@link #onGetInstantAppIntentFilter(Intent, int[], UserHandle,
- * String, InstantAppResolutionCallback)}.
+ *
+ * @deprecated Should implement {@link #onGetInstantAppIntentFilter(InstantAppRequestInfo,
+ * InstantAppResolutionCallback)}
*/
@Deprecated
public void onGetInstantAppIntentFilter(@Nullable int[] digestPrefix, @NonNull String token,
@@ -103,8 +106,8 @@
*
* @see InstantAppResolveInfo
*
- * @deprecated Should implement {@link #onGetInstantAppResolveInfo(Intent, int[], UserHandle,
- * String, InstantAppResolutionCallback)}.
+ * @deprecated Should implement {@link #onGetInstantAppResolveInfo(InstantAppRequestInfo,
+ * InstantAppResolutionCallback)}
*/
@Deprecated
public void onGetInstantAppResolveInfo(@NonNull Intent sanitizedIntent,
@@ -134,8 +137,8 @@
* {@link Intent#EXTRA_INSTANT_APP_TOKEN}.
* @param callback The {@link InstantAppResolutionCallback} to provide results to.
*
- * @deprecated Should implement {@link #onGetInstantAppIntentFilter(Intent, int[], UserHandle,
- * String, InstantAppResolutionCallback)}.
+ * @deprecated Should implement {@link #onGetInstantAppIntentFilter(InstantAppRequestInfo,
+ * InstantAppResolutionCallback)}
*/
@Deprecated
public void onGetInstantAppIntentFilter(@NonNull Intent sanitizedIntent,
@@ -170,7 +173,11 @@
* @param callback The {@link InstantAppResolutionCallback} to provide results to.
*
* @see InstantAppResolveInfo
+ *
+ * @deprecated Should implement {@link #onGetInstantAppResolveInfo(InstantAppRequestInfo,
+ * InstantAppResolutionCallback
*/
+ @Deprecated
public void onGetInstantAppResolveInfo(@NonNull Intent sanitizedIntent,
@Nullable int[] hostDigestPrefix, @NonNull UserHandle userHandle,
@NonNull String token, @NonNull InstantAppResolutionCallback callback) {
@@ -193,7 +200,11 @@
* Intent, int[], UserHandle, String, InstantAppResolutionCallback)} and provided
* to the currently visible installer via {@link Intent#EXTRA_INSTANT_APP_TOKEN}.
* @param callback The {@link InstantAppResolutionCallback} to provide results to.
+ *
+ * @deprecated Should implement {@link #onGetInstantAppIntentFilter(InstantAppRequestInfo,
+ * InstantAppResolutionCallback)}
*/
+ @Deprecated
public void onGetInstantAppIntentFilter(@NonNull Intent sanitizedIntent,
@Nullable int[] hostDigestPrefix, @NonNull UserHandle userHandle,
@NonNull String token, @NonNull InstantAppResolutionCallback callback) {
@@ -202,6 +213,41 @@
}
/**
+ * Called to retrieve resolve info for instant applications immediately. The response will be
+ * ignored if not provided within a reasonable time. {@link InstantAppResolveInfo}s provided
+ * in response to this method may be partial to request a second phase of resolution which will
+ * result in a subsequent call to {@link #onGetInstantAppIntentFilter(InstantAppRequestInfo,
+ * InstantAppResolutionCallback)}
+ *
+ * @param request The parameters for this resolution request
+ * @param callback The {@link InstantAppResolutionCallback} to provide results to.
+ *
+ * @see InstantAppResolveInfo
+ */
+ public void onGetInstantAppResolveInfo(@NonNull InstantAppRequestInfo request,
+ @NonNull InstantAppResolutionCallback callback) {
+ // If not overridden, forward to the old method.
+ onGetInstantAppResolveInfo(request.intent, request.hostDigestPrefix, request.userHandle,
+ request.token, callback);
+ }
+
+ /**
+ * Called to retrieve intent filters for potentially matching instant applications. Unlike
+ * {@link #onGetInstantAppResolveInfo(InstantAppRequestInfo, InstantAppResolutionCallback)},
+ * the response may take as long as necessary to respond. All {@link InstantAppResolveInfo}s
+ * provided in response to this method must be completely populated.
+ *
+ * @param request The parameters for this resolution request
+ * @param callback The {@link InstantAppResolutionCallback} to provide results to.
+ */
+ public void onGetInstantAppIntentFilter(@NonNull InstantAppRequestInfo request,
+ @NonNull InstantAppResolutionCallback callback) {
+ // If not overridden, forward to the old method.
+ onGetInstantAppIntentFilter(request.intent, request.hostDigestPrefix, request.userHandle,
+ request.token, callback);
+ }
+
+ /**
* Returns a {@link Looper} to perform service operations on.
*/
Looper getLooper() {
@@ -218,35 +264,29 @@
public final IBinder onBind(Intent intent) {
return new IInstantAppResolver.Stub() {
@Override
- public void getInstantAppResolveInfoList(Intent sanitizedIntent, int[] digestPrefix,
- int userId, String token, int sequence, IRemoteCallback callback) {
+ public void getInstantAppResolveInfoList(InstantAppRequestInfo request, int sequence,
+ IRemoteCallback callback) {
if (DEBUG_INSTANT) {
- Slog.v(TAG, "[" + token + "] Phase1 called; posting");
+ Slog.v(TAG, "[" + request.token + "] Phase1 called; posting");
}
final SomeArgs args = SomeArgs.obtain();
- args.arg1 = callback;
- args.arg2 = digestPrefix;
- args.arg3 = userId;
- args.arg4 = token;
- args.arg5 = sanitizedIntent;
- mHandler.obtainMessage(ServiceHandler.MSG_GET_INSTANT_APP_RESOLVE_INFO,
- sequence, 0, args).sendToTarget();
+ args.arg1 = request;
+ args.arg2 = callback;
+ mHandler.obtainMessage(ServiceHandler.MSG_GET_INSTANT_APP_RESOLVE_INFO, sequence,
+ 0, args).sendToTarget();
}
@Override
- public void getInstantAppIntentFilterList(Intent sanitizedIntent,
- int[] digestPrefix, int userId, String token, IRemoteCallback callback) {
+ public void getInstantAppIntentFilterList(InstantAppRequestInfo request,
+ IRemoteCallback callback) {
if (DEBUG_INSTANT) {
- Slog.v(TAG, "[" + token + "] Phase2 called; posting");
+ Slog.v(TAG, "[" + request.token + "] Phase2 called; posting");
}
final SomeArgs args = SomeArgs.obtain();
- args.arg1 = callback;
- args.arg2 = digestPrefix;
- args.arg3 = userId;
- args.arg4 = token;
- args.arg5 = sanitizedIntent;
- mHandler.obtainMessage(ServiceHandler.MSG_GET_INSTANT_APP_INTENT_FILTER,
- args).sendToTarget();
+ args.arg1 = request;
+ args.arg2 = callback;
+ mHandler.obtainMessage(ServiceHandler.MSG_GET_INSTANT_APP_INTENT_FILTER, args)
+ .sendToTarget();
}
};
}
@@ -287,36 +327,33 @@
switch (action) {
case MSG_GET_INSTANT_APP_RESOLVE_INFO: {
final SomeArgs args = (SomeArgs) message.obj;
- final IRemoteCallback callback = (IRemoteCallback) args.arg1;
- final int[] digestPrefix = (int[]) args.arg2;
- final int userId = (int) args.arg3;
- final String token = (String) args.arg4;
- final Intent intent = (Intent) args.arg5;
+ final InstantAppRequestInfo request = (InstantAppRequestInfo) args.arg1;
+ final IRemoteCallback callback = (IRemoteCallback) args.arg2;
+ args.recycle();
final int sequence = message.arg1;
if (DEBUG_INSTANT) {
- Slog.d(TAG, "[" + token + "] Phase1 request;"
- + " prefix: " + Arrays.toString(digestPrefix)
- + ", userId: " + userId);
+ Slog.d(TAG, "[" + request.token + "] Phase1 request;"
+ + " prefix: " + Arrays.toString(request.hostDigestPrefix)
+ + ", userId: " + request.userHandle.getIdentifier());
}
- onGetInstantAppResolveInfo(intent, digestPrefix, UserHandle.of(userId), token,
+ onGetInstantAppResolveInfo(request,
new InstantAppResolutionCallback(sequence, callback));
} break;
case MSG_GET_INSTANT_APP_INTENT_FILTER: {
final SomeArgs args = (SomeArgs) message.obj;
- final IRemoteCallback callback = (IRemoteCallback) args.arg1;
- final int[] digestPrefix = (int[]) args.arg2;
- final int userId = (int) args.arg3;
- final String token = (String) args.arg4;
- final Intent intent = (Intent) args.arg5;
+ final InstantAppRequestInfo request = (InstantAppRequestInfo) args.arg1;
+ final IRemoteCallback callback = (IRemoteCallback) args.arg2;
+ args.recycle();
if (DEBUG_INSTANT) {
- Slog.d(TAG, "[" + token + "] Phase2 request;"
- + " prefix: " + Arrays.toString(digestPrefix)
- + ", userId: " + userId);
+ Slog.d(TAG, "[" + request.token + "] Phase2 request;"
+ + " prefix: " + Arrays.toString(request.hostDigestPrefix)
+ + ", userId: " + request.userHandle.getIdentifier());
}
- onGetInstantAppIntentFilter(intent, digestPrefix, UserHandle.of(userId), token,
+ onGetInstantAppIntentFilter(request,
new InstantAppResolutionCallback(-1 /*sequence*/, callback));
- } break;
+ }
+ break;
default: {
throw new IllegalArgumentException("Unknown message: " + action);
diff --git a/core/java/android/app/StatsManager.java b/core/java/android/app/StatsManager.java
index 90cd51f..f6e9569 100644
--- a/core/java/android/app/StatsManager.java
+++ b/core/java/android/app/StatsManager.java
@@ -27,8 +27,8 @@
import android.os.IPullAtomCallback;
import android.os.IPullAtomResultReceiver;
import android.os.IStatsCompanionService;
-import android.os.IStatsManager;
import android.os.IStatsPullerCallback;
+import android.os.IStatsd;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.AndroidException;
@@ -56,7 +56,7 @@
private final Context mContext;
@GuardedBy("sLock")
- private IStatsManager mService;
+ private IStatsd mService;
@GuardedBy("sLock")
private IStatsCompanionService mStatsCompanion;
@@ -129,7 +129,7 @@
public void addConfig(long configKey, byte[] config) throws StatsUnavailableException {
synchronized (sLock) {
try {
- IStatsManager service = getIStatsManagerLocked();
+ IStatsd service = getIStatsdLocked();
// can throw IllegalArgumentException
service.addConfiguration(configKey, config, mContext.getOpPackageName());
} catch (RemoteException e) {
@@ -166,7 +166,7 @@
public void removeConfig(long configKey) throws StatsUnavailableException {
synchronized (sLock) {
try {
- IStatsManager service = getIStatsManagerLocked();
+ IStatsd service = getIStatsdLocked();
service.removeConfiguration(configKey, mContext.getOpPackageName());
} catch (RemoteException e) {
Slog.e(TAG, "Failed to connect to statsd when removing configuration");
@@ -227,7 +227,7 @@
throws StatsUnavailableException {
synchronized (sLock) {
try {
- IStatsManager service = getIStatsManagerLocked();
+ IStatsd service = getIStatsdLocked();
if (pendingIntent != null) {
// Extracts IIntentSender from the PendingIntent and turns it into an IBinder.
IBinder intentSender = pendingIntent.getTarget().asBinder();
@@ -281,7 +281,7 @@
throws StatsUnavailableException {
synchronized (sLock) {
try {
- IStatsManager service = getIStatsManagerLocked();
+ IStatsd service = getIStatsdLocked();
if (pendingIntent == null) {
service.removeDataFetchOperation(configKey, mContext.getOpPackageName());
} else {
@@ -319,7 +319,7 @@
throws StatsUnavailableException {
synchronized (sLock) {
try {
- IStatsManager service = getIStatsManagerLocked();
+ IStatsd service = getIStatsdLocked();
if (pendingIntent == null) {
service.removeActiveConfigsChangedOperation(mContext.getOpPackageName());
return new long[0];
@@ -367,7 +367,7 @@
public byte[] getReports(long configKey) throws StatsUnavailableException {
synchronized (sLock) {
try {
- IStatsManager service = getIStatsManagerLocked();
+ IStatsd service = getIStatsdLocked();
return service.getData(configKey, mContext.getOpPackageName());
} catch (RemoteException e) {
Slog.e(TAG, "Failed to connect to statsd when getting data");
@@ -404,7 +404,7 @@
public byte[] getStatsMetadata() throws StatsUnavailableException {
synchronized (sLock) {
try {
- IStatsManager service = getIStatsManagerLocked();
+ IStatsd service = getIStatsdLocked();
return service.getMetadata(mContext.getOpPackageName());
} catch (RemoteException e) {
Slog.e(TAG, "Failed to connect to statsd when getting metadata");
@@ -439,7 +439,7 @@
throws StatsUnavailableException {
synchronized (sLock) {
try {
- IStatsManager service = getIStatsManagerLocked();
+ IStatsd service = getIStatsdLocked();
if (service == null) {
if (DEBUG) {
Slog.d(TAG, "Failed to find statsd when getting experiment IDs");
@@ -476,7 +476,7 @@
throws StatsUnavailableException {
synchronized (sLock) {
try {
- IStatsManager service = getIStatsManagerLocked();
+ IStatsd service = getIStatsdLocked();
if (callback == null) {
service.unregisterPullerCallback(atomTag, mContext.getOpPackageName());
} else {
@@ -660,11 +660,11 @@
}
@GuardedBy("sLock")
- private IStatsManager getIStatsManagerLocked() throws StatsUnavailableException {
+ private IStatsd getIStatsdLocked() throws StatsUnavailableException {
if (mService != null) {
return mService;
}
- mService = IStatsManager.Stub.asInterface(ServiceManager.getService("stats"));
+ mService = IStatsd.Stub.asInterface(ServiceManager.getService("stats"));
if (mService == null) {
throw new StatsUnavailableException("could not be found");
}
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index 601b658..a1305da 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -53,7 +53,9 @@
import android.content.om.IOverlayManager;
import android.content.om.OverlayManager;
import android.content.pm.CrossProfileApps;
+import android.content.pm.DataLoaderManager;
import android.content.pm.ICrossProfileApps;
+import android.content.pm.IDataLoaderManager;
import android.content.pm.IPackageManager;
import android.content.pm.IShortcutService;
import android.content.pm.LauncherApps;
@@ -118,6 +120,7 @@
import android.net.lowpan.LowpanManager;
import android.net.nsd.INsdManager;
import android.net.nsd.NsdManager;
+import android.net.wifi.WifiCondManager;
import android.net.wifi.WifiFrameworkInitializer;
import android.nfc.NfcManager;
import android.os.BatteryManager;
@@ -694,6 +697,14 @@
return new EthernetManager(ctx.getOuterContext(), service);
}});
+ registerService(Context.WIFI_COND_SERVICE, WifiCondManager.class,
+ new CachedServiceFetcher<WifiCondManager>() {
+ @Override
+ public WifiCondManager createService(ContextImpl ctx) {
+ return new WifiCondManager(ctx.getOuterContext());
+ }
+ });
+
registerService(Context.WINDOW_SERVICE, WindowManager.class,
new CachedServiceFetcher<WindowManager>() {
@Override
@@ -1134,6 +1145,14 @@
return new TimeZoneDetector();
}});
+ registerService(Context.TELEPHONY_IMS_SERVICE, android.telephony.ims.ImsManager.class,
+ new CachedServiceFetcher<android.telephony.ims.ImsManager>() {
+ @Override
+ public android.telephony.ims.ImsManager createService(ContextImpl ctx) {
+ return new android.telephony.ims.ImsManager(ctx.getOuterContext());
+ }
+ });
+
registerService(Context.PERMISSION_SERVICE, PermissionManager.class,
new CachedServiceFetcher<PermissionManager>() {
@Override
@@ -1197,6 +1216,15 @@
return new BatteryStatsManager(
IBatteryStats.Stub.asInterface(b));
}});
+ registerService(Context.DATA_LOADER_MANAGER_SERVICE, DataLoaderManager.class,
+ new CachedServiceFetcher<DataLoaderManager>() {
+ @Override
+ public DataLoaderManager createService(ContextImpl ctx)
+ throws ServiceNotFoundException {
+ IBinder b = ServiceManager.getServiceOrThrow(
+ Context.DATA_LOADER_MANAGER_SERVICE);
+ return new DataLoaderManager(IDataLoaderManager.Stub.asInterface(b));
+ }});
//CHECKSTYLE:ON IndentationCheck
sInitializing = true;
diff --git a/core/java/android/app/TaskEmbedder.java b/core/java/android/app/TaskEmbedder.java
index 79d88fd..e5707bb 100644
--- a/core/java/android/app/TaskEmbedder.java
+++ b/core/java/android/app/TaskEmbedder.java
@@ -184,7 +184,7 @@
return false;
}
- // Create a container surface to which the ActivityDisplay will be reparented
+ // Create a container surface to which the DisplayContent will be reparented
final String name = "TaskEmbedder - " + Integer.toHexString(System.identityHashCode(this));
mSurfaceControl = new SurfaceControl.Builder()
.setContainerLayer()
@@ -276,7 +276,7 @@
* @see ActivityView.StateCallback
* @see #startActivity(Intent)
*/
- void setListener(TaskEmbedder.Listener listener) {
+ public void setListener(TaskEmbedder.Listener listener) {
mListener = listener;
if (mListener != null && isInitialized()) {
mListener.onInitialized();
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 915e457..7332978 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -1349,6 +1349,9 @@
* Broadcast action: send when any policy admin changes a policy.
* This is generally used to find out when a new policy is in effect.
*
+ * If the profile owner of an organization-owned managed profile changes some user
+ * restriction explicitly on the parent user, this broadcast will <em>not</em> be
+ * sent to the parent user.
* @hide
*/
@UnsupportedAppUsage
@@ -2324,6 +2327,11 @@
/**
* Activity action: Starts the administrator to show policy compliance for the provisioning.
+ * This action is used any time that the administrator has an opportunity to show policy
+ * compliance before the end of setup wizard. This could happen as part of the admin-integrated
+ * provisioning flow (in which case this gets sent after {@link #ACTION_GET_PROVISIONING_MODE}),
+ * or it could happen during provisioning finalization if the administrator supports
+ * finalization during setup wizard.
*/
public static final String ACTION_ADMIN_POLICY_COMPLIANCE =
"android.app.action.ADMIN_POLICY_COMPLIANCE";
@@ -5805,6 +5813,49 @@
}
/**
+ * Called by a device owner, a profile owner for the primary user or a profile
+ * owner of an organization-owned managed profile to turn auto time zone on and off.
+ * Callers are recommended to use {@link UserManager#DISALLOW_CONFIG_DATE_TIME}
+ * to prevent the user from changing this setting.
+ * <p>
+ * If user restriction {@link UserManager#DISALLOW_CONFIG_DATE_TIME} is used,
+ * no user will be able set the date and time zone. Instead, the network date
+ * and time zone will be used.
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+ * @param enabled Whether time zone should be obtained automatically from the network or not.
+ * @throws SecurityException if caller is not a device owner, a profile owner for the
+ * primary user, or a profile owner of an organization-owned managed profile.
+ */
+ public void setAutoTimeZone(@NonNull ComponentName admin, boolean enabled) {
+ throwIfParentInstance("setAutoTimeZone");
+ if (mService != null) {
+ try {
+ mService.setAutoTimeZone(admin, enabled);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+ }
+
+ /**
+ * @return true if auto time zone is enabled on the device.
+ * @throws SecurityException if caller is not a device owner, a profile owner for the
+ * primary user, or a profile owner of an organization-owned managed profile.
+ */
+ public boolean getAutoTimeZone(@NonNull ComponentName admin) {
+ throwIfParentInstance("getAutoTimeZone");
+ if (mService != null) {
+ try {
+ return mService.getAutoTimeZone(admin);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+ return false;
+ }
+
+ /**
* Called by a device owner to set whether all users created on the device should be ephemeral.
* <p>
* The system user is exempt from this policy - it is never ephemeral.
@@ -7910,18 +7961,23 @@
* <p>
* The calling device admin must be a profile or device owner; if it is not, a security
* exception will be thrown.
+ * <p>
+ * The profile owner of an organization-owned managed profile may invoke this method on
+ * the {@link DevicePolicyManager} instance it obtained from
+ * {@link #getParentProfileInstance(ComponentName)}, for enforcing device-wide restrictions.
+ * <p>
+ * See the constants in {@link android.os.UserManager} for the list of restrictions that can
+ * be enforced device-wide.
*
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
- * @param key The key of the restriction. See the constants in {@link android.os.UserManager}
- * for the list of keys.
+ * @param key The key of the restriction.
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public void addUserRestriction(@NonNull ComponentName admin,
@UserManager.UserRestrictionKey String key) {
- throwIfParentInstance("addUserRestriction");
if (mService != null) {
try {
- mService.setUserRestriction(admin, key, true);
+ mService.setUserRestriction(admin, key, true, mParentInstance);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -7933,18 +7989,22 @@
* <p>
* The calling device admin must be a profile or device owner; if it is not, a security
* exception will be thrown.
+ * <p>
+ * The profile owner of an organization-owned managed profile may invoke this method on
+ * the {@link DevicePolicyManager} instance it obtained from
+ * {@link #getParentProfileInstance(ComponentName)}, for clearing device-wide restrictions.
+ * <p>
+ * See the constants in {@link android.os.UserManager} for the list of restrictions.
*
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
- * @param key The key of the restriction. See the constants in {@link android.os.UserManager}
- * for the list of keys.
+ * @param key The key of the restriction.
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public void clearUserRestriction(@NonNull ComponentName admin,
@UserManager.UserRestrictionKey String key) {
- throwIfParentInstance("clearUserRestriction");
if (mService != null) {
try {
- mService.setUserRestriction(admin, key, false);
+ mService.setUserRestriction(admin, key, false, mParentInstance);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -7958,16 +8018,20 @@
* The target user may have more restrictions set by the system or other device owner / profile
* owner. To get all the user restrictions currently set, use
* {@link UserManager#getUserRestrictions()}.
+ * <p>
+ * The profile owner of an organization-owned managed profile may invoke this method on
+ * the {@link DevicePolicyManager} instance it obtained from
+ * {@link #getParentProfileInstance(ComponentName)}, for retrieving device-wide restrictions
+ * it previously set with {@link #addUserRestriction(ComponentName, String)}.
*
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
* @throws SecurityException if {@code admin} is not a device or profile owner.
*/
public @NonNull Bundle getUserRestrictions(@NonNull ComponentName admin) {
- throwIfParentInstance("getUserRestrictions");
Bundle ret = null;
if (mService != null) {
try {
- ret = mService.getUserRestrictions(admin);
+ ret = mService.getUserRestrictions(admin, mParentInstance);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -11085,6 +11149,53 @@
}
/**
+ * Sets the set of package names that are allowed to request user consent for cross-profile
+ * communication.
+ *
+ * <p>Assumes that the caller is a profile owner and is the given {@code admin}.
+ *
+ * <p>Previous calls are overridden by each subsequent call to this method.
+ *
+ * @param admin the {@link DeviceAdminReceiver} this request is associated with
+ * @param packageNames the new cross-profile package names
+ */
+ public void setCrossProfilePackages(
+ @NonNull ComponentName admin, @NonNull Set<String> packageNames) {
+ throwIfParentInstance("setCrossProfilePackages");
+ if (mService != null) {
+ try {
+ mService.setCrossProfilePackages(admin, new ArrayList<>(packageNames));
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+ }
+
+ /**
+ * Returns the set of package names that the admin has previously set as allowed to request user
+ * consent for cross-profile communication, via {@link
+ * #setCrossProfilePackages(ComponentName, Set)}.
+ *
+ * <p>Assumes that the caller is a profile owner and is the given {@code admin}.
+ *
+ * @param admin the {@link DeviceAdminReceiver} this request is associated with
+ * @return the set of package names the admin has previously set as allowed to request user
+ * consent for cross-profile communication, via {@link
+ * #setCrossProfilePackages(ComponentName, Set)}
+ */
+ public @NonNull Set<String> getCrossProfilePackages(@NonNull ComponentName admin) {
+ throwIfParentInstance("getCrossProfilePackages");
+ if (mService != null) {
+ try {
+ return new ArraySet<>(mService.getCrossProfilePackages(admin));
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+ return Collections.emptySet();
+ }
+
+ /**
* Returns whether the device is being used as a managed kiosk. These requirements are as
* follows:
* <ul>
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 34246fa..9c82ff6 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -208,8 +208,8 @@
void setRestrictionsProvider(in ComponentName who, in ComponentName provider);
ComponentName getRestrictionsProvider(int userHandle);
- void setUserRestriction(in ComponentName who, in String key, boolean enable);
- Bundle getUserRestrictions(in ComponentName who);
+ void setUserRestriction(in ComponentName who, in String key, boolean enable, boolean parent);
+ Bundle getUserRestrictions(in ComponentName who, boolean parent);
void addCrossProfileIntentFilter(in ComponentName admin, in IntentFilter filter, int flags);
void clearCrossProfileIntentFilters(in ComponentName admin);
@@ -298,6 +298,9 @@
void setAutoTime(in ComponentName who, boolean enabled);
boolean getAutoTime(in ComponentName who);
+ void setAutoTimeZone(in ComponentName who, boolean enabled);
+ boolean getAutoTimeZone(in ComponentName who);
+
void setForceEphemeralUsers(in ComponentName who, boolean forceEpehemeralUsers);
boolean getForceEphemeralUsers(in ComponentName who);
@@ -438,6 +441,9 @@
boolean isPackageAllowedToAccessCalendarForUser(String packageName, int userHandle);
List<String> getCrossProfileCalendarPackagesForUser(int userHandle);
+ void setCrossProfilePackages(in ComponentName admin, in List<String> packageNames);
+ List<String> getCrossProfilePackages(in ComponentName admin);
+
boolean isManagedKiosk();
boolean isUnattendedManagedKiosk();
diff --git a/core/java/android/app/backup/IBackupManager.aidl b/core/java/android/app/backup/IBackupManager.aidl
index 099272d..4940976 100644
--- a/core/java/android/app/backup/IBackupManager.aidl
+++ b/core/java/android/app/backup/IBackupManager.aidl
@@ -597,6 +597,12 @@
boolean isBackupServiceActive(int whichUser);
/**
+ * Checks if the user is ready for backup or not.
+ * @param userId User id for which this operation should be performed.
+ */
+ boolean isUserReadyForBackup(int userId);
+
+ /**
* Ask the framework which dataset, if any, the given package's data would be
* restored from if we were to install it right now.
*
diff --git a/core/java/android/app/slice/SliceProvider.java b/core/java/android/app/slice/SliceProvider.java
index 5e530ee..bd1eea5 100644
--- a/core/java/android/app/slice/SliceProvider.java
+++ b/core/java/android/app/slice/SliceProvider.java
@@ -515,8 +515,8 @@
public static PendingIntent createPermissionIntent(Context context, Uri sliceUri,
String callingPackage) {
Intent intent = new Intent(SliceManager.ACTION_REQUEST_SLICE_PERMISSION);
- intent.setComponent(new ComponentName("com.android.systemui",
- "com.android.systemui.SlicePermissionActivity"));
+ intent.setComponent(ComponentName.unflattenFromString(context.getResources().getString(
+ com.android.internal.R.string.config_slicePermissionComponent)));
intent.putExtra(EXTRA_BIND_URI, sliceUri);
intent.putExtra(EXTRA_PKG, callingPackage);
intent.putExtra(EXTRA_PROVIDER_PKG, context.getPackageName());
diff --git a/core/java/android/app/usage/UsageStatsManager.java b/core/java/android/app/usage/UsageStatsManager.java
index fb5645a..419377c 100644
--- a/core/java/android/app/usage/UsageStatsManager.java
+++ b/core/java/android/app/usage/UsageStatsManager.java
@@ -1125,8 +1125,11 @@
/**
* Inform usage stats that the carrier privileged apps access rules have changed.
+ * <p> The caller must have {@link android.Manifest.permission#BIND_CARRIER_SERVICES} </p>
* @hide
*/
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.BIND_CARRIER_SERVICES)
public void onCarrierPrivilegedAppsChanged() {
try {
mService.onCarrierPrivilegedAppsChanged();
diff --git a/core/java/android/bluetooth/BluetoothA2dpSink.java b/core/java/android/bluetooth/BluetoothA2dpSink.java
index cf33676..c6957e1 100755
--- a/core/java/android/bluetooth/BluetoothA2dpSink.java
+++ b/core/java/android/bluetooth/BluetoothA2dpSink.java
@@ -17,7 +17,9 @@
package android.bluetooth;
import android.Manifest;
+import android.annotation.Nullable;
import android.annotation.RequiresPermission;
+import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.UnsupportedAppUsage;
import android.content.Context;
@@ -39,6 +41,7 @@
*
* @hide
*/
+@SystemApi
public final class BluetoothA2dpSink implements BluetoothProfile {
private static final String TAG = "BluetoothA2dpSink";
private static final boolean DBG = true;
@@ -59,71 +62,14 @@
* {@link #STATE_DISCONNECTED}, {@link #STATE_CONNECTING},
* {@link #STATE_CONNECTED}, {@link #STATE_DISCONNECTING}.
*
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
- * receive.
+ * @hide
*/
+ @SystemApi
+ @SuppressLint("ActionValue")
+ @RequiresPermission(Manifest.permission.BLUETOOTH)
public static final String ACTION_CONNECTION_STATE_CHANGED =
"android.bluetooth.a2dp-sink.profile.action.CONNECTION_STATE_CHANGED";
- /**
- * Intent used to broadcast the change in the Playing state of the A2DP Sink
- * profile.
- *
- * <p>This intent will have 3 extras:
- * <ul>
- * <li> {@link #EXTRA_STATE} - The current state of the profile. </li>
- * <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile. </li>
- * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
- * </ul>
- *
- * <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
- * {@link #STATE_PLAYING}, {@link #STATE_NOT_PLAYING},
- *
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
- * receive.
- */
- public static final String ACTION_PLAYING_STATE_CHANGED =
- "android.bluetooth.a2dp-sink.profile.action.PLAYING_STATE_CHANGED";
-
- /**
- * A2DP sink device is streaming music. This state can be one of
- * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of
- * {@link #ACTION_PLAYING_STATE_CHANGED} intent.
- */
- public static final int STATE_PLAYING = 10;
-
- /**
- * A2DP sink device is NOT streaming music. This state can be one of
- * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of
- * {@link #ACTION_PLAYING_STATE_CHANGED} intent.
- */
- public static final int STATE_NOT_PLAYING = 11;
-
- /**
- * Intent used to broadcast the change in the Playing state of the A2DP Sink
- * profile.
- *
- * <p>This intent will have 3 extras:
- * <ul>
- * <li> {@link #EXTRA_AUDIO_CONFIG} - The audio configuration for the remote device. </li>
- * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
- * </ul>
- *
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
- * receive.
- */
- public static final String ACTION_AUDIO_CONFIG_CHANGED =
- "android.bluetooth.a2dp-sink.profile.action.AUDIO_CONFIG_CHANGED";
-
- /**
- * Extra for the {@link #ACTION_AUDIO_CONFIG_CHANGED} intent.
- *
- * This extra represents the current audio configuration of the A2DP source device.
- * {@see BluetoothAudioConfig}
- */
- public static final String EXTRA_AUDIO_CONFIG =
- "android.bluetooth.a2dp-sink.profile.extra.AUDIO_CONFIG";
-
private BluetoothAdapter mAdapter;
private final BluetoothProfileConnector<IBluetoothA2dpSink> mProfileConnector =
new BluetoothProfileConnector(this, BluetoothProfile.A2DP_SINK,
@@ -170,13 +116,11 @@
* the state. Users can get the connection state of the profile
* from this intent.
*
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
- * permission.
- *
* @param device Remote Bluetooth Device
* @return false on immediate error, true otherwise
* @hide
*/
+ @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
public boolean connect(BluetoothDevice device) {
if (DBG) log("connect(" + device + ")");
final IBluetoothA2dpSink service = getService();
@@ -210,14 +154,12 @@
* {@link #STATE_DISCONNECTING} can be used to distinguish between the
* two scenarios.
*
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
- * permission.
- *
* @param device Remote Bluetooth Device
* @return false on immediate error, true otherwise
* @hide
*/
@UnsupportedAppUsage
+ @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
public boolean disconnect(BluetoothDevice device) {
if (DBG) log("disconnect(" + device + ")");
final IBluetoothA2dpSink service = getService();
@@ -235,6 +177,8 @@
/**
* {@inheritDoc}
+ *
+ * @hide
*/
@Override
public List<BluetoothDevice> getConnectedDevices() {
@@ -254,6 +198,8 @@
/**
* {@inheritDoc}
+ *
+ * @hide
*/
@Override
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
@@ -273,6 +219,8 @@
/**
* {@inheritDoc}
+ *
+ * @hide
*/
@Override
public int getConnectionState(BluetoothDevice device) {
@@ -300,6 +248,8 @@
* @return audio configuration for the device, or null
*
* {@see BluetoothAudioConfig}
+ *
+ * @hide
*/
public BluetoothAudioConfig getAudioConfig(BluetoothDevice device) {
if (VDBG) log("getAudioConfig(" + device + ")");
@@ -347,7 +297,7 @@
*/
@SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
- public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
+ public boolean setConnectionPolicy(@Nullable BluetoothDevice device, int connectionPolicy) {
if (DBG) log("setConnectionPolicy(" + device + ", " + connectionPolicy + ")");
final IBluetoothA2dpSink service = getService();
if (service != null && isEnabled() && isValidDevice(device)) {
@@ -395,7 +345,7 @@
*/
@SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH)
- public int getConnectionPolicy(BluetoothDevice device) {
+ public int getConnectionPolicy(@Nullable BluetoothDevice device) {
if (VDBG) log("getConnectionPolicy(" + device + ")");
final IBluetoothA2dpSink service = getService();
if (service != null && isEnabled() && isValidDevice(device)) {
@@ -411,13 +361,16 @@
}
/**
- * Check if A2DP profile is streaming music.
- *
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
+ * Check if audio is playing on the bluetooth device (A2DP profile is streaming music).
*
* @param device BluetoothDevice device
+ * @return true if audio is playing (A2dp is streaming music), false otherwise
+ *
+ * @hide
*/
- public boolean isA2dpPlaying(BluetoothDevice device) {
+ @SystemApi
+ @RequiresPermission(Manifest.permission.BLUETOOTH)
+ public boolean isAudioPlaying(@Nullable BluetoothDevice device) {
final IBluetoothA2dpSink service = getService();
if (service != null && isEnabled() && isValidDevice(device)) {
try {
@@ -448,9 +401,9 @@
return "connected";
case STATE_DISCONNECTING:
return "disconnecting";
- case STATE_PLAYING:
+ case BluetoothA2dp.STATE_PLAYING:
return "playing";
- case STATE_NOT_PLAYING:
+ case BluetoothA2dp.STATE_NOT_PLAYING:
return "not playing";
default:
return "<unknown state " + state + ">";
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index 3f8cb62..8404705 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -847,7 +847,8 @@
}
synchronized (mLock) {
if (sBluetoothLeScanner == null) {
- sBluetoothLeScanner = new BluetoothLeScanner(mManagerService);
+ sBluetoothLeScanner = new BluetoothLeScanner(mManagerService, getOpPackageName(),
+ getFeatureId());
}
}
return sBluetoothLeScanner;
@@ -1637,6 +1638,15 @@
return ActivityThread.currentOpPackageName();
}
+ private String getFeatureId() {
+ // Workaround for legacy API for getting a BluetoothAdapter not
+ // passing a context
+ if (mContext != null) {
+ return mContext.getFeatureId();
+ }
+ return null;
+ }
+
/**
* Start the remote device discovery process.
* <p>The discovery process usually involves an inquiry scan of about 12
@@ -1674,7 +1684,7 @@
try {
mServiceLock.readLock().lock();
if (mService != null) {
- return mService.startDiscovery(getOpPackageName());
+ return mService.startDiscovery(getOpPackageName(), getFeatureId());
}
} catch (RemoteException e) {
Log.e(TAG, "", e);
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java
index 49187dc..323c7d1 100644
--- a/core/java/android/bluetooth/BluetoothDevice.java
+++ b/core/java/android/bluetooth/BluetoothDevice.java
@@ -17,6 +17,7 @@
package android.bluetooth;
import android.Manifest;
+import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
@@ -33,8 +34,12 @@
import android.os.RemoteException;
import android.util.Log;
+import com.android.internal.annotations.VisibleForTesting;
+
import java.io.IOException;
import java.io.UnsupportedEncodingException;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.UUID;
/**
@@ -771,6 +776,13 @@
@UnsupportedAppUsage
public static final String EXTRA_SDP_SEARCH_STATUS =
"android.bluetooth.device.extra.SDP_SEARCH_STATUS";
+
+ /** @hide */
+ @IntDef(prefix = "ACCESS_", value = {ACCESS_UNKNOWN,
+ ACCESS_ALLOWED, ACCESS_REJECTED})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface AccessPermission{}
+
/**
* For {@link #getPhonebookAccessPermission}, {@link #setPhonebookAccessPermission},
* {@link #getMessageAccessPermission} and {@link #setMessageAccessPermission}.
@@ -1096,15 +1108,14 @@
/**
* Get the most recent identified battery level of this Bluetooth device
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
*
* @return Battery level in percents from 0 to 100, or {@link #BATTERY_LEVEL_UNKNOWN} if
* Bluetooth is disabled, or device is disconnected, or does not have any battery reporting
* service, or return value is invalid
* @hide
*/
+ @SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH)
- @UnsupportedAppUsage
public int getBatteryLevel() {
final IBluetooth service = sService;
if (service == null) {
@@ -1187,8 +1198,15 @@
return false;
}
- /** @hide */
- @UnsupportedAppUsage
+ /**
+ * Gets whether bonding was initiated locally
+ *
+ * @return true if bonding is initiated locally, false otherwise
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(Manifest.permission.BLUETOOTH)
public boolean isBondingInitiatedLocally() {
final IBluetooth service = sService;
if (service == null) {
@@ -1480,15 +1498,20 @@
return false;
}
- /** @hide */
- @UnsupportedAppUsage
- public boolean setPasskey(int passkey) {
- //TODO(BT)
- /*
- try {
- return sService.setPasskey(this, true, 4, passkey);
- } catch (RemoteException e) {Log.e(TAG, "", e);}*/
- return false;
+ /**
+ * Set the pin during pairing when the pairing method is {@link #PAIRING_VARIANT_PIN}
+ *
+ * @return true pin has been set false for error
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
+ public boolean setPin(@Nullable String pin) {
+ byte[] pinBytes = convertPinToBytes(pin);
+ if (pinBytes == null) {
+ return false;
+ }
+ return setPin(pinBytes);
}
/**
@@ -1511,22 +1534,18 @@
return false;
}
- /** @hide */
- public boolean setRemoteOutOfBandData() {
- // TODO(BT)
- /*
- try {
- return sService.setRemoteOutOfBandData(this);
- } catch (RemoteException e) {Log.e(TAG, "", e);}*/
- return false;
- }
-
- /** @hide */
- @UnsupportedAppUsage
- public boolean cancelPairingUserInput() {
+ /**
+ * Cancels pairing to this device
+ *
+ * @return true if pairing cancelled successfully, false otherwise
+ *
+ * @hide
+ */
+ @SystemApi
+ public boolean cancelPairing() {
final IBluetooth service = sService;
if (service == null) {
- Log.e(TAG, "BT not enabled. Cannot create pairing user input");
+ Log.e(TAG, "BT not enabled. Cannot cancel pairing");
return false;
}
try {
@@ -1537,17 +1556,6 @@
return false;
}
- /** @hide */
- @UnsupportedAppUsage
- public boolean isBluetoothDock() {
- // TODO(BT)
- /*
- try {
- return sService.isBluetoothDock(this);
- } catch (RemoteException e) {Log.e(TAG, "", e);}*/
- return false;
- }
-
boolean isBluetoothEnabled() {
boolean ret = false;
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
@@ -1558,13 +1566,14 @@
}
/**
- * Requires {@link android.Manifest.permission#BLUETOOTH}.
+ * Gets whether the phonebook access is allowed for this bluetooth device
*
* @return Whether the phonebook access is allowed to this device. Can be {@link
* #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or {@link #ACCESS_REJECTED}.
* @hide
*/
- @UnsupportedAppUsage
+ @SystemApi
+ @RequiresPermission(Manifest.permission.BLUETOOTH)
public int getPhonebookAccessPermission() {
final IBluetooth service = sService;
if (service == null) {
@@ -1667,14 +1676,14 @@
}
/**
- * Requires {@link android.Manifest.permission#BLUETOOTH}.
+ * Gets whether message access is allowed to this bluetooth device
*
- * @return Whether the message access is allowed to this device. Can be {@link #ACCESS_UNKNOWN},
- * {@link #ACCESS_ALLOWED} or {@link #ACCESS_REJECTED}.
+ * @return Whether the message access is allowed to this device.
* @hide
*/
- @UnsupportedAppUsage
- public int getMessageAccessPermission() {
+ @SystemApi
+ @RequiresPermission(Manifest.permission.BLUETOOTH)
+ public @AccessPermission int getMessageAccessPermission() {
final IBluetooth service = sService;
if (service == null) {
return ACCESS_UNKNOWN;
@@ -1689,15 +1698,18 @@
/**
* Sets whether the message access is allowed to this device.
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}.
*
- * @param value Can be {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or {@link
- * #ACCESS_REJECTED}.
+ * @param value is the value we are setting the message access permission to
* @return Whether the value has been successfully set.
* @hide
*/
- @UnsupportedAppUsage
- public boolean setMessageAccessPermission(int value) {
+ @SystemApi
+ @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ public boolean setMessageAccessPermission(@AccessPermission int value) {
+ // Validates param value is one of the accepted constants
+ if (value != ACCESS_ALLOWED && value != ACCESS_REJECTED && value != ACCESS_UNKNOWN) {
+ throw new IllegalArgumentException(value + "is not a valid AccessPermission value");
+ }
final IBluetooth service = sService;
if (service == null) {
return false;
@@ -1711,13 +1723,14 @@
}
/**
- * Requires {@link android.Manifest.permission#BLUETOOTH}.
+ * Gets whether sim access is allowed for this bluetooth device
*
- * @return Whether the Sim access is allowed to this device. Can be {@link #ACCESS_UNKNOWN},
- * {@link #ACCESS_ALLOWED} or {@link #ACCESS_REJECTED}.
+ * @return Whether the Sim access is allowed to this device.
* @hide
*/
- public int getSimAccessPermission() {
+ @SystemApi
+ @RequiresPermission(Manifest.permission.BLUETOOTH)
+ public @AccessPermission int getSimAccessPermission() {
final IBluetooth service = sService;
if (service == null) {
return ACCESS_UNKNOWN;
@@ -1732,14 +1745,14 @@
/**
* Sets whether the Sim access is allowed to this device.
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}.
*
* @param value Can be {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or {@link
* #ACCESS_REJECTED}.
* @return Whether the value has been successfully set.
* @hide
*/
- @UnsupportedAppUsage
+ @SystemApi
+ @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
public boolean setSimAccessPermission(int value) {
final IBluetooth service = sService;
if (service == null) {
@@ -1970,7 +1983,7 @@
* @return the pin code as a UTF-8 byte array, or null if it is an invalid Bluetooth pin.
* @hide
*/
- @UnsupportedAppUsage
+ @VisibleForTesting
public static byte[] convertPinToBytes(String pin) {
if (pin == null) {
return null;
diff --git a/core/java/android/bluetooth/BluetoothHearingAid.java b/core/java/android/bluetooth/BluetoothHearingAid.java
index ead8429..b4521c6 100644
--- a/core/java/android/bluetooth/BluetoothHearingAid.java
+++ b/core/java/android/bluetooth/BluetoothHearingAid.java
@@ -335,9 +335,9 @@
* is not active, it will be null on that position. Returns empty list on error.
* @hide
*/
- @UnsupportedAppUsage
+ @SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH)
- public List<BluetoothDevice> getActiveDevices() {
+ public @NonNull List<BluetoothDevice> getActiveDevices() {
if (VDBG) log("getActiveDevices()");
final IBluetoothHearingAid service = getService();
try {
@@ -559,8 +559,9 @@
* @return the CustomerId of the device
* @hide
*/
+ @SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH)
- public long getHiSyncId(BluetoothDevice device) {
+ public long getHiSyncId(@Nullable BluetoothDevice device) {
if (VDBG) {
log("getCustomerId(" + device + ")");
}
diff --git a/core/java/android/bluetooth/BluetoothManager.java b/core/java/android/bluetooth/BluetoothManager.java
index adedff3..7ff6466 100644
--- a/core/java/android/bluetooth/BluetoothManager.java
+++ b/core/java/android/bluetooth/BluetoothManager.java
@@ -22,7 +22,9 @@
import android.annotation.SystemService;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.os.IBinder;
import android.os.RemoteException;
+import android.os.ServiceManager;
import android.util.Log;
import java.util.ArrayList;
@@ -60,22 +62,34 @@
* @hide
*/
public BluetoothManager(Context context) {
- context = context.getApplicationContext();
- if (context == null) {
- throw new IllegalArgumentException(
- "context not associated with any application (using a mock context?)");
+ if (context.getFeatureId() == null) {
+ context = context.getApplicationContext();
+ if (context == null) {
+ throw new IllegalArgumentException(
+ "context not associated with any application (using a mock context?)");
+ }
+
+ mAdapter = BluetoothAdapter.getDefaultAdapter();
+ } else {
+ IBinder b = ServiceManager.getService(BluetoothAdapter.BLUETOOTH_MANAGER_SERVICE);
+ if (b != null) {
+ mAdapter = new BluetoothAdapter(IBluetoothManager.Stub.asInterface(b));
+ } else {
+ Log.e(TAG, "Bluetooth binder is null");
+ mAdapter = null;
+ }
}
- // Legacy api - getDefaultAdapter does not take in the context
- mAdapter = BluetoothAdapter.getDefaultAdapter();
+
+ // Context is not initialized in constructor
if (mAdapter != null) {
mAdapter.setContext(context);
}
}
/**
- * Get the default BLUETOOTH Adapter for this device.
+ * Get the BLUETOOTH Adapter for this device.
*
- * @return the default BLUETOOTH Adapter
+ * @return the BLUETOOTH Adapter
*/
public BluetoothAdapter getAdapter() {
return mAdapter;
diff --git a/core/java/android/bluetooth/BluetoothPbap.java b/core/java/android/bluetooth/BluetoothPbap.java
index d94c657..df02896 100644
--- a/core/java/android/bluetooth/BluetoothPbap.java
+++ b/core/java/android/bluetooth/BluetoothPbap.java
@@ -16,7 +16,10 @@
package android.bluetooth;
+import android.annotation.Nullable;
import android.annotation.SdkConstant;
+import android.annotation.SuppressLint;
+import android.annotation.SystemApi;
import android.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.Context;
@@ -54,6 +57,7 @@
*
* @hide
*/
+@SystemApi
public class BluetoothPbap implements BluetoothProfile {
private static final String TAG = "BluetoothPbap";
@@ -75,7 +79,11 @@
* {@link BluetoothProfile#STATE_DISCONNECTING}.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
* receive.
+ *
+ * @hide
*/
+ @SuppressLint("ActionValue")
+ @SystemApi
@SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_CONNECTION_STATE_CHANGED =
"android.bluetooth.pbap.profile.action.CONNECTION_STATE_CHANGED";
@@ -85,33 +93,16 @@
private ServiceListener mServiceListener;
private BluetoothAdapter mAdapter;
+ /** @hide */
public static final int RESULT_FAILURE = 0;
+ /** @hide */
public static final int RESULT_SUCCESS = 1;
- /** Connection canceled before completion. */
- public static final int RESULT_CANCELED = 2;
-
/**
- * An interface for notifying Bluetooth PCE IPC clients when they have
- * been connected to the BluetoothPbap service.
+ * Connection canceled before completion.
+ *
+ * @hide
*/
- public interface ServiceListener {
- /**
- * Called to notify the client when this proxy object has been
- * connected to the BluetoothPbap service. Clients must wait for
- * this callback before making IPC calls on the BluetoothPbap
- * service.
- */
- public void onServiceConnected(BluetoothPbap proxy);
-
- /**
- * Called to notify the client that this proxy object has been
- * disconnected from the BluetoothPbap service. Clients must not
- * make IPC calls on the BluetoothPbap service after this callback.
- * This callback will currently only occur if the application hosting
- * the BluetoothPbap service, but may be called more often in future.
- */
- public void onServiceDisconnected();
- }
+ public static final int RESULT_CANCELED = 2;
private final IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
new IBluetoothStateChangeCallback.Stub() {
@@ -127,6 +118,8 @@
/**
* Create a BluetoothPbap proxy object.
+ *
+ * @hide
*/
public BluetoothPbap(Context context, ServiceListener l) {
mContext = context;
@@ -181,6 +174,7 @@
}
}
+ /** @hide */
protected void finalize() throws Throwable {
try {
close();
@@ -194,6 +188,8 @@
* Other public functions of BluetoothPbap will return default error
* results once close() has been called. Multiple invocations of close()
* are ok.
+ *
+ * @hide
*/
public synchronized void close() {
IBluetoothManager mgr = mAdapter.getBluetoothManager();
@@ -210,6 +206,8 @@
/**
* {@inheritDoc}
+ *
+ * @hide
*/
@Override
public List<BluetoothDevice> getConnectedDevices() {
@@ -229,17 +227,22 @@
/**
* {@inheritDoc}
+ *
+ * @hide
*/
+ @SystemApi
@Override
- public int getConnectionState(BluetoothDevice device) {
+ public int getConnectionState(@Nullable BluetoothDevice device) {
log("getConnectionState: device=" + device);
- final IBluetoothPbap service = mService;
- if (service == null) {
- Log.w(TAG, "Proxy not attached to service");
- return BluetoothProfile.STATE_DISCONNECTED;
- }
try {
- return service.getConnectionState(device);
+ final IBluetoothPbap service = mService;
+ if (service != null && isEnabled() && isValidDevice(device)) {
+ return service.getConnectionState(device);
+ }
+ if (service == null) {
+ Log.w(TAG, "Proxy not attached to service");
+ }
+ return BluetoothProfile.STATE_DISCONNECTED;
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -248,6 +251,8 @@
/**
* {@inheritDoc}
+ *
+ * @hide
*/
@Override
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
@@ -266,22 +271,12 @@
}
/**
- * Returns true if the specified Bluetooth device is connected (does not
- * include connecting). Returns false if not connected, or if this proxy
- * object is not currently connected to the Pbap service.
- */
- // TODO: This is currently being used by SettingsLib and internal app.
- public boolean isConnected(BluetoothDevice device) {
- return getConnectionState(device) == BluetoothAdapter.STATE_CONNECTED;
- }
-
- /**
* Disconnects the current Pbap client (PCE). Currently this call blocks,
* it may soon be made asynchronous. Returns false if this proxy object is
* not currently connected to the Pbap service.
+ *
+ * @hide
*/
- // TODO: This is currently being used by SettingsLib and will be used in the future.
- // TODO: Must specify target device. Implement this in the service.
@UnsupportedAppUsage
public boolean disconnect(BluetoothDevice device) {
log("disconnect()");
@@ -304,7 +299,7 @@
log("Proxy object connected");
mService = IBluetoothPbap.Stub.asInterface(service);
if (mServiceListener != null) {
- mServiceListener.onServiceConnected(BluetoothPbap.this);
+ mServiceListener.onServiceConnected(BluetoothProfile.PBAP, BluetoothPbap.this);
}
}
@@ -312,11 +307,23 @@
log("Proxy object disconnected");
doUnbind();
if (mServiceListener != null) {
- mServiceListener.onServiceDisconnected();
+ mServiceListener.onServiceDisconnected(BluetoothProfile.PBAP);
}
}
};
+ private boolean isEnabled() {
+ if (mAdapter.getState() == BluetoothAdapter.STATE_ON) return true;
+ return false;
+ }
+
+ private boolean isValidDevice(BluetoothDevice device) {
+ if (device == null) return false;
+
+ if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) return true;
+ return false;
+ }
+
private static void log(String msg) {
if (DBG) {
Log.d(TAG, msg);
diff --git a/core/java/android/bluetooth/le/BluetoothLeScanner.java b/core/java/android/bluetooth/le/BluetoothLeScanner.java
index ac126ae..9a17346 100644
--- a/core/java/android/bluetooth/le/BluetoothLeScanner.java
+++ b/core/java/android/bluetooth/le/BluetoothLeScanner.java
@@ -21,7 +21,6 @@
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
-import android.app.ActivityThread;
import android.app.PendingIntent;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothGatt;
@@ -84,17 +83,25 @@
private BluetoothAdapter mBluetoothAdapter;
private final Map<ScanCallback, BleScanCallbackWrapper> mLeScanClients;
+ private final String mOpPackageName;
+ private final String mFeatureId;
+
/**
* Use {@link BluetoothAdapter#getBluetoothLeScanner()} instead.
*
* @param bluetoothManager BluetoothManager that conducts overall Bluetooth Management.
+ * @param opPackageName The opPackageName of the context this object was created from
+ * @param featureId The featureId of the context this object was created from
* @hide
*/
- public BluetoothLeScanner(IBluetoothManager bluetoothManager) {
+ public BluetoothLeScanner(IBluetoothManager bluetoothManager,
+ @NonNull String opPackageName, @Nullable String featureId) {
mBluetoothManager = bluetoothManager;
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mHandler = new Handler(Looper.getMainLooper());
mLeScanClients = new HashMap<ScanCallback, BleScanCallbackWrapper>();
+ mOpPackageName = opPackageName;
+ mFeatureId = featureId;
}
/**
@@ -246,8 +253,8 @@
wrapper.startRegistration();
} else {
try {
- gatt.startScanForIntent(callbackIntent, settings, filters,
- ActivityThread.currentOpPackageName());
+ gatt.startScanForIntent(callbackIntent, settings, filters, mOpPackageName,
+ mFeatureId);
} catch (RemoteException e) {
return ScanCallback.SCAN_FAILED_INTERNAL_ERROR;
}
@@ -288,7 +295,7 @@
IBluetoothGatt gatt;
try {
gatt = mBluetoothManager.getBluetoothGatt();
- gatt.stopScanForIntent(callbackIntent, ActivityThread.currentOpPackageName());
+ gatt.stopScanForIntent(callbackIntent, mOpPackageName);
} catch (RemoteException e) {
}
}
@@ -448,8 +455,7 @@
} else {
mScannerId = scannerId;
mBluetoothGatt.startScan(mScannerId, mSettings, mFilters,
- mResultStorages,
- ActivityThread.currentOpPackageName());
+ mResultStorages, mOpPackageName, mFeatureId);
}
} catch (RemoteException e) {
Log.e(TAG, "fail to start le scan: " + e);
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 7b580c3..808f2160 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -3973,6 +3973,17 @@
public static final String WIFI_SERVICE = "wifi";
/**
+ * Use with {@link #getSystemService(String)} to retrieve a
+ * {@link android.net.wifi.WifiCondManager} for handling management of the Wi-Fi control
+ * daemon.
+ *
+ * @see #getSystemService(String)
+ * @see android.net.wifi.WifiCondManager
+ * @hide
+ */
+ public static final String WIFI_COND_SERVICE = "wificond";
+
+ /**
* Use with {@link #getSystemService(String)} to retrieve a {@link
* android.net.wifi.p2p.WifiP2pManager} for handling management of
* Wi-Fi peer-to-peer connections.
@@ -4905,6 +4916,8 @@
* {@link android.telephony.ims.ImsManager}.
* @hide
*/
+ @SystemApi
+ @TestApi
public static final String TELEPHONY_IMS_SERVICE = "telephony_ims";
/**
@@ -4980,7 +4993,7 @@
* {@link android.os.incremental.IncrementalManager}.
* @hide
*/
- public static final String INCREMENTAL_SERVICE = "incremental";
+ public static final String INCREMENTAL_SERVICE = "incremental_service";
/**
* Determine whether the given permission is allowed for a particular
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index ca2de6a..47fb375 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1728,6 +1728,7 @@
* @hide
*/
@SystemApi
+ @TestApi
public static final String EXTRA_ORIGINATING_UID
= "android.intent.extra.ORIGINATING_UID";
diff --git a/core/java/android/content/pm/AuxiliaryResolveInfo.java b/core/java/android/content/pm/AuxiliaryResolveInfo.java
index 202df50..7d07e1d 100644
--- a/core/java/android/content/pm/AuxiliaryResolveInfo.java
+++ b/core/java/android/content/pm/AuxiliaryResolveInfo.java
@@ -46,17 +46,21 @@
public final Intent failureIntent;
/** The matching filters for this resolve info. */
public final List<AuxiliaryFilter> filters;
+ /** Stored {@link InstantAppRequest#hostDigestPrefixSecure} to prevent re-generation */
+ public final int[] hostDigestPrefixSecure;
/** Create a response for installing an instant application. */
public AuxiliaryResolveInfo(@NonNull String token,
boolean needsPhase2,
@Nullable Intent failureIntent,
- @Nullable List<AuxiliaryFilter> filters) {
+ @Nullable List<AuxiliaryFilter> filters,
+ @Nullable int[] hostDigestPrefix) {
this.token = token;
this.needsPhaseTwo = needsPhase2;
this.failureIntent = failureIntent;
this.filters = filters;
this.installFailureActivity = null;
+ this.hostDigestPrefixSecure = hostDigestPrefix;
}
/** Create a response for installing a split on demand. */
@@ -69,6 +73,7 @@
this.token = null;
this.needsPhaseTwo = false;
this.failureIntent = failureIntent;
+ this.hostDigestPrefixSecure = null;
}
/** Create a response for installing a split on demand. */
@@ -126,4 +131,4 @@
+ ", splitName='" + splitName + '\'' + '}';
}
}
-}
\ No newline at end of file
+}
diff --git a/core/java/android/content/pm/BaseParceledListSlice.java b/core/java/android/content/pm/BaseParceledListSlice.java
index 4178309..ffbca16 100644
--- a/core/java/android/content/pm/BaseParceledListSlice.java
+++ b/core/java/android/content/pm/BaseParceledListSlice.java
@@ -47,7 +47,7 @@
* TODO get this number from somewhere else. For now set it to a quarter of
* the 1MB limit.
*/
- private static final int MAX_IPC_SIZE = IBinder.MAX_IPC_SIZE;
+ private static final int MAX_IPC_SIZE = IBinder.getSuggestedMaxIpcSizeBytes();
private final List<T> mList;
diff --git a/core/java/android/content/pm/IPackageInstallerSession.aidl b/core/java/android/content/pm/IPackageInstallerSession.aidl
index 0b3c765..e954635 100644
--- a/core/java/android/content/pm/IPackageInstallerSession.aidl
+++ b/core/java/android/content/pm/IPackageInstallerSession.aidl
@@ -39,6 +39,9 @@
void transfer(in String packageName, in IntentSender statusReceiver);
void abandon();
+ void addFile(String name, long lengthBytes, in byte[] metadata);
+ void removeFile(String name);
+
boolean isMultiPackage();
int[] getChildSessionIds();
void addChildSessionId(in int sessionId);
@@ -46,5 +49,4 @@
int getParentSessionId();
boolean isStaged();
- void addFile(in String name, long size, in byte[] metadata);
}
diff --git a/core/java/android/content/pm/InstantAppRequest.java b/core/java/android/content/pm/InstantAppRequest.java
index 361d4e4..f692db1 100644
--- a/core/java/android/content/pm/InstantAppRequest.java
+++ b/core/java/android/content/pm/InstantAppRequest.java
@@ -16,9 +16,10 @@
package android.content.pm;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.Intent;
import android.os.Bundle;
-import android.text.TextUtils;
/**
* Information needed to make an instant application resolution request.
@@ -34,32 +35,40 @@
public final String resolvedType;
/** The name of the package requesting the instant application */
public final String callingPackage;
+ /** Whether or not the requesting package was an instant app */
+ public final boolean isRequesterInstantApp;
/** ID of the user requesting the instant application */
public final int userId;
/**
* Optional extra bundle provided by the source application to the installer for additional
- * verification. */
+ * verification.
+ */
public final Bundle verificationBundle;
/** Whether resolution occurs because an application is starting */
public final boolean resolveForStart;
- /** The instant app digest for this request */
- public final InstantAppResolveInfo.InstantAppDigest digest;
+ /**
+ * The hash prefix of an instant app's domain or null if no host is defined.
+ * Secure version that should be carried through for external use.
+ */
+ @Nullable
+ public final int[] hostDigestPrefixSecure;
+ /** A unique identifier */
+ @NonNull
+ public final String token;
public InstantAppRequest(AuxiliaryResolveInfo responseObj, Intent origIntent,
- String resolvedType, String callingPackage, int userId, Bundle verificationBundle,
- boolean resolveForStart) {
+ String resolvedType, String callingPackage, boolean isRequesterInstantApp,
+ int userId, Bundle verificationBundle, boolean resolveForStart,
+ @Nullable int[] hostDigestPrefixSecure, @NonNull String token) {
this.responseObj = responseObj;
this.origIntent = origIntent;
this.resolvedType = resolvedType;
this.callingPackage = callingPackage;
+ this.isRequesterInstantApp = isRequesterInstantApp;
this.userId = userId;
this.verificationBundle = verificationBundle;
this.resolveForStart = resolveForStart;
- if (origIntent.getData() != null && !TextUtils.isEmpty(origIntent.getData().getHost())) {
- digest = new InstantAppResolveInfo.InstantAppDigest(
- origIntent.getData().getHost(), 5 /*maxDigests*/);
- } else {
- digest = InstantAppResolveInfo.InstantAppDigest.UNDEFINED;
- }
+ this.hostDigestPrefixSecure = hostDigestPrefixSecure;
+ this.token = token;
}
}
diff --git a/core/java/android/content/pm/InstantAppRequestInfo.aidl b/core/java/android/content/pm/InstantAppRequestInfo.aidl
new file mode 100644
index 0000000..0f94220
--- /dev/null
+++ b/core/java/android/content/pm/InstantAppRequestInfo.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2019 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 android.content.pm;
+
+parcelable InstantAppRequestInfo;
diff --git a/core/java/android/content/pm/InstantAppRequestInfo.java b/core/java/android/content/pm/InstantAppRequestInfo.java
new file mode 100644
index 0000000..83d5536
--- /dev/null
+++ b/core/java/android/content/pm/InstantAppRequestInfo.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2019 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 android.content.pm;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
+import android.content.Intent;
+import android.os.Parcelable;
+import android.os.UserHandle;
+
+import com.android.internal.util.DataClass;
+
+/**
+ * Information exposed to {@link android.app.InstantAppResolverService} to complete
+ * an instant application resolution request.
+ * @hide
+ */
+@SystemApi
+@DataClass(genParcelable = true, genConstructor = true, genAidl = true)
+public final class InstantAppRequestInfo implements Parcelable {
+
+ /**
+ * The sanitized {@link Intent} used for resolution. A sanitized Intent is an intent with
+ * potential PII removed from the original intent. Fields removed include extras and the
+ * host + path of the data, if defined.
+ */
+ @NonNull
+ public final Intent intent;
+
+ /** The hash prefix of the instant app's domain or null if no host is defined. */
+ @Nullable
+ public final int[] hostDigestPrefix;
+
+ /** The user requesting the instant application */
+ @NonNull
+ public final UserHandle userHandle;
+
+ /** Whether or not the requesting package was an instant app itself */
+ public final boolean isRequesterInstantApp;
+
+ /** A unique identifier */
+ @NonNull
+ public final String token;
+
+
+
+ // Code below generated by codegen v1.0.13.
+ //
+ // DO NOT MODIFY!
+ // CHECKSTYLE:OFF Generated code
+ //
+ // To regenerate run:
+ // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/InstantAppRequestInfo.java
+ //
+ // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
+ // Settings > Editor > Code Style > Formatter Control
+ //@formatter:off
+
+
+ /**
+ * Creates a new InstantAppRequestInfo.
+ *
+ * @param intent
+ * The sanitized {@link Intent} used for resolution. A sanitized Intent is an intent with
+ * potential PII removed from the original intent. Fields removed include extras and the
+ * host + path of the data, if defined.
+ * @param hostDigestPrefix
+ * The hash prefix of the instant app's domain or null if no host is defined.
+ * @param userHandle
+ * The user requesting the instant application
+ * @param isRequesterInstantApp
+ * Whether or not the requesting package was an instant app itself
+ * @param token
+ * A unique identifier
+ */
+ @DataClass.Generated.Member
+ public InstantAppRequestInfo(
+ @NonNull Intent intent,
+ @Nullable int[] hostDigestPrefix,
+ @NonNull UserHandle userHandle,
+ boolean isRequesterInstantApp,
+ @NonNull String token) {
+ this.intent = intent;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, intent);
+ this.hostDigestPrefix = hostDigestPrefix;
+ this.userHandle = userHandle;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, userHandle);
+ this.isRequesterInstantApp = isRequesterInstantApp;
+ this.token = token;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, token);
+
+ // onConstructed(); // You can define this method to get a callback
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
+ // You can override field parcelling by defining methods like:
+ // void parcelFieldName(Parcel dest, int flags) { ... }
+
+ byte flg = 0;
+ if (isRequesterInstantApp) flg |= 0x8;
+ if (hostDigestPrefix != null) flg |= 0x2;
+ dest.writeByte(flg);
+ dest.writeTypedObject(intent, flags);
+ if (hostDigestPrefix != null) dest.writeIntArray(hostDigestPrefix);
+ dest.writeTypedObject(userHandle, flags);
+ dest.writeString(token);
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public int describeContents() { return 0; }
+
+ /** @hide */
+ @SuppressWarnings({"unchecked", "RedundantCast"})
+ @DataClass.Generated.Member
+ /* package-private */ InstantAppRequestInfo(@NonNull android.os.Parcel in) {
+ // You can override field unparcelling by defining methods like:
+ // static FieldType unparcelFieldName(Parcel in) { ... }
+
+ byte flg = in.readByte();
+ boolean _isRequesterInstantApp = (flg & 0x8) != 0;
+ Intent _intent = (Intent) in.readTypedObject(Intent.CREATOR);
+ int[] _hostDigestPrefix = (flg & 0x2) == 0 ? null : in.createIntArray();
+ UserHandle _userHandle = (UserHandle) in.readTypedObject(UserHandle.CREATOR);
+ String _token = in.readString();
+
+ this.intent = _intent;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, intent);
+ this.hostDigestPrefix = _hostDigestPrefix;
+ this.userHandle = _userHandle;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, userHandle);
+ this.isRequesterInstantApp = _isRequesterInstantApp;
+ this.token = _token;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, token);
+
+ // onConstructed(); // You can define this method to get a callback
+ }
+
+ @DataClass.Generated.Member
+ public static final @NonNull Parcelable.Creator<InstantAppRequestInfo> CREATOR
+ = new Parcelable.Creator<InstantAppRequestInfo>() {
+ @Override
+ public InstantAppRequestInfo[] newArray(int size) {
+ return new InstantAppRequestInfo[size];
+ }
+
+ @Override
+ public InstantAppRequestInfo createFromParcel(@NonNull android.os.Parcel in) {
+ return new InstantAppRequestInfo(in);
+ }
+ };
+
+ @DataClass.Generated(
+ time = 1574373347443L,
+ codegenVersion = "1.0.13",
+ sourceFile = "frameworks/base/core/java/android/content/pm/InstantAppRequestInfo.java",
+ inputSignatures = "public final @android.annotation.NonNull android.content.Intent intent\npublic final @android.annotation.Nullable int[] hostDigestPrefix\npublic final @android.annotation.NonNull android.os.UserHandle userHandle\npublic final boolean isRequesterInstantApp\npublic final @android.annotation.NonNull java.lang.String token\nclass InstantAppRequestInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genParcelable=true, genConstructor=true, genAidl=true)")
+ @Deprecated
+ private void __metadata() {}
+
+
+ //@formatter:on
+ // End of generated code
+
+}
diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java
index f017aad..898631e 100644
--- a/core/java/android/content/pm/PackageInstaller.java
+++ b/core/java/android/content/pm/PackageInstaller.java
@@ -231,6 +231,15 @@
public static final String EXTRA_CALLBACK = "android.content.pm.extra.CALLBACK";
/**
+ * Streaming installation pending.
+ * Caller should make sure DataLoader is able to prepare image and reinitiate the operation.
+ *
+ * @see #EXTRA_SESSION_ID
+ * {@hide}
+ */
+ public static final int STATUS_PENDING_STREAMING = -2;
+
+ /**
* User action is currently required to proceed. You can launch the intent
* activity described by {@link Intent#EXTRA_INTENT} to involve the user and
* continue.
@@ -1059,13 +1068,56 @@
}
}
+
+ /**
+ * Adds a file to session. On commit this file will be pulled from dataLoader.
+ *
+ * @param name arbitrary, unique name of your choosing to identify the
+ * APK being written. You can open a file again for
+ * additional writes (such as after a reboot) by using the
+ * same name. This name is only meaningful within the context
+ * of a single install session.
+ * @param lengthBytes total size of the file being written.
+ * The system may clear various caches as needed to allocate
+ * this space.
+ * @param metadata additional info use by dataLoader to pull data for the file.
+ * @throws SecurityException if called after the session has been
+ * sealed or abandoned
+ * @throws IllegalStateException if called for non-callback session
+ * {@hide}
+ */
+ public void addFile(@NonNull String name, long lengthBytes, @NonNull byte[] metadata) {
+ try {
+ mSession.addFile(name, lengthBytes, metadata);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Removes a file.
+ *
+ * @param name name of a file, e.g. split.
+ * @throws SecurityException if called after the session has been
+ * sealed or abandoned
+ * @throws IllegalStateException if called for non-callback session
+ * {@hide}
+ */
+ public void removeFile(@NonNull String name) {
+ try {
+ mSession.removeFile(name);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
/**
* Attempt to commit everything staged in this session. This may require
* user intervention, and so it may not happen immediately. The final
* result of the commit will be reported through the given callback.
* <p>
- * Once this method is called, the session is sealed and no additional
- * mutations may be performed on the session. If the device reboots
+ * Once this method is called, the session is sealed and no additional mutations may be
+ * performed on the session. In case of device reboot or data loader transient failure
* before the session has been finalized, you may commit the session again.
* <p>
* If the installer is the device owner or the affiliated profile owner, there will be no
@@ -1220,27 +1272,6 @@
}
/**
- * Configure files for an installation session.
- *
- * Currently only for Incremental installation session. Once this method is called,
- * the files and their paths, as specified in the parameters, will be created and properly
- * configured in the Incremental File System.
- *
- * TODO(b/136132412): update this and InstallationFile class with latest API design.
- *
- * @throws IllegalStateException if {@link SessionParams#incrementalParams} is null.
- *
- * @hide
- */
- public void addFile(@NonNull String name, long size, @NonNull byte[] metadata) {
- try {
- mSession.addFile(name, size, metadata);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
* Release this session object. You can open the session again if it
* hasn't been finalized.
*/
@@ -1429,6 +1460,9 @@
public long requiredInstalledVersionCode = PackageManager.VERSION_CODE_HIGHEST;
/** {@hide} */
public IncrementalDataLoaderParams incrementalParams;
+ /** TODO(b/146080380): add a class name to make it fully compatible with ComponentName.
+ * {@hide} */
+ public String dataLoaderPackageName;
/**
* Construct parameters for a new package install session.
@@ -1468,6 +1502,7 @@
incrementalParams = new IncrementalDataLoaderParams(
dataLoaderParamsParcel);
}
+ dataLoaderPackageName = source.readString();
}
/** {@hide} */
@@ -1492,6 +1527,7 @@
ret.isStaged = isStaged;
ret.requiredInstalledVersionCode = requiredInstalledVersionCode;
ret.incrementalParams = incrementalParams;
+ ret.dataLoaderPackageName = dataLoaderPackageName;
return ret;
}
@@ -1770,7 +1806,8 @@
* @param installerPackageName name of the installer package
* {@hide}
*/
- public void setInstallerPackageName(String installerPackageName) {
+ @TestApi
+ public void setInstallerPackageName(@Nullable String installerPackageName) {
this.installerPackageName = installerPackageName;
}
@@ -1830,6 +1867,20 @@
this.incrementalParams = incrementalParams;
}
+ /**
+ * Set the data provider params for the session.
+ * This also switches installation into callback mode and disallow direct writes into
+ * staging folder.
+ * TODO(b/146080380): unify dataprovider params with Incremental.
+ *
+ * @param dataLoaderPackageName name of the dataLoader package
+ * {@hide}
+ */
+ @RequiresPermission(Manifest.permission.INSTALL_PACKAGES)
+ public void setDataLoaderPackageName(String dataLoaderPackageName) {
+ this.dataLoaderPackageName = dataLoaderPackageName;
+ }
+
/** {@hide} */
public void dump(IndentingPrintWriter pw) {
pw.printPair("mode", mode);
@@ -1850,6 +1901,7 @@
pw.printPair("isMultiPackage", isMultiPackage);
pw.printPair("isStaged", isStaged);
pw.printPair("requiredInstalledVersionCode", requiredInstalledVersionCode);
+ pw.printPair("dataLoaderPackageName", dataLoaderPackageName);
pw.println();
}
@@ -1884,6 +1936,7 @@
} else {
dest.writeParcelable(null, flags);
}
+ dest.writeString(dataLoaderPackageName);
}
public static final Parcelable.Creator<SessionParams>
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 6e890ba..94af541 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -946,7 +946,8 @@
INSTALL_REASON_POLICY,
INSTALL_REASON_DEVICE_RESTORE,
INSTALL_REASON_DEVICE_SETUP,
- INSTALL_REASON_USER
+ INSTALL_REASON_USER,
+ INSTALL_REASON_ROLLBACK
})
@Retention(RetentionPolicy.SOURCE)
public @interface InstallReason {}
@@ -977,6 +978,13 @@
public static final int INSTALL_REASON_USER = 4;
/**
+ * Code indicating that the package installation was a rollback initiated by RollbackManager.
+ *
+ * @hide
+ */
+ public static final int INSTALL_REASON_ROLLBACK = 5;
+
+ /**
* @hide
*/
public static final int INSTALL_UNKNOWN = 0;
diff --git a/core/java/android/content/pm/parsing/AndroidPackage.java b/core/java/android/content/pm/parsing/AndroidPackage.java
index 515185e..35df474 100644
--- a/core/java/android/content/pm/parsing/AndroidPackage.java
+++ b/core/java/android/content/pm/parsing/AndroidPackage.java
@@ -229,6 +229,11 @@
String getOverlayTargetName();
+ /**
+ * Map of overlayable name to actor name.
+ */
+ Map<String, String> getOverlayables();
+
// TODO(b/135203078): Does this and getAppInfoPackageName have to be separate methods?
// The refactor makes them the same value with no known consequences, so should be redundant.
String getPackageName();
diff --git a/core/java/android/content/pm/parsing/ApkParseUtils.java b/core/java/android/content/pm/parsing/ApkParseUtils.java
index edbf73a0..7732316 100644
--- a/core/java/android/content/pm/parsing/ApkParseUtils.java
+++ b/core/java/android/content/pm/parsing/ApkParseUtils.java
@@ -52,6 +52,7 @@
import android.content.pm.split.DefaultSplitAssetLoader;
import android.content.pm.split.SplitAssetDependencyLoader;
import android.content.pm.split.SplitAssetLoader;
+import android.content.res.ApkAssets;
import android.content.res.AssetManager;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -92,6 +93,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
import java.util.Set;
/** @hide */
@@ -287,8 +289,23 @@
+ result.getErrorMessage());
}
- return result.getResultAndNull()
- .setVolumeUuid(volumeUuid)
+ ParsingPackage pkg = result.getResultAndNull();
+ ApkAssets apkAssets = assets.getApkAssets()[0];
+ if (apkAssets.definesOverlayable()) {
+ SparseArray<String> packageNames = assets.getAssignedPackageIdentifiers();
+ int size = packageNames.size();
+ for (int index = 0; index < size; index++) {
+ String packageName = packageNames.get(index);
+ Map<String, String> overlayableToActor = assets.getOverlayableMap(packageName);
+ if (overlayableToActor != null && !overlayableToActor.isEmpty()) {
+ for (String overlayable : overlayableToActor.keySet()) {
+ pkg.addOverlayable(overlayable, overlayableToActor.get(overlayable));
+ }
+ }
+ }
+ }
+
+ return pkg.setVolumeUuid(volumeUuid)
.setApplicationVolumeUuid(volumeUuid)
.setSigningDetails(SigningDetails.UNKNOWN);
} catch (PackageParserException e) {
@@ -2321,7 +2338,7 @@
parsingPackage.setProfileableByShell(true);
}
XmlUtils.skipCurrentTag(parser);
-
+ break;
default:
if (!PackageParser.RIGID_PARSER) {
Slog.w(TAG, "Unknown element under <application>: " + tagName
diff --git a/core/java/android/content/pm/parsing/ComponentParseUtils.java b/core/java/android/content/pm/parsing/ComponentParseUtils.java
index 5364313..fc210b2 100644
--- a/core/java/android/content/pm/parsing/ComponentParseUtils.java
+++ b/core/java/android/content/pm/parsing/ComponentParseUtils.java
@@ -768,6 +768,10 @@
protected PatternMatcher[] uriPermissionPatterns;
protected PathPermission[] pathPermissions;
+ public ParsedProvider(ParsedProvider other) {
+ this.setFrom(other);
+ }
+
protected void setFrom(ParsedProvider other) {
super.setFrom(other);
this.exported = other.exported;
@@ -823,6 +827,10 @@
return authority;
}
+ public void setSyncable(boolean isSyncable) {
+ this.isSyncable = isSyncable;
+ }
+
public boolean isSyncable() {
return isSyncable;
}
diff --git a/core/java/android/content/pm/parsing/PackageImpl.java b/core/java/android/content/pm/parsing/PackageImpl.java
index 377279e..0e736d5 100644
--- a/core/java/android/content/pm/parsing/PackageImpl.java
+++ b/core/java/android/content/pm/parsing/PackageImpl.java
@@ -18,6 +18,8 @@
import static android.os.Build.VERSION_CODES.DONUT;
+import static java.util.Collections.emptyMap;
+
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Intent;
@@ -55,11 +57,13 @@
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
+import com.android.internal.util.CollectionUtils;
import com.android.server.SystemConfig;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -126,6 +130,7 @@
private String overlayCategory;
private int overlayPriority;
private boolean overlayIsStatic;
+ private Map<String, String> overlayables = emptyMap();
private String staticSharedLibName;
private long staticSharedLibVersion;
@@ -475,7 +480,7 @@
@Override
public Map<String, ArraySet<PublicKey>> getKeySetMapping() {
- return keySetMapping == null ? Collections.emptyMap() : keySetMapping;
+ return keySetMapping == null ? emptyMap() : keySetMapping;
}
@Override
@@ -773,6 +778,13 @@
}
@Override
+ public ParsingPackage addOverlayable(String overlayableName, String actorName) {
+ this.overlayables = CollectionUtils.add(this.overlayables,
+ TextUtils.safeIntern(overlayableName), TextUtils.safeIntern(actorName));
+ return this;
+ }
+
+ @Override
public PackageImpl addAdoptPermission(String adoptPermission) {
this.adoptPermissions = ArrayUtils.add(this.adoptPermissions, adoptPermission);
return this;
@@ -2125,6 +2137,11 @@
}
@Override
+ public Map<String, String> getOverlayables() {
+ return overlayables;
+ }
+
+ @Override
public boolean isOverlayIsStatic() {
return overlayIsStatic;
}
@@ -2291,7 +2308,7 @@
appInfo.metaData = appMetaData;
appInfo.minAspectRatio = minAspectRatio;
appInfo.minSdkVersion = minSdkVersion;
- appInfo.name = name;
+ appInfo.name = className;
if (appInfo.name != null) {
appInfo.name = appInfo.name.trim();
}
@@ -2957,6 +2974,7 @@
dest.writeString(this.overlayCategory);
dest.writeInt(this.overlayPriority);
dest.writeBoolean(this.overlayIsStatic);
+ dest.writeMap(this.overlayables);
dest.writeString(this.staticSharedLibName);
dest.writeLong(this.staticSharedLibVersion);
dest.writeStringList(this.libraryNames);
@@ -3100,6 +3118,8 @@
this.overlayCategory = in.readString();
this.overlayPriority = in.readInt();
this.overlayIsStatic = in.readBoolean();
+ this.overlayables = new HashMap<>();
+ in.readMap(overlayables, boot);
this.staticSharedLibName = TextUtils.safeIntern(in.readString());
this.staticSharedLibVersion = in.readLong();
this.libraryNames = in.createStringArrayList();
diff --git a/core/java/android/content/pm/parsing/PackageInfoUtils.java b/core/java/android/content/pm/parsing/PackageInfoUtils.java
index af9ba8d..f2cf9a4 100644
--- a/core/java/android/content/pm/parsing/PackageInfoUtils.java
+++ b/core/java/android/content/pm/parsing/PackageInfoUtils.java
@@ -485,6 +485,7 @@
pg.backgroundRequestDetailResourceId
);
assignSharedFieldsForPackageItemInfo(pgi, pg);
+ pgi.descriptionRes = pg.descriptionRes;
pgi.priority = pg.priority;
pgi.requestRes = pg.requestRes;
pgi.flags = pg.flags;
diff --git a/core/java/android/content/pm/parsing/ParsingPackage.java b/core/java/android/content/pm/parsing/ParsingPackage.java
index 43c1f6e..aff1b2e 100644
--- a/core/java/android/content/pm/parsing/ParsingPackage.java
+++ b/core/java/android/content/pm/parsing/ParsingPackage.java
@@ -62,6 +62,8 @@
ParsingPackage addOriginalPackage(String originalPackage);
+ ParsingPackage addOverlayable(String overlayableName, String actorName);
+
ParsingPackage addPermission(ParsedPermission permission);
ParsingPackage addPermissionGroup(ParsedPermissionGroup permissionGroup);
diff --git a/core/java/android/content/rollback/IRollbackManager.aidl b/core/java/android/content/rollback/IRollbackManager.aidl
index 8c2a65f..cda0e98 100644
--- a/core/java/android/content/rollback/IRollbackManager.aidl
+++ b/core/java/android/content/rollback/IRollbackManager.aidl
@@ -44,9 +44,10 @@
// Used by the staging manager to notify the RollbackManager that a session is
// being staged. In the case of multi-package sessions, the specified sessionId
// is that of the parent session.
+ // Returns the rollback id if rollback was enabled successfully, or -1 if not.
//
// NOTE: This call is synchronous.
- boolean notifyStagedSession(int sessionId);
+ int notifyStagedSession(int sessionId);
// Used by the staging manager to notify the RollbackManager of the apk
// session for a staged session.
diff --git a/core/java/android/hardware/biometrics/Authenticator.java b/core/java/android/hardware/biometrics/Authenticator.java
deleted file mode 100644
index 6d7e748..0000000
--- a/core/java/android/hardware/biometrics/Authenticator.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2019 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 android.hardware.biometrics;
-
-/**
- * Type of authenticators defined on a granularity that the BiometricManager / BiometricPrompt
- * supports.
- * @hide
- */
-public class Authenticator {
-
- /**
- * Device credential, e.g. Pin/Pattern/Password.
- */
- public static final int TYPE_CREDENTIAL = 1 << 0;
- /**
- * Encompasses all biometrics on the device, e.g. Fingerprint/Iris/Face.
- */
- public static final int TYPE_BIOMETRIC = 1 << 1;
-
-}
diff --git a/core/java/android/hardware/biometrics/BiometricConstants.java b/core/java/android/hardware/biometrics/BiometricConstants.java
index 191516b..d28b7c5 100644
--- a/core/java/android/hardware/biometrics/BiometricConstants.java
+++ b/core/java/android/hardware/biometrics/BiometricConstants.java
@@ -16,8 +16,9 @@
package android.hardware.biometrics;
+import static android.hardware.biometrics.BiometricManager.Authenticators;
+
import android.annotation.UnsupportedAppUsage;
-import android.app.KeyguardManager;
/**
@@ -126,8 +127,8 @@
/**
* The device does not have pin, pattern, or password set up. See
- * {@link BiometricPrompt.Builder#setDeviceCredentialAllowed(boolean)} and
- * {@link KeyguardManager#isDeviceSecure()}
+ * {@link BiometricPrompt.Builder#setAllowedAuthenticators(int)},
+ * {@link Authenticators#DEVICE_CREDENTIAL}, and {@link BiometricManager#canAuthenticate(int)}.
*/
int BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL = 14;
diff --git a/core/java/android/hardware/biometrics/BiometricManager.java b/core/java/android/hardware/biometrics/BiometricManager.java
index f17b3ae..7e1506f 100644
--- a/core/java/android/hardware/biometrics/BiometricManager.java
+++ b/core/java/android/hardware/biometrics/BiometricManager.java
@@ -21,6 +21,7 @@
import android.annotation.IntDef;
import android.annotation.RequiresPermission;
+import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -65,6 +66,77 @@
BIOMETRIC_ERROR_NO_HARDWARE})
@interface BiometricError {}
+ /**
+ * Types of authenticators, defined at a level of granularity supported by
+ * {@link BiometricManager} and {@link BiometricPrompt}.
+ *
+ * <p>Types may combined via bitwise OR into a single integer representing multiple
+ * authenticators (e.g. <code>DEVICE_CREDENTIAL | BIOMETRIC_WEAK</code>).
+ */
+ public interface Authenticators {
+ /**
+ * An {@link IntDef} representing valid combinations of authenticator types.
+ * @hide
+ */
+ @IntDef(flag = true, value = {
+ BIOMETRIC_STRONG,
+ BIOMETRIC_WEAK,
+ DEVICE_CREDENTIAL,
+ })
+ @interface Types {}
+
+ /**
+ * Empty set with no authenticators specified.
+ * @hide
+ */
+ @SystemApi
+ int EMPTY_SET = 0x0;
+
+ /**
+ * Placeholder for the theoretical strongest biometric security tier.
+ * @hide
+ */
+ int BIOMETRIC_MAX_STRENGTH = 0x001;
+
+ /**
+ * Any biometric (e.g. fingerprint, iris, or face) on the device that meets or exceeds the
+ * requirements for <strong>Strong</strong>, as defined by the Android CDD.
+ */
+ int BIOMETRIC_STRONG = 0x00F;
+
+ /**
+ * Any biometric (e.g. fingerprint, iris, or face) on the device that meets or exceeds the
+ * requirements for <strong>Weak</strong>, as defined by the Android CDD.
+ *
+ * <p>Note that this is a superset of {@link #BIOMETRIC_STRONG} and is defined such that
+ * <code>BIOMETRIC_STRONG | BIOMETRIC_WEAK == BIOMETRIC_WEAK</code>.
+ */
+ int BIOMETRIC_WEAK = 0x0FF;
+
+ /**
+ * Any biometric (e.g. fingerprint, iris, or face) on the device that meets or exceeds the
+ * requirements for <strong>Convenience</strong>, as defined by the Android CDD. This
+ * is not a valid parameter to any of the {@link android.hardware.biometrics} APIs, since
+ * the CDD allows only {@link #BIOMETRIC_WEAK} and stronger authenticators to participate.
+ * @hide
+ */
+ @SystemApi
+ int BIOMETRIC_CONVENIENCE = 0xFFF;
+
+ /**
+ * Placeholder for the theoretical weakest biometric security tier.
+ * @hide
+ */
+ int BIOMETRIC_MIN_STRENGTH = 0x7FFF;
+
+ /**
+ * The non-biometric credential used to secure the device (i.e., PIN, pattern, or password).
+ * This should typically only be used in combination with a biometric auth type, such as
+ * {@link #BIOMETRIC_WEAK}.
+ */
+ int DEVICE_CREDENTIAL = 1 << 15;
+ }
+
private final Context mContext;
private final IAuthService mService;
private final boolean mHasHardware;
@@ -94,27 +166,64 @@
}
/**
- * Determine if biometrics can be used. In other words, determine if {@link BiometricPrompt}
- * can be expected to be shown (hardware available, templates enrolled, user-enabled).
+ * Determine if biometrics can be used. In other words, determine if
+ * {@link BiometricPrompt} can be expected to be shown (hardware available, templates enrolled,
+ * user-enabled). This is the equivalent of {@link #canAuthenticate(int)} with
+ * {@link Authenticators#BIOMETRIC_WEAK}
*
- * @return Returns {@link #BIOMETRIC_ERROR_NONE_ENROLLED} if the user does not have any
- * enrolled, or {@link #BIOMETRIC_ERROR_HW_UNAVAILABLE} if none are currently
- * supported/enabled. Returns {@link #BIOMETRIC_SUCCESS} if a biometric can currently be
- * used (enrolled and available).
+ * @return {@link #BIOMETRIC_ERROR_NONE_ENROLLED} if the user does not have any strong
+ * biometrics enrolled, or {@link #BIOMETRIC_ERROR_HW_UNAVAILABLE} if none are currently
+ * supported/enabled. Returns {@link #BIOMETRIC_SUCCESS} if a strong biometric can currently
+ * be used (enrolled and available).
+ *
+ * @deprecated See {@link #canAuthenticate(int)}.
*/
+ @Deprecated
@RequiresPermission(USE_BIOMETRIC)
public @BiometricError int canAuthenticate() {
- return canAuthenticate(mContext.getUserId());
+ return canAuthenticate(Authenticators.BIOMETRIC_WEAK);
+ }
+
+ /**
+ * Determine if any of the provided authenticators can be used. In other words, determine if
+ * {@link BiometricPrompt} can be expected to be shown (hardware available, templates enrolled,
+ * user-enabled).
+ *
+ * For biometric authenticators, determine if the device can currently authenticate with at
+ * least the requested strength. For example, invoking this API with
+ * {@link Authenticators#BIOMETRIC_WEAK} on a device that currently only has
+ * {@link Authenticators#BIOMETRIC_STRONG} enrolled will return {@link #BIOMETRIC_SUCCESS}.
+ *
+ * Invoking this API with {@link Authenticators#DEVICE_CREDENTIAL} can be used to determine
+ * if the user has a PIN/Pattern/Password set up.
+ *
+ * @param authenticators bit field consisting of constants defined in {@link Authenticators}.
+ * If multiple authenticators are queried, a logical OR will be applied.
+ * For example, if {@link Authenticators#DEVICE_CREDENTIAL} |
+ * {@link Authenticators#BIOMETRIC_STRONG} is queried and only
+ * {@link Authenticators#DEVICE_CREDENTIAL} is set up, this API will
+ * return {@link #BIOMETRIC_SUCCESS}
+ *
+ * @return {@link #BIOMETRIC_ERROR_NONE_ENROLLED} if the user does not have any of the
+ * requested authenticators enrolled, or {@link #BIOMETRIC_ERROR_HW_UNAVAILABLE} if none are
+ * currently supported/enabled. Returns {@link #BIOMETRIC_SUCCESS} if one of the requested
+ * authenticators can currently be used (enrolled and available).
+ */
+ @RequiresPermission(USE_BIOMETRIC)
+ public @BiometricError int canAuthenticate(@Authenticators.Types int authenticators) {
+ return canAuthenticate(mContext.getUserId(), authenticators);
}
/**
* @hide
*/
@RequiresPermission(USE_BIOMETRIC_INTERNAL)
- public @BiometricError int canAuthenticate(int userId) {
+ public @BiometricError int canAuthenticate(int userId,
+ @Authenticators.Types int authenticators) {
if (mService != null) {
try {
- return mService.canAuthenticate(mContext.getOpPackageName(), userId);
+ final String opPackageName = mContext.getOpPackageName();
+ return mService.canAuthenticate(opPackageName, userId, authenticators);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
diff --git a/core/java/android/hardware/biometrics/BiometricPrompt.java b/core/java/android/hardware/biometrics/BiometricPrompt.java
index 9c51b52..6f9c9e6 100644
--- a/core/java/android/hardware/biometrics/BiometricPrompt.java
+++ b/core/java/android/hardware/biometrics/BiometricPrompt.java
@@ -18,6 +18,7 @@
import static android.Manifest.permission.USE_BIOMETRIC;
import static android.Manifest.permission.USE_BIOMETRIC_INTERNAL;
+import static android.hardware.biometrics.BiometricManager.Authenticators;
import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
@@ -149,7 +150,7 @@
/**
* A builder that collects arguments to be shown on the system-provided biometric dialog.
- **/
+ */
public static class Builder {
private final Bundle mBundle;
private ButtonInfo mPositiveButtonInfo;
@@ -157,8 +158,8 @@
private Context mContext;
/**
- * Creates a builder for a biometric dialog.
- * @param context
+ * Creates a builder for a {@link BiometricPrompt} dialog.
+ * @param context The {@link Context} that will be used to build the prompt.
*/
public Builder(Context context) {
mBundle = new Bundle();
@@ -166,58 +167,67 @@
}
/**
- * Required: Set the title to display.
- * @param title
- * @return
+ * Required: Sets the title that will be shown on the prompt.
+ * @param title The title to display.
+ * @return This builder.
*/
- @NonNull public Builder setTitle(@NonNull CharSequence title) {
+ @NonNull
+ public Builder setTitle(@NonNull CharSequence title) {
mBundle.putCharSequence(KEY_TITLE, title);
return this;
}
/**
- * For internal use currently. Only takes effect if title is null/empty. Shows a default
- * modality-specific title.
+ * Shows a default, modality-specific title for the prompt if the title would otherwise be
+ * null or empty. Currently for internal use only.
+ * @return This builder.
* @hide
*/
@RequiresPermission(USE_BIOMETRIC_INTERNAL)
- @NonNull public Builder setUseDefaultTitle() {
+ @NonNull
+ public Builder setUseDefaultTitle() {
mBundle.putBoolean(KEY_USE_DEFAULT_TITLE, true);
return this;
}
/**
- * Optional: Set the subtitle to display.
- * @param subtitle
- * @return
+ * Optional: Sets a subtitle that will be shown on the prompt.
+ * @param subtitle The subtitle to display.
+ * @return This builder.
*/
- @NonNull public Builder setSubtitle(@NonNull CharSequence subtitle) {
+ @NonNull
+ public Builder setSubtitle(@NonNull CharSequence subtitle) {
mBundle.putCharSequence(KEY_SUBTITLE, subtitle);
return this;
}
/**
- * Optional: Set the description to display.
- * @param description
- * @return
+ * Optional: Sets a description that will be shown on the prompt.
+ * @param description The description to display.
+ * @return This builder.
*/
- @NonNull public Builder setDescription(@NonNull CharSequence description) {
+ @NonNull
+ public Builder setDescription(@NonNull CharSequence description) {
mBundle.putCharSequence(KEY_DESCRIPTION, description);
return this;
}
/**
- * Required: Set the text for the negative button. This would typically be used as a
- * "Cancel" button, but may be also used to show an alternative method for authentication,
- * such as screen that asks for a backup password.
+ * Required: Sets the text, executor, and click listener for the negative button on the
+ * prompt. This is typically a cancel button, but may be also used to show an alternative
+ * method for authentication, such as a screen that asks for a backup password.
*
- * Note that this should not be set if {@link #setDeviceCredentialAllowed(boolean)}(boolean)
- * is set to true.
+ * <p>Note that this setting is not required, and in fact is explicitly disallowed, if
+ * device credential authentication is enabled via {@link #setAllowedAuthenticators(int)} or
+ * {@link #setDeviceCredentialAllowed(boolean)}.
*
- * @param text
- * @return
+ * @param text Text to be shown on the negative button for the prompt.
+ * @param executor Executor that will be used to run the on click callback.
+ * @param listener Listener containing a callback to be run when the button is pressed.
+ * @return This builder.
*/
- @NonNull public Builder setNegativeButton(@NonNull CharSequence text,
+ @NonNull
+ public Builder setNegativeButton(@NonNull CharSequence text,
@NonNull @CallbackExecutor Executor executor,
@NonNull DialogInterface.OnClickListener listener) {
if (TextUtils.isEmpty(text)) {
@@ -235,70 +245,112 @@
}
/**
- * Optional: A hint to the system to require user confirmation after a biometric has been
- * authenticated. For example, implicit modalities like Face and Iris authentication are
- * passive, meaning they don't require an explicit user action to complete. When set to
- * 'false', the user action (e.g. pressing a button) will not be required. BiometricPrompt
- * will require confirmation by default.
+ * Optional: Sets a hint to the system for whether to require user confirmation after
+ * authentication. For example, implicit modalities like face and iris are passive, meaning
+ * they don't require an explicit user action to complete authentication. If set to true,
+ * these modalities should require the user to take some action (e.g. press a button)
+ * before {@link AuthenticationCallback#onAuthenticationSucceeded(AuthenticationResult)} is
+ * called. Defaults to true.
*
- * A typical use case for not requiring confirmation would be for low-risk transactions,
+ * <p>A typical use case for not requiring confirmation would be for low-risk transactions,
* such as re-authenticating a recently authenticated application. A typical use case for
* requiring confirmation would be for authorizing a purchase.
*
- * Note that this is a hint to the system. The system may choose to ignore the flag. For
- * example, if the user disables implicit authentication in Settings, or if it does not
- * apply to a modality (e.g. Fingerprint). When ignored, the system will default to
- * requiring confirmation.
+ * <p>Note that this just passes a hint to the system, which the system may then ignore. For
+ * example, a value of false may be ignored if the user has disabled implicit authentication
+ * in Settings, or if it does not apply to a particular modality (e.g. fingerprint).
*
- * @param requireConfirmation
+ * @param requireConfirmation true if explicit user confirmation should be required, or
+ * false otherwise.
+ * @return This builder.
*/
- @NonNull public Builder setConfirmationRequired(boolean requireConfirmation) {
+ @NonNull
+ public Builder setConfirmationRequired(boolean requireConfirmation) {
mBundle.putBoolean(KEY_REQUIRE_CONFIRMATION, requireConfirmation);
return this;
}
/**
- * The user will first be prompted to authenticate with biometrics, but also given the
- * option to authenticate with their device PIN, pattern, or password. Developers should
- * first check {@link KeyguardManager#isDeviceSecure()} before enabling this. If the device
- * is not secure, {@link BiometricPrompt#BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL} will be
- * returned in {@link AuthenticationCallback#onAuthenticationError(int, CharSequence)}}.
+ * Optional: If enabled, the user will first be prompted to authenticate with biometrics,
+ * but also given the option to authenticate with their device PIN, pattern, or password.
+ * Developers should first check {@link KeyguardManager#isDeviceSecure()} before enabling.
+ * If the device is not secure, {@link BiometricPrompt#BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL}
+ * will be given to {@link AuthenticationCallback#onAuthenticationError(int, CharSequence)}.
* Defaults to false.
*
- * Note that {@link #setNegativeButton(CharSequence, Executor,
- * DialogInterface.OnClickListener)} should not be set if this is set to true.
+ * <p>Note that enabling this option replaces the negative button on the prompt with one
+ * that allows the user to authenticate with their device credential, making it an error to
+ * call {@link #setNegativeButton(CharSequence, Executor, DialogInterface.OnClickListener)}.
*
- * @param allowed When true, the prompt will fall back to ask for the user's device
- * credentials (PIN, pattern, or password).
- * @return
+ * @param allowed true if the prompt should fall back to asking for the user's device
+ * credential (PIN/pattern/password), or false otherwise.
+ * @return This builder.
+ *
+ * @deprecated Replaced by {@link #setAllowedAuthenticators(int)}.
*/
- @NonNull public Builder setDeviceCredentialAllowed(boolean allowed) {
+ @Deprecated
+ @NonNull
+ public Builder setDeviceCredentialAllowed(boolean allowed) {
mBundle.putBoolean(KEY_ALLOW_DEVICE_CREDENTIAL, allowed);
return this;
}
/**
- * Creates a {@link BiometricPrompt}.
- * @return a {@link BiometricPrompt}
- * @throws IllegalArgumentException if any of the required fields are not set.
+ * Optional: Specifies the type(s) of authenticators that may be invoked by
+ * {@link BiometricPrompt} to authenticate the user. Available authenticator types are
+ * defined in {@link Authenticators} and can be combined via bitwise OR. Defaults to:
+ * <ul>
+ * <li>{@link Authenticators#BIOMETRIC_WEAK} for non-crypto authentication, or</li>
+ * <li>{@link Authenticators#BIOMETRIC_STRONG} for crypto-based authentication.</li>
+ * </ul>
+ *
+ * <p>If this method is used and no authenticator of any of the specified types is available
+ * at the time <code>BiometricPrompt#authenticate(...)</code> is called, authentication will
+ * be canceled and {@link AuthenticationCallback#onAuthenticationError(int, CharSequence)}
+ * will be invoked with an appropriate error code.
+ *
+ * <p>This method should be preferred over {@link #setDeviceCredentialAllowed(boolean)} and
+ * overrides the latter if both are used. Using this method to enable device credential
+ * authentication (with {@link Authenticators#DEVICE_CREDENTIAL}) will replace the negative
+ * button on the prompt, making it an error to also call
+ * {@link #setNegativeButton(CharSequence, Executor, DialogInterface.OnClickListener)}.
+ *
+ * @param authenticators A bit field representing all valid authenticator types that may be
+ * invoked by the prompt.
+ * @return This builder.
*/
- @NonNull public BiometricPrompt build() {
+ @NonNull
+ public Builder setAllowedAuthenticators(@Authenticators.Types int authenticators) {
+ mBundle.putInt(KEY_AUTHENTICATORS_ALLOWED, authenticators);
+ return this;
+ }
+
+ /**
+ * Creates a {@link BiometricPrompt}.
+ *
+ * @return An instance of {@link BiometricPrompt}.
+ *
+ * @throws IllegalArgumentException If any required fields are unset, or if given any
+ * invalid combination of field values.
+ */
+ @NonNull
+ public BiometricPrompt build() {
final CharSequence title = mBundle.getCharSequence(KEY_TITLE);
final CharSequence negative = mBundle.getCharSequence(KEY_NEGATIVE_TEXT);
- final boolean useDefaultTitle = mBundle.getBoolean(KEY_USE_DEFAULT_TITLE);
- final boolean allowCredential = mBundle.getBoolean(KEY_ALLOW_DEVICE_CREDENTIAL);
- final Object authenticatorsAllowed = mBundle.get(KEY_AUTHENTICATORS_ALLOWED);
+ final boolean useDefaultTitle = mBundle.getBoolean(KEY_USE_DEFAULT_TITLE, false);
+ final boolean deviceCredentialAllowed = mBundle.getBoolean(KEY_ALLOW_DEVICE_CREDENTIAL);
+ final @Authenticators.Types int authenticators =
+ mBundle.getInt(KEY_AUTHENTICATORS_ALLOWED, 0);
+ final boolean willShowDeviceCredentialButton = deviceCredentialAllowed
+ || (authenticators & Authenticators.DEVICE_CREDENTIAL) != 0;
if (TextUtils.isEmpty(title) && !useDefaultTitle) {
throw new IllegalArgumentException("Title must be set and non-empty");
- } else if (TextUtils.isEmpty(negative) && !allowCredential) {
+ } else if (TextUtils.isEmpty(negative) && !willShowDeviceCredentialButton) {
throw new IllegalArgumentException("Negative text must be set and non-empty");
- } else if (!TextUtils.isEmpty(negative) && allowCredential) {
+ } else if (!TextUtils.isEmpty(negative) && willShowDeviceCredentialButton) {
throw new IllegalArgumentException("Can't have both negative button behavior"
+ " and device credential enabled");
- } else if (authenticatorsAllowed != null && allowCredential) {
- throw new IllegalArgumentException("setAuthenticatorsAllowed and"
- + " setDeviceCredentialAllowed should not be used simultaneously");
}
return new BiometricPrompt(mContext, mBundle, mPositiveButtonInfo, mNegativeButtonInfo);
}
@@ -394,6 +446,75 @@
}
/**
+ * Gets the title for the prompt, as set by {@link Builder#setTitle(CharSequence)}.
+ * @return The title of the prompt, which is guaranteed to be non-null.
+ */
+ @NonNull
+ public CharSequence getTitle() {
+ return mBundle.getCharSequence(KEY_TITLE, "");
+ }
+
+ /**
+ * Whether to use a default modality-specific title. For internal use only.
+ * @return See {@link Builder#setUseDefaultTitle()}.
+ * @hide
+ */
+ @RequiresPermission(USE_BIOMETRIC_INTERNAL)
+ public boolean shouldUseDefaultTitle() {
+ return mBundle.getBoolean(KEY_USE_DEFAULT_TITLE, false);
+ }
+
+ /**
+ * Gets the subtitle for the prompt, as set by {@link Builder#setSubtitle(CharSequence)}.
+ * @return The subtitle for the prompt, or null if the prompt has no subtitle.
+ */
+ @Nullable
+ public CharSequence getSubtitle() {
+ return mBundle.getCharSequence(KEY_SUBTITLE);
+ }
+
+ /**
+ * Gets the description for the prompt, as set by {@link Builder#setDescription(CharSequence)}.
+ * @return The description for the prompt, or null if the prompt has no description.
+ */
+ @Nullable
+ public CharSequence getDescription() {
+ return mBundle.getCharSequence(KEY_DESCRIPTION);
+ }
+
+ /**
+ * Gets the negative button text for the prompt, as set by
+ * {@link Builder#setNegativeButton(CharSequence, Executor, DialogInterface.OnClickListener)}.
+ * @return The negative button text for the prompt, or null if no negative button text was set.
+ */
+ @Nullable
+ public CharSequence getNegativeButtonText() {
+ return mBundle.getCharSequence(KEY_NEGATIVE_TEXT);
+ }
+
+ /**
+ * Determines if explicit user confirmation is required by the prompt, as set by
+ * {@link Builder#setConfirmationRequired(boolean)}.
+ *
+ * @return true if explicit user confirmation is required, or false otherwise.
+ */
+ public boolean isConfirmationRequired() {
+ return mBundle.getBoolean(KEY_REQUIRE_CONFIRMATION, true);
+ }
+
+ /**
+ * Gets the type(s) of authenticators that may be invoked by the prompt to authenticate the
+ * user, as set by {@link Builder#setAllowedAuthenticators(int)}.
+ *
+ * @return A bit field representing the type(s) of authenticators that may be invoked by the
+ * prompt (as defined by {@link Authenticators}), or 0 if this field was not set.
+ */
+ @Nullable
+ public int getAllowedAuthenticators() {
+ return mBundle.getInt(KEY_AUTHENTICATORS_ALLOWED, 0);
+ }
+
+ /**
* A wrapper class for the crypto objects supported by BiometricPrompt. Currently the framework
* supports {@link Signature}, {@link Cipher} and {@link Mac} objects.
*/
@@ -509,10 +630,12 @@
/**
* Authenticates for the given user.
+ *
* @param cancel An object that can be used to cancel authentication
* @param executor An executor to handle callback events
* @param callback An object to receive authentication events
* @param userId The user to authenticate
+ *
* @hide
*/
@RequiresPermission(USE_BIOMETRIC_INTERNAL)
@@ -542,23 +665,33 @@
* authentication errors through {@link AuthenticationCallback}, and button events through the
* corresponding callback set in {@link Builder#setNegativeButton(CharSequence, Executor,
* DialogInterface.OnClickListener)}. It is safe to reuse the {@link BiometricPrompt} object,
- * and calling {@link BiometricPrompt#authenticate( CancellationSignal, Executor,
+ * and calling {@link BiometricPrompt#authenticate(CancellationSignal, Executor,
* AuthenticationCallback)} while an existing authentication attempt is occurring will stop the
* previous client and start a new authentication. The interrupted client will receive a
* cancelled notification through {@link AuthenticationCallback#onAuthenticationError(int,
* CharSequence)}.
*
- * Note: Applications generally should not cancel and start authentication in quick succession.
- * For example, to properly handle authentication across configuration changes, it's recommended
- * to use BiometricPrompt in a fragment with setRetainInstance(true). By doing so, the
- * application will not need to cancel/restart authentication during the configuration change.
+ * <p>Note: Applications generally should not cancel and start authentication in quick
+ * succession. For example, to properly handle authentication across configuration changes, it's
+ * recommended to use BiometricPrompt in a fragment with setRetainInstance(true). By doing so,
+ * the application will not need to cancel/restart authentication during the configuration
+ * change.
*
- * @throws IllegalArgumentException If any of the arguments are null
+ * <p>Per the Android CDD, only biometric authenticators that meet or exceed the requirements
+ * for <strong>Strong</strong> are permitted to integrate with Keystore to perform related
+ * cryptographic operations. Therefore, it is an error to call this method after explicitly
+ * calling {@link Builder#setAllowedAuthenticators(int)} with any value other than
+ * {@link Authenticators#BIOMETRIC_STRONG}.
*
- * @param crypto Object associated with the call
- * @param cancel An object that can be used to cancel authentication
- * @param executor An executor to handle callback events
- * @param callback An object to receive authentication events
+ * @throws IllegalArgumentException If any of the arguments are null, if
+ * {@link Builder#setDeviceCredentialAllowed(boolean)} was explicitly set to true, or if
+ * {@link Builder#setAllowedAuthenticators(int)} was explicitly called with any value other than
+ * {@link Authenticators#BIOMETRIC_STRONG}.
+ *
+ * @param crypto A cryptographic operation to be unlocked after successful authentication.
+ * @param cancel An object that can be used to cancel authentication.
+ * @param executor An executor to handle callback events.
+ * @param callback An object to receive authentication events.
*/
@RequiresPermission(USE_BIOMETRIC)
public void authenticate(@NonNull CryptoObject crypto,
@@ -577,9 +710,20 @@
if (callback == null) {
throw new IllegalArgumentException("Must supply a callback");
}
- if (mBundle.getBoolean(KEY_ALLOW_DEVICE_CREDENTIAL)) {
+
+ @Authenticators.Types int authenticators = mBundle.getInt(
+ KEY_AUTHENTICATORS_ALLOWED, Authenticators.BIOMETRIC_STRONG);
+
+ if (mBundle.getBoolean(KEY_ALLOW_DEVICE_CREDENTIAL)
+ || (authenticators & Authenticators.DEVICE_CREDENTIAL) != 0) {
throw new IllegalArgumentException("Device credential not supported with crypto");
}
+
+ // Disallow any non-Strong biometric authenticator types.
+ if ((authenticators & ~Authenticators.BIOMETRIC_STRONG) != 0) {
+ throw new IllegalArgumentException("Only Strong biometrics supported with crypto");
+ }
+
authenticateInternal(crypto, cancel, executor, callback, mContext.getUserId());
}
@@ -598,16 +742,17 @@
* authentication. The interrupted client will receive a cancelled notification through {@link
* AuthenticationCallback#onAuthenticationError(int, CharSequence)}.
*
- * Note: Applications generally should not cancel and start authentication in quick succession.
- * For example, to properly handle authentication across configuration changes, it's recommended
- * to use BiometricPrompt in a fragment with setRetainInstance(true). By doing so, the
- * application will not need to cancel/restart authentication during the configuration change.
+ * <p>Note: Applications generally should not cancel and start authentication in quick
+ * succession. For example, to properly handle authentication across configuration changes, it's
+ * recommended to use BiometricPrompt in a fragment with setRetainInstance(true). By doing so,
+ * the application will not need to cancel/restart authentication during the configuration
+ * change.
*
- * @throws IllegalArgumentException If any of the arguments are null
+ * @throws IllegalArgumentException If any of the arguments are null.
*
- * @param cancel An object that can be used to cancel authentication
- * @param executor An executor to handle callback events
- * @param callback An object to receive authentication events
+ * @param cancel An object that can be used to cancel authentication.
+ * @param executor An executor to handle callback events.
+ * @param callback An object to receive authentication events.
*/
@RequiresPermission(USE_BIOMETRIC)
public void authenticate(@NonNull CancellationSignal cancel,
@@ -653,8 +798,22 @@
mAuthenticationCallback = callback;
final long sessionId = crypto != null ? crypto.getOpId() : 0;
if (BiometricManager.hasBiometrics(mContext)) {
+ final Bundle bundle;
+ if (crypto != null) {
+ // Allowed authenticators should default to BIOMETRIC_STRONG for crypto auth.
+ // Note that we use a new bundle here so as to not overwrite the application's
+ // preference, since it is possible that the same prompt configuration be used
+ // without a crypto object later.
+ bundle = new Bundle(mBundle);
+ bundle.putInt(KEY_AUTHENTICATORS_ALLOWED,
+ mBundle.getInt(KEY_AUTHENTICATORS_ALLOWED,
+ Authenticators.BIOMETRIC_STRONG));
+ } else {
+ bundle = mBundle;
+ }
+
mService.authenticate(mToken, sessionId, userId, mBiometricServiceReceiver,
- mContext.getOpPackageName(), mBundle);
+ mContext.getOpPackageName(), bundle);
} else {
mExecutor.execute(() -> {
callback.onAuthenticationError(BiometricPrompt.BIOMETRIC_ERROR_HW_NOT_PRESENT,
diff --git a/core/java/android/hardware/biometrics/IAuthService.aidl b/core/java/android/hardware/biometrics/IAuthService.aidl
index 516a25d..d482198 100644
--- a/core/java/android/hardware/biometrics/IAuthService.aidl
+++ b/core/java/android/hardware/biometrics/IAuthService.aidl
@@ -35,7 +35,7 @@
// TODO(b/141025588): Make userId the first arg to be consistent with hasEnrolledBiometrics.
// Checks if biometrics can be used.
- int canAuthenticate(String opPackageName, int userId);
+ int canAuthenticate(String opPackageName, int userId, int authenticators);
// Checks if any biometrics are enrolled.
boolean hasEnrolledBiometrics(int userId, String opPackageName);
diff --git a/core/java/android/hardware/biometrics/IBiometricService.aidl b/core/java/android/hardware/biometrics/IBiometricService.aidl
index ca02421..8a6be18 100644
--- a/core/java/android/hardware/biometrics/IBiometricService.aidl
+++ b/core/java/android/hardware/biometrics/IBiometricService.aidl
@@ -35,7 +35,7 @@
void cancelAuthentication(IBinder token, String opPackageName);
// Checks if biometrics can be used.
- int canAuthenticate(String opPackageName, int userId);
+ int canAuthenticate(String opPackageName, int userId, int authenticators);
// Checks if any biometrics are enrolled.
boolean hasEnrolledBiometrics(int userId, String opPackageName);
@@ -43,7 +43,8 @@
// Registers an authenticator (e.g. face, fingerprint, iris).
// Id must be unique, whereas strength and modality don't need to be.
// TODO(b/123321528): Turn strength and modality into enums.
- void registerAuthenticator(int id, int strength, int modality, IBiometricAuthenticator authenticator);
+ void registerAuthenticator(int id, int modality, int strength,
+ IBiometricAuthenticator authenticator);
// Register callback for when keyguard biometric eligibility changes.
void registerEnabledOnKeyguardCallback(IBiometricEnabledOnKeyguardCallback callback);
diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java
index 1f29d1a..c84c4a7 100644
--- a/core/java/android/hardware/camera2/CameraCharacteristics.java
+++ b/core/java/android/hardware/camera2/CameraCharacteristics.java
@@ -935,7 +935,7 @@
/**
* <p>List of the maximum number of regions that can be used for metering in
* auto-exposure (AE), auto-white balance (AWB), and auto-focus (AF);
- * this corresponds to the the maximum number of elements in
+ * this corresponds to the maximum number of elements in
* {@link CaptureRequest#CONTROL_AE_REGIONS android.control.aeRegions}, {@link CaptureRequest#CONTROL_AWB_REGIONS android.control.awbRegions},
* and {@link CaptureRequest#CONTROL_AF_REGIONS android.control.afRegions}.</p>
* <p><b>Range of valid values:</b><br></p>
@@ -955,7 +955,7 @@
/**
* <p>The maximum number of metering regions that can be used by the auto-exposure (AE)
* routine.</p>
- * <p>This corresponds to the the maximum allowed number of elements in
+ * <p>This corresponds to the maximum allowed number of elements in
* {@link CaptureRequest#CONTROL_AE_REGIONS android.control.aeRegions}.</p>
* <p><b>Range of valid values:</b><br>
* Value will be >= 0. For FULL-capability devices, this
@@ -973,7 +973,7 @@
/**
* <p>The maximum number of metering regions that can be used by the auto-white balance (AWB)
* routine.</p>
- * <p>This corresponds to the the maximum allowed number of elements in
+ * <p>This corresponds to the maximum allowed number of elements in
* {@link CaptureRequest#CONTROL_AWB_REGIONS android.control.awbRegions}.</p>
* <p><b>Range of valid values:</b><br>
* Value will be >= 0.</p>
@@ -989,7 +989,7 @@
/**
* <p>The maximum number of metering regions that can be used by the auto-focus (AF) routine.</p>
- * <p>This corresponds to the the maximum allowed number of elements in
+ * <p>This corresponds to the maximum allowed number of elements in
* {@link CaptureRequest#CONTROL_AF_REGIONS android.control.afRegions}.</p>
* <p><b>Range of valid values:</b><br>
* Value will be >= 0. For FULL-capability devices, this
@@ -1987,6 +1987,7 @@
* <li>{@link #REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME MONOCHROME}</li>
* <li>{@link #REQUEST_AVAILABLE_CAPABILITIES_SECURE_IMAGE_DATA SECURE_IMAGE_DATA}</li>
* <li>{@link #REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA SYSTEM_CAMERA}</li>
+ * <li>{@link #REQUEST_AVAILABLE_CAPABILITIES_OFFLINE_PROCESSING OFFLINE_PROCESSING}</li>
* </ul></p>
* <p>This key is available on all devices.</p>
*
@@ -2006,6 +2007,7 @@
* @see #REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME
* @see #REQUEST_AVAILABLE_CAPABILITIES_SECURE_IMAGE_DATA
* @see #REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA
+ * @see #REQUEST_AVAILABLE_CAPABILITIES_OFFLINE_PROCESSING
*/
@PublicKey
@NonNull
diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java
index 799c716..f2a7abd 100644
--- a/core/java/android/hardware/camera2/CameraMetadata.java
+++ b/core/java/android/hardware/camera2/CameraMetadata.java
@@ -1004,6 +1004,51 @@
*/
public static final int REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA = 14;
+ /**
+ * <p>The camera device supports the OFFLINE_PROCESSING use case.</p>
+ * <p>With OFFLINE_PROCESSING capability, the application can switch an ongoing
+ * capture session to offline mode by calling the
+ * CameraCaptureSession#switchToOffline method and specify streams to be kept in offline
+ * mode. The camera will then stop currently active repeating requests, prepare for
+ * some requests to go into offline mode, and return an offline session object. After
+ * the switchToOffline call returns, the original capture session is in closed state as
+ * if the CameraCaptureSession#close method has been called.
+ * In the offline mode, all inflight requests will continue to be processed in the
+ * background, and the application can immediately close the camera or create a new
+ * capture session without losing those requests' output images and capture results.</p>
+ * <p>While the camera device is processing offline requests, it
+ * might not be able to support all stream configurations it can support
+ * without offline requests. When that happens, the createCaptureSession
+ * method call will fail. The following stream configurations are guaranteed to work
+ * without hitting the resource busy exception:</p>
+ * <ul>
+ * <li>One ongoing offline session: target one output surface of YUV or
+ * JPEG format, any resolution.</li>
+ * <li>The active camera capture session:<ol>
+ * <li>One preview surface (SurfaceView or SurfaceTexture) up to 1920 width</li>
+ * <li>One YUV ImageReader surface up to 1920 width</li>
+ * <li>One Jpeg ImageReader, any resolution: the camera device is
+ * allowed to slow down JPEG output speed by 50% if there is any ongoing offline
+ * session.</li>
+ * <li>One ImageWriter surface of private format, any resolution if the device supports
+ * PRIVATE_REPROCESSING capability</li>
+ * </ol>
+ * </li>
+ * <li>Alternatively, the active camera session above can be replaced by an legacy
+ * {@link android.hardware.Camera Camera} with the following parameter settings:<ol>
+ * <li>Preview size up to 1920 width</li>
+ * <li>Preview callback size up to 1920 width</li>
+ * <li>Video size up to 1920 width</li>
+ * <li>Picture size, any resolution: the camera device is
+ * allowed to slow down JPEG output speed by 50% if there is any ongoing offline
+ * session.</li>
+ * </ol>
+ * </li>
+ * </ul>
+ * @see CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES
+ */
+ public static final int REQUEST_AVAILABLE_CAPABILITIES_OFFLINE_PROCESSING = 15;
+
//
// Enumeration values for CameraCharacteristics#SCALER_CROPPING_TYPE
//
diff --git a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
index bcbc337..41435c9 100644
--- a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
+++ b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
@@ -29,6 +29,7 @@
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.ICameraDeviceCallbacks;
import android.hardware.camera2.ICameraDeviceUser;
+import android.hardware.camera2.ICameraOfflineSession;
import android.hardware.camera2.TotalCaptureResult;
import android.hardware.camera2.params.InputConfiguration;
import android.hardware.camera2.params.OutputConfiguration;
@@ -866,6 +867,38 @@
}
}
+ public void switchToOffline(ICameraDeviceCallbacks cbs, Surface[] offlineOutputs)
+ throws CameraAccessException {
+ if ((offlineOutputs == null) || (offlineOutputs.length == 0)) {
+ throw new IllegalArgumentException("Invalid offline outputs!");
+ }
+ if (cbs == null) {
+ throw new IllegalArgumentException("Invalid device callbacks!");
+ }
+
+ ICameraOfflineSession offlineSession = null;
+ synchronized(mInterfaceLock) {
+ int streamId = -1;
+ for (Surface surface : offlineOutputs) {
+ for (int i = 0; i < mConfiguredOutputs.size(); i++) {
+ if (surface == mConfiguredOutputs.valueAt(i).getSurface()) {
+ streamId = mConfiguredOutputs.keyAt(i);
+ break;
+ }
+ }
+ if (streamId == -1) {
+ throw new IllegalArgumentException("Offline surface is not part of this" +
+ " session");
+ }
+ }
+
+ offlineSession = mRemoteDevice.switchToOffline(cbs,
+ offlineOutputs);
+ // TODO: Initialize CameraOfflineSession wrapper, clear 'mConfiguredOutputs',
+ // and update request tracking
+ }
+ }
+
public void tearDown(Surface surface) throws CameraAccessException {
if (surface == null) throw new IllegalArgumentException("Surface is null");
diff --git a/core/java/android/hardware/camera2/impl/ICameraDeviceUserWrapper.java b/core/java/android/hardware/camera2/impl/ICameraDeviceUserWrapper.java
index 3660f29..397417b 100644
--- a/core/java/android/hardware/camera2/impl/ICameraDeviceUserWrapper.java
+++ b/core/java/android/hardware/camera2/impl/ICameraDeviceUserWrapper.java
@@ -28,6 +28,8 @@
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.ICameraDeviceUser;
+import android.hardware.camera2.ICameraDeviceCallbacks;
+import android.hardware.camera2.ICameraOfflineSession;
import android.hardware.camera2.impl.CameraMetadataNative;
import android.hardware.camera2.params.OutputConfiguration;
import android.hardware.camera2.params.SessionConfiguration;
@@ -248,6 +250,17 @@
}
}
+ public ICameraOfflineSession switchToOffline(ICameraDeviceCallbacks cbs,
+ Surface[] offlineOutputs)
+ throws CameraAccessException {
+ try {
+ return mRemoteDevice.switchToOffline(cbs, offlineOutputs);
+ } catch (Throwable t) {
+ CameraManager.throwAsPublicException(t);
+ throw new UnsupportedOperationException("Unexpected exception", t);
+ }
+ }
+
public void finalizeOutputConfigurations(int streamId, OutputConfiguration deferredConfig)
throws CameraAccessException {
try {
diff --git a/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java b/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java
index 5d1435a..6ab0c29 100644
--- a/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java
+++ b/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java
@@ -24,6 +24,7 @@
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.ICameraDeviceCallbacks;
import android.hardware.camera2.ICameraDeviceUser;
+import android.hardware.camera2.ICameraOfflineSession;
import android.hardware.camera2.impl.CameraMetadataNative;
import android.hardware.camera2.impl.CaptureResultExtras;
import android.hardware.camera2.impl.PhysicalCaptureResultInfo;
@@ -789,6 +790,12 @@
}
@Override
+ public ICameraOfflineSession switchToOffline(ICameraDeviceCallbacks cbs,
+ Surface[] offlineOutputs) {
+ throw new UnsupportedOperationException("Legacy device does not support switchToOffline");
+ }
+
+ @Override
public IBinder asBinder() {
// This is solely intended to be used for in-process binding.
return null;
diff --git a/core/java/android/hardware/camera2/params/MandatoryStreamCombination.java b/core/java/android/hardware/camera2/params/MandatoryStreamCombination.java
index 6eaf54b..23f18a8 100644
--- a/core/java/android/hardware/camera2/params/MandatoryStreamCombination.java
+++ b/core/java/android/hardware/camera2/params/MandatoryStreamCombination.java
@@ -1163,7 +1163,7 @@
if (orderedPreviewSizes != null) {
for (Size size : orderedPreviewSizes) {
if ((mDisplaySize.getWidth() >= size.getWidth()) &&
- (mDisplaySize.getWidth() >= size.getHeight())) {
+ (mDisplaySize.getHeight() >= size.getHeight())) {
return size;
}
}
diff --git a/core/java/android/hardware/soundtrigger/ModelParams.aidl b/core/java/android/hardware/soundtrigger/ModelParams.aidl
new file mode 100644
index 0000000..d90dc81
--- /dev/null
+++ b/core/java/android/hardware/soundtrigger/ModelParams.aidl
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2019 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 android.hardware.soundtrigger;
+
+/**
+ * Model specific parameters to be used with parameter set and get APIs
+ * {@hide}
+ */
+@Backing(type="int")
+enum ModelParams {
+ /**
+ * Placeholder for invalid model parameter used for returning error or
+ * passing an invalid value.
+ */
+ INVALID = -1,
+ /**
+ * Controls the sensitivity threshold adjustment factor for a given model.
+ * Negative value corresponds to less sensitive model (high threshold) and
+ * a positive value corresponds to a more sensitive model (low threshold).
+ * Default value is 0.
+ */
+ THRESHOLD_FACTOR = 0,
+}
diff --git a/core/java/android/hardware/soundtrigger/SoundTrigger.aidl b/core/java/android/hardware/soundtrigger/SoundTrigger.aidl
index 325a9ad..94c4216 100644
--- a/core/java/android/hardware/soundtrigger/SoundTrigger.aidl
+++ b/core/java/android/hardware/soundtrigger/SoundTrigger.aidl
@@ -24,5 +24,6 @@
parcelable SoundTrigger.KeyphraseRecognitionExtra;
parcelable SoundTrigger.KeyphraseSoundModel;
parcelable SoundTrigger.GenericSoundModel;
+parcelable SoundTrigger.ModelParamRange;
parcelable SoundTrigger.ModuleProperties;
parcelable SoundTrigger.RecognitionConfig;
diff --git a/core/java/android/hardware/soundtrigger/SoundTrigger.java b/core/java/android/hardware/soundtrigger/SoundTrigger.java
index b1134e1..86f3eec 100644
--- a/core/java/android/hardware/soundtrigger/SoundTrigger.java
+++ b/core/java/android/hardware/soundtrigger/SoundTrigger.java
@@ -567,6 +567,65 @@
}
}
+ /*****************************************************************************
+ * A ModelParamRange is a representation of supported parameter range for a
+ * given loaded model.
+ ****************************************************************************/
+ public static final class ModelParamRange implements Parcelable {
+
+ /**
+ * start of supported range inclusive
+ */
+ public final int start;
+
+ /**
+ * end of supported range inclusive
+ */
+ public final int end;
+
+ ModelParamRange(int start, int end) {
+ this.start = start;
+ this.end = end;
+ }
+
+ private ModelParamRange(@NonNull Parcel in) {
+ this.start = in.readInt();
+ this.end = in.readInt();
+ }
+
+ @NonNull
+ public static final Creator<ModelParamRange> CREATOR = new Creator<ModelParamRange>() {
+ @Override
+ @NonNull
+ public ModelParamRange createFromParcel(@NonNull Parcel in) {
+ return new ModelParamRange(in);
+ }
+
+ @Override
+ @NonNull
+ public ModelParamRange[] newArray(int size) {
+ return new ModelParamRange[size];
+ }
+ };
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeInt(start);
+ dest.writeInt(end);
+ }
+
+ @Override
+ @NonNull
+ public String toString() {
+ return "ModelParamRange [start=" + start + ", end=" + end + "]";
+ }
+ }
+
/**
* Modes for key phrase recognition
*/
diff --git a/core/java/android/hardware/soundtrigger/SoundTriggerModule.java b/core/java/android/hardware/soundtrigger/SoundTriggerModule.java
index 9113548..b16ef5c 100644
--- a/core/java/android/hardware/soundtrigger/SoundTriggerModule.java
+++ b/core/java/android/hardware/soundtrigger/SoundTriggerModule.java
@@ -16,7 +16,9 @@
package android.hardware.soundtrigger;
+import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
+import android.hardware.soundtrigger.SoundTrigger.ModelParamRange;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -150,6 +152,57 @@
*/
public native int getModelState(int soundModelHandle);
+ /**
+ * Set a model specific {@link ModelParams} with the given value. This
+ * parameter will keep its value for the duration the model is loaded regardless of starting and
+ * stopping recognition. Once the model is unloaded, the value will be lost.
+ * {@link SoundTriggerModule#isParameterSupported} should be checked first before calling this
+ * method.
+ *
+ * @param soundModelHandle handle of model to apply parameter
+ * @param modelParam {@link ModelParams}
+ * @param value Value to set
+ * @return - {@link SoundTrigger#STATUS_OK} in case of success
+ * - {@link SoundTrigger#STATUS_NO_INIT} if the native service cannot be reached
+ * - {@link SoundTrigger#STATUS_BAD_VALUE} invalid input parameter
+ * - {@link SoundTrigger#STATUS_INVALID_OPERATION} if the call is out of sequence or
+ * if API is not supported by HAL
+ */
+ public native int setParameter(int soundModelHandle,
+ @ModelParams int modelParam, int value);
+
+ /**
+ * Get a model specific {@link ModelParams}. This parameter will keep its value
+ * for the duration the model is loaded regardless of starting and stopping recognition.
+ * Once the model is unloaded, the value will be lost. If the value is not set, a default
+ * value is returned. See {@link ModelParams} for parameter default values.
+ * {@link SoundTriggerModule#isParameterSupported} should be checked first before
+ * calling this method. Otherwise, an exception can be thrown.
+ *
+ * @param soundModelHandle handle of model to get parameter
+ * @param modelParam {@link ModelParams}
+ * @return value of parameter
+ * @throws UnsupportedOperationException if hal or model do not support this API.
+ * {@link SoundTriggerModule#isParameterSupported} should be checked first.
+ * @throws IllegalArgumentException if invalid model handle or parameter is passed.
+ * {@link SoundTriggerModule#isParameterSupported} should be checked first.
+ */
+ public native int getParameter(int soundModelHandle,
+ @ModelParams int modelParam)
+ throws UnsupportedOperationException, IllegalArgumentException;
+
+ /**
+ * Determine if parameter control is supported for the given model handle.
+ * This method should be checked prior to calling {@link SoundTriggerModule#setParameter} or
+ * {@link SoundTriggerModule#getParameter}.
+ *
+ * @param soundModelHandle handle of model to get parameter
+ * @param modelParam {@link ModelParams}
+ * @return supported range of parameter, null if not supported
+ */
+ @Nullable
+ public native ModelParamRange queryParameter(int soundModelHandle, @ModelParams int modelParam);
+
private class NativeEventHandlerDelegate {
private final Handler mHandler;
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 43842c5..156bcfe 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -21,6 +21,7 @@
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE;
import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
+import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_ONLY_DRAW_BOTTOM_BAR_BACKGROUND;
import static java.lang.annotation.RetentionPolicy.SOURCE;
@@ -66,6 +67,7 @@
import android.view.ViewRootImpl;
import android.view.ViewTreeObserver;
import android.view.Window;
+import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.CompletionInfo;
@@ -1019,6 +1021,16 @@
Context.LAYOUT_INFLATER_SERVICE);
mWindow = new SoftInputWindow(this, "InputMethod", mTheme, null, null, mDispatcherState,
WindowManager.LayoutParams.TYPE_INPUT_METHOD, Gravity.BOTTOM, false);
+ mWindow.getWindow().setFitWindowInsetsTypes(WindowInsets.Type.systemBars());
+ mWindow.getWindow().addPrivateFlags(PRIVATE_FLAG_ONLY_DRAW_BOTTOM_BAR_BACKGROUND);
+ mWindow.getWindow().getDecorView().setOnApplyWindowInsetsListener(
+ (v, insets) -> v.onApplyWindowInsets(
+ new WindowInsets.Builder(insets).setSystemWindowInsets(
+ android.graphics.Insets.of(
+ insets.getSystemWindowInsetLeft(),
+ insets.getSystemWindowInsetTop(),
+ insets.getSystemWindowInsetRight(),
+ insets.getStableInsetBottom())).build()));
// For ColorView in DecorView to work, FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS needs to be set
// by default (but IME developers can opt this out later if they want a new behavior).
mWindow.getWindow().setFlags(
diff --git a/core/java/android/net/InvalidPacketException.java b/core/java/android/net/InvalidPacketException.java
new file mode 100644
index 0000000..909998d
--- /dev/null
+++ b/core/java/android/net/InvalidPacketException.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2019 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 android.net;
+
+import android.annotation.IntDef;
+import android.annotation.SystemApi;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Thrown when a packet is invalid.
+ * @hide
+ */
+@SystemApi
+public class InvalidPacketException extends Exception {
+ public final int error;
+
+ // Must match SocketKeepalive#ERROR_INVALID_IP_ADDRESS.
+ /** Invalid IP address. */
+ public static final int ERROR_INVALID_IP_ADDRESS = -21;
+
+ // Must match SocketKeepalive#ERROR_INVALID_PORT.
+ /** Invalid port number. */
+ public static final int ERROR_INVALID_PORT = -22;
+
+ // Must match SocketKeepalive#ERROR_INVALID_LENGTH.
+ /** Invalid packet length. */
+ public static final int ERROR_INVALID_LENGTH = -23;
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = { "ERROR_" }, value = {
+ ERROR_INVALID_IP_ADDRESS,
+ ERROR_INVALID_PORT,
+ ERROR_INVALID_LENGTH
+ })
+ public @interface ErrorCode {}
+
+ /**
+ * This packet is invalid.
+ * See the error code for details.
+ */
+ public InvalidPacketException(@ErrorCode final int error) {
+ this.error = error;
+ }
+}
diff --git a/core/java/android/net/KeepalivePacketData.java b/core/java/android/net/KeepalivePacketData.java
index 9b8b732..2b8b7e6 100644
--- a/core/java/android/net/KeepalivePacketData.java
+++ b/core/java/android/net/KeepalivePacketData.java
@@ -16,13 +16,13 @@
package android.net;
-import static android.net.SocketKeepalive.ERROR_INVALID_IP_ADDRESS;
-import static android.net.SocketKeepalive.ERROR_INVALID_PORT;
+import static android.net.InvalidPacketException.ERROR_INVALID_IP_ADDRESS;
+import static android.net.InvalidPacketException.ERROR_INVALID_PORT;
-import android.net.SocketKeepalive.InvalidPacketException;
+import android.annotation.NonNull;
+import android.annotation.SystemApi;
import android.net.util.IpUtils;
import android.os.Parcel;
-import android.os.Parcelable;
import android.util.Log;
import java.net.InetAddress;
@@ -33,13 +33,16 @@
*
* @hide
*/
-public class KeepalivePacketData implements Parcelable {
+@SystemApi
+public class KeepalivePacketData {
private static final String TAG = "KeepalivePacketData";
/** Source IP address */
+ @NonNull
public final InetAddress srcAddress;
/** Destination IP address */
+ @NonNull
public final InetAddress dstAddress;
/** Source port */
@@ -51,13 +54,14 @@
/** Packet data. A raw byte string of packet data, not including the link-layer header. */
private final byte[] mPacket;
- protected static final int IPV4_HEADER_LENGTH = 20;
- protected static final int UDP_HEADER_LENGTH = 8;
-
// This should only be constructed via static factory methods, such as
- // nattKeepalivePacket
- protected KeepalivePacketData(InetAddress srcAddress, int srcPort,
- InetAddress dstAddress, int dstPort, byte[] data) throws InvalidPacketException {
+ // nattKeepalivePacket.
+ /**
+ * A holding class for data necessary to build a keepalive packet.
+ */
+ protected KeepalivePacketData(@NonNull InetAddress srcAddress, int srcPort,
+ @NonNull InetAddress dstAddress, int dstPort,
+ @NonNull byte[] data) throws InvalidPacketException {
this.srcAddress = srcAddress;
this.dstAddress = dstAddress;
this.srcPort = srcPort;
@@ -78,16 +82,12 @@
}
}
+ @NonNull
public byte[] getPacket() {
return mPacket.clone();
}
- /* Parcelable Implementation */
- public int describeContents() {
- return 0;
- }
-
- /** Write to parcel */
+ /** @hide */
public void writeToParcel(Parcel out, int flags) {
out.writeString(srcAddress.getHostAddress());
out.writeString(dstAddress.getHostAddress());
@@ -96,6 +96,7 @@
out.writeByteArray(mPacket);
}
+ /** @hide */
protected KeepalivePacketData(Parcel in) {
srcAddress = NetworkUtils.numericToInetAddress(in.readString());
dstAddress = NetworkUtils.numericToInetAddress(in.readString());
@@ -103,17 +104,4 @@
dstPort = in.readInt();
mPacket = in.createByteArray();
}
-
- /** Parcelable Creator */
- public static final @android.annotation.NonNull Parcelable.Creator<KeepalivePacketData> CREATOR =
- new Parcelable.Creator<KeepalivePacketData>() {
- public KeepalivePacketData createFromParcel(Parcel in) {
- return new KeepalivePacketData(in);
- }
-
- public KeepalivePacketData[] newArray(int size) {
- return new KeepalivePacketData[size];
- }
- };
-
}
diff --git a/core/java/android/net/NattKeepalivePacketData.java b/core/java/android/net/NattKeepalivePacketData.java
index a77c244..3fb52f1 100644
--- a/core/java/android/net/NattKeepalivePacketData.java
+++ b/core/java/android/net/NattKeepalivePacketData.java
@@ -19,7 +19,6 @@
import static android.net.SocketKeepalive.ERROR_INVALID_IP_ADDRESS;
import static android.net.SocketKeepalive.ERROR_INVALID_PORT;
-import android.net.SocketKeepalive.InvalidPacketException;
import android.net.util.IpUtils;
import android.os.Parcel;
import android.os.Parcelable;
@@ -32,6 +31,9 @@
/** @hide */
public final class NattKeepalivePacketData extends KeepalivePacketData implements Parcelable {
+ private static final int IPV4_HEADER_LENGTH = 20;
+ private static final int UDP_HEADER_LENGTH = 8;
+
// This should only be constructed via static factory methods, such as
// nattKeepalivePacket
private NattKeepalivePacketData(InetAddress srcAddress, int srcPort,
diff --git a/core/java/android/net/SocketKeepalive.java b/core/java/android/net/SocketKeepalive.java
index ec73866..fb224fb 100644
--- a/core/java/android/net/SocketKeepalive.java
+++ b/core/java/android/net/SocketKeepalive.java
@@ -147,17 +147,6 @@
}
}
- /**
- * This packet is invalid.
- * See the error code for details.
- * @hide
- */
- public static class InvalidPacketException extends ErrorCodeException {
- public InvalidPacketException(final int error) {
- super(error);
- }
- }
-
@NonNull final IConnectivityManager mService;
@NonNull final Network mNetwork;
@NonNull final ParcelFileDescriptor mPfd;
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 9fed269..53ea936 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -17,6 +17,8 @@
package android.os;
import static android.app.ActivityManager.PROCESS_STATE_BOUND_TOP;
+import static android.os.BatteryStatsManager.NUM_WIFI_STATES;
+import static android.os.BatteryStatsManager.NUM_WIFI_SUPPL_STATES;
import android.annotation.IntDef;
import android.annotation.UnsupportedAppUsage;
@@ -24,6 +26,8 @@
import android.app.job.JobParameters;
import android.content.Context;
import android.content.pm.ApplicationInfo;
+import android.os.BatteryStatsManager.WifiState;
+import android.os.BatteryStatsManager.WifiSupplState;
import android.server.ServerProtoEnums;
import android.service.batterystats.BatteryStatsServiceDumpHistoryProto;
import android.service.batterystats.BatteryStatsServiceDumpProto;
@@ -2422,7 +2426,7 @@
public static final int DATA_CONNECTION_OUT_OF_SERVICE = 0;
public static final int DATA_CONNECTION_EMERGENCY_SERVICE =
- TelephonyManager.MAX_NETWORK_TYPE + 1;
+ TelephonyManager.getAllNetworkTypes().length + 1;
public static final int DATA_CONNECTION_OTHER = DATA_CONNECTION_EMERGENCY_SERVICE + 1;
@@ -2458,41 +2462,6 @@
*/
public abstract Timer getPhoneDataConnectionTimer(int dataType);
- public static final int WIFI_SUPPL_STATE_INVALID = 0;
- public static final int WIFI_SUPPL_STATE_DISCONNECTED = 1;
- public static final int WIFI_SUPPL_STATE_INTERFACE_DISABLED = 2;
- public static final int WIFI_SUPPL_STATE_INACTIVE = 3;
- public static final int WIFI_SUPPL_STATE_SCANNING = 4;
- public static final int WIFI_SUPPL_STATE_AUTHENTICATING = 5;
- public static final int WIFI_SUPPL_STATE_ASSOCIATING = 6;
- public static final int WIFI_SUPPL_STATE_ASSOCIATED = 7;
- public static final int WIFI_SUPPL_STATE_FOUR_WAY_HANDSHAKE = 8;
- public static final int WIFI_SUPPL_STATE_GROUP_HANDSHAKE = 9;
- public static final int WIFI_SUPPL_STATE_COMPLETED = 10;
- public static final int WIFI_SUPPL_STATE_DORMANT = 11;
- public static final int WIFI_SUPPL_STATE_UNINITIALIZED = 12;
-
- public static final int NUM_WIFI_SUPPL_STATES = WIFI_SUPPL_STATE_UNINITIALIZED+1;
-
- /** @hide */
- @IntDef(flag = true, prefix = { "WIFI_SUPPL_STATE_" }, value = {
- WIFI_SUPPL_STATE_INVALID,
- WIFI_SUPPL_STATE_DISCONNECTED,
- WIFI_SUPPL_STATE_INTERFACE_DISABLED,
- WIFI_SUPPL_STATE_INACTIVE,
- WIFI_SUPPL_STATE_SCANNING,
- WIFI_SUPPL_STATE_AUTHENTICATING,
- WIFI_SUPPL_STATE_ASSOCIATING,
- WIFI_SUPPL_STATE_ASSOCIATED,
- WIFI_SUPPL_STATE_FOUR_WAY_HANDSHAKE,
- WIFI_SUPPL_STATE_GROUP_HANDSHAKE,
- WIFI_SUPPL_STATE_COMPLETED,
- WIFI_SUPPL_STATE_DORMANT,
- WIFI_SUPPL_STATE_UNINITIALIZED,
- })
- @Retention(RetentionPolicy.SOURCE)
- public @interface WifiSupplState {}
-
static final String[] WIFI_SUPPL_STATE_NAMES = {
"invalid", "disconn", "disabled", "inactive", "scanning",
"authenticating", "associating", "associated", "4-way-handshake",
@@ -2635,31 +2604,6 @@
@UnsupportedAppUsage
public abstract long getGlobalWifiRunningTime(long elapsedRealtimeUs, int which);
- public static final int WIFI_STATE_OFF = 0;
- public static final int WIFI_STATE_OFF_SCANNING = 1;
- public static final int WIFI_STATE_ON_NO_NETWORKS = 2;
- public static final int WIFI_STATE_ON_DISCONNECTED = 3;
- public static final int WIFI_STATE_ON_CONNECTED_STA = 4;
- public static final int WIFI_STATE_ON_CONNECTED_P2P = 5;
- public static final int WIFI_STATE_ON_CONNECTED_STA_P2P = 6;
- public static final int WIFI_STATE_SOFT_AP = 7;
-
- public static final int NUM_WIFI_STATES = WIFI_STATE_SOFT_AP + 1;
-
- /** @hide */
- @IntDef(flag = true, prefix = { "WIFI_STATE_" }, value = {
- WIFI_STATE_OFF,
- WIFI_STATE_OFF_SCANNING,
- WIFI_STATE_ON_NO_NETWORKS,
- WIFI_STATE_ON_DISCONNECTED,
- WIFI_STATE_ON_CONNECTED_STA,
- WIFI_STATE_ON_CONNECTED_P2P,
- WIFI_STATE_ON_CONNECTED_STA_P2P,
- WIFI_STATE_SOFT_AP
- })
- @Retention(RetentionPolicy.SOURCE)
- public @interface WifiState {}
-
static final String[] WIFI_STATE_NAMES = {
"off", "scanning", "no_net", "disconn",
"sta", "p2p", "sta_p2p", "soft_ap"
diff --git a/core/java/android/os/BatteryStatsManager.java b/core/java/android/os/BatteryStatsManager.java
index e5650ae..0545666 100644
--- a/core/java/android/os/BatteryStatsManager.java
+++ b/core/java/android/os/BatteryStatsManager.java
@@ -16,6 +16,7 @@
package android.os;
+import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -28,6 +29,9 @@
import com.android.internal.app.IBatteryStats;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
/**
* This class provides an API surface for internal system components to report events that are
* needed for battery usage/estimation and battery blaming for apps.
@@ -39,6 +43,116 @@
@SystemApi
@SystemService(Context.BATTERY_STATS_SERVICE)
public class BatteryStatsManager {
+ /**
+ * Wifi states.
+ *
+ * @see #noteWifiState(int, String)
+ */
+ /**
+ * Wifi fully off.
+ */
+ public static final int WIFI_STATE_OFF = 0;
+ /**
+ * Wifi connectivity off, but scanning enabled.
+ */
+ public static final int WIFI_STATE_OFF_SCANNING = 1;
+ /**
+ * Wifi on, but no saved infrastructure networks to connect to.
+ */
+ public static final int WIFI_STATE_ON_NO_NETWORKS = 2;
+ /**
+ * Wifi on, but not connected to any infrastructure networks.
+ */
+ public static final int WIFI_STATE_ON_DISCONNECTED = 3;
+ /**
+ * Wifi on and connected to a infrastructure network.
+ */
+ public static final int WIFI_STATE_ON_CONNECTED_STA = 4;
+ /**
+ * Wifi on and connected to a P2P device, but no infrastructure connection to a network.
+ */
+ public static final int WIFI_STATE_ON_CONNECTED_P2P = 5;
+ /**
+ * Wifi on and connected to both a P2P device and infrastructure connection to a network.
+ */
+ public static final int WIFI_STATE_ON_CONNECTED_STA_P2P = 6;
+ /**
+ * SoftAp/Hotspot turned on.
+ */
+ public static final int WIFI_STATE_SOFT_AP = 7;
+
+ /** @hide */
+ public static final int NUM_WIFI_STATES = WIFI_STATE_SOFT_AP + 1;
+
+ /** @hide */
+ @IntDef(flag = true, prefix = { "WIFI_STATE_" }, value = {
+ WIFI_STATE_OFF,
+ WIFI_STATE_OFF_SCANNING,
+ WIFI_STATE_ON_NO_NETWORKS,
+ WIFI_STATE_ON_DISCONNECTED,
+ WIFI_STATE_ON_CONNECTED_STA,
+ WIFI_STATE_ON_CONNECTED_P2P,
+ WIFI_STATE_ON_CONNECTED_STA_P2P,
+ WIFI_STATE_SOFT_AP
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface WifiState {}
+
+ /**
+ * Wifi supplicant daemon states.
+ *
+ * @see android.net.wifi.SupplicantState for detailed description of states.
+ * @see #noteWifiSupplicantStateChanged(int)
+ */
+ /** @see android.net.wifi.SupplicantState#INVALID */
+ public static final int WIFI_SUPPL_STATE_INVALID = 0;
+ /** @see android.net.wifi.SupplicantState#DISCONNECTED*/
+ public static final int WIFI_SUPPL_STATE_DISCONNECTED = 1;
+ /** @see android.net.wifi.SupplicantState#INTERFACE_DISABLED */
+ public static final int WIFI_SUPPL_STATE_INTERFACE_DISABLED = 2;
+ /** @see android.net.wifi.SupplicantState#INACTIVE*/
+ public static final int WIFI_SUPPL_STATE_INACTIVE = 3;
+ /** @see android.net.wifi.SupplicantState#SCANNING*/
+ public static final int WIFI_SUPPL_STATE_SCANNING = 4;
+ /** @see android.net.wifi.SupplicantState#AUTHENTICATING */
+ public static final int WIFI_SUPPL_STATE_AUTHENTICATING = 5;
+ /** @see android.net.wifi.SupplicantState#ASSOCIATING */
+ public static final int WIFI_SUPPL_STATE_ASSOCIATING = 6;
+ /** @see android.net.wifi.SupplicantState#ASSOCIATED */
+ public static final int WIFI_SUPPL_STATE_ASSOCIATED = 7;
+ /** @see android.net.wifi.SupplicantState#FOUR_WAY_HANDSHAKE */
+ public static final int WIFI_SUPPL_STATE_FOUR_WAY_HANDSHAKE = 8;
+ /** @see android.net.wifi.SupplicantState#GROUP_HANDSHAKE */
+ public static final int WIFI_SUPPL_STATE_GROUP_HANDSHAKE = 9;
+ /** @see android.net.wifi.SupplicantState#COMPLETED */
+ public static final int WIFI_SUPPL_STATE_COMPLETED = 10;
+ /** @see android.net.wifi.SupplicantState#DORMANT */
+ public static final int WIFI_SUPPL_STATE_DORMANT = 11;
+ /** @see android.net.wifi.SupplicantState#UNINITIALIZED */
+ public static final int WIFI_SUPPL_STATE_UNINITIALIZED = 12;
+
+ /** @hide */
+ public static final int NUM_WIFI_SUPPL_STATES = WIFI_SUPPL_STATE_UNINITIALIZED + 1;
+
+ /** @hide */
+ @IntDef(flag = true, prefix = { "WIFI_SUPPL_STATE_" }, value = {
+ WIFI_SUPPL_STATE_INVALID,
+ WIFI_SUPPL_STATE_DISCONNECTED,
+ WIFI_SUPPL_STATE_INTERFACE_DISABLED,
+ WIFI_SUPPL_STATE_INACTIVE,
+ WIFI_SUPPL_STATE_SCANNING,
+ WIFI_SUPPL_STATE_AUTHENTICATING,
+ WIFI_SUPPL_STATE_ASSOCIATING,
+ WIFI_SUPPL_STATE_ASSOCIATED,
+ WIFI_SUPPL_STATE_FOUR_WAY_HANDSHAKE,
+ WIFI_SUPPL_STATE_GROUP_HANDSHAKE,
+ WIFI_SUPPL_STATE_COMPLETED,
+ WIFI_SUPPL_STATE_DORMANT,
+ WIFI_SUPPL_STATE_UNINITIALIZED,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface WifiSupplState {}
+
private final IBatteryStats mBatteryStats;
/** @hide */
@@ -91,7 +205,7 @@
* @param accessPoint SSID of the network if wifi is connected to STA, else null.
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
- public void noteWifiState(@BatteryStats.WifiState int newWifiState,
+ public void noteWifiState(@WifiState int newWifiState,
@Nullable String accessPoint) {
try {
mBatteryStats.noteWifiState(newWifiState, accessPoint);
@@ -224,7 +338,7 @@
* authentication failure.
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
- public void noteWifiSupplicantStateChanged(@BatteryStats.WifiSupplState int newSupplState,
+ public void noteWifiSupplicantStateChanged(@WifiSupplState int newSupplState,
boolean failedAuth) {
try {
mBatteryStats.noteWifiSupplicantStateChanged(newSupplState, failedAuth);
diff --git a/core/java/android/os/BinderProxy.java b/core/java/android/os/BinderProxy.java
index ee95fce..b0c2546 100644
--- a/core/java/android/os/BinderProxy.java
+++ b/core/java/android/os/BinderProxy.java
@@ -479,8 +479,14 @@
// For now, avoid spamming the log by disabling after we've logged
// about this interface at least once
mWarnOnBlocking = false;
- Log.w(Binder.TAG, "Outgoing transactions from this process must be FLAG_ONEWAY",
- new Throwable());
+ if (Build.IS_USERDEBUG) {
+ // Log this as a WTF on userdebug builds.
+ Log.wtf(Binder.TAG, "Outgoing transactions from this process must be FLAG_ONEWAY",
+ new Throwable());
+ } else {
+ Log.w(Binder.TAG, "Outgoing transactions from this process must be FLAG_ONEWAY",
+ new Throwable());
+ }
}
final boolean tracingEnabled = Binder.isTracingEnabled();
diff --git a/core/java/android/os/IBinder.java b/core/java/android/os/IBinder.java
index 12bce8a..ed980f3 100644
--- a/core/java/android/os/IBinder.java
+++ b/core/java/android/os/IBinder.java
@@ -182,6 +182,14 @@
public static final int MAX_IPC_SIZE = 64 * 1024;
/**
+ * Limit that should be placed on IPC sizes, in bytes, to keep them safely under the transaction
+ * buffer limit.
+ */
+ static int getSuggestedMaxIpcSizeBytes() {
+ return MAX_IPC_SIZE;
+ }
+
+ /**
* Get the canonical name of the interface supported by this binder.
*/
public @Nullable String getInterfaceDescriptor() throws RemoteException;
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index 9eb6445..339397b 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -1815,8 +1815,12 @@
p.writeToParcel(this, parcelableFlags);
}
- /** @hide */
- @UnsupportedAppUsage
+ /**
+ * Flatten the name of the class of the Parcelable into this Parcel.
+ *
+ * @param p The Parcelable object to be written.
+ * @see #readParcelableCreator
+ */
public final void writeParcelableCreator(@NonNull Parcelable p) {
String name = p.getClass().getName();
writeString(name);
@@ -3011,8 +3015,19 @@
return (T) creator.createFromParcel(this);
}
- /** @hide */
- @UnsupportedAppUsage
+ /**
+ * Read and return a Parcelable.Creator from the parcel. The given class loader will be used to
+ * load the {@link Parcelable.Creator}. If it is null, the default class loader will be used.
+ *
+ * @param loader A ClassLoader from which to instantiate the {@link Parcelable.Creator}
+ * object, or null for the default class loader.
+ * @return the previously written {@link Parcelable.Creator}, or null if a null Creator was
+ * written.
+ * @throws BadParcelableException Throws BadParcelableException if there was an error trying to
+ * read the {@link Parcelable.Creator}.
+ *
+ * @see #writeParcelableCreator
+ */
@Nullable
public final Parcelable.Creator<?> readParcelableCreator(@Nullable ClassLoader loader) {
String name = readString();
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 725e0fb..5e478b5 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -44,70 +44,10 @@
* <p>
* <b>Device battery life will be significantly affected by the use of this API.</b>
* Do not acquire {@link WakeLock}s unless you really need them, use the minimum levels
- * possible, and be sure to release them as soon as possible.
- * </p><p>
- * The primary API you'll use is {@link #newWakeLock(int, String) newWakeLock()}.
- * This will create a {@link PowerManager.WakeLock} object. You can then use methods
- * on the wake lock object to control the power state of the device.
- * </p><p>
- * In practice it's quite simple:
- * {@samplecode
- * PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
- * PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
- * wl.acquire();
- * ..screen will stay on during this section..
- * wl.release();
- * }
- * </p><p>
- * The following wake lock levels are defined, with varying effects on system power.
- * <i>These levels are mutually exclusive - you may only specify one of them.</i>
+ * possible, and be sure to release them as soon as possible. In most cases,
+ * you'll want to use
+ * {@link android.view.WindowManager.LayoutParams#FLAG_KEEP_SCREEN_ON} instead.
*
- * <table>
- * <tr><th>Flag Value</th>
- * <th>CPU</th> <th>Screen</th> <th>Keyboard</th></tr>
- *
- * <tr><td>{@link #PARTIAL_WAKE_LOCK}</td>
- * <td>On*</td> <td>Off</td> <td>Off</td>
- * </tr>
- *
- * <tr><td>{@link #SCREEN_DIM_WAKE_LOCK}</td>
- * <td>On</td> <td>Dim</td> <td>Off</td>
- * </tr>
- *
- * <tr><td>{@link #SCREEN_BRIGHT_WAKE_LOCK}</td>
- * <td>On</td> <td>Bright</td> <td>Off</td>
- * </tr>
- *
- * <tr><td>{@link #FULL_WAKE_LOCK}</td>
- * <td>On</td> <td>Bright</td> <td>Bright</td>
- * </tr>
- * </table>
- * </p><p>
- * *<i>If you hold a partial wake lock, the CPU will continue to run, regardless of any
- * display timeouts or the state of the screen and even after the user presses the power button.
- * In all other wake locks, the CPU will run, but the user can still put the device to sleep
- * using the power button.</i>
- * </p><p>
- * In addition, you can add two more flags, which affect behavior of the screen only.
- * <i>These flags have no effect when combined with a {@link #PARTIAL_WAKE_LOCK}.</i></p>
- *
- * <table>
- * <tr><th>Flag Value</th> <th>Description</th></tr>
- *
- * <tr><td>{@link #ACQUIRE_CAUSES_WAKEUP}</td>
- * <td>Normal wake locks don't actually turn on the illumination. Instead, they cause
- * the illumination to remain on once it turns on (e.g. from user activity). This flag
- * will force the screen and/or keyboard to turn on immediately, when the WakeLock is
- * acquired. A typical use would be for notifications which are important for the user to
- * see immediately.</td>
- * </tr>
- *
- * <tr><td>{@link #ON_AFTER_RELEASE}</td>
- * <td>If this flag is set, the user activity timer will be reset when the WakeLock is
- * released, causing the illumination to remain on a bit longer. This can be used to
- * reduce flicker if you are cycling between wake lock conditions.</td>
- * </tr>
- * </table>
* <p>
* Any application using a WakeLock must request the {@code android.permission.WAKE_LOCK}
* permission in an {@code <uses-permission>} element of the application's manifest.
@@ -931,7 +871,8 @@
* {@link #FULL_WAKE_LOCK}, {@link #SCREEN_DIM_WAKE_LOCK}
* and {@link #SCREEN_BRIGHT_WAKE_LOCK}. Exactly one wake lock level must be
* specified as part of the {@code levelAndFlags} parameter.
- * </p><p>
+ * </p>
+ * <p>
* The wake lock flags are: {@link #ACQUIRE_CAUSES_WAKEUP}
* and {@link #ON_AFTER_RELEASE}. Multiple flags can be combined as part of the
* {@code levelAndFlags} parameters.
diff --git a/core/java/android/os/ServiceManager.java b/core/java/android/os/ServiceManager.java
index bf9225a..3c0997b 100644
--- a/core/java/android/os/ServiceManager.java
+++ b/core/java/android/os/ServiceManager.java
@@ -140,7 +140,7 @@
/**
* Returns a reference to a service with the given name, or throws
- * {@link NullPointerException} if none is found.
+ * {@link ServiceNotFoundException} if none is found.
*
* @hide
*/
diff --git a/core/java/android/os/TelephonyServiceManager.java b/core/java/android/os/TelephonyServiceManager.java
new file mode 100644
index 0000000..1211dd6
--- /dev/null
+++ b/core/java/android/os/TelephonyServiceManager.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2019 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 android.os;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
+
+/**
+ * Provides a way to register and obtain the system service binder objects managed by the telephony
+ * service.
+ *
+ * <p>Only the telephony mainline module will be able to access an instance of this class.
+ *
+ * @hide
+ */
+@SystemApi
+public class TelephonyServiceManager {
+ /**
+ * @hide
+ */
+ public TelephonyServiceManager() {
+ }
+
+ /**
+ * A class that exposes the methods to register and obtain each system service.
+ */
+ public final class ServiceRegisterer {
+ private final String mServiceName;
+
+ /**
+ * @hide
+ */
+ public ServiceRegisterer(String serviceName) {
+ mServiceName = serviceName;
+ }
+
+ /**
+ * Register a system server binding object for a service.
+ */
+ public void register(@NonNull IBinder binder) {
+ ServiceManager.addService(mServiceName, binder);
+ }
+
+ /**
+ * Get the system server binding object for a service.
+ *
+ * <p>This blocks until the service instance is ready,
+ * or a timeout happens, in which case it returns null.
+ */
+ @Nullable
+ public IBinder get() {
+ return ServiceManager.getService(mServiceName);
+ }
+
+ /**
+ * Get the system server binding object for a service.
+ *
+ * <p>This blocks until the service instance is ready,
+ * or a timeout happens, in which case it throws {@link ServiceNotFoundException}.
+ */
+ @NonNull
+ public IBinder getOrThrow() throws ServiceNotFoundException {
+ try {
+ return ServiceManager.getServiceOrThrow(mServiceName);
+ } catch (ServiceManager.ServiceNotFoundException e) {
+ throw new ServiceNotFoundException(mServiceName);
+ }
+ }
+
+ /**
+ * Get the system server binding object for a service. If the specified service is
+ * not available, it returns null.
+ */
+ @Nullable
+ public IBinder tryGet() {
+ return ServiceManager.checkService(mServiceName);
+ }
+ }
+
+ /**
+ * See {@link ServiceRegisterer#getOrThrow}.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static class ServiceNotFoundException extends ServiceManager.ServiceNotFoundException {
+ /**
+ * Constructor.
+ *
+ * @param name the name of the binder service that cannot be found.
+ *
+ */
+ public ServiceNotFoundException(@NonNull String name) {
+ super(name);
+ }
+ }
+
+ /**
+ * Returns {@link ServiceRegisterer} for the "telephony" service.
+ */
+ @NonNull
+ public ServiceRegisterer getTelephonyServiceRegisterer() {
+ return new ServiceRegisterer("phone");
+ }
+
+
+// TODO: Add more services...
+//
+// /**
+// * Returns {@link ServiceRegisterer} for the "subscription" service.
+// */
+// @NonNull
+// public ServiceRegisterer getSubscriptionServiceRegisterer() {
+// return new ServiceRegisterer("isub");
+// }
+//
+// /**
+// * Returns {@link ServiceRegisterer} for the "SMS" service.
+// */
+// @NonNull
+// public ServiceRegisterer getSmsServiceRegisterer() {
+// return new ServiceRegisterer("isms");
+// }
+}
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 137f537..d099629 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -2391,19 +2391,11 @@
*/
public @Nullable UserInfo createUser(@Nullable String name, @NonNull String userType,
@UserInfoFlag int flags) {
- UserInfo user = null;
try {
- user = mService.createUser(name, userType, flags);
- // TODO: Keep this in sync with
- // UserManagerService.LocalService.createUserEvenWhenDisallowed
- if (user != null && !user.isAdmin() && !user.isDemo()) {
- mService.setUserRestriction(DISALLOW_SMS, true, user.id);
- mService.setUserRestriction(DISALLOW_OUTGOING_CALLS, true, user.id);
- }
+ return mService.createUser(name, userType, flags);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
- return user;
}
/**
@@ -2748,8 +2740,7 @@
/**
* Assigns admin privileges to the user, if such a user exists.
*
- * <p>Requires {@link android.Manifest.permission#MANAGE_USERS} and
- * {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} permissions.
+ * <p>Note that this does not alter the user's pre-existing user restrictions.
*
* @param userId the id of the user to become admin
* @hide
diff --git a/core/java/android/os/connectivity/WifiBatteryStats.java b/core/java/android/os/connectivity/WifiBatteryStats.java
index e9b3837..895d837 100644
--- a/core/java/android/os/connectivity/WifiBatteryStats.java
+++ b/core/java/android/os/connectivity/WifiBatteryStats.java
@@ -19,6 +19,7 @@
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.BatteryStats;
+import android.os.BatteryStatsManager;
import android.os.Parcel;
import android.os.Parcelable;
@@ -46,9 +47,9 @@
private long mEnergyConsumedMaMillis = 0;
private long mNumAppScanRequest = 0;
private long[] mTimeInStateMillis =
- new long[BatteryStats.NUM_WIFI_STATES];
+ new long[BatteryStatsManager.NUM_WIFI_STATES];
private long[] mTimeInSupplicantStateMillis =
- new long[BatteryStats.NUM_WIFI_SUPPL_STATES];
+ new long[BatteryStatsManager.NUM_WIFI_SUPPL_STATES];
private long[] mTimeInRxSignalStrengthLevelMillis =
new long[BatteryStats.NUM_WIFI_SIGNAL_STRENGTH_BINS];
private long mMonitoredRailChargeConsumedMaMillis = 0;
@@ -369,7 +370,7 @@
/** @hide */
public void setTimeInStateMillis(long[] t) {
mTimeInStateMillis = Arrays.copyOfRange(t, 0,
- Math.min(t.length, BatteryStats.NUM_WIFI_STATES));
+ Math.min(t.length, BatteryStatsManager.NUM_WIFI_STATES));
return;
}
@@ -383,7 +384,7 @@
/** @hide */
public void setTimeInSupplicantStateMillis(long[] t) {
mTimeInSupplicantStateMillis = Arrays.copyOfRange(
- t, 0, Math.min(t.length, BatteryStats.NUM_WIFI_SUPPL_STATES));
+ t, 0, Math.min(t.length, BatteryStatsManager.NUM_WIFI_SUPPL_STATES));
return;
}
diff --git a/core/java/android/os/incremental/IIncrementalManager.aidl b/core/java/android/os/incremental/IIncrementalManager.aidl
index d6446d4..f84d7ef 100644
--- a/core/java/android/os/incremental/IIncrementalManager.aidl
+++ b/core/java/android/os/incremental/IIncrementalManager.aidl
@@ -16,89 +16,22 @@
package android.os.incremental;
+import android.os.incremental.IncrementalFileSystemControlParcel;
import android.os.incremental.IncrementalDataLoaderParamsParcel;
+import android.content.pm.IDataLoaderStatusListener;
-/** @hide */
+/**
+ * Binder service to receive calls from native Incremental Service and handle Java tasks such as
+ * looking up data loader service package names, binding and talking to the data loader service.
+ * @hide
+ */
interface IIncrementalManager {
- /**
- * A set of flags for the |createMode| parameters when creating a new Incremental storage.
- */
- const int CREATE_MODE_TEMPORARY_BIND = 1;
- const int CREATE_MODE_PERMANENT_BIND = 2;
- const int CREATE_MODE_CREATE = 4;
- const int CREATE_MODE_OPEN_EXISTING = 8;
-
- /**
- * Opens or creates a storage given a target path and data loader params. Returns the storage ID.
- */
- int openStorage(in @utf8InCpp String path);
- int createStorage(in @utf8InCpp String path, in IncrementalDataLoaderParamsParcel params, int createMode);
- int createLinkedStorage(in @utf8InCpp String path, int otherStorageId, int createMode);
-
- /**
- * Bind-mounts a path under a storage to a full path. Can be permanent or temporary.
- */
- const int BIND_TEMPORARY = 0;
- const int BIND_PERMANENT = 1;
- int makeBindMount(int storageId, in @utf8InCpp String pathUnderStorage, in @utf8InCpp String targetFullPath, int bindType);
-
- /**
- * Deletes an existing bind mount on a path under a storage. Returns 0 on success, and -errno on failure.
- */
- int deleteBindMount(int storageId, in @utf8InCpp String targetFullPath);
-
- /**
- * Creates a directory under a storage. The target directory is specified by its relative path under the storage.
- */
- int makeDirectory(int storageId, in @utf8InCpp String pathUnderStorage);
-
- /**
- * Recursively creates a directory under a storage. The target directory is specified by its relative path under the storage.
- * All the parent directories of the target directory will be created if they do not exist already.
- */
- int makeDirectories(int storageId, in @utf8InCpp String pathUnderStorage);
-
- /**
- * Creates a file under a storage, specifying its name, size and metadata.
- */
- int makeFile(int storageId, in @utf8InCpp String pathUnderStorage, long size, in byte[] metadata);
-
- /**
- * Creates a file under a storage. Content of the file is from a range inside another file.
- * Both files are specified by relative paths under storage.
- */
- int makeFileFromRange(int storageId, in @utf8InCpp String targetPathUnderStorage, in @utf8InCpp String sourcePathUnderStorage, long start, long end);
-
- /**
- * Creates a hard link between two files in two storage instances.
- * Source and dest specified by parent storage IDs and their relative paths under the storage.
- * The source and dest storage instances should be in the same fs mount.
- * Note: destStorageId can be the same as sourceStorageId.
- */
- int makeLink(int sourceStorageId, in @utf8InCpp String sourcePathUnderStorage, int destStorageId, in @utf8InCpp String destPathUnderStorage);
-
- /**
- * Deletes a hard link in a storage, specified by the relative path of the link target under storage.
- */
- int unlink(int storageId, in @utf8InCpp String pathUnderStorage);
-
- /**
- * Checks if a file's certain range is loaded. File is specified by relative file path under storage.
- */
- boolean isFileRangeLoaded(int storageId, in @utf8InCpp String pathUnderStorage, long start, long end);
-
- /**
- * Reads the metadata of a file. File is specified by relative path under storage.
- */
- byte[] getFileMetadata(int storageId, in @utf8InCpp String pathUnderStorage);
-
- /**
- * Starts loading data for a storage.
- */
- boolean startLoading(int storageId);
-
- /**
- * Deletes a storage given its ID. Deletes its bind mounts and unmount it. Stop its data loader.
- */
- void deleteStorage(int storageId);
+ boolean prepareDataLoader(int mountId,
+ in IncrementalFileSystemControlParcel control,
+ in IncrementalDataLoaderParamsParcel params,
+ in IDataLoaderStatusListener listener);
+ boolean startDataLoader(int mountId);
+ void showHealthBlockedUI(int mountId);
+ void destroyDataLoader(int mountId);
+ void newFileForDataLoader(int mountId, long inode, in byte[] metadata);
}
diff --git a/core/java/android/os/incremental/IIncrementalManagerNative.aidl b/core/java/android/os/incremental/IIncrementalManagerNative.aidl
new file mode 100644
index 0000000..d9c7c6b
--- /dev/null
+++ b/core/java/android/os/incremental/IIncrementalManagerNative.aidl
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2019 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 android.os.incremental;
+
+import android.os.incremental.IncrementalDataLoaderParamsParcel;
+
+/** @hide */
+interface IIncrementalManagerNative {
+ /**
+ * A set of flags for the |createMode| parameters when creating a new Incremental storage.
+ */
+ const int CREATE_MODE_TEMPORARY_BIND = 1;
+ const int CREATE_MODE_PERMANENT_BIND = 2;
+ const int CREATE_MODE_CREATE = 4;
+ const int CREATE_MODE_OPEN_EXISTING = 8;
+
+ /**
+ * Opens or creates a storage given a target path and data loader params. Returns the storage ID.
+ */
+ int openStorage(in @utf8InCpp String path);
+ int createStorage(in @utf8InCpp String path, in IncrementalDataLoaderParamsParcel params, int createMode);
+ int createLinkedStorage(in @utf8InCpp String path, int otherStorageId, int createMode);
+
+ /**
+ * Bind-mounts a path under a storage to a full path. Can be permanent or temporary.
+ */
+ const int BIND_TEMPORARY = 0;
+ const int BIND_PERMANENT = 1;
+ int makeBindMount(int storageId, in @utf8InCpp String pathUnderStorage, in @utf8InCpp String targetFullPath, int bindType);
+
+ /**
+ * Deletes an existing bind mount on a path under a storage. Returns 0 on success, and -errno on failure.
+ */
+ int deleteBindMount(int storageId, in @utf8InCpp String targetFullPath);
+
+ /**
+ * Creates a directory under a storage. The target directory is specified by its relative path under the storage.
+ */
+ int makeDirectory(int storageId, in @utf8InCpp String pathUnderStorage);
+
+ /**
+ * Recursively creates a directory under a storage. The target directory is specified by its relative path under the storage.
+ * All the parent directories of the target directory will be created if they do not exist already.
+ */
+ int makeDirectories(int storageId, in @utf8InCpp String pathUnderStorage);
+
+ /**
+ * Creates a file under a storage, specifying its name, size and metadata.
+ */
+ int makeFile(int storageId, in @utf8InCpp String pathUnderStorage, long size, in byte[] metadata);
+
+ /**
+ * Creates a file under a storage. Content of the file is from a range inside another file.
+ * Both files are specified by relative paths under storage.
+ */
+ int makeFileFromRange(int storageId, in @utf8InCpp String targetPathUnderStorage, in @utf8InCpp String sourcePathUnderStorage, long start, long end);
+
+ /**
+ * Creates a hard link between two files in two storage instances.
+ * Source and dest specified by parent storage IDs and their relative paths under the storage.
+ * The source and dest storage instances should be in the same fs mount.
+ * Note: destStorageId can be the same as sourceStorageId.
+ */
+ int makeLink(int sourceStorageId, in @utf8InCpp String sourcePathUnderStorage, int destStorageId, in @utf8InCpp String destPathUnderStorage);
+
+ /**
+ * Deletes a hard link in a storage, specified by the relative path of the link target under storage.
+ */
+ int unlink(int storageId, in @utf8InCpp String pathUnderStorage);
+
+ /**
+ * Checks if a file's certain range is loaded. File is specified by relative file path under storage.
+ */
+ boolean isFileRangeLoaded(int storageId, in @utf8InCpp String pathUnderStorage, long start, long end);
+
+ /**
+ * Reads the metadata of a file. File is specified by relative path under storage.
+ */
+ byte[] getFileMetadata(int storageId, in @utf8InCpp String pathUnderStorage);
+
+ /**
+ * Starts loading data for a storage.
+ */
+ boolean startLoading(int storageId);
+
+ /**
+ * Deletes a storage given its ID. Deletes its bind mounts and unmount it. Stop its data loader.
+ */
+ void deleteStorage(int storageId);
+}
diff --git a/core/java/android/os/incremental/IIncrementalServiceProxy.aidl b/core/java/android/os/incremental/IIncrementalServiceProxy.aidl
deleted file mode 100644
index ffff52e..0000000
--- a/core/java/android/os/incremental/IIncrementalServiceProxy.aidl
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2019 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 android.os.incremental;
-
-import android.os.incremental.IncrementalFileSystemControlParcel;
-import android.os.incremental.IncrementalDataLoaderParamsParcel;
-import android.content.pm.IDataLoaderStatusListener;
-
-/**
- * Binder service to receive calls from native Incremental Service and handle Java tasks such as
- * looking up data loader service package names, binding and talking to the data loader service.
- * @hide
- */
-interface IIncrementalServiceProxy {
- boolean prepareDataLoader(int mountId,
- in IncrementalFileSystemControlParcel control,
- in IncrementalDataLoaderParamsParcel params,
- in IDataLoaderStatusListener listener);
- boolean startDataLoader(int mountId);
- void showHealthBlockedUI(int mountId);
- void destroyDataLoader(int mountId);
- void newFileForDataLoader(int mountId, long inode, in byte[] metadata);
-}
diff --git a/core/java/android/os/incremental/IncrementalManager.java b/core/java/android/os/incremental/IncrementalManager.java
index 5aabf86..c30f558 100644
--- a/core/java/android/os/incremental/IncrementalManager.java
+++ b/core/java/android/os/incremental/IncrementalManager.java
@@ -36,31 +36,28 @@
import java.nio.file.Paths;
/**
- * Provides operations to open or create an IncrementalStorage, using IIncrementalManager service.
- * Example Usage:
+ * Provides operations to open or create an IncrementalStorage, using IIncrementalManagerNative
+ * service. Example Usage:
*
* <blockquote><pre>
- * IncrementalManager manager = (IncrementalManager) getSystemService(Context.INCREMENTAL_MANAGER);
+ * IncrementalManager manager = (IncrementalManager) getSystemService(Context.INCREMENTAL_SERVICE);
* IncrementalStorage storage = manager.openStorage("/path/to/incremental/dir");
* </pre></blockquote>
*
* @hide
*/
@SystemService(Context.INCREMENTAL_SERVICE)
-public class IncrementalManager {
+public final class IncrementalManager {
private static final String TAG = "IncrementalManager";
- private final IIncrementalManager mService;
- @GuardedBy("mStorages")
- private final SparseArray<IncrementalStorage> mStorages = new SparseArray<>();
public static final int CREATE_MODE_TEMPORARY_BIND =
- IIncrementalManager.CREATE_MODE_TEMPORARY_BIND;
+ IIncrementalManagerNative.CREATE_MODE_TEMPORARY_BIND;
public static final int CREATE_MODE_PERMANENT_BIND =
- IIncrementalManager.CREATE_MODE_PERMANENT_BIND;
+ IIncrementalManagerNative.CREATE_MODE_PERMANENT_BIND;
public static final int CREATE_MODE_CREATE =
- IIncrementalManager.CREATE_MODE_CREATE;
+ IIncrementalManagerNative.CREATE_MODE_CREATE;
public static final int CREATE_MODE_OPEN_EXISTING =
- IIncrementalManager.CREATE_MODE_OPEN_EXISTING;
+ IIncrementalManagerNative.CREATE_MODE_OPEN_EXISTING;
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = {"CREATE_MODE_"}, value = {
@@ -72,8 +69,12 @@
public @interface CreateMode {
}
- public IncrementalManager(@NonNull IIncrementalManager is) {
- mService = is;
+ private final @Nullable IIncrementalManagerNative mNativeService;
+ @GuardedBy("mStorages")
+ private final SparseArray<IncrementalStorage> mStorages = new SparseArray<>();
+
+ public IncrementalManager(IIncrementalManagerNative nativeService) {
+ mNativeService = nativeService;
}
/**
@@ -82,6 +83,7 @@
* @param storageId The storage ID to identify the storage object.
* @return IncrementalStorage object corresponding to storage ID.
*/
+ // TODO(b/136132412): remove this
@Nullable
public IncrementalStorage getStorage(int storageId) {
synchronized (mStorages) {
@@ -95,8 +97,8 @@
*
* @param path Absolute path to mount Incremental File System on.
* @param params IncrementalDataLoaderParams object to configure data loading.
- * @param createMode Mode for opening an old Incremental File System mount or
- * creating a new mount.
+ * @param createMode Mode for opening an old Incremental File System mount or creating
+ * a new mount.
* @param autoStartDataLoader Set true to immediately start data loader after creating storage.
* @return IncrementalStorage object corresponding to the mounted directory.
*/
@@ -105,11 +107,11 @@
@NonNull IncrementalDataLoaderParams params, @CreateMode int createMode,
boolean autoStartDataLoader) {
try {
- final int id = mService.createStorage(path, params.getData(), createMode);
+ final int id = mNativeService.createStorage(path, params.getData(), createMode);
if (id < 0) {
return null;
}
- final IncrementalStorage storage = new IncrementalStorage(mService, id);
+ final IncrementalStorage storage = new IncrementalStorage(mNativeService, id);
synchronized (mStorages) {
mStorages.put(id, storage);
}
@@ -123,8 +125,8 @@
}
/**
- * Opens an existing Incremental File System mounted directory and returns an
- * IncrementalStorage object.
+ * Opens an existing Incremental File System mounted directory and returns an IncrementalStorage
+ * object.
*
* @param path Absolute target path that Incremental File System has been mounted on.
* @return IncrementalStorage object corresponding to the mounted directory.
@@ -132,11 +134,11 @@
@Nullable
public IncrementalStorage openStorage(@NonNull String path) {
try {
- final int id = mService.openStorage(path);
+ final int id = mNativeService.openStorage(path);
if (id < 0) {
return null;
}
- final IncrementalStorage storage = new IncrementalStorage(mService, id);
+ final IncrementalStorage storage = new IncrementalStorage(mNativeService, id);
synchronized (mStorages) {
mStorages.put(id, storage);
}
@@ -155,11 +157,12 @@
public IncrementalStorage createStorage(@NonNull String path,
@NonNull IncrementalStorage linkedStorage, @CreateMode int createMode) {
try {
- final int id = mService.createLinkedStorage(path, linkedStorage.getId(), createMode);
+ final int id = mNativeService.createLinkedStorage(
+ path, linkedStorage.getId(), createMode);
if (id < 0) {
return null;
}
- final IncrementalStorage storage = new IncrementalStorage(mService, id);
+ final IncrementalStorage storage = new IncrementalStorage(mNativeService, id);
synchronized (mStorages) {
mStorages.put(id, storage);
}
@@ -175,6 +178,7 @@
* @param file Target file to search storage for.
* @return Absolute path which is a bind-mount point of Incremental File System.
*/
+ @Nullable
private Path getStoragePathForFile(File file) {
File currentPath = new File(file.getParent());
while (currentPath.getParent() != null) {
@@ -198,18 +202,19 @@
* </li>
* </ol>
*
- * @param sourcePath Absolute path to the source. Should be the same type as the destPath
- * (file or dir). Expected to already exist and is an Incremental path.
- * @param destPath Absolute path to the destination.
- * @throws IllegalArgumentException when 1) source does not exist,
- * or 2) source and dest type mismatch (one is file and the other is dir),
- * or 3) source path is not on Incremental File System,
- * @throws IOException when 1) cannot find the root path of the Incremental storage of source,
- * or 2) cannot retrieve the Incremental storage instance of the source,
- * or 3) renaming a file, but dest is not on the same Incremental Storage,
- * or 4) renaming a dir, dest dir does not exist but fails to be created.
- *
- * TODO(b/136132412): add unit tests
+ * @param sourcePath Absolute path to the source. Should be the same type as the destPath (file
+ * or dir). Expected to already exist and is an Incremental path.
+ * @param destPath Absolute path to the destination.
+ * @throws IllegalArgumentException when 1) source does not exist, or 2) source and dest type
+ * mismatch (one is file and the other is dir), or 3) source
+ * path is not on Incremental File System,
+ * @throws IOException when 1) cannot find the root path of the Incremental storage
+ * of source, or 2) cannot retrieve the Incremental storage
+ * instance of the source, or 3) renaming a file, but dest is
+ * not on the same Incremental Storage, or 4) renaming a dir,
+ * dest dir does not exist but fails to be created.
+ * <p>
+ * TODO(b/136132412): add unit tests
*/
public void rename(@NonNull String sourcePath, @NonNull String destPath) throws IOException {
final File source = new File(sourcePath);
@@ -243,6 +248,7 @@
if (storage == null) {
throw new IOException("Failed to retrieve storage from Incremental Service.");
}
+
if (source.isFile()) {
renameFile(storage, storagePath, source, dest);
} else {
@@ -304,11 +310,11 @@
*/
public void closeStorage(@NonNull String path) {
try {
- final int id = mService.openStorage(path);
+ final int id = mNativeService.openStorage(path);
if (id < 0) {
return;
}
- mService.deleteStorage(id);
+ mNativeService.deleteStorage(id);
synchronized (mStorages) {
mStorages.remove(id);
}
@@ -321,7 +327,7 @@
* Checks if path is mounted on Incremental File System.
*/
public static boolean isIncrementalPath(@NonNull String path) {
- // TODO(b/136132412): implement native method
+ // TODO(b/136132412): add jni implementation
return false;
}
}
diff --git a/core/java/android/os/incremental/IncrementalStorage.java b/core/java/android/os/incremental/IncrementalStorage.java
index 2bf89ed..2750868 100644
--- a/core/java/android/os/incremental/IncrementalStorage.java
+++ b/core/java/android/os/incremental/IncrementalStorage.java
@@ -24,11 +24,11 @@
import java.io.IOException;
/**
- * Provides operations on an Incremental File System directory, using IncrementalService. Example
- * usage:
+ * Provides operations on an Incremental File System directory, using IncrementalServiceNative.
+ * Example usage:
*
* <blockquote><pre>
- * IncrementalManager manager = (IncrementalManager) getSystemService(Context.INCREMENTAL_MANAGER);
+ * IncrementalManager manager = (IncrementalManager) getSystemService(Context.INCREMENTAL_SERVICE);
* IncrementalStorage storage = manager.openStorage("/path/to/incremental/dir");
* storage.makeDirectory("subdir");
* </pre></blockquote>
@@ -38,10 +38,10 @@
public final class IncrementalStorage {
private static final String TAG = "IncrementalStorage";
private final int mId;
- private final IIncrementalManager mService;
+ private final IIncrementalManagerNative mService;
- public IncrementalStorage(@NonNull IIncrementalManager is, int id) {
+ public IncrementalStorage(@NonNull IIncrementalManagerNative is, int id) {
mService = is;
mId = id;
}
@@ -72,7 +72,7 @@
throws IOException {
try {
int res = mService.makeBindMount(mId, sourcePathUnderStorage, targetPath,
- IIncrementalManager.BIND_TEMPORARY);
+ IIncrementalManagerNative.BIND_TEMPORARY);
if (res < 0) {
throw new IOException("bind() failed with errno " + -res);
}
@@ -103,7 +103,7 @@
throws IOException {
try {
int res = mService.makeBindMount(mId, sourcePathUnderStorage, targetPath,
- IIncrementalManager.BIND_PERMANENT);
+ IIncrementalManagerNative.BIND_PERMANENT);
if (res < 0) {
throw new IOException("bind() permanent failed with errno " + -res);
}
@@ -274,7 +274,8 @@
throw new IOException("moveDir() requires that destination dir already exists.");
}
try {
- int res = mService.makeBindMount(mId, "", destPath, IIncrementalManager.BIND_PERMANENT);
+ int res = mService.makeBindMount(mId, "", destPath,
+ IIncrementalManagerNative.BIND_PERMANENT);
if (res < 0) {
throw new IOException("moveDir() failed at making bind mount, errno " + -res);
}
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index 2d70986d..62603fe 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -80,6 +80,7 @@
import android.system.OsConstants;
import android.text.TextUtils;
import android.util.DataUnit;
+import android.util.FeatureFlagUtils;
import android.util.Log;
import android.util.Pair;
import android.util.Slog;
@@ -156,7 +157,8 @@
/** {@hide} */
public static final String PROP_FUSE = "persist.sys.fuse";
/** {@hide} */
- public static final String PROP_FUSE_SNAPSHOT = "sys.fuse_snapshot";
+ public static final String PROP_SETTINGS_FUSE = FeatureFlagUtils.PERSIST_PREFIX
+ + FeatureFlagUtils.SETTINGS_FUSE_FLAG;
/** {@hide} */
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index 8bf723f..c86c83c 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -2381,7 +2381,11 @@
* This id is provided by its own data source, and can be used to backup metadata
* to the server.
* This should be unique within each set of account_name/account_type/data_set
+ *
+ * @deprecated This column is no longer supported as of Android version
+ * {@link android.os.Build.VERSION_CODES#R}.
*/
+ @Deprecated
public static final String BACKUP_ID = "backup_id";
/**
@@ -2445,7 +2449,11 @@
* Flag indicating that a raw contact's metadata has changed, and its metadata
* needs to be synchronized by the server.
* <P>Type: INTEGER (boolean)</P>
+ *
+ * @deprecated This column is no longer supported as of Android version
+ * {@link android.os.Build.VERSION_CODES#R}.
*/
+ @Deprecated
public static final String METADATA_DIRTY = "metadata_dirty";
}
@@ -2916,6 +2924,8 @@
*/
@Nullable
public static String getLocalAccountName(@NonNull Context context) {
+ // config_rawContactsLocalAccountName is defined in
+ // platform/frameworks/base/core/res/res/values/config.xml
return TextUtils.nullIfEmpty(context.getString(
com.android.internal.R.string.config_rawContactsLocalAccountName));
}
@@ -2933,6 +2943,8 @@
*/
@Nullable
public static String getLocalAccountType(@NonNull Context context) {
+ // config_rawContactsLocalAccountType is defined in
+ // platform/frameworks/base/core/res/res/values/config.xml
return TextUtils.nullIfEmpty(context.getString(
com.android.internal.R.string.config_rawContactsLocalAccountType));
}
@@ -4184,7 +4196,10 @@
* Hash id on the data fields, used for backup and restore.
*
* @hide
+ * @deprecated This column is no longer supported as of Android version
+ * {@link android.os.Build.VERSION_CODES#R}.
*/
+ @Deprecated
public static final String HASH_ID = "hash_id";
/**
@@ -9491,7 +9506,10 @@
/**
* @hide
+ * @deprecated These columns are no longer supported as of Android version
+ * {@link android.os.Build.VERSION_CODES#R}.
*/
+ @Deprecated
@SystemApi
protected interface MetadataSyncColumns {
@@ -9598,7 +9616,10 @@
* from server before it is merged into other CP2 tables.
*
* @hide
+ * @deprecated These columns are no longer supported as of Android version
+ * {@link android.os.Build.VERSION_CODES#R}.
*/
+ @Deprecated
@SystemApi
public static final class MetadataSync implements BaseColumns, MetadataSyncColumns {
@@ -9634,7 +9655,10 @@
/**
* @hide
+ * @deprecated These columns are no longer supported as of Android version
+ * {@link android.os.Build.VERSION_CODES#R}.
*/
+ @Deprecated
@SystemApi
protected interface MetadataSyncStateColumns {
@@ -9668,7 +9692,10 @@
* sync state for a set of accounts.
*
* @hide
+ * @deprecated These columns are no longer supported as of Android version
+ * {@link android.os.Build.VERSION_CODES#R}.
*/
+ @Deprecated
@SystemApi
public static final class MetadataSyncState implements BaseColumns, MetadataSyncStateColumns {
diff --git a/core/java/android/provider/DeviceConfig.java b/core/java/android/provider/DeviceConfig.java
index 9dc6806..6650cf2 100644
--- a/core/java/android/provider/DeviceConfig.java
+++ b/core/java/android/provider/DeviceConfig.java
@@ -40,6 +40,7 @@
import com.android.internal.util.Preconditions;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -349,6 +350,15 @@
public static final String NAMESPACE_PRIVACY = "privacy";
/**
+ * Namespace for biometrics related features
+ *
+ * @hide
+ */
+ @SystemApi
+ @TestApi
+ public static final String NAMESPACE_BIOMETRICS = "biometrics";
+
+ /**
* Permission related properties definitions.
*
* @hide
@@ -578,11 +588,13 @@
* none or all of this update is picked up, but never only part of it.
*
* @param properties the complete set of properties to set for a specific namespace.
+ * @throws BadConfigException if the provided properties are banned by RescueParty.
+ * @return True if the values were set, false otherwise.
* @hide
*/
@SystemApi
@RequiresPermission(WRITE_DEVICE_CONFIG)
- public static boolean setProperties(@NonNull Properties properties) {
+ public static boolean setProperties(@NonNull Properties properties) throws BadConfigException {
ContentResolver contentResolver = ActivityThread.currentApplication().getContentResolver();
return Settings.Config.setStrings(contentResolver, properties.getNamespace(),
properties.mMap);
@@ -732,19 +744,19 @@
List<String> pathSegments = uri.getPathSegments();
// pathSegments(0) is "config"
final String namespace = pathSegments.get(1);
- Map<String, String> propertyMap = new ArrayMap<>();
+ Properties.Builder propBuilder = new Properties.Builder(namespace);
try {
Properties allProperties = getProperties(namespace);
for (int i = 2; i < pathSegments.size(); ++i) {
String key = pathSegments.get(i);
- propertyMap.put(key, allProperties.getString(key, null));
+ propBuilder.setString(key, allProperties.getString(key, null));
}
} catch (SecurityException e) {
// Silently failing to not crash binder or listener threads.
Log.e(TAG, "OnPropertyChangedListener update failed: permission violation.");
return;
}
- Properties properties = new Properties(namespace, propertyMap);
+ Properties properties = propBuilder.build();
synchronized (sLock) {
for (int i = 0; i < sListeners.size(); i++) {
@@ -799,6 +811,15 @@
}
/**
+ * Thrown by {@link #setProperties(Properties)} when a configuration is rejected. This
+ * happens if RescueParty has identified a bad configuration and reset the namespace.
+ *
+ * @hide
+ */
+ @SystemApi
+ public static class BadConfigException extends Exception {}
+
+ /**
* A mapping of properties to values, as well as a single namespace which they all belong to.
*
* @hide
@@ -808,6 +829,7 @@
public static class Properties {
private final String mNamespace;
private final HashMap<String, String> mMap;
+ private Set<String> mKeyset;
/**
* Create a mapping of properties to values and the namespace they belong to.
@@ -838,7 +860,10 @@
*/
@NonNull
public Set<String> getKeyset() {
- return mMap.keySet();
+ if (mKeyset == null) {
+ mKeyset = Collections.unmodifiableSet(mMap.keySet());
+ }
+ return mKeyset;
}
/**
@@ -933,5 +958,93 @@
return defaultValue;
}
}
+
+ /**
+ * Builder class for the construction of {@link Properties} objects.
+ */
+ public static final class Builder {
+ @NonNull
+ private final String mNamespace;
+ @NonNull
+ private final Map<String, String> mKeyValues = new HashMap<>();
+
+ /**
+ * Create a new Builders for the specified namespace.
+ * @param namespace non null namespace.
+ */
+ public Builder(@NonNull String namespace) {
+ mNamespace = namespace;
+ }
+
+ /**
+ * Add a new property with the specified key and value.
+ * @param name non null name of the property.
+ * @param value nullable string value of the property.
+ * @return this Builder object
+ */
+ @NonNull
+ public Builder setString(@NonNull String name, @Nullable String value) {
+ mKeyValues.put(name, value);
+ return this;
+ }
+
+ /**
+ * Add a new property with the specified key and value.
+ * @param name non null name of the property.
+ * @param value nullable string value of the property.
+ * @return this Builder object
+ */
+ @NonNull
+ public Builder setBoolean(@NonNull String name, boolean value) {
+ mKeyValues.put(name, Boolean.toString(value));
+ return this;
+ }
+
+ /**
+ * Add a new property with the specified key and value.
+ * @param name non null name of the property.
+ * @param value int value of the property.
+ * @return this Builder object
+ */
+ @NonNull
+ public Builder setInt(@NonNull String name, int value) {
+ mKeyValues.put(name, Integer.toString(value));
+ return this;
+ }
+
+ /**
+ * Add a new property with the specified key and value.
+ * @param name non null name of the property.
+ * @param value long value of the property.
+ * @return this Builder object
+ */
+ @NonNull
+ public Builder setLong(@NonNull String name, long value) {
+ mKeyValues.put(name, Long.toString(value));
+ return this;
+ }
+
+ /**
+ * Add a new property with the specified key and value.
+ * @param name non null name of the property.
+ * @param value float value of the property.
+ * @return this Builder object
+ */
+ @NonNull
+ public Builder setFloat(@NonNull String name, float value) {
+ mKeyValues.put(name, Float.toString(value));
+ return this;
+ }
+
+ /**
+ * Create a new {@link Properties} object.
+ * @return non null Properties.
+ */
+ @NonNull
+ public Properties build() {
+ return new Properties(mNamespace, mKeyValues);
+ }
+ }
}
+
}
diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java
index 2fa3386..701ba91 100644
--- a/core/java/android/provider/MediaStore.java
+++ b/core/java/android/provider/MediaStore.java
@@ -32,6 +32,7 @@
import android.annotation.UnsupportedAppUsage;
import android.app.Activity;
import android.app.AppGlobals;
+import android.app.PendingIntent;
import android.content.ClipData;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
@@ -86,6 +87,7 @@
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
@@ -162,6 +164,15 @@
/** {@hide} */
public static final String SUICIDE_CALL = "suicide";
+ /** {@hide} */
+ public static final String CREATE_WRITE_REQUEST_CALL = "create_write_request";
+ /** {@hide} */
+ public static final String CREATE_TRASH_REQUEST_CALL = "create_trash_request";
+ /** {@hide} */
+ public static final String CREATE_FAVORITE_REQUEST_CALL = "create_favorite_request";
+ /** {@hide} */
+ public static final String CREATE_DELETE_REQUEST_CALL = "create_delete_request";
+
/**
* Extra used with {@link #SCAN_FILE_CALL} or {@link #SCAN_VOLUME_CALL} to indicate that
* the file path originated from shell.
@@ -199,6 +210,13 @@
/** {@hide} */
public static final String DELETE_CONTRIBUTED_MEDIA_CALL = "delete_contributed_media";
+ /** {@hide} */
+ public static final String EXTRA_CLIP_DATA = "clip_data";
+ /** {@hide} */
+ public static final String EXTRA_CONTENT_VALUES = "content_values";
+ /** {@hide} */
+ public static final String EXTRA_RESULT = "result";
+
/**
* This is for internal use by the media scanner only.
* Name of the (optional) Uri parameter that determines whether to skip deleting
@@ -606,6 +624,10 @@
* {@link ContentResolver#delete}.
* <p>
* By default, trashed items are filtered away from operations.
+ *
+ * @see MediaColumns#IS_TRASHED
+ * @see MediaStore#QUERY_ARG_MATCH_TRASHED
+ * @see MediaStore#createTrashRequest
*/
@Match
public static final String QUERY_ARG_MATCH_TRASHED = "android:query-arg-match-trashed";
@@ -620,6 +642,10 @@
* <p>
* By default, favorite items are <em>not</em> filtered away from
* operations.
+ *
+ * @see MediaColumns#IS_FAVORITE
+ * @see MediaStore#QUERY_ARG_MATCH_FAVORITE
+ * @see MediaStore#createFavoriteRequest
*/
@Match
public static final String QUERY_ARG_MATCH_FAVORITE = "android:query-arg-match-favorite";
@@ -952,7 +978,9 @@
* @see MediaStore#setIncludeTrashed(Uri)
* @see MediaStore#trash(Context, Uri)
* @see MediaStore#untrash(Context, Uri)
+ * @removed
*/
+ @Deprecated
public static void trash(@NonNull Context context, @NonNull Uri uri) {
trash(context, uri, 48 * DateUtils.HOUR_IN_MILLIS);
}
@@ -970,7 +998,9 @@
* @see MediaStore#setIncludeTrashed(Uri)
* @see MediaStore#trash(Context, Uri)
* @see MediaStore#untrash(Context, Uri)
+ * @removed
*/
+ @Deprecated
public static void trash(@NonNull Context context, @NonNull Uri uri,
@DurationMillisLong long timeoutMillis) {
if (timeoutMillis < 0) {
@@ -992,7 +1022,9 @@
* @see MediaStore#setIncludeTrashed(Uri)
* @see MediaStore#trash(Context, Uri)
* @see MediaStore#untrash(Context, Uri)
+ * @removed
*/
+ @Deprecated
public static void untrash(@NonNull Context context, @NonNull Uri uri) {
final ContentValues values = new ContentValues();
values.put(MediaColumns.IS_TRASHED, 0);
@@ -1010,6 +1042,180 @@
return uri.buildUpon().authority(MediaStore.AUTHORITY_LEGACY).build();
}
+ private static @NonNull PendingIntent createRequest(@NonNull ContentResolver resolver,
+ @NonNull String method, @NonNull Collection<Uri> uris, @Nullable ContentValues values) {
+ Objects.requireNonNull(resolver);
+ Objects.requireNonNull(uris);
+
+ final Iterator<Uri> it = uris.iterator();
+ final ClipData clipData = ClipData.newRawUri(null, it.next());
+ while (it.hasNext()) {
+ clipData.addItem(new ClipData.Item(it.next()));
+ }
+
+ final Bundle extras = new Bundle();
+ extras.putParcelable(EXTRA_CLIP_DATA, clipData);
+ extras.putParcelable(EXTRA_CONTENT_VALUES, values);
+ return resolver.call(AUTHORITY, method, null, extras).getParcelable(EXTRA_RESULT);
+ }
+
+ /**
+ * Create a {@link PendingIntent} that will prompt the user to grant your
+ * app write access for the requested media items.
+ * <p>
+ * This call only generates the request for a prompt; to display the prompt,
+ * call {@link Activity#startIntentSenderForResult} with
+ * {@link PendingIntent#getIntentSender()}. You can then determine if the
+ * user granted your request by testing for {@link Activity#RESULT_OK} in
+ * {@link Activity#onActivityResult}.
+ * <p>
+ * Permissions granted through this mechanism are tied to the lifecycle of
+ * the {@link Activity} that requests them. If you need to retain
+ * longer-term access for background actions, you can place items into a
+ * {@link ClipData} or {@link Intent} which can then be passed to
+ * {@link Context#startService} or
+ * {@link android.app.job.JobInfo.Builder#setClipData}. Be sure to include
+ * any relevant access modes you want to retain, such as
+ * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION}.
+ * <p>
+ * The displayed prompt will reflect all the media items you're requesting,
+ * including those for which you already hold write access. If you want to
+ * determine if you already hold write access before requesting access, use
+ * {@code ContentResolver#checkUriPermission(Uri, int, int)} with
+ * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION}.
+ * <p>
+ * For security and performance reasons this method does not support
+ * {@link Intent#FLAG_GRANT_PERSISTABLE_URI_PERMISSION} or
+ * {@link Intent#FLAG_GRANT_PREFIX_URI_PERMISSION}.
+ *
+ * @param resolver Used to connect with {@link MediaStore#AUTHORITY}.
+ * Typically this value is {@link Context#getContentResolver()},
+ * but if you need more explicit lifecycle controls, you can
+ * obtain a {@link ContentProviderClient} and wrap it using
+ * {@link ContentResolver#wrap(ContentProviderClient)}.
+ * @param uris The set of media items to include in this request. Each item
+ * must be hosted by {@link MediaStore#AUTHORITY} and must
+ * reference a specific media item by {@link BaseColumns#_ID}.
+ */
+ public static @NonNull PendingIntent createWriteRequest(@NonNull ContentResolver resolver,
+ @NonNull Collection<Uri> uris) {
+ return createRequest(resolver, CREATE_WRITE_REQUEST_CALL, uris, null);
+ }
+
+ /**
+ * Create a {@link PendingIntent} that will prompt the user to trash the
+ * requested media items. When the user approves this request,
+ * {@link MediaColumns#IS_TRASHED} is set on these items.
+ * <p>
+ * This call only generates the request for a prompt; to display the prompt,
+ * call {@link Activity#startIntentSenderForResult} with
+ * {@link PendingIntent#getIntentSender()}. You can then determine if the
+ * user granted your request by testing for {@link Activity#RESULT_OK} in
+ * {@link Activity#onActivityResult}.
+ * <p>
+ * The displayed prompt will reflect all the media items you're requesting,
+ * including those for which you already hold write access. If you want to
+ * determine if you already hold write access before requesting access, use
+ * {@code ContentResolver#checkUriPermission(Uri, int, int)} with
+ * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION}.
+ *
+ * @param resolver Used to connect with {@link MediaStore#AUTHORITY}.
+ * Typically this value is {@link Context#getContentResolver()},
+ * but if you need more explicit lifecycle controls, you can
+ * obtain a {@link ContentProviderClient} and wrap it using
+ * {@link ContentResolver#wrap(ContentProviderClient)}.
+ * @param uris The set of media items to include in this request. Each item
+ * must be hosted by {@link MediaStore#AUTHORITY} and must
+ * reference a specific media item by {@link BaseColumns#_ID}.
+ * @param value The {@link MediaColumns#IS_TRASHED} value to apply.
+ * @see MediaColumns#IS_TRASHED
+ * @see MediaStore#QUERY_ARG_MATCH_TRASHED
+ */
+ public static @NonNull PendingIntent createTrashRequest(@NonNull ContentResolver resolver,
+ @NonNull Collection<Uri> uris, boolean value) {
+ final ContentValues values = new ContentValues();
+ if (value) {
+ values.put(MediaColumns.IS_TRASHED, 1);
+ values.put(MediaColumns.DATE_EXPIRES,
+ (System.currentTimeMillis() + DateUtils.WEEK_IN_MILLIS) / 1000);
+ } else {
+ values.put(MediaColumns.IS_TRASHED, 0);
+ values.putNull(MediaColumns.DATE_EXPIRES);
+ }
+ return createRequest(resolver, CREATE_TRASH_REQUEST_CALL, uris, values);
+ }
+
+ /**
+ * Create a {@link PendingIntent} that will prompt the user to favorite the
+ * requested media items. When the user approves this request,
+ * {@link MediaColumns#IS_FAVORITE} is set on these items.
+ * <p>
+ * This call only generates the request for a prompt; to display the prompt,
+ * call {@link Activity#startIntentSenderForResult} with
+ * {@link PendingIntent#getIntentSender()}. You can then determine if the
+ * user granted your request by testing for {@link Activity#RESULT_OK} in
+ * {@link Activity#onActivityResult}.
+ * <p>
+ * The displayed prompt will reflect all the media items you're requesting,
+ * including those for which you already hold write access. If you want to
+ * determine if you already hold write access before requesting access, use
+ * {@code ContentResolver#checkUriPermission(Uri, int, int)} with
+ * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION}.
+ *
+ * @param resolver Used to connect with {@link MediaStore#AUTHORITY}.
+ * Typically this value is {@link Context#getContentResolver()},
+ * but if you need more explicit lifecycle controls, you can
+ * obtain a {@link ContentProviderClient} and wrap it using
+ * {@link ContentResolver#wrap(ContentProviderClient)}.
+ * @param uris The set of media items to include in this request. Each item
+ * must be hosted by {@link MediaStore#AUTHORITY} and must
+ * reference a specific media item by {@link BaseColumns#_ID}.
+ * @param value The {@link MediaColumns#IS_FAVORITE} value to apply.
+ * @see MediaColumns#IS_FAVORITE
+ * @see MediaStore#QUERY_ARG_MATCH_FAVORITE
+ */
+ public static @NonNull PendingIntent createFavoriteRequest(@NonNull ContentResolver resolver,
+ @NonNull Collection<Uri> uris, boolean value) {
+ final ContentValues values = new ContentValues();
+ if (value) {
+ values.put(MediaColumns.IS_FAVORITE, 1);
+ } else {
+ values.put(MediaColumns.IS_FAVORITE, 0);
+ }
+ return createRequest(resolver, CREATE_FAVORITE_REQUEST_CALL, uris, values);
+ }
+
+ /**
+ * Create a {@link PendingIntent} that will prompt the user to permanently
+ * delete the requested media items. When the user approves this request,
+ * {@link ContentResolver#delete} will be called on these items.
+ * <p>
+ * This call only generates the request for a prompt; to display the prompt,
+ * call {@link Activity#startIntentSenderForResult} with
+ * {@link PendingIntent#getIntentSender()}. You can then determine if the
+ * user granted your request by testing for {@link Activity#RESULT_OK} in
+ * {@link Activity#onActivityResult}.
+ * <p>
+ * The displayed prompt will reflect all the media items you're requesting,
+ * including those for which you already hold write access. If you want to
+ * determine if you already hold write access before requesting access, use
+ * {@code ContentResolver#checkUriPermission(Uri, int, int)} with
+ * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION}.
+ *
+ * @param resolver Used to connect with {@link MediaStore#AUTHORITY}.
+ * Typically this value is {@link Context#getContentResolver()},
+ * but if you need more explicit lifecycle controls, you can
+ * obtain a {@link ContentProviderClient} and wrap it using
+ * {@link ContentResolver#wrap(ContentProviderClient)}.
+ * @param uris The set of media items to include in this request. Each item
+ * must be hosted by {@link MediaStore#AUTHORITY} and must
+ * reference a specific media item by {@link BaseColumns#_ID}.
+ */
+ public static @NonNull PendingIntent createDeleteRequest(@NonNull ContentResolver resolver,
+ @NonNull Collection<Uri> uris) {
+ return createRequest(resolver, CREATE_DELETE_REQUEST_CALL, uris, null);
+ }
+
/**
* Common media metadata columns.
*/
@@ -1127,9 +1333,9 @@
* Trashed items are retained until they expire as defined by
* {@link #DATE_EXPIRES}.
*
+ * @see MediaColumns#IS_TRASHED
* @see MediaStore#QUERY_ARG_MATCH_TRASHED
- * @see MediaStore#trash(Context, Uri)
- * @see MediaStore#untrash(Context, Uri)
+ * @see MediaStore#createTrashRequest
*/
@Column(Cursor.FIELD_TYPE_INTEGER)
public static final String IS_TRASHED = "is_trashed";
@@ -1302,7 +1508,9 @@
* Flag indicating if the media item has been marked as being a
* "favorite" by the user.
*
+ * @see MediaColumns#IS_FAVORITE
* @see MediaStore#QUERY_ARG_MATCH_FAVORITE
+ * @see MediaStore#createFavoriteRequest
*/
@Column(Cursor.FIELD_TYPE_INTEGER)
public static final String IS_FAVORITE = "is_favorite";
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 165c284..0318129 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -8410,6 +8410,18 @@
public static final String TAP_GESTURE = "tap_gesture";
/**
+ * Controls whether the people strip is enabled.
+ * @hide
+ */
+ public static final String PEOPLE_STRIP = "people_strip";
+
+ /**
+ * Controls if window magnification is enabled.
+ * @hide
+ */
+ public static final String WINDOW_MAGNIFICATION = "window_magnification";
+
+ /**
* Keys we no longer back up under the current schema, but want to continue to
* process when restoring historical backup datasets.
*
@@ -10312,6 +10324,19 @@
public static final String ERROR_LOGCAT_PREFIX = "logcat_for_";
/**
+ * Maximum number of bytes of a system crash/ANR/etc. report that
+ * ActivityManagerService should send to DropBox, as a prefix of the
+ * dropbox tag of the report type. For example,
+ * "max_error_bytes_for_system_server_anr" controls the maximum
+ * number of bytes captured with system server ANR reports.
+ * <p>
+ * Type: int (max size in bytes)
+ *
+ * @hide
+ */
+ public static final String MAX_ERROR_BYTES_PREFIX = "max_error_bytes_for_";
+
+ /**
* The interval in minutes after which the amount of free storage left
* on the device is logged to the event log
*
@@ -14210,6 +14235,20 @@
*/
public static final int ADD_WIFI_RESULT_ALREADY_EXISTS = 2;
+ /**
+ * Activity Action: Allows user to select current bug report handler.
+ * <p>
+ * Input: Nothing.
+ * <p>
+ * Output: Nothing.
+ *
+ * @hide
+ */
+ @SystemApi
+ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+ public static final String ACTION_BUGREPORT_HANDLER_SETTINGS =
+ "android.settings.BUGREPORT_HANDLER_SETTINGS";
+
private static final String[] PM_WRITE_SETTINGS = {
android.Manifest.permission.WRITE_SETTINGS
};
diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java
index 70c8e5d..c287ae3 100644
--- a/core/java/android/provider/Telephony.java
+++ b/core/java/android/provider/Telephony.java
@@ -25,6 +25,7 @@
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
+import android.compat.annotation.ChangeId;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentValues;
@@ -1307,8 +1308,7 @@
* Broadcast action: When SMS-MMS db is being created. If file-based encryption is
* supported, this broadcast indicates creation of the db in credential-encrypted
* storage. A boolean is specified in {@link #EXTRA_IS_INITIAL_CREATE} to indicate if
- * this is the initial create of the db. Requires
- * {@link android.Manifest.permission#READ_SMS} to receive.
+ * this is the initial create of the db.
*
* @see #EXTRA_IS_INITIAL_CREATE
*
@@ -4032,6 +4032,16 @@
@Retention(RetentionPolicy.SOURCE)
public @interface Skip464XlatStatus {}
+ /**
+ * Compat framework change ID for the APN db read permission change.
+ *
+ * In API level 30 and beyond, accessing the APN database will require the
+ * {@link android.Manifest.permission#WRITE_APN_SETTINGS} permission. This change ID tracks
+ * apps that are affected because they don't hold this permission.
+ * @hide
+ */
+ @ChangeId
+ public static final long APN_READING_PERMISSION_CHANGE_ID = 124107808L;
}
/**
diff --git a/core/java/android/security/keymaster/KeymasterDefs.java b/core/java/android/security/keymaster/KeymasterDefs.java
index 15ded8d..e4ba87c 100644
--- a/core/java/android/security/keymaster/KeymasterDefs.java
+++ b/core/java/android/security/keymaster/KeymasterDefs.java
@@ -94,6 +94,7 @@
public static final int KM_TAG_ATTESTATION_ID_MEID = KM_BYTES | 715;
public static final int KM_TAG_ATTESTATION_ID_MANUFACTURER = KM_BYTES | 716;
public static final int KM_TAG_ATTESTATION_ID_MODEL = KM_BYTES | 717;
+ public static final int KM_TAG_DEVICE_UNIQUE_ATTESTATION = KM_BOOL | 720;
public static final int KM_TAG_ASSOCIATED_DATA = KM_BYTES | 1000;
public static final int KM_TAG_NONCE = KM_BYTES | 1001;
diff --git a/core/java/android/service/dreams/Sandman.java b/core/java/android/service/dreams/Sandman.java
index efb8923..f2cedbc 100644
--- a/core/java/android/service/dreams/Sandman.java
+++ b/core/java/android/service/dreams/Sandman.java
@@ -36,12 +36,6 @@
public final class Sandman {
private static final String TAG = "Sandman";
- // The component name of a special dock app that merely launches a dream.
- // We don't want to launch this app when docked because it causes an unnecessary
- // activity transition. We just want to start the dream.
- private static final ComponentName SOMNAMBULATOR_COMPONENT =
- new ComponentName("com.android.systemui", "com.android.systemui.Somnambulator");
-
// The sandman is eternal. No one instantiates him.
private Sandman() {
@@ -52,8 +46,11 @@
* False if we should dream instead, if appropriate.
*/
public static boolean shouldStartDockApp(Context context, Intent intent) {
+ final ComponentName somnambulatorComponent = ComponentName.unflattenFromString(
+ context.getResources().getString(
+ com.android.internal.R.string.config_somnambulatorComponent));
ComponentName name = intent.resolveActivity(context.getPackageManager());
- return name != null && !name.equals(SOMNAMBULATOR_COMPONENT);
+ return name != null && !name.equals(somnambulatorComponent);
}
/**
diff --git a/core/java/android/service/notification/Adjustment.java b/core/java/android/service/notification/Adjustment.java
index 8ab687f..c84fbc7 100644
--- a/core/java/android/service/notification/Adjustment.java
+++ b/core/java/android/service/notification/Adjustment.java
@@ -124,6 +124,13 @@
public static final String KEY_IMPORTANCE = "key_importance";
/**
+ * Data type: float, a ranking score from 0 (lowest) to 1 (highest).
+ * Used to rank notifications inside that fall under the same classification (i.e. alerting,
+ * silenced).
+ */
+ public static final String KEY_RANKING_SCORE = "key_ranking_score";
+
+ /**
* Create a notification adjustment.
*
* @param pkg The package of the notification.
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java
index 85f13d5..c04ac59 100644
--- a/core/java/android/service/notification/NotificationListenerService.java
+++ b/core/java/android/service/notification/NotificationListenerService.java
@@ -1895,7 +1895,8 @@
&& ((mSmartActions == null ? 0 : mSmartActions.size())
== (other.mSmartActions == null ? 0 : other.mSmartActions.size()))
&& Objects.equals(mSmartReplies, other.mSmartReplies)
- && Objects.equals(mCanBubble, other.mCanBubble);
+ && Objects.equals(mCanBubble, other.mCanBubble)
+ && Objects.equals(mVisuallyInterruptive, other.mVisuallyInterruptive);
}
}
diff --git a/core/java/android/service/quicksettings/TileService.java b/core/java/android/service/quicksettings/TileService.java
index dd2586c..d0675ed 100644
--- a/core/java/android/service/quicksettings/TileService.java
+++ b/core/java/android/service/quicksettings/TileService.java
@@ -481,9 +481,12 @@
* as true on their TileService Manifest declaration, and will do nothing otherwise.
*/
public static final void requestListeningState(Context context, ComponentName component) {
+ final ComponentName sysuiComponent = ComponentName.unflattenFromString(
+ context.getResources().getString(
+ com.android.internal.R.string.config_systemUIServiceComponent));
Intent intent = new Intent(ACTION_REQUEST_LISTENING);
intent.putExtra(Intent.EXTRA_COMPONENT_NAME, component);
- intent.setPackage("com.android.systemui");
+ intent.setPackage(sysuiComponent.getPackageName());
context.sendBroadcast(intent, Manifest.permission.BIND_QUICK_SETTINGS_TILE);
}
}
diff --git a/core/java/android/service/voice/VoiceInteractionSession.java b/core/java/android/service/voice/VoiceInteractionSession.java
index c9d37bf..52b7294 100644
--- a/core/java/android/service/voice/VoiceInteractionSession.java
+++ b/core/java/android/service/voice/VoiceInteractionSession.java
@@ -1137,6 +1137,7 @@
mWindow = new SoftInputWindow(mContext, "VoiceInteractionSession", mTheme,
mCallbacks, this, mDispatcherState,
WindowManager.LayoutParams.TYPE_VOICE_INTERACTION, Gravity.BOTTOM, true);
+ mWindow.getWindow().setFitWindowInsetsTypes(0 /* types */);
mWindow.getWindow().addFlags(
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED |
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index d5c6766..e50d6c2 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -811,6 +811,7 @@
// Add window
mLayout.type = mIWallpaperEngine.mWindowType;
mLayout.gravity = Gravity.START|Gravity.TOP;
+ mLayout.setFitWindowInsetsTypes(0 /* types */);
mLayout.setTitle(WallpaperService.this.getClass().getName());
mLayout.windowAnimations =
com.android.internal.R.style.Animation_Wallpaper;
diff --git a/core/java/android/telephony/PhoneStateListener.java b/core/java/android/telephony/PhoneStateListener.java
index 716a522..e3f11a1 100644
--- a/core/java/android/telephony/PhoneStateListener.java
+++ b/core/java/android/telephony/PhoneStateListener.java
@@ -35,8 +35,8 @@
import android.telephony.emergency.EmergencyNumber;
import android.telephony.ims.ImsReasonInfo;
-import com.android.internal.telephony.IPhoneStateListener;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.telephony.IPhoneStateListener;
import dalvik.system.VMRuntime;
@@ -196,12 +196,13 @@
/**
* Listen for {@link PreciseDataConnectionState} on the data connection (cellular).
*
- * @see #onPreciseDataConnectionStateChanged
+ * <p>Requires permission {@link android.Manifest.permission#MODIFY_PHONE_STATE}
+ * or the calling app has carrier privileges
+ * (see {@link TelephonyManager#hasCarrierPrivileges}).
*
- * @hide
+ * @see #onPreciseDataConnectionStateChanged
*/
- @RequiresPermission((android.Manifest.permission.READ_PRECISE_PHONE_STATE))
- @SystemApi
+ @RequiresPermission((android.Manifest.permission.MODIFY_PHONE_STATE))
public static final int LISTEN_PRECISE_DATA_CONNECTION_STATE = 0x00001000;
/**
@@ -719,8 +720,9 @@
}
/**
- * Callback invoked when data connection state changes with precise information
- * on the registered subscription.
+ * Callback providing update about the default/internet data connection on the registered
+ * subscription.
+ *
* Note, the registration subId comes from {@link TelephonyManager} object which registers
* PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}.
* If this TelephonyManager object was created with
@@ -728,12 +730,13 @@
* subId. Otherwise, this callback applies to
* {@link SubscriptionManager#getDefaultSubscriptionId()}.
*
- * @param dataConnectionState {@link PreciseDataConnectionState}
+ * <p>Requires permission {@link android.Manifest.permission#MODIFY_PHONE_STATE}
+ * or the calling app has carrier privileges
+ * (see {@link TelephonyManager#hasCarrierPrivileges}).
*
- * @hide
+ * @param dataConnectionState {@link PreciseDataConnectionState}
*/
- @RequiresPermission((android.Manifest.permission.READ_PRECISE_PHONE_STATE))
- @SystemApi
+ @RequiresPermission((android.Manifest.permission.MODIFY_PHONE_STATE))
public void onPreciseDataConnectionStateChanged(
@NonNull PreciseDataConnectionState dataConnectionState) {
// default implementation empty
@@ -1042,11 +1045,21 @@
PhoneStateListener psl = mPhoneStateListenerWeakRef.get();
if (psl == null) return;
- Binder.withCleanCallingIdentity(() -> mExecutor.execute(
- () -> {
- psl.onDataConnectionStateChanged(state, networkType);
- psl.onDataConnectionStateChanged(state);
- }));
+ if (state == TelephonyManager.DATA_DISCONNECTING
+ && VMRuntime.getRuntime().getTargetSdkVersion() < Build.VERSION_CODES.R) {
+ Binder.withCleanCallingIdentity(() -> mExecutor.execute(
+ () -> {
+ psl.onDataConnectionStateChanged(
+ TelephonyManager.DATA_CONNECTED, networkType);
+ psl.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED);
+ }));
+ } else {
+ Binder.withCleanCallingIdentity(() -> mExecutor.execute(
+ () -> {
+ psl.onDataConnectionStateChanged(state, networkType);
+ psl.onDataConnectionStateChanged(state);
+ }));
+ }
}
public void onDataActivity(int direction) {
diff --git a/core/java/android/telephony/TelephonyRegistryManager.java b/core/java/android/telephony/TelephonyRegistryManager.java
index 9d7b57b..b3702e6 100644
--- a/core/java/android/telephony/TelephonyRegistryManager.java
+++ b/core/java/android/telephony/TelephonyRegistryManager.java
@@ -21,17 +21,13 @@
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.content.Context;
-import android.net.LinkProperties;
-import android.net.NetworkCapabilities;
import android.os.Binder;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
-import android.telephony.Annotation.ApnType;
import android.telephony.Annotation.CallState;
import android.telephony.Annotation.DataActivityType;
import android.telephony.Annotation.DataFailureCause;
-import android.telephony.Annotation.DataState;
import android.telephony.Annotation.NetworkType;
import android.telephony.Annotation.PreciseCallStates;
import android.telephony.Annotation.RadioPowerState;
@@ -357,27 +353,18 @@
* @param subId for which data connection state changed.
* @param slotIndex for which data connections state changed. Can be derived from subId except
* when subId is invalid.
- * @param state latest data connection state, e.g,
- * @param isDataConnectivityPossible indicates if data is allowed
- * @param apn the APN {@link ApnSetting#getApnName()} of this data connection.
- * @param apnType the apnType, "ims" for IMS APN, "emergency" for EMERGENCY APN.
- * @param linkProperties {@link LinkProperties} associated with this data connection.
- * @param networkCapabilities {@link NetworkCapabilities} associated with this data connection.
- * @param networkType associated with this data connection.
- * @param roaming {@code true} indicates in roaming, {@false} otherwise.
- * @see TelephonyManager#DATA_DISCONNECTED
- * @see TelephonyManager#isDataConnectivityPossible()
+ * @param apnType the APN type that triggered this update
+ * @param preciseState the PreciseDataConnectionState
*
+ * @see android.telephony.PreciseDataConnection
+ * @see TelephonyManager#DATA_DISCONNECTED
* @hide
*/
- public void notifyDataConnectionForSubscriber(int slotIndex, int subId, @DataState int state,
- boolean isDataConnectivityPossible,
- @ApnType String apn, String apnType, LinkProperties linkProperties,
- NetworkCapabilities networkCapabilities, int networkType, boolean roaming) {
+ public void notifyDataConnectionForSubscriber(int slotIndex, int subId,
+ String apnType, PreciseDataConnectionState preciseState) {
try {
- sRegistry.notifyDataConnectionForSubscriber(slotIndex, subId, state,
- isDataConnectivityPossible,
- apn, apnType, linkProperties, networkCapabilities, networkType, roaming);
+ sRegistry.notifyDataConnectionForSubscriber(
+ slotIndex, subId, apnType, preciseState);
} catch (RemoteException ex) {
// system process is dead
}
@@ -662,25 +649,6 @@
}
/**
- * Notify data connection failed on certain subscription.
- *
- * @param subId for which data connection failed.
- * @param slotIndex for which data conenction faled. Can be derived from subId except when subId
- * is invalid.
- * @param apnType the apnType, "ims" for IMS APN, "emergency" for EMERGENCY APN. Note each data
- * connection can support multiple anyTypes.
- *
- * @hide
- */
- public void notifyDataConnectionFailed(int subId, int slotIndex, String apnType) {
- try {
- sRegistry.notifyDataConnectionFailedForSubscriber(slotIndex, subId, apnType);
- } catch (RemoteException ex) {
- // system process is dead
- }
- }
-
- /**
* TODO change from bundle to CellLocation?
* @hide
*/
diff --git a/core/java/android/text/format/DateUtils.java b/core/java/android/text/format/DateUtils.java
index b00a938..0c27923 100644
--- a/core/java/android/text/format/DateUtils.java
+++ b/core/java/android/text/format/DateUtils.java
@@ -59,8 +59,12 @@
public static final long DAY_IN_MILLIS = HOUR_IN_MILLIS * 24;
public static final long WEEK_IN_MILLIS = DAY_IN_MILLIS * 7;
/**
- * This constant is actually the length of 364 days, not of a year!
+ * @deprecated Not all years have the same number of days, and this constant is actually the
+ * length of 364 days. Please use other date/time constructs such as
+ * {@link java.util.concurrent.TimeUnit}, {@link java.util.Calendar} or
+ * {@link java.time.Duration} instead.
*/
+ @Deprecated
public static final long YEAR_IN_MILLIS = WEEK_IN_MILLIS * 52;
// The following FORMAT_* symbols are used for specifying the format of
diff --git a/core/java/android/util/CloseGuard.java b/core/java/android/util/CloseGuard.java
new file mode 100644
index 0000000..c39a6c9
--- /dev/null
+++ b/core/java/android/util/CloseGuard.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2019 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 android.util;
+
+import android.annotation.NonNull;
+
+/**
+ * CloseGuard is a mechanism for flagging implicit finalizer cleanup of
+ * resources that should have been cleaned up by explicit close
+ * methods (aka "explicit termination methods" in Effective Java).
+ * <p>
+ * A simple example: <pre> {@code
+ * class Foo {
+ *
+ * private final CloseGuard guard = CloseGuard.get();
+ *
+ * ...
+ *
+ * public Foo() {
+ * ...;
+ * guard.open("cleanup");
+ * }
+ *
+ * public void cleanup() {
+ * guard.close();
+ * ...;
+ * }
+ *
+ * protected void finalize() throws Throwable {
+ * try {
+ * // Note that guard could be null if the constructor threw.
+ * if (guard != null) {
+ * guard.warnIfOpen();
+ * }
+ * cleanup();
+ * } finally {
+ * super.finalize();
+ * }
+ * }
+ * }
+ * }</pre>
+ *
+ * In usage where the resource to be explicitly cleaned up is
+ * allocated after object construction, CloseGuard protection can
+ * be deferred. For example: <pre> {@code
+ * class Bar {
+ *
+ * private final CloseGuard guard = CloseGuard.get();
+ *
+ * ...
+ *
+ * public Bar() {
+ * ...;
+ * }
+ *
+ * public void connect() {
+ * ...;
+ * guard.open("cleanup");
+ * }
+ *
+ * public void cleanup() {
+ * guard.close();
+ * ...;
+ * Reference.reachabilityFence(this);
+ * // For full correctness in the absence of a close() call, other methods may also need
+ * // reachabilityFence() calls.
+ * }
+ *
+ * protected void finalize() throws Throwable {
+ * try {
+ * // Note that guard could be null if the constructor threw.
+ * if (guard != null) {
+ * guard.warnIfOpen();
+ * }
+ * cleanup();
+ * } finally {
+ * super.finalize();
+ * }
+ * }
+ * }
+ * }</pre>
+ *
+ * When used in a constructor, calls to {@code open} should occur at
+ * the end of the constructor since an exception that would cause
+ * abrupt termination of the constructor will mean that the user will
+ * not have a reference to the object to cleanup explicitly. When used
+ * in a method, the call to {@code open} should occur just after
+ * resource acquisition.
+ */
+public final class CloseGuard {
+ private final dalvik.system.CloseGuard mImpl;
+
+ /**
+ * Constructs a new CloseGuard instance.
+ * {@link #open(String)} can be used to set up the instance to warn on failure to close.
+ */
+ public CloseGuard() {
+ mImpl = dalvik.system.CloseGuard.get();
+ }
+
+ /**
+ * Initializes the instance with a warning that the caller should have explicitly called the
+ * {@code closeMethodName} method instead of relying on finalization.
+ *
+ * @param closeMethodName non-null name of explicit termination method. Printed by warnIfOpen.
+ * @throws NullPointerException if closeMethodName is null.
+ */
+ public void open(@NonNull String closeMethodName) {
+ mImpl.open(closeMethodName);
+ }
+
+ /** Marks this CloseGuard instance as closed to avoid warnings on finalization. */
+ public void close() {
+ mImpl.close();
+ }
+
+ /**
+ * Logs a warning if the caller did not properly cleanup by calling an explicit close method
+ * before finalization.
+ */
+ public void warnIfOpen() {
+ mImpl.warnIfOpen();
+ }
+}
diff --git a/core/java/android/util/FeatureFlagUtils.java b/core/java/android/util/FeatureFlagUtils.java
index 236e5ae..1b2db36 100644
--- a/core/java/android/util/FeatureFlagUtils.java
+++ b/core/java/android/util/FeatureFlagUtils.java
@@ -59,6 +59,7 @@
DEFAULT_FLAGS.put(SETTINGS_WIFITRACKER2, "false");
DEFAULT_FLAGS.put("settings_work_profile", "true");
DEFAULT_FLAGS.put("settings_controller_loading_enhancement", "false");
+ DEFAULT_FLAGS.put("settings_conditionals", "false");
}
/**
diff --git a/core/java/android/util/LongArrayQueue.java b/core/java/android/util/LongArrayQueue.java
index d5f0484..5c701db 100644
--- a/core/java/android/util/LongArrayQueue.java
+++ b/core/java/android/util/LongArrayQueue.java
@@ -162,4 +162,24 @@
final int index = (mTail == 0) ? mValues.length - 1 : mTail - 1;
return mValues[index];
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ if (mSize <= 0) {
+ return "{}";
+ }
+
+ final StringBuilder buffer = new StringBuilder(mSize * 64);
+ buffer.append('{');
+ buffer.append(get(0));
+ for (int i = 1; i < mSize; i++) {
+ buffer.append(", ");
+ buffer.append(get(i));
+ }
+ buffer.append('}');
+ return buffer.toString();
+ }
}
diff --git a/core/java/android/util/SparseSetArray.java b/core/java/android/util/SparseSetArray.java
index c1873d7..9f0f246 100644
--- a/core/java/android/util/SparseSetArray.java
+++ b/core/java/android/util/SparseSetArray.java
@@ -27,8 +27,8 @@
}
/**
- * Add a value at index n.
- * @return FALSE when the value already existed at the given index, TRUE otherwise.
+ * Add a value for key n.
+ * @return FALSE when the value already existed for the given key, TRUE otherwise.
*/
public boolean add(int n, T value) {
ArraySet<T> set = mData.get(n);
@@ -51,7 +51,7 @@
}
/**
- * @return whether a value exists at index n.
+ * @return whether the value exists for the key n.
*/
public boolean contains(int n, T value) {
final ArraySet<T> set = mData.get(n);
@@ -62,15 +62,15 @@
}
/**
- * @return the set of items at index n
+ * @return the set of items of key n
*/
public ArraySet<T> get(int n) {
return mData.get(n);
}
/**
- * Remove a value from index n.
- * @return TRUE when the value existed at the given index and removed, FALSE otherwise.
+ * Remove a value for key n.
+ * @return TRUE when the value existed for the given key and removed, FALSE otherwise.
*/
public boolean remove(int n, T value) {
final ArraySet<T> set = mData.get(n);
@@ -85,7 +85,7 @@
}
/**
- * Remove all values from index n.
+ * Remove all values for key n.
*/
public void remove(int n) {
mData.remove(n);
diff --git a/core/java/android/util/StatsLog.java b/core/java/android/util/StatsLog.java
index 9ac4cf2..952d7cb 100644
--- a/core/java/android/util/StatsLog.java
+++ b/core/java/android/util/StatsLog.java
@@ -24,7 +24,7 @@
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.content.Context;
-import android.os.IStatsManager;
+import android.os.IStatsd;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -36,7 +36,7 @@
private static final String TAG = "StatsLog";
private static final boolean DEBUG = false;
- private static IStatsManager sService;
+ private static IStatsd sService;
private static Object sLogLock = new Object();
@@ -52,7 +52,7 @@
public static boolean logStart(int label) {
synchronized (sLogLock) {
try {
- IStatsManager service = getIStatsManagerLocked();
+ IStatsd service = getIStatsdLocked();
if (service == null) {
if (DEBUG) {
Slog.d(TAG, "Failed to find statsd when logging start");
@@ -81,7 +81,7 @@
public static boolean logStop(int label) {
synchronized (sLogLock) {
try {
- IStatsManager service = getIStatsManagerLocked();
+ IStatsd service = getIStatsdLocked();
if (service == null) {
if (DEBUG) {
Slog.d(TAG, "Failed to find statsd when logging stop");
@@ -109,7 +109,7 @@
public static boolean logEvent(int label) {
synchronized (sLogLock) {
try {
- IStatsManager service = getIStatsManagerLocked();
+ IStatsd service = getIStatsdLocked();
if (service == null) {
if (DEBUG) {
Slog.d(TAG, "Failed to find statsd when logging event");
@@ -151,7 +151,7 @@
@NonNull long[] experimentIds) {
synchronized (sLogLock) {
try {
- IStatsManager service = getIStatsManagerLocked();
+ IStatsd service = getIStatsdLocked();
if (service == null) {
if (DEBUG) {
Slog.d(TAG, "Failed to find statsd when logging event");
@@ -191,7 +191,7 @@
long packageVersionCode, int rollbackReason, String failingPackageName) {
synchronized (sLogLock) {
try {
- IStatsManager service = getIStatsManagerLocked();
+ IStatsd service = getIStatsdLocked();
if (service == null) {
if (DEBUG) {
Slog.d(TAG, "Failed to find statsd when logging event");
@@ -215,11 +215,11 @@
}
- private static IStatsManager getIStatsManagerLocked() throws RemoteException {
+ private static IStatsd getIStatsdLocked() throws RemoteException {
if (sService != null) {
return sService;
}
- sService = IStatsManager.Stub.asInterface(ServiceManager.getService("stats"));
+ sService = IStatsd.Stub.asInterface(ServiceManager.getService("stats"));
return sService;
}
diff --git a/core/java/android/view/Choreographer.java b/core/java/android/view/Choreographer.java
index 28eb79a..71ac578 100644
--- a/core/java/android/view/Choreographer.java
+++ b/core/java/android/view/Choreographer.java
@@ -16,13 +16,13 @@
package android.view;
-import static android.view.DisplayEventReceiver.CONFIG_CHANGED_EVENT_SUPPRESS;
import static android.view.DisplayEventReceiver.VSYNC_SOURCE_APP;
import static android.view.DisplayEventReceiver.VSYNC_SOURCE_SURFACE_FLINGER;
import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.graphics.FrameInfo;
+import android.graphics.Insets;
import android.hardware.display.DisplayManagerGlobal;
import android.os.Build;
import android.os.Handler;
@@ -219,9 +219,10 @@
/**
* Callback type: Animation callback to handle inset updates. This is separate from
* {@link #CALLBACK_ANIMATION} as we need to "gather" all inset animation updates via
- * {@link WindowInsetsAnimationController#changeInsets} for multiple ongoing animations but then
- * update the whole view system with a single callback to {@link View#dispatchWindowInsetsAnimationProgress}
- * that contains all the combined updated insets.
+ * {@link WindowInsetsAnimationController#setInsetsAndAlpha(Insets, float, float)} for multiple
+ * ongoing animations but then update the whole view system with a single callback to
+ * {@link View#dispatchWindowInsetsAnimationProgress} that contains all the combined updated
+ * insets.
* <p>
* Both input and animation may change insets, so we need to run this after these callbacks, but
* before traversals.
diff --git a/core/java/android/view/DisplayCutout.java b/core/java/android/view/DisplayCutout.java
index 411508f..615dab0 100644
--- a/core/java/android/view/DisplayCutout.java
+++ b/core/java/android/view/DisplayCutout.java
@@ -66,6 +66,7 @@
private static final String BOTTOM_MARKER = "@bottom";
private static final String DP_MARKER = "@dp";
private static final String RIGHT_MARKER = "@right";
+ private static final String LEFT_MARKER = "@left";
/**
* Category for overlays that allow emulating a display cutout on devices that don't have
@@ -647,6 +648,9 @@
if (spec.endsWith(RIGHT_MARKER)) {
offsetX = displayWidth;
spec = spec.substring(0, spec.length() - RIGHT_MARKER.length()).trim();
+ } else if (spec.endsWith(LEFT_MARKER)) {
+ offsetX = 0;
+ spec = spec.substring(0, spec.length() - LEFT_MARKER.length()).trim();
} else {
offsetX = displayWidth / 2f;
}
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index b829c9f..9496827 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -44,6 +44,7 @@
import android.view.IRotationWatcher;
import android.view.ISystemGestureExclusionListener;
import android.view.IWallpaperVisibilityListener;
+import android.view.IWindow;
import android.view.IWindowSession;
import android.view.IWindowSessionCallback;
import android.view.KeyEvent;
@@ -120,6 +121,17 @@
void setDisplayWindowRotationController(IDisplayWindowRotationController controller);
/**
+ * Adds a root container that a client shell can populate with its own windows (usually via
+ * WindowlessWindowManager).
+ *
+ * @param client an IWindow used for window-level communication (ime, finish draw, etc.).
+ * @param windowType used by WM to determine the z-order. This is the same as the window type
+ * used in {@link WindowManager.LayoutParams}.
+ * @return a SurfaceControl to add things to.
+ */
+ SurfaceControl addShellRoot(int displayId, IWindow client, int windowType);
+
+ /**
* Like overridePendingAppTransitionMultiThumb, but uses a future to supply the specs. This is
* used for recents, where generating the thumbnails of the specs takes a non-trivial amount of
* time, so we want to move that off the critical path for starting the new activity.
diff --git a/core/java/android/view/InsetsAnimationControlImpl.java b/core/java/android/view/InsetsAnimationControlImpl.java
index 3d139cd..7ea4f30 100644
--- a/core/java/android/view/InsetsAnimationControlImpl.java
+++ b/core/java/android/view/InsetsAnimationControlImpl.java
@@ -21,7 +21,6 @@
import static android.view.InsetsState.ISIDE_LEFT;
import static android.view.InsetsState.ISIDE_RIGHT;
import static android.view.InsetsState.ISIDE_TOP;
-import static android.view.InsetsState.toPublicType;
import android.annotation.Nullable;
import android.graphics.Insets;
@@ -34,7 +33,8 @@
import android.view.InsetsState.InternalInsetsSide;
import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams;
import android.view.WindowInsets.Type.InsetsType;
-import android.view.WindowInsetsAnimationListener.InsetsAnimation;
+import android.view.WindowInsetsAnimationCallback.AnimationBounds;
+import android.view.WindowInsetsAnimationCallback.InsetsAnimation;
import android.view.WindowManager.LayoutParams;
import com.android.internal.annotations.VisibleForTesting;
@@ -66,20 +66,21 @@
private final @InsetsType int mTypes;
private final Supplier<SyncRtSurfaceTransactionApplier> mTransactionApplierSupplier;
private final InsetsController mController;
- private final WindowInsetsAnimationListener.InsetsAnimation mAnimation;
+ private final WindowInsetsAnimationCallback.InsetsAnimation mAnimation;
private final Rect mFrame;
private Insets mCurrentInsets;
private Insets mPendingInsets;
+ private float mPendingFraction;
private boolean mFinished;
private boolean mCancelled;
- private int mFinishedShownTypes;
+ private boolean mShownOnFinish;
@VisibleForTesting
public InsetsAnimationControlImpl(SparseArray<InsetsSourceConsumer> consumers, Rect frame,
InsetsState state, WindowInsetsAnimationControlListener listener,
@InsetsType int types,
Supplier<SyncRtSurfaceTransactionApplier> transactionApplierSupplier,
- InsetsController controller) {
+ InsetsController controller, long durationMs) {
mConsumers = consumers;
mListener = listener;
mTypes = types;
@@ -97,9 +98,10 @@
// TODO: Check for controllability first and wait for IME if needed.
listener.onReady(this, types);
- mAnimation = new WindowInsetsAnimationListener.InsetsAnimation(mTypes, mHiddenInsets,
- mShownInsets);
- mController.dispatchAnimationStarted(mAnimation);
+ mAnimation = new WindowInsetsAnimationCallback.InsetsAnimation(mTypes,
+ InsetsController.INTERPOLATOR, durationMs);
+ mController.dispatchAnimationStarted(mAnimation,
+ new AnimationBounds(mHiddenInsets, mShownInsets));
}
@Override
@@ -123,7 +125,7 @@
}
@Override
- public void changeInsets(Insets insets) {
+ public void setInsetsAndAlpha(Insets insets, float alpha, float fraction) {
if (mFinished) {
throw new IllegalStateException(
"Can't change insets on an animation that is finished.");
@@ -132,6 +134,7 @@
throw new IllegalStateException(
"Can't change insets on an animation that is cancelled.");
}
+ mPendingFraction = sanitize(fraction);
mPendingInsets = sanitize(insets);
mController.scheduleApplyChangeInsets();
}
@@ -155,30 +158,35 @@
SyncRtSurfaceTransactionApplier applier = mTransactionApplierSupplier.get();
applier.scheduleApply(params.toArray(new SurfaceParams[params.size()]));
mCurrentInsets = mPendingInsets;
+ mAnimation.setFraction(mPendingFraction);
if (mFinished) {
- mController.notifyFinished(this, mFinishedShownTypes);
+ mController.notifyFinished(this, mShownOnFinish);
}
return mFinished;
}
@Override
- public void finish(int shownTypes) {
+ public void finish(boolean shown) {
if (mCancelled) {
return;
}
InsetsState state = new InsetsState(mController.getState());
for (int i = mConsumers.size() - 1; i >= 0; i--) {
InsetsSourceConsumer consumer = mConsumers.valueAt(i);
- boolean visible = (shownTypes & toPublicType(consumer.getType())) != 0;
- state.getSource(consumer.getType()).setVisible(visible);
+ state.getSource(consumer.getType()).setVisible(shown);
}
Insets insets = getInsetsFromState(state, mFrame, null /* typeSideMap */);
- changeInsets(insets);
+ setInsetsAndAlpha(insets, 1f /* alpha */, shown ? 1f : 0f /* fraction */);
mFinished = true;
- mFinishedShownTypes = shownTypes;
+ mShownOnFinish = shown;
}
+ @Override
@VisibleForTesting
+ public float getCurrentFraction() {
+ return mAnimation.getFraction();
+ }
+
public void onCancelled() {
if (mFinished) {
return;
@@ -191,6 +199,10 @@
return mAnimation;
}
+ WindowInsetsAnimationControlListener getListener() {
+ return mListener;
+ }
+
private Insets calculateInsets(InsetsState state, Rect frame,
SparseArray<InsetsSourceConsumer> consumers, boolean shown,
@Nullable @InternalInsetsSide SparseIntArray typeSideMap) {
@@ -210,9 +222,16 @@
}
private Insets sanitize(Insets insets) {
+ if (insets == null) {
+ insets = getCurrentInsets();
+ }
return Insets.max(Insets.min(insets, mShownInsets), mHiddenInsets);
}
+ private static float sanitize(float alpha) {
+ return alpha >= 1 ? 1 : (alpha <= 0 ? 0 : alpha);
+ }
+
private void updateLeashesForSide(@InternalInsetsSide int side, int offset, int inset,
ArrayList<SurfaceParams> surfaceParams, InsetsState state) {
ArraySet<InsetsSourceConsumer> items = mSideSourceMap.get(side);
diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java
index bc70d63..8870311 100644
--- a/core/java/android/view/InsetsController.java
+++ b/core/java/android/view/InsetsController.java
@@ -39,6 +39,8 @@
import android.view.SurfaceControl.Transaction;
import android.view.WindowInsets.Type;
import android.view.WindowInsets.Type.InsetsType;
+import android.view.WindowInsetsAnimationCallback.AnimationBounds;
+import android.view.WindowInsetsAnimationCallback.InsetsAnimation;
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;
@@ -55,11 +57,12 @@
private static final int ANIMATION_DURATION_SHOW_MS = 275;
private static final int ANIMATION_DURATION_HIDE_MS = 340;
- private static final Interpolator INTERPOLATOR = new PathInterpolator(0.4f, 0f, 0.2f, 1f);
private static final int DIRECTION_NONE = 0;
private static final int DIRECTION_SHOW = 1;
private static final int DIRECTION_HIDE = 2;
+ static final Interpolator INTERPOLATOR = new PathInterpolator(0.4f, 0f, 0.2f, 1f);
+
@IntDef ({DIRECTION_NONE, DIRECTION_SHOW, DIRECTION_HIDE})
private @interface AnimationDirection{}
@@ -85,8 +88,75 @@
return object.getCurrentInsets();
}
@Override
- public void set(WindowInsetsAnimationController object, Insets value) {
- object.changeInsets(value);
+ public void set(WindowInsetsAnimationController controller, Insets value) {
+ controller.setInsetsAndAlpha(
+ value, 1f /* alpha */, (((DefaultAnimationControlListener)
+ ((InsetsAnimationControlImpl) controller).getListener())
+ .getRawProgress()));
+ }
+ }
+
+ private class DefaultAnimationControlListener implements WindowInsetsAnimationControlListener {
+
+ private WindowInsetsAnimationController mController;
+ private ObjectAnimator mAnimator;
+ private boolean mShow;
+
+ DefaultAnimationControlListener(boolean show) {
+ mShow = show;
+ }
+
+ @Override
+ public void onReady(WindowInsetsAnimationController controller, int types) {
+ mController = controller;
+ if (mShow) {
+ showDirectly(types);
+ } else {
+ hideDirectly(types);
+ }
+ mAnimationDirection = mShow ? DIRECTION_SHOW : DIRECTION_HIDE;
+ mAnimator = ObjectAnimator.ofObject(
+ controller,
+ new InsetsProperty(),
+ sEvaluator,
+ mShow ? controller.getHiddenStateInsets() : controller.getShownStateInsets(),
+ mShow ? controller.getShownStateInsets() : controller.getHiddenStateInsets()
+ );
+ mAnimator.setDuration(getDurationMs());
+ mAnimator.setInterpolator(INTERPOLATOR);
+ mAnimator.addListener(new AnimatorListenerAdapter() {
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ onAnimationFinish();
+ }
+ });
+ mAnimator.start();
+ }
+
+ @Override
+ public void onCancelled() {
+ // Animator can be null when it is cancelled before onReady() completes.
+ if (mAnimator != null) {
+ mAnimator.cancel();
+ }
+ }
+
+ private void onAnimationFinish() {
+ mAnimationDirection = DIRECTION_NONE;
+ mController.finish(mShow);
+ }
+
+ private float getRawProgress() {
+ float fraction = (float) mAnimator.getCurrentPlayTime() / mAnimator.getDuration();
+ return mShow ? fraction : 1 - fraction;
+ }
+
+ private long getDurationMs() {
+ if (mAnimator != null) {
+ return mAnimator.getDuration();
+ }
+ return mShow ? ANIMATION_DURATION_SHOW_MS : ANIMATION_DURATION_HIDE_MS;
}
}
@@ -123,6 +193,10 @@
if (mAnimationControls.isEmpty()) {
return;
}
+ if (mViewRoot.mView == null) {
+ // The view has already detached from window.
+ return;
+ }
mTmpFinishedControls.clear();
InsetsState state = new InsetsState(mState, true /* copySources */);
@@ -154,6 +228,7 @@
mFrame.set(frame);
}
+ @Override
public InsetsState getState() {
return mState;
}
@@ -273,24 +348,25 @@
}
@Override
- public void controlWindowInsetsAnimation(@InsetsType int types,
+ public void controlWindowInsetsAnimation(@InsetsType int types, long durationMs,
WindowInsetsAnimationControlListener listener) {
- controlWindowInsetsAnimation(types, listener, false /* fromIme */);
+ controlWindowInsetsAnimation(types, listener, false /* fromIme */, durationMs);
}
private void controlWindowInsetsAnimation(@InsetsType int types,
- WindowInsetsAnimationControlListener listener, boolean fromIme) {
+ WindowInsetsAnimationControlListener listener, boolean fromIme, long durationMs) {
// If the frame of our window doesn't span the entire display, the control API makes very
// little sense, as we don't deal with negative insets. So just cancel immediately.
if (!mState.getDisplayFrame().equals(mFrame)) {
listener.onCancelled();
return;
}
- controlAnimationUnchecked(types, listener, mFrame, fromIme);
+ controlAnimationUnchecked(types, listener, mFrame, fromIme, durationMs);
}
private void controlAnimationUnchecked(@InsetsType int types,
- WindowInsetsAnimationControlListener listener, Rect frame, boolean fromIme) {
+ WindowInsetsAnimationControlListener listener, Rect frame, boolean fromIme,
+ long durationMs) {
if (types == 0) {
// nothing to animate.
return;
@@ -321,7 +397,7 @@
final InsetsAnimationControlImpl controller = new InsetsAnimationControlImpl(consumers,
frame, mState, listener, typesReady,
- () -> new SyncRtSurfaceTransactionApplier(mViewRoot.mView), this);
+ () -> new SyncRtSurfaceTransactionApplier(mViewRoot.mView), this, durationMs);
mAnimationControls.add(controller);
}
@@ -392,10 +468,13 @@
}
@VisibleForTesting
- public void notifyFinished(InsetsAnimationControlImpl controller, int shownTypes) {
+ public void notifyFinished(InsetsAnimationControlImpl controller, boolean shown) {
mAnimationControls.remove(controller);
- hideDirectly(controller.getTypes() & ~shownTypes);
- showDirectly(controller.getTypes() & shownTypes);
+ if (shown) {
+ showDirectly(controller.getTypes());
+ } else {
+ hideDirectly(controller.getTypes());
+ }
}
void notifyControlRevoked(InsetsSourceConsumer consumer) {
@@ -505,58 +584,11 @@
return;
}
- WindowInsetsAnimationControlListener listener = new WindowInsetsAnimationControlListener() {
-
- private WindowInsetsAnimationController mController;
- private ObjectAnimator mAnimator;
-
- @Override
- public void onReady(WindowInsetsAnimationController controller, int types) {
- mController = controller;
- if (show) {
- showDirectly(types);
- } else {
- hideDirectly(types);
- }
- mAnimationDirection = show ? DIRECTION_SHOW : DIRECTION_HIDE;
- mAnimator = ObjectAnimator.ofObject(
- controller,
- new InsetsProperty(),
- sEvaluator,
- show ? controller.getHiddenStateInsets() : controller.getShownStateInsets(),
- show ? controller.getShownStateInsets() : controller.getHiddenStateInsets()
- );
- mAnimator.setDuration(show
- ? ANIMATION_DURATION_SHOW_MS
- : ANIMATION_DURATION_HIDE_MS);
- mAnimator.setInterpolator(INTERPOLATOR);
- mAnimator.addListener(new AnimatorListenerAdapter() {
-
- @Override
- public void onAnimationEnd(Animator animation) {
- onAnimationFinish();
- }
- });
- mAnimator.start();
- }
-
- @Override
- public void onCancelled() {
- // Animator can be null when it is cancelled before onReady() completes.
- if (mAnimator != null) {
- mAnimator.cancel();
- }
- }
-
- private void onAnimationFinish() {
- mAnimationDirection = DIRECTION_NONE;
- mController.finish(show ? types : 0);
- }
- };
-
+ final DefaultAnimationControlListener listener = new DefaultAnimationControlListener(show);
// Show/hide animations always need to be relative to the display frame, in order that shown
// and hidden state insets are correct.
- controlAnimationUnchecked(types, listener, mState.getDisplayFrame(), fromIme);
+ controlAnimationUnchecked(
+ types, listener, mState.getDisplayFrame(), fromIme, listener.getDurationMs());
}
private void hideDirectly(@InsetsType int types) {
@@ -587,12 +619,12 @@
}
@VisibleForTesting
- public void dispatchAnimationStarted(WindowInsetsAnimationListener.InsetsAnimation animation) {
- mViewRoot.mView.dispatchWindowInsetsAnimationStarted(animation);
+ public void dispatchAnimationStarted(InsetsAnimation animation, AnimationBounds bounds) {
+ mViewRoot.mView.dispatchWindowInsetsAnimationStarted(animation, bounds);
}
@VisibleForTesting
- public void dispatchAnimationFinished(WindowInsetsAnimationListener.InsetsAnimation animation) {
+ public void dispatchAnimationFinished(InsetsAnimation animation) {
mViewRoot.mView.dispatchWindowInsetsAnimationFinished(animation);
}
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 9d4f3878..2d0b954 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -109,7 +109,8 @@
import android.view.AccessibilityIterators.TextSegmentIterator;
import android.view.AccessibilityIterators.WordTextSegmentIterator;
import android.view.ContextMenu.ContextMenuInfo;
-import android.view.WindowInsetsAnimationListener.InsetsAnimation;
+import android.view.WindowInsetsAnimationCallback.AnimationBounds;
+import android.view.WindowInsetsAnimationCallback.InsetsAnimation;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityEventSource;
import android.view.accessibility.AccessibilityManager;
@@ -4626,7 +4627,7 @@
private ArrayList<OnUnhandledKeyEventListener> mUnhandledKeyListeners;
- private WindowInsetsAnimationListener mWindowInsetsAnimationListener;
+ private WindowInsetsAnimationCallback mWindowInsetsAnimationCallback;
/**
* This lives here since it's only valid for interactive views.
@@ -11091,33 +11092,55 @@
}
/**
- * Sets a {@link WindowInsetsAnimationListener} to be notified about animations of windows that
+ * Sets a {@link WindowInsetsAnimationCallback} to be notified about animations of windows that
* cause insets.
*
* @param listener The listener to set.
- * @hide pending unhide
*/
- public void setWindowInsetsAnimationListener(WindowInsetsAnimationListener listener) {
- getListenerInfo().mWindowInsetsAnimationListener = listener;
+ public void setWindowInsetsAnimationCallback(@Nullable WindowInsetsAnimationCallback listener) {
+ getListenerInfo().mWindowInsetsAnimationCallback = listener;
}
- void dispatchWindowInsetsAnimationStarted(InsetsAnimation animation) {
- if (mListenerInfo != null && mListenerInfo.mWindowInsetsAnimationListener != null) {
- mListenerInfo.mWindowInsetsAnimationListener.onStarted(animation);
+ /**
+ * Dispatches {@link WindowInsetsAnimationCallback#onStarted(InsetsAnimation, AnimationBounds)}
+ * when Window Insets animation is started.
+ * @param animation current animation
+ * @param bounds the upper and lower {@link AnimationBounds} that provides range of
+ * {@link InsetsAnimation}.
+ * @return the upper and lower {@link AnimationBounds}.
+ */
+ @NonNull
+ public AnimationBounds dispatchWindowInsetsAnimationStarted(
+ @NonNull InsetsAnimation animation, @NonNull AnimationBounds bounds) {
+ if (mListenerInfo != null && mListenerInfo.mWindowInsetsAnimationCallback != null) {
+ return mListenerInfo.mWindowInsetsAnimationCallback.onStarted(animation, bounds);
}
+ return bounds;
}
- WindowInsets dispatchWindowInsetsAnimationProgress(WindowInsets insets) {
- if (mListenerInfo != null && mListenerInfo.mWindowInsetsAnimationListener != null) {
- return mListenerInfo.mWindowInsetsAnimationListener.onProgress(insets);
+ /**
+ * Dispatches {@link WindowInsetsAnimationCallback#onProgress(WindowInsets)}
+ * when Window Insets animation makes progress.
+ * @param insets The current {@link WindowInsets}.
+ * @return current {@link WindowInsets}.
+ */
+ @NonNull
+ public WindowInsets dispatchWindowInsetsAnimationProgress(@NonNull WindowInsets insets) {
+ if (mListenerInfo != null && mListenerInfo.mWindowInsetsAnimationCallback != null) {
+ return mListenerInfo.mWindowInsetsAnimationCallback.onProgress(insets);
} else {
return insets;
}
}
- void dispatchWindowInsetsAnimationFinished(InsetsAnimation animation) {
- if (mListenerInfo != null && mListenerInfo.mWindowInsetsAnimationListener != null) {
- mListenerInfo.mWindowInsetsAnimationListener.onFinished(animation);
+ /**
+ * Dispatches {@link WindowInsetsAnimationCallback#onFinished(InsetsAnimation)}
+ * when Window Insets animation finishes.
+ * @param animation The current ongoing {@link InsetsAnimation}.
+ */
+ public void dispatchWindowInsetsAnimationFinished(@NonNull InsetsAnimation animation) {
+ if (mListenerInfo != null && mListenerInfo.mWindowInsetsAnimationCallback != null) {
+ mListenerInfo.mWindowInsetsAnimationCallback.onFinished(animation);
}
}
@@ -11253,7 +11276,6 @@
* @return The {@link WindowInsetsController} or {@code null} if the view isn't attached to a
* a window.
* @see Window#getInsetsController()
- * @hide pending unhide
*/
public @Nullable WindowInsetsController getWindowInsetsController() {
if (mAttachInfo != null) {
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 853a302..4334bb5 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -51,7 +51,8 @@
import android.util.Pools.SynchronizedPool;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
-import android.view.WindowInsetsAnimationListener.InsetsAnimation;
+import android.view.WindowInsetsAnimationCallback.AnimationBounds;
+import android.view.WindowInsetsAnimationCallback.InsetsAnimation;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
@@ -7198,16 +7199,20 @@
}
@Override
- void dispatchWindowInsetsAnimationStarted(InsetsAnimation animation) {
- super.dispatchWindowInsetsAnimationStarted(animation);
+ @NonNull
+ public AnimationBounds dispatchWindowInsetsAnimationStarted(
+ @NonNull InsetsAnimation animation, @NonNull AnimationBounds bounds) {
+ super.dispatchWindowInsetsAnimationStarted(animation, bounds);
final int count = getChildCount();
for (int i = 0; i < count; i++) {
- getChildAt(i).dispatchWindowInsetsAnimationStarted(animation);
+ getChildAt(i).dispatchWindowInsetsAnimationStarted(animation, bounds);
}
+ return bounds;
}
@Override
- WindowInsets dispatchWindowInsetsAnimationProgress(WindowInsets insets) {
+ @NonNull
+ public WindowInsets dispatchWindowInsetsAnimationProgress(@NonNull WindowInsets insets) {
insets = super.dispatchWindowInsetsAnimationProgress(insets);
final int count = getChildCount();
for (int i = 0; i < count; i++) {
@@ -7217,7 +7222,7 @@
}
@Override
- void dispatchWindowInsetsAnimationFinished(InsetsAnimation animation) {
+ public void dispatchWindowInsetsAnimationFinished(@NonNull InsetsAnimation animation) {
super.dispatchWindowInsetsAnimationFinished(animation);
final int count = getChildCount();
for (int i = 0; i < count; i++) {
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 3171306..e3f0da1 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -19,12 +19,29 @@
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.View.PFLAG_DRAW_ANIMATION;
+import static android.view.View.SYSTEM_UI_FLAG_FULLSCREEN;
+import static android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
+import static android.view.View.SYSTEM_UI_FLAG_IMMERSIVE;
+import static android.view.View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
+import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
+import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
import static android.view.WindowCallbacks.RESIZE_MODE_DOCKED_DIVIDER;
import static android.view.WindowCallbacks.RESIZE_MODE_FREEFORM;
+import static android.view.WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_SWIPE;
+import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
+import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
+import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
+import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
+import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
+import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FIT_INSETS_CONTROLLED;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY;
+import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
+import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL;
+import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
+import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY;
import android.Manifest;
@@ -93,6 +110,7 @@
import android.view.View.AttachInfo;
import android.view.View.FocusDirection;
import android.view.View.MeasureSpec;
+import android.view.WindowInsets.Type;
import android.view.WindowInsets.Type.InsetsType;
import android.view.WindowManager.LayoutParams.SoftInputModeFlags;
import android.view.accessibility.AccessibilityEvent;
@@ -118,6 +136,7 @@
import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.IResultReceiver;
import com.android.internal.os.SomeArgs;
import com.android.internal.policy.PhoneFallbackEventHandler;
@@ -519,6 +538,9 @@
private WindowInsets mLastWindowInsets;
+ // Insets types hidden by legacy window flags or system UI flags.
+ private @InsetsType int mTypesHiddenByFlags = 0;
+
/** Last applied configuration obtained from resources. */
private final Configuration mLastConfigurationFromResources = new Configuration();
/** Last configuration reported from WM or via {@link #MSG_UPDATE_CONFIGURATION}. */
@@ -890,6 +912,7 @@
mOrigWindowType = mWindowAttributes.type;
mAttachInfo.mRecomputeGlobalAttributes = true;
collectViewAttributes();
+ adjustLayoutParamsForCompatibility(mWindowAttributes);
res = mWindowSession.addToDisplay(mWindow, mSeq, mWindowAttributes,
getHostVisibility(), mDisplay.getDisplayId(), mTmpFrame,
mAttachInfo.mContentInsets, mAttachInfo.mStableInsets,
@@ -1841,15 +1864,96 @@
private int getImpliedSystemUiVisibility(WindowManager.LayoutParams params) {
int vis = 0;
// Translucent decor window flags imply stable system ui visibility.
- if ((params.flags & WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) != 0) {
+ if ((params.flags & FLAG_TRANSLUCENT_STATUS) != 0) {
vis |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
}
- if ((params.flags & WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) != 0) {
+ if ((params.flags & FLAG_TRANSLUCENT_NAVIGATION) != 0) {
vis |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
}
return vis;
}
+ @VisibleForTesting
+ public static void adjustLayoutParamsForCompatibility(WindowManager.LayoutParams inOutParams) {
+ if (sNewInsetsMode != NEW_INSETS_MODE_FULL) {
+ return;
+ }
+ final int sysUiVis = inOutParams.systemUiVisibility | inOutParams.subtreeSystemUiVisibility;
+ final int flags = inOutParams.flags;
+ final int type = inOutParams.type;
+ final int adjust = inOutParams.softInputMode & SOFT_INPUT_MASK_ADJUST;
+
+ if ((sysUiVis & SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0) {
+ inOutParams.insetsFlags.behavior = BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
+ } else if ((sysUiVis & SYSTEM_UI_FLAG_IMMERSIVE) != 0) {
+ inOutParams.insetsFlags.behavior = BEHAVIOR_SHOW_BARS_BY_SWIPE;
+ }
+
+ if ((inOutParams.privateFlags & PRIVATE_FLAG_FIT_INSETS_CONTROLLED) != 0) {
+ return;
+ }
+
+ int types = inOutParams.getFitWindowInsetsTypes();
+ int sides = inOutParams.getFitWindowInsetsSides();
+ boolean ignoreVis = inOutParams.getFitIgnoreVisibility();
+
+ if (((sysUiVis & SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) != 0
+ || (flags & FLAG_LAYOUT_IN_SCREEN) != 0)
+ || (flags & FLAG_TRANSLUCENT_STATUS) != 0) {
+ types &= ~Type.statusBars();
+ }
+ if ((sysUiVis & SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0
+ || (flags & FLAG_TRANSLUCENT_NAVIGATION) != 0) {
+ types &= ~Type.systemBars();
+ }
+ if (type == TYPE_TOAST || type == TYPE_SYSTEM_ALERT) {
+ ignoreVis = true;
+ } else if ((types & Type.systemBars()) == Type.systemBars()
+ && adjust == SOFT_INPUT_ADJUST_RESIZE) {
+ types |= Type.ime();
+ }
+ inOutParams.setFitWindowInsetsTypes(types);
+ inOutParams.setFitWindowInsetsSides(sides);
+ inOutParams.setFitIgnoreVisibility(ignoreVis);
+
+ // The fitting of insets are not really controlled by the clients, so we remove the flag.
+ inOutParams.privateFlags &= ~PRIVATE_FLAG_FIT_INSETS_CONTROLLED;
+ }
+
+ private void controlInsetsForCompatibility(WindowManager.LayoutParams params) {
+ if (sNewInsetsMode != NEW_INSETS_MODE_FULL) {
+ return;
+ }
+ final int sysUiVis = params.systemUiVisibility | params.subtreeSystemUiVisibility;
+ final int flags = params.flags;
+ final boolean statusWasHiddenByFlags = (mTypesHiddenByFlags & Type.statusBars()) != 0;
+ final boolean statusIsHiddenByFlags = (sysUiVis & SYSTEM_UI_FLAG_FULLSCREEN) != 0
+ || (flags & FLAG_FULLSCREEN) != 0;
+ final boolean navWasHiddenByFlags = (mTypesHiddenByFlags & Type.navigationBars()) != 0;
+ final boolean navIsHiddenByFlags = (sysUiVis & SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0;
+
+ @InsetsType int typesToHide = 0;
+ @InsetsType int typesToShow = 0;
+ if (statusIsHiddenByFlags && !statusWasHiddenByFlags) {
+ typesToHide |= Type.statusBars();
+ } else if (!statusIsHiddenByFlags && statusWasHiddenByFlags) {
+ typesToShow |= Type.statusBars();
+ }
+ if (navIsHiddenByFlags && !navWasHiddenByFlags) {
+ typesToHide |= Type.navigationBars();
+ } else if (!navIsHiddenByFlags && navWasHiddenByFlags) {
+ typesToShow |= Type.navigationBars();
+ }
+ if (typesToHide != 0) {
+ getInsetsController().hide(typesToHide);
+ }
+ if (typesToShow != 0) {
+ getInsetsController().show(typesToShow);
+ }
+ mTypesHiddenByFlags |= typesToHide;
+ mTypesHiddenByFlags &= ~typesToShow;
+ }
+
private boolean measureHierarchy(final View host, final WindowManager.LayoutParams lp,
final Resources res, final int desiredWindowWidth, final int desiredWindowHeight) {
int childWidthMeasureSpec;
@@ -2271,6 +2375,8 @@
&& !PixelFormat.formatHasAlpha(params.format)) {
params.format = PixelFormat.TRANSLUCENT;
}
+ adjustLayoutParamsForCompatibility(params);
+ controlInsetsForCompatibility(params);
}
if (mFirst || windowShouldResize || insetsChanged ||
@@ -2757,7 +2863,7 @@
if (changedVisibility || regainedFocus) {
// Toasts are presented as notifications - don't present them as windows as well
boolean isToast = (mWindowAttributes == null) ? false
- : (mWindowAttributes.type == WindowManager.LayoutParams.TYPE_TOAST);
+ : (mWindowAttributes.type == TYPE_TOAST);
if (!isToast) {
host.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
@@ -4051,7 +4157,7 @@
}
boolean scrollToRectOrFocus(Rect rectangle, boolean immediate) {
- final Rect ci = mAttachInfo.mContentInsets;
+ final Rect ci = getWindowInsets(false).getSystemWindowInsetsAsRect();
final Rect vi = mAttachInfo.mVisibleInsets;
int scrollY = 0;
boolean handled = false;
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index d79abc2..ff31115 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -46,6 +46,8 @@
import android.transition.Scene;
import android.transition.Transition;
import android.transition.TransitionManager;
+import android.view.WindowInsets.Side.InsetsSide;
+import android.view.WindowInsets.Type.InsetsType;
import android.view.accessibility.AccessibilityEvent;
import java.util.Collections;
@@ -1241,6 +1243,60 @@
}
/**
+ * A shortcut for {@link WindowManager.LayoutParams#setFitWindowInsetsTypes(int)}
+ * @hide pending unhide
+ */
+ public void setFitWindowInsetsTypes(@InsetsType int types) {
+ final WindowManager.LayoutParams attrs = getAttributes();
+ attrs.setFitWindowInsetsTypes(types);
+ dispatchWindowAttributesChanged(attrs);
+ }
+
+ /**
+ * A shortcut for {@link WindowManager.LayoutParams#setFitWindowInsetsSides(int)}
+ * @hide pending unhide
+ */
+ public void setFitWindowInsetsSides(@InsetsSide int sides) {
+ final WindowManager.LayoutParams attrs = getAttributes();
+ attrs.setFitWindowInsetsSides(sides);
+ dispatchWindowAttributesChanged(attrs);
+ }
+
+ /**
+ * A shortcut for {@link WindowManager.LayoutParams#setFitIgnoreVisibility(boolean)}
+ * @hide pending unhide
+ */
+ public void setFitIgnoreVisibility(boolean ignore) {
+ final WindowManager.LayoutParams attrs = getAttributes();
+ attrs.setFitIgnoreVisibility(ignore);
+ dispatchWindowAttributesChanged(attrs);
+ }
+
+ /**
+ * A shortcut for {@link WindowManager.LayoutParams#getFitWindowInsetsTypes}
+ * @hide pending unhide
+ */
+ public @InsetsType int getFitWindowInsetsTypes() {
+ return getAttributes().getFitWindowInsetsTypes();
+ }
+
+ /**
+ * A shortcut for {@link WindowManager.LayoutParams#getFitWindowInsetsSides()}
+ * @hide pending unhide
+ */
+ public @InsetsSide int getFitWindowInsetsSides() {
+ return getAttributes().getFitWindowInsetsSides();
+ }
+
+ /**
+ * A shortcut for {@link WindowManager.LayoutParams#getFitIgnoreVisibility()}
+ * @hide pending unhide
+ */
+ public boolean getFitIgnoreVisibility() {
+ return getAttributes().getFitIgnoreVisibility();
+ }
+
+ /**
* Specify custom window attributes. <strong>PLEASE NOTE:</strong> the
* layout params you give here should generally be from values previously
* retrieved with {@link #getAttributes()}; you probably do not want to
@@ -2517,7 +2573,8 @@
/**
* @return The {@link WindowInsetsController} associated with this window
* @see View#getWindowInsetsController()
- * @hide pending unhide
*/
- public abstract @NonNull WindowInsetsController getInsetsController();
+ public @Nullable WindowInsetsController getInsetsController() {
+ return null;
+ }
}
diff --git a/core/java/android/view/WindowInsets.java b/core/java/android/view/WindowInsets.java
index 57bd5bb..2404c84 100644
--- a/core/java/android/view/WindowInsets.java
+++ b/core/java/android/view/WindowInsets.java
@@ -177,7 +177,7 @@
* @return The insets that include system bars indicated by {@code typeMask}, taken from
* {@code typeInsetsMap}.
*/
- private static Insets getInsets(Insets[] typeInsetsMap, @InsetsType int typeMask) {
+ static Insets getInsets(Insets[] typeInsetsMap, @InsetsType int typeMask) {
Insets result = null;
for (int i = FIRST; i <= LAST; i = i << 1) {
if ((typeMask & i) == 0) {
@@ -289,9 +289,8 @@
*
* @param typeMask Bit mask of {@link InsetsType}s to query the insets for.
* @return The insets.
- *
- * @hide pending unhide
*/
+ @NonNull
public Insets getInsets(@InsetsType int typeMask) {
return getInsets(mTypeInsetsMap, typeMask);
}
@@ -313,8 +312,8 @@
* insets are not available for this type as the height of the
* IME is dynamic depending on the {@link EditorInfo} of the
* currently focused view, as well as the UI state of the IME.
- * @hide pending unhide
*/
+ @NonNull
public Insets getMaxInsets(@InsetsType int typeMask) throws IllegalArgumentException {
if ((typeMask & IME) != 0) {
throw new IllegalArgumentException("Unable to query the maximum insets for IME");
@@ -329,7 +328,6 @@
* @param typeMask Bit mask of {@link Type.InsetsType}s to query visibility status.
* @return {@code true} if and only if all windows included in {@code typeMask} are currently
* visible on screen.
- * @hide pending unhide
*/
public boolean isVisible(@InsetsType int typeMask) {
for (int i = FIRST; i <= LAST; i = i << 1) {
@@ -874,7 +872,7 @@
return typeInsetsMap;
}
- private static Insets insetInsets(Insets insets, int left, int top, int right, int bottom) {
+ static Insets insetInsets(Insets insets, int left, int top, int right, int bottom) {
int newLeft = Math.max(0, insets.left - left);
int newTop = Math.max(0, insets.top - top);
int newRight = Math.max(0, insets.right - right);
@@ -1015,7 +1013,6 @@
* @param insets The insets to set.
*
* @return itself
- * @hide pending unhide
*/
@NonNull
public Builder setInsets(@InsetsType int typeMask, @NonNull Insets insets) {
@@ -1046,7 +1043,6 @@
* the IME is dynamic depending on the {@link EditorInfo}
* of the currently focused view, as well as the UI
* state of the IME.
- * @hide pending unhide
*/
@NonNull
public Builder setMaxInsets(@InsetsType int typeMask, @NonNull Insets insets)
@@ -1070,7 +1066,6 @@
* @param visible Whether to mark the windows as visible or not.
*
* @return itself
- * @hide pending unhide
*/
@NonNull
public Builder setVisible(@InsetsType int typeMask, boolean visible) {
@@ -1145,7 +1140,6 @@
/**
* Class that defines different types of sources causing window insets.
- * @hide pending unhide
*/
public static final class Type {
@@ -1295,4 +1289,31 @@
return 0xFFFFFFFF;
}
}
+
+ /**
+ * Class that defines different sides for insets.
+ * @hide pending unhide
+ */
+ public static final class Side {
+
+ public static final int LEFT = 1 << 0;
+ public static final int TOP = 1 << 1;
+ public static final int RIGHT = 1 << 2;
+ public static final int BOTTOM = 1 << 3;
+
+ private Side() {
+ }
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(flag = true, value = {LEFT, TOP, RIGHT, BOTTOM})
+ public @interface InsetsSide {}
+
+ /**
+ * @return all four sides.
+ */
+ public static @InsetsSide int all() {
+ return LEFT | TOP | RIGHT | BOTTOM;
+ }
+ }
}
diff --git a/core/java/android/view/WindowInsetsAnimationCallback.java b/core/java/android/view/WindowInsetsAnimationCallback.java
new file mode 100644
index 0000000..8ae8520
--- /dev/null
+++ b/core/java/android/view/WindowInsetsAnimationCallback.java
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2019 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 android.view;
+
+import android.annotation.FloatRange;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.graphics.Insets;
+import android.view.WindowInsets.Type.InsetsType;
+import android.view.animation.Interpolator;
+
+/**
+ * Interface that allows the application to listen to animation events for windows that cause
+ * insets.
+ */
+public interface WindowInsetsAnimationCallback {
+
+ /**
+ * Called when an inset animation gets started.
+ * <p>
+ * Note that, like {@link #onProgress}, dispatch of the animation start event is hierarchical:
+ * It will starts at the root of the view hierarchy and then traverse it and invoke the callback
+ * of the specific {@link View} that is being traversed. The method my return a modified
+ * instance of the bounds by calling {@link AnimationBounds#inset} to indicate that a part of
+ * the insets have been used to offset or clip its children, and the children shouldn't worry
+ * about that part anymore.
+ *
+ * @param animation The animation that is about to start.
+ * @param bounds The bounds in which animation happens.
+ * @return The animation representing the part of the insets that should be dispatched to the
+ * subtree of the hierarchy.
+ */
+ @NonNull
+ default AnimationBounds onStarted(
+ @NonNull InsetsAnimation animation, @NonNull AnimationBounds bounds) {
+ return bounds;
+ }
+
+ /**
+ * Called when the insets change as part of running an animation. Note that even if multiple
+ * animations for different types are running, there will only be one progress callback per
+ * frame. The {@code insets} passed as an argument represents the overall state and will include
+ * all types, regardless of whether they are animating or not.
+ * <p>
+ * Note that insets dispatch is hierarchical: It will start at the root of the view hierarchy,
+ * and then traverse it and invoke the callback of the specific {@link View} being traversed.
+ * The method may return a modified instance by calling
+ * {@link WindowInsets#inset(int, int, int, int)} to indicate that a part of the insets have
+ * been used to offset or clip its children, and the children shouldn't worry about that part
+ * anymore.
+ * TODO: Introduce a way to map (type -> InsetAnimation) so app developer can query animation
+ * for a given type e.g. callback.getAnimation(type) OR controller.getAnimation(type).
+ * Or on the controller directly?
+ * @param insets The current insets.
+ * @return The insets to dispatch to the subtree of the hierarchy.
+ */
+ @NonNull
+ WindowInsets onProgress(@NonNull WindowInsets insets);
+
+ /**
+ * Called when an inset animation has finished.
+ *
+ * @param animation The animation that has finished running. This will be the same instance as
+ * passed into {@link #onStarted}
+ */
+ default void onFinished(@NonNull InsetsAnimation animation) {
+ }
+
+ /**
+ * Class representing an animation of a set of windows that cause insets.
+ */
+ final class InsetsAnimation {
+
+ private final @InsetsType int mTypeMask;
+ private float mFraction;
+ @Nullable private final Interpolator mInterpolator;
+ private long mDurationMs;
+
+ public InsetsAnimation(
+ @InsetsType int typeMask, @Nullable Interpolator interpolator, long durationMs) {
+ mTypeMask = typeMask;
+ mInterpolator = interpolator;
+ mDurationMs = durationMs;
+ }
+
+ /**
+ * @return The bitmask of {@link WindowInsets.Type.InsetsType}s that are animating.
+ */
+ public @InsetsType int getTypeMask() {
+ return mTypeMask;
+ }
+
+ /**
+ * Returns the raw fractional progress of this animation between
+ * {@link AnimationBounds#getLowerBound()} and {@link AnimationBounds#getUpperBound()}. Note
+ * that this progress is the global progress of the animation, whereas
+ * {@link WindowInsetsAnimationCallback#onProgress} will only dispatch the insets that may
+ * be inset with {@link WindowInsets#inset} by parents of views in the hierarchy.
+ * Progress per insets animation is global for the entire animation. One animation animates
+ * all things together (in, out, ...). If they don't animate together, we'd have
+ * multiple animations.
+ *
+ * @return The current progress of this animation.
+ */
+ @FloatRange(from = 0f, to = 1f)
+ public float getFraction() {
+ return mFraction;
+ }
+
+ /**
+ * Returns the interpolated fractional progress of this animation between
+ * {@link AnimationBounds#getLowerBound()} and {@link AnimationBounds#getUpperBound()}. Note
+ * that this progress is the global progress of the animation, whereas
+ * {@link WindowInsetsAnimationCallback#onProgress} will only dispatch the insets that may
+ * be inset with {@link WindowInsets#inset} by parents of views in the hierarchy.
+ * Progress per insets animation is global for the entire animation. One animation animates
+ * all things together (in, out, ...). If they don't animate together, we'd have
+ * multiple animations.
+ * @see #getFraction() for raw fraction.
+ * @return The current interpolated progress of this animation. -1 if interpolator isn't
+ * specified.
+ */
+ public float getInterpolatedFraction() {
+ if (mInterpolator != null) {
+ return mInterpolator.getInterpolation(mFraction);
+ }
+ return -1;
+ }
+
+ @Nullable
+ public Interpolator getInterpolator() {
+ return mInterpolator;
+ }
+
+ /**
+ * @return duration of animation in {@link java.util.concurrent.TimeUnit#MILLISECONDS}.
+ */
+ public long getDurationMillis() {
+ return mDurationMs;
+ }
+
+ /**
+ * Set fraction of the progress if {@link WindowInsets.Type.InsetsType} animation is
+ * controlled by the app {@see #getCurrentFraction}.
+ * <p>Note: If app didn't create {@link InsetsAnimation}, it shouldn't set progress either.
+ * Progress would be set by system with the system-default animation.
+ * </p>
+ * @param fraction fractional progress between 0 and 1 where 0 represents hidden and
+ * zero progress and 1 represent fully shown final state.
+ */
+ public void setFraction(@FloatRange(from = 0f, to = 1f) float fraction) {
+ mFraction = fraction;
+ }
+
+ /**
+ * Set duration of the animation if {@link WindowInsets.Type.InsetsType} animation is
+ * controlled by the app.
+ * <p>Note: If app didn't create {@link InsetsAnimation}, it shouldn't set duration either.
+ * Duration would be set by system with the system-default animation.
+ * </p>
+ * @param durationMs in {@link java.util.concurrent.TimeUnit#MILLISECONDS}
+ */
+ public void setDuration(long durationMs) {
+ mDurationMs = durationMs;
+ }
+ }
+
+ /**
+ * Class representing the range of an {@link InsetsAnimation}
+ */
+ final class AnimationBounds {
+ private final Insets mLowerBound;
+ private final Insets mUpperBound;
+
+ public AnimationBounds(@NonNull Insets lowerBound, @NonNull Insets upperBound) {
+ mLowerBound = lowerBound;
+ mUpperBound = upperBound;
+ }
+
+ /**
+ * Queries the lower inset bound of the animation. If the animation is about showing or
+ * hiding a window that cause insets, the lower bound is {@link Insets#NONE} and the upper
+ * bound is the same as {@link WindowInsets#getInsets(int)} for the fully shown state. This
+ * is the same as {@link WindowInsetsAnimationController#getHiddenStateInsets} and
+ * {@link WindowInsetsAnimationController#getShownStateInsets} in case the listener gets
+ * invoked because of an animation that originates from
+ * {@link WindowInsetsAnimationController}.
+ * <p>
+ * However, if the size of a window that causes insets is changing, these are the
+ * lower/upper bounds of that size animation.
+ * </p>
+ * There are no overlapping animations for a specific type, but there may be multiple
+ * animations running at the same time for different inset types.
+ *
+ * @see #getUpperBound()
+ * @see WindowInsetsAnimationController#getHiddenStateInsets
+ */
+ @NonNull
+ public Insets getLowerBound() {
+ return mLowerBound;
+ }
+
+ /**
+ * Queries the upper inset bound of the animation. If the animation is about showing or
+ * hiding a window that cause insets, the lower bound is {@link Insets#NONE}
+ * nd the upper bound is the same as {@link WindowInsets#getInsets(int)} for the fully
+ * shown state. This is the same as
+ * {@link WindowInsetsAnimationController#getHiddenStateInsets} and
+ * {@link WindowInsetsAnimationController#getShownStateInsets} in case the listener gets
+ * invoked because of an animation that originates from
+ * {@link WindowInsetsAnimationController}.
+ * <p>
+ * However, if the size of a window that causes insets is changing, these are the
+ * lower/upper bounds of that size animation.
+ * <p>
+ * There are no overlapping animations for a specific type, but there may be multiple
+ * animations running at the same time for different inset types.
+ *
+ * @see #getLowerBound()
+ * @see WindowInsetsAnimationController#getShownStateInsets
+ */
+ @NonNull
+ public Insets getUpperBound() {
+ return mUpperBound;
+ }
+
+ /**
+ * Insets both the lower and upper bound by the specified insets. This is to be used in
+ * {@link WindowInsetsAnimationCallback#onStarted} to indicate that a part of the insets has
+ * been used to offset or clip its children, and the children shouldn't worry about that
+ * part anymore.
+ *
+ * @param insets The amount to inset.
+ * @return A copy of this instance inset in the given directions.
+ * @see WindowInsets#inset
+ * @see WindowInsetsAnimationCallback#onStarted
+ */
+ @NonNull
+ public AnimationBounds inset(@NonNull Insets insets) {
+ return new AnimationBounds(
+ // TODO: refactor so that WindowInsets.insetInsets() is in a more appropriate
+ // place eventually.
+ WindowInsets.insetInsets(
+ mLowerBound, insets.left, insets.top, insets.right, insets.bottom),
+ WindowInsets.insetInsets(
+ mUpperBound, insets.left, insets.top, insets.right, insets.bottom));
+ }
+ }
+}
diff --git a/core/java/android/view/WindowInsetsAnimationControlListener.java b/core/java/android/view/WindowInsetsAnimationControlListener.java
index 33fb327..8a226c1 100644
--- a/core/java/android/view/WindowInsetsAnimationControlListener.java
+++ b/core/java/android/view/WindowInsetsAnimationControlListener.java
@@ -22,19 +22,17 @@
/**
* Interface that informs the client about {@link WindowInsetsAnimationController} state changes.
- * @hide pending unhide
*/
public interface WindowInsetsAnimationControlListener {
/**
- * Gets called as soon as the animation is ready to be controlled. This may be
- * delayed when the IME needs to redraw because of an {@link EditorInfo} change, or when the
- * window is starting up.
+ * Called when the animation is ready to be controlled. This may be delayed when the IME needs
+ * to redraw because of an {@link EditorInfo} change, or when the window is starting up.
*
* @param controller The controller to control the inset animation.
* @param types The {@link InsetsType}s it was able to gain control over. Note that this may be
* different than the types passed into
- * {@link WindowInsetsController#controlWindowInsetsAnimation} in case the window
+ * {@link WindowInsetsController#controlInputMethodAnimation} in case the window
* wasn't able to gain the controls because it wasn't the IME target or not
* currently the window that's controlling the system bars.
*/
diff --git a/core/java/android/view/WindowInsetsAnimationController.java b/core/java/android/view/WindowInsetsAnimationController.java
index 5cbf3b8..5149103 100644
--- a/core/java/android/view/WindowInsetsAnimationController.java
+++ b/core/java/android/view/WindowInsetsAnimationController.java
@@ -16,83 +16,127 @@
package android.view;
+import android.annotation.FloatRange;
import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SuppressLint;
import android.graphics.Insets;
import android.view.WindowInsets.Type.InsetsType;
-import android.view.WindowInsetsAnimationListener.InsetsAnimation;
+import android.view.WindowInsetsAnimationCallback.AnimationBounds;
/**
- * Interface to control a window inset animation frame-by-frame.
- * @hide pending unhide
+ * Controller for app-driven animation of system windows.
+ * <p>
+ * {@code WindowInsetsAnimationController} lets apps animate system windows such as
+ * the {@link android.inputmethodservice.InputMethodService IME}. The animation is
+ * synchronized, such that changes the system windows and the app's current frame
+ * are rendered at the same time.
+ * <p>
+ * Control is obtained through {@link WindowInsetsController#controlInputMethodAnimation}.
*/
+@SuppressLint("NotClosable")
public interface WindowInsetsAnimationController {
/**
* Retrieves the {@link Insets} when the windows this animation is controlling are fully hidden.
* <p>
+ * Note that these insets are always relative to the window, which is the same as being relative
+ * to {@link View#getRootView}
+ * <p>
* If there are any animation listeners registered, this value is the same as
- * {@link InsetsAnimation#getLowerBound()} that will be passed into the callbacks.
+ * {@link AnimationBounds#getLowerBound()} that is being be passed into the root view of the
+ * hierarchy.
*
* @return Insets when the windows this animation is controlling are fully hidden.
*
- * @see InsetsAnimation#getLowerBound()
+ * @see AnimationBounds#getLowerBound()
*/
@NonNull Insets getHiddenStateInsets();
/**
* Retrieves the {@link Insets} when the windows this animation is controlling are fully shown.
* <p>
- * In case the size of a window causing insets is changing in the middle of the animation, we
- * execute that height change after this animation has finished.
+ * Note that these insets are always relative to the window, which is the same as being relative
+ * to {@link View#getRootView}
* <p>
* If there are any animation listeners registered, this value is the same as
- * {@link InsetsAnimation#getUpperBound()} that will be passed into the callbacks.
+ * {@link AnimationBounds#getUpperBound()} that is being passed into the root view of hierarchy.
*
* @return Insets when the windows this animation is controlling are fully shown.
*
- * @see InsetsAnimation#getUpperBound()
+ * @see AnimationBounds#getUpperBound()
*/
@NonNull Insets getShownStateInsets();
/**
- * @return The current insets on the window. These will follow any animation changes.
+ * Retrieves the current insets.
+ * <p>
+ * Note that these insets are always relative to the window, which is the same as
+ * being relative
+ * to {@link View#getRootView}
+ * @return The current insets on the currently showing frame. These insets will change as the
+ * animation progresses to reflect the current insets provided by the controlled window.
*/
@NonNull Insets getCurrentInsets();
/**
+ * Returns the progress as previously set by {@code fraction} in {@link #setInsetsAndAlpha}
+ *
+ * @return the progress of the animation, where {@code 0} is fully hidden and {@code 1} is
+ * fully shown.
+ * <p>
+ * Note: this value represents raw overall progress of the animation
+ * i.e. the combined progress of insets and alpha.
+ * <p>
+ */
+ @FloatRange(from = 0f, to = 1f)
+ float getCurrentFraction();
+
+ /**
* @return The {@link InsetsType}s this object is currently controlling.
*/
@InsetsType int getTypes();
/**
- * Modifies the insets by indirectly moving the windows around in the system that are causing
- * window insets.
+ * Modifies the insets for the frame being drawn by indirectly moving the windows around in the
+ * system that are causing window insets.
* <p>
- * Note that this will <b>not</b> inform the view system of a full inset change via
+ * Note that these insets are always relative to the window, which is the same as being relative
+ * to {@link View#getRootView}
+ * <p>
+ * Also note that this will <b>not</b> inform the view system of a full inset change via
* {@link View#dispatchApplyWindowInsets} in order to avoid a full layout pass during the
* animation. If you'd like to animate views during a window inset animation, register a
- * {@link WindowInsetsAnimationListener} by calling
- * {@link View#setWindowInsetsAnimationListener(WindowInsetsAnimationListener)} that will be
- * notified about any insets change via {@link WindowInsetsAnimationListener#onProgress} during
+ * {@link WindowInsetsAnimationCallback} by calling
+ * {@link View#setWindowInsetsAnimationCallback(WindowInsetsAnimationCallback)} that will be
+ * notified about any insets change via {@link WindowInsetsAnimationCallback#onProgress} during
* the animation.
* <p>
* {@link View#dispatchApplyWindowInsets} will instead be called once the animation has
* finished, i.e. once {@link #finish} has been called.
+ * Note: If there are no insets, alpha animation is still applied.
*
* @param insets The new insets to apply. Based on the requested insets, the system will
* calculate the positions of the windows in the system causing insets such that
* the resulting insets of that configuration will match the passed in parameter.
* Note that these insets are being clamped to the range from
- * {@link #getHiddenStateInsets} to {@link #getShownStateInsets}
+ * {@link #getHiddenStateInsets} to {@link #getShownStateInsets}.
+ * If you intend on changing alpha only, pass null or {@link #getCurrentInsets()}.
+ * @param alpha The new alpha to apply to the inset side.
+ * @param fraction instantaneous animation progress. This value is dispatched to
+ * {@link WindowInsetsAnimationCallback}.
*
- * @see WindowInsetsAnimationListener
- * @see View#setWindowInsetsAnimationListener(WindowInsetsAnimationListener)
+ * @see WindowInsetsAnimationCallback
+ * @see View#setWindowInsetsAnimationCallback(WindowInsetsAnimationCallback)
*/
- void changeInsets(@NonNull Insets insets);
+ void setInsetsAndAlpha(@Nullable Insets insets, @FloatRange(from = 0f, to = 1f) float alpha,
+ @FloatRange(from = 0f, to = 1f) float fraction);
/**
- * @param shownTypes The list of windows causing insets that should remain shown after finishing
- * the animation.
+ * Finishes the animation, and leaves the windows shown or hidden. After invoking
+ * {@link #finish(boolean)}, this instance is no longer valid.
+ * @param shown if {@code true}, the windows will be shown after finishing the
+ * animation. Otherwise they will be hidden.
*/
- void finish(@InsetsType int shownTypes);
+ void finish(boolean shown);
}
diff --git a/core/java/android/view/WindowInsetsAnimationListener.java b/core/java/android/view/WindowInsetsAnimationListener.java
deleted file mode 100644
index f734b4b..0000000
--- a/core/java/android/view/WindowInsetsAnimationListener.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2018 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 android.view;
-
-import android.graphics.Insets;
-
-/**
- * Interface that allows the application to listen to animation events for windows that cause
- * insets.
- * @hide pending unhide
- */
-public interface WindowInsetsAnimationListener {
-
- /**
- * Called when an inset animation gets started.
- *
- * @param animation The animation that is about to start.
- */
- void onStarted(InsetsAnimation animation);
-
- /**
- * Called when the insets change as part of running an animation. Note that even if multiple
- * animations for different types are running, there will only be one progress callback per
- * frame. The {@code insets} passed as an argument represents the overall state and will include
- * all types, regardless of whether they are animating or not.
- * <p>
- * Note that insets dispatch is hierarchical: It will start at the root of the view hierarchy,
- * and then traverse it and invoke the callback of the specific {@link View} being traversed.
- * The callback may return a modified instance by calling {@link WindowInsets#inset(int, int, int, int)}
- * to indicate that a part of the insets have been used to offset or clip its children, and the
- * children shouldn't worry about that part anymore.
- *
- * @param insets The current insets.
- * @return The insets to dispatch to the subtree of the hierarchy.
- */
- WindowInsets onProgress(WindowInsets insets);
-
- /**
- * Called when an inset animation has finished.
- *
- * @param animation The animation that has finished running.
- */
- void onFinished(InsetsAnimation animation);
-
- /**
- * Class representing an animation of a set of windows that cause insets.
- */
- class InsetsAnimation {
-
- private final @WindowInsets.Type.InsetsType int mTypeMask;
- private final Insets mLowerBound;
- private final Insets mUpperBound;
-
- /**
- * @hide
- */
- InsetsAnimation(int typeMask, Insets lowerBound, Insets upperBound) {
- mTypeMask = typeMask;
- mLowerBound = lowerBound;
- mUpperBound = upperBound;
- }
-
- /**
- * @return The bitmask of {@link WindowInsets.Type.InsetsType}s that are animating.
- */
- public @WindowInsets.Type.InsetsType int getTypeMask() {
- return mTypeMask;
- }
-
- /**
- * Queries the lower inset bound of the animation. If the animation is about showing or
- * hiding a window that cause insets, the lower bound is {@link Insets#NONE} and the upper
- * bound is the same as {@link WindowInsets#getInsets(int)} for the fully shown state. This
- * is the same as {@link WindowInsetsAnimationController#getHiddenStateInsets} and
- * {@link WindowInsetsAnimationController#getShownStateInsets} in case the listener gets
- * invoked because of an animation that originates from
- * {@link WindowInsetsAnimationController}.
- * <p>
- * However, if the size of a window that causes insets is changing, these are the
- * lower/upper bounds of that size animation.
- * <p>
- * There are no overlapping animations for a specific type, but there may be two animations
- * running at the same time for different inset types.
- *
- * @see #getUpperBound()
- * @see WindowInsetsAnimationController#getHiddenStateInsets
- * TODO: It's a bit weird that these are global per window but onProgress is hierarchical.
- * TODO: If multiple types are animating, querying the bound per type isn't possible. Should
- * we:
- * 1. Offer bounds by type here?
- * 2. Restrict one animation to one single type only?
- * Returning WindowInsets here isn't feasible in case of overlapping animations: We can't
- * fill in the insets for the types from the other animation into the WindowInsets object
- * as it's changing as well.
- */
- public Insets getLowerBound() {
- return mLowerBound;
- }
-
- /**
- * @see #getLowerBound()
- * @see WindowInsetsAnimationController#getShownStateInsets
- */
- public Insets getUpperBound() {
- return mUpperBound;
- }
- }
-}
diff --git a/core/java/android/view/WindowInsetsController.java b/core/java/android/view/WindowInsetsController.java
index 39e2e73..6de56be 100644
--- a/core/java/android/view/WindowInsetsController.java
+++ b/core/java/android/view/WindowInsetsController.java
@@ -30,7 +30,6 @@
* Interface to control windows that generate insets.
*
* TODO Needs more information and examples once the API is more baked.
- * @hide pending unhide
*/
public interface WindowInsetsController {
@@ -64,7 +63,10 @@
*/
int APPEARANCE_LIGHT_NAVIGATION_BARS = 1 << 4;
- /** Determines the appearance of system bars. */
+ /**
+ * Determines the appearance of system bars.
+ * @hide
+ */
@Retention(RetentionPolicy.SOURCE)
@IntDef(flag = true, value = {APPEARANCE_OPAQUE_STATUS_BARS, APPEARANCE_OPAQUE_NAVIGATION_BARS,
APPEARANCE_LOW_PROFILE_BARS, APPEARANCE_LIGHT_STATUS_BARS,
@@ -75,33 +77,40 @@
/**
* The default option for {@link #setSystemBarsBehavior(int)}. System bars will be forcibly
* shown on any user interaction on the corresponding display if navigation bars are hidden by
- * {@link #hide(int)} or {@link WindowInsetsAnimationController#changeInsets(Insets)}.
+ * {@link #hide(int)} or
+ * {@link WindowInsetsAnimationController#setInsetsAndAlpha(Insets, float, float)}.
+ * @hide
*/
int BEHAVIOR_SHOW_BARS_BY_TOUCH = 0;
/**
* Option for {@link #setSystemBarsBehavior(int)}: Window would like to remain interactive when
* hiding navigation bars by calling {@link #hide(int)} or
- * {@link WindowInsetsAnimationController#changeInsets(Insets)}.
+ * {@link WindowInsetsAnimationController#setInsetsAndAlpha(Insets, float, float)}.
*
* <p>When system bars are hidden in this mode, they can be revealed with system gestures, such
* as swiping from the edge of the screen where the bar is hidden from.</p>
+ * @hide
*/
int BEHAVIOR_SHOW_BARS_BY_SWIPE = 1;
/**
* Option for {@link #setSystemBarsBehavior(int)}: Window would like to remain interactive when
* hiding navigation bars by calling {@link #hide(int)} or
- * {@link WindowInsetsAnimationController#changeInsets(Insets)}.
+ * {@link WindowInsetsAnimationController#setInsetsAndAlpha(Insets, float, float)}.
*
* <p>When system bars are hidden in this mode, they can be revealed temporarily with system
* gestures, such as swiping from the edge of the screen where the bar is hidden from. These
* transient system bars will overlay app’s content, may have some degree of transparency, and
* will automatically hide after a short timeout.</p>
+ * @hide
*/
int BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE = 2;
- /** Determines the behavior of system bars when hiding them by calling {@link #hide}. */
+ /**
+ * Determines the behavior of system bars when hiding them by calling {@link #hide}.
+ * @hide
+ */
@Retention(RetentionPolicy.SOURCE)
@IntDef(value = {BEHAVIOR_SHOW_BARS_BY_TOUCH, BEHAVIOR_SHOW_BARS_BY_SWIPE,
BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE})
@@ -139,23 +148,27 @@
* the position of the windows in the system causing insets directly.
*
* @param types The {@link InsetsType}s the application has requested to control.
+ * @param durationMillis duration of animation in
+ * {@link java.util.concurrent.TimeUnit#MILLISECONDS}
* @param listener The {@link WindowInsetsAnimationControlListener} that gets called when the
* windows are ready to be controlled, among other callbacks.
* @hide
*/
- void controlWindowInsetsAnimation(@InsetsType int types,
+ void controlWindowInsetsAnimation(@InsetsType int types, long durationMillis,
@NonNull WindowInsetsAnimationControlListener listener);
/**
* Lets the application control the animation for showing the IME in a frame-by-frame manner by
* modifying the position of the IME when it's causing insets.
*
+ * @param durationMillis duration of the animation in
+ * {@link java.util.concurrent.TimeUnit#MILLISECONDS}
* @param listener The {@link WindowInsetsAnimationControlListener} that gets called when the
* IME are ready to be controlled, among other callbacks.
*/
- default void controlInputMethodAnimation(
+ default void controlInputMethodAnimation(long durationMillis,
@NonNull WindowInsetsAnimationControlListener listener) {
- controlWindowInsetsAnimation(ime(), listener);
+ controlWindowInsetsAnimation(ime(), durationMillis, listener);
}
/**
@@ -166,7 +179,7 @@
* the event by observing {@link View#onApplyWindowInsets} and checking visibility with
* {@link WindowInsets#isVisible}.
*
- * @see #controlInputMethodAnimation(WindowInsetsAnimationControlListener)
+ * @see #controlInputMethodAnimation(long, WindowInsetsAnimationControlListener)
* @see #hideInputMethod()
*/
default void showInputMethod() {
@@ -181,7 +194,7 @@
* the event by observing {@link View#onApplyWindowInsets} and checking visibility with
* {@link WindowInsets#isVisible}.
*
- * @see #controlInputMethodAnimation(WindowInsetsAnimationControlListener)
+ * @see #controlInputMethodAnimation(long, WindowInsetsAnimationControlListener)
* @see #showInputMethod()
*/
default void hideInputMethod() {
@@ -203,4 +216,9 @@
* @see Behavior
*/
void setSystemBarsBehavior(@Behavior int behavior);
+
+ /**
+ * @hide
+ */
+ InsetsState getState();
}
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 9d5f98e..3b6c55b 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -17,11 +17,26 @@
package android.view;
import static android.content.pm.ActivityInfo.COLOR_MODE_DEFAULT;
+import static android.view.WindowInsets.Side.BOTTOM;
+import static android.view.WindowInsets.Side.LEFT;
+import static android.view.WindowInsets.Side.RIGHT;
+import static android.view.WindowInsets.Side.TOP;
+import static android.view.WindowInsets.Type.CAPTION_BAR;
+import static android.view.WindowInsets.Type.IME;
+import static android.view.WindowInsets.Type.MANDATORY_SYSTEM_GESTURES;
+import static android.view.WindowInsets.Type.NAVIGATION_BARS;
+import static android.view.WindowInsets.Type.STATUS_BARS;
+import static android.view.WindowInsets.Type.SYSTEM_GESTURES;
+import static android.view.WindowInsets.Type.TAPPABLE_ELEMENT;
+import static android.view.WindowInsets.Type.WINDOW_DECOR;
import static android.view.WindowLayoutParamsProto.ALPHA;
import static android.view.WindowLayoutParamsProto.APPEARANCE;
import static android.view.WindowLayoutParamsProto.BEHAVIOR;
import static android.view.WindowLayoutParamsProto.BUTTON_BRIGHTNESS;
import static android.view.WindowLayoutParamsProto.COLOR_MODE;
+import static android.view.WindowLayoutParamsProto.FIT_IGNORE_VISIBILITY;
+import static android.view.WindowLayoutParamsProto.FIT_INSETS_SIDES;
+import static android.view.WindowLayoutParamsProto.FIT_INSETS_TYPES;
import static android.view.WindowLayoutParamsProto.FLAGS;
import static android.view.WindowLayoutParamsProto.FORMAT;
import static android.view.WindowLayoutParamsProto.GRAVITY;
@@ -65,6 +80,10 @@
import android.text.TextUtils;
import android.util.Log;
import android.util.proto.ProtoOutputStream;
+import android.view.WindowInsets.Side;
+import android.view.WindowInsets.Side.InsetsSide;
+import android.view.WindowInsets.Type;
+import android.view.WindowInsets.Type.InsetsType;
import android.view.accessibility.AccessibilityNodeInfo;
import java.lang.annotation.Retention;
@@ -1294,14 +1313,11 @@
* set for you by Window as described in {@link Window#setFlags}.*/
public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000;
- /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with
- * respect to how this window interacts with the current method. That
- * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the
- * window will behave as if it needs to interact with the input method
- * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is
- * not set and this flag is set, then the window will behave as if it
- * doesn't need to interact with the input method and can be placed
- * to use more space and cover the input method.
+ /** Window flag: When set, input method can't interact with the focusable window
+ * and can be placed to use more space and cover the input method.
+ * Note: When combined with {@link #FLAG_NOT_FOCUSABLE}, this flag has no
+ * effect since input method cannot interact with windows having {@link #FLAG_NOT_FOCUSABLE}
+ * flag set.
*/
public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
@@ -1840,6 +1856,20 @@
public static final int PRIVATE_FLAG_USE_BLAST = 0x02000000;
/**
+ * Flag to indicate that the window is controlling how it fits window insets on its own.
+ * So we don't need to adjust its attributes for fitting window insets.
+ * @hide
+ */
+ public static final int PRIVATE_FLAG_FIT_INSETS_CONTROLLED = 0x04000000;
+
+ /**
+ * Flag to indicate that the window only draws the bottom bar background so that we don't
+ * extend it to system bar areas at other sides.
+ * @hide
+ */
+ public static final int PRIVATE_FLAG_ONLY_DRAW_BOTTOM_BAR_BACKGROUND = 0x08000000;
+
+ /**
* An internal annotation for flags that can be specified to {@link #softInputMode}.
*
* @hide
@@ -1941,7 +1971,15 @@
@ViewDebug.FlagToString(
mask = PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC,
equals = PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC,
- name = "COLOR_SPACE_AGNOSTIC")
+ name = "COLOR_SPACE_AGNOSTIC"),
+ @ViewDebug.FlagToString(
+ mask = PRIVATE_FLAG_FIT_INSETS_CONTROLLED,
+ equals = PRIVATE_FLAG_FIT_INSETS_CONTROLLED,
+ name = "FIT_INSETS_CONTROLLED"),
+ @ViewDebug.FlagToString(
+ mask = PRIVATE_FLAG_ONLY_DRAW_BOTTOM_BAR_BACKGROUND,
+ equals = PRIVATE_FLAG_ONLY_DRAW_BOTTOM_BAR_BACKGROUND,
+ name = "ONLY_DRAW_BOTTOM_BAR_BACKGROUND")
})
@TestApi
public int privateFlags;
@@ -1957,16 +1995,12 @@
*
* @param flags The current window manager flags.
*
- * @return Returns true if such a window should be behind/interact
- * with an input method, false if not.
+ * @return Returns {@code true} if such a window should be behind/interact
+ * with an input method, {@code false} if not.
*/
public static boolean mayUseInputMethod(int flags) {
- switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
- case 0:
- case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM:
- return true;
- }
- return false;
+ return (flags & FLAG_NOT_FOCUSABLE) != FLAG_NOT_FOCUSABLE
+ && (flags & FLAG_ALT_FOCUSABLE_IM) != FLAG_ALT_FOCUSABLE_IM;
}
/**
@@ -2591,6 +2625,124 @@
*/
public final InsetsFlags insetsFlags = new InsetsFlags();
+ @ViewDebug.ExportedProperty(flagMapping = {
+ @ViewDebug.FlagToString(
+ mask = STATUS_BARS,
+ equals = STATUS_BARS,
+ name = "STATUS_BARS"),
+ @ViewDebug.FlagToString(
+ mask = NAVIGATION_BARS,
+ equals = NAVIGATION_BARS,
+ name = "NAVIGATION_BARS"),
+ @ViewDebug.FlagToString(
+ mask = CAPTION_BAR,
+ equals = CAPTION_BAR,
+ name = "CAPTION_BAR"),
+ @ViewDebug.FlagToString(
+ mask = IME,
+ equals = IME,
+ name = "IME"),
+ @ViewDebug.FlagToString(
+ mask = SYSTEM_GESTURES,
+ equals = SYSTEM_GESTURES,
+ name = "SYSTEM_GESTURES"),
+ @ViewDebug.FlagToString(
+ mask = MANDATORY_SYSTEM_GESTURES,
+ equals = MANDATORY_SYSTEM_GESTURES,
+ name = "MANDATORY_SYSTEM_GESTURES"),
+ @ViewDebug.FlagToString(
+ mask = TAPPABLE_ELEMENT,
+ equals = TAPPABLE_ELEMENT,
+ name = "TAPPABLE_ELEMENT"),
+ @ViewDebug.FlagToString(
+ mask = WINDOW_DECOR,
+ equals = WINDOW_DECOR,
+ name = "WINDOW_DECOR")
+ })
+ private @InsetsType int mFitWindowInsetsTypes = Type.systemBars();
+
+ @ViewDebug.ExportedProperty(flagMapping = {
+ @ViewDebug.FlagToString(
+ mask = LEFT,
+ equals = LEFT,
+ name = "LEFT"),
+ @ViewDebug.FlagToString(
+ mask = TOP,
+ equals = TOP,
+ name = "TOP"),
+ @ViewDebug.FlagToString(
+ mask = RIGHT,
+ equals = RIGHT,
+ name = "RIGHT"),
+ @ViewDebug.FlagToString(
+ mask = BOTTOM,
+ equals = BOTTOM,
+ name = "BOTTOM")
+ })
+ private @InsetsSide int mFitWindowInsetsSides = Side.all();
+
+ private boolean mFitIgnoreVisibility = false;
+
+ /**
+ * Specifies types of insets that this window should avoid overlapping during layout.
+ *
+ * @param types which types of insets that this window should avoid. The initial value of
+ * this object includes all system bars.
+ * @hide pending unhide
+ */
+ public void setFitWindowInsetsTypes(@InsetsType int types) {
+ mFitWindowInsetsTypes = types;
+ privateFlags |= PRIVATE_FLAG_FIT_INSETS_CONTROLLED;
+ }
+
+ /**
+ * Specifies sides of insets that this window should avoid overlapping during layout.
+ *
+ * @param sides which sides that this window should avoid overlapping with the types
+ * specified. The initial value of this object includes all sides.
+ * @hide pending unhide
+ */
+ public void setFitWindowInsetsSides(@InsetsSide int sides) {
+ mFitWindowInsetsSides = sides;
+ privateFlags |= PRIVATE_FLAG_FIT_INSETS_CONTROLLED;
+ }
+
+ /**
+ * Specifies if this window should fit the window insets no matter they are visible or not.
+ *
+ * @param ignore if true, this window will fit the given types even if they are not visible.
+ * @hide pending unhide
+ */
+ public void setFitIgnoreVisibility(boolean ignore) {
+ mFitIgnoreVisibility = ignore;
+ privateFlags |= PRIVATE_FLAG_FIT_INSETS_CONTROLLED;
+ }
+
+ /**
+ * @return the insets types that this window is avoiding overlapping.
+ * @hide pending unhide
+ */
+ public @InsetsType int getFitWindowInsetsTypes() {
+ return mFitWindowInsetsTypes;
+ }
+
+ /**
+ * @return the sides that this window is avoiding overlapping.
+ * @hide pending unhide
+ */
+ public @InsetsSide int getFitWindowInsetsSides() {
+ return mFitWindowInsetsSides;
+ }
+
+ /**
+ * @return {@code true} if this window fits the window insets no matter they are visible or
+ * not.
+ * @hide pending unhide
+ */
+ public boolean getFitIgnoreVisibility() {
+ return mFitIgnoreVisibility;
+ }
+
public LayoutParams() {
super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
type = TYPE_APPLICATION;
@@ -2754,6 +2906,9 @@
out.writeLong(hideTimeoutMilliseconds);
out.writeInt(insetsFlags.appearance);
out.writeInt(insetsFlags.behavior);
+ out.writeInt(mFitWindowInsetsTypes);
+ out.writeInt(mFitWindowInsetsSides);
+ out.writeBoolean(mFitIgnoreVisibility);
}
public static final @android.annotation.NonNull Parcelable.Creator<LayoutParams> CREATOR
@@ -2811,6 +2966,9 @@
hideTimeoutMilliseconds = in.readLong();
insetsFlags.appearance = in.readInt();
insetsFlags.behavior = in.readInt();
+ mFitWindowInsetsTypes = in.readInt();
+ mFitWindowInsetsSides = in.readInt();
+ mFitIgnoreVisibility = in.readBoolean();
}
@SuppressWarnings({"PointlessBitwiseExpression"})
@@ -3049,6 +3207,21 @@
changes |= INSET_FLAGS_CHANGED;
}
+ if (mFitWindowInsetsTypes != o.mFitWindowInsetsTypes) {
+ mFitWindowInsetsTypes = o.mFitWindowInsetsTypes;
+ changes |= LAYOUT_CHANGED;
+ }
+
+ if (mFitWindowInsetsSides != o.mFitWindowInsetsSides) {
+ mFitWindowInsetsSides = o.mFitWindowInsetsSides;
+ changes |= LAYOUT_CHANGED;
+ }
+
+ if (mFitIgnoreVisibility != o.mFitIgnoreVisibility) {
+ mFitIgnoreVisibility = o.mFitIgnoreVisibility;
+ changes |= LAYOUT_CHANGED;
+ }
+
return changes;
}
@@ -3203,6 +3376,20 @@
sb.append(prefix).append(" bhv=").append(ViewDebug.flagsToString(
InsetsFlags.class, "behavior", insetsFlags.behavior));
}
+ if (mFitWindowInsetsTypes != 0) {
+ sb.append(System.lineSeparator());
+ sb.append(prefix).append(" fitTypes=").append(ViewDebug.flagsToString(
+ LayoutParams.class, "mFitWindowInsetsTypes", mFitWindowInsetsTypes));
+ }
+ if (mFitWindowInsetsSides != Side.all()) {
+ sb.append(System.lineSeparator());
+ sb.append(prefix).append(" fitSides=").append(ViewDebug.flagsToString(
+ LayoutParams.class, "mFitWindowInsetsSides", mFitWindowInsetsSides));
+ }
+ if (mFitIgnoreVisibility) {
+ sb.append(System.lineSeparator());
+ sb.append(prefix).append(" fitIgnoreVis");
+ }
sb.append('}');
return sb.toString();
@@ -3240,6 +3427,9 @@
proto.write(SUBTREE_SYSTEM_UI_VISIBILITY_FLAGS, subtreeSystemUiVisibility);
proto.write(APPEARANCE, insetsFlags.appearance);
proto.write(BEHAVIOR, insetsFlags.behavior);
+ proto.write(FIT_INSETS_TYPES, mFitWindowInsetsTypes);
+ proto.write(FIT_INSETS_SIDES, mFitWindowInsetsSides);
+ proto.write(FIT_IGNORE_VISIBILITY, mFitIgnoreVisibility);
proto.end(token);
}
diff --git a/core/java/android/view/accessibility/AccessibilityCache.java b/core/java/android/view/accessibility/AccessibilityCache.java
index dc8bf9b..9ab2c2b 100644
--- a/core/java/android/view/accessibility/AccessibilityCache.java
+++ b/core/java/android/view/accessibility/AccessibilityCache.java
@@ -69,6 +69,8 @@
private long mAccessibilityFocus = AccessibilityNodeInfo.UNDEFINED_ITEM_ID;
private long mInputFocus = AccessibilityNodeInfo.UNDEFINED_ITEM_ID;
+ private int mAccessibilityFocusedWindow = AccessibilityWindowInfo.UNDEFINED_WINDOW_ID;
+
private boolean mIsAllWindowsCached;
// The SparseArray of all {@link AccessibilityWindowInfo}s on all displays.
@@ -164,16 +166,19 @@
switch (eventType) {
case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: {
if (mAccessibilityFocus != AccessibilityNodeInfo.UNDEFINED_ITEM_ID) {
- refreshCachedNodeLocked(event.getWindowId(), mAccessibilityFocus);
+ refreshCachedNodeLocked(mAccessibilityFocusedWindow, mAccessibilityFocus);
}
mAccessibilityFocus = event.getSourceNodeId();
- refreshCachedNodeLocked(event.getWindowId(), mAccessibilityFocus);
+ mAccessibilityFocusedWindow = event.getWindowId();
+ refreshCachedNodeLocked(mAccessibilityFocusedWindow, mAccessibilityFocus);
} break;
case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED: {
- if (mAccessibilityFocus == event.getSourceNodeId()) {
- refreshCachedNodeLocked(event.getWindowId(), mAccessibilityFocus);
+ if (mAccessibilityFocus == event.getSourceNodeId()
+ && mAccessibilityFocusedWindow == event.getWindowId()) {
+ refreshCachedNodeLocked(mAccessibilityFocusedWindow, mAccessibilityFocus);
mAccessibilityFocus = AccessibilityNodeInfo.UNDEFINED_ITEM_ID;
+ mAccessibilityFocusedWindow = AccessibilityWindowInfo.UNDEFINED_WINDOW_ID;
}
} break;
@@ -210,6 +215,13 @@
} break;
case AccessibilityEvent.TYPE_WINDOWS_CHANGED:
+ if (event.getWindowChanges()
+ == AccessibilityEvent.WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED) {
+ // Don't need to clear all cache. Unless the changes are related to
+ // content, we won't clear all cache here.
+ refreshCachedWindowLocked(event.getWindowId());
+ break;
+ }
case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: {
clear();
} break;
@@ -243,6 +255,34 @@
clearSubTreeLocked(windowId, sourceId);
}
+ private void refreshCachedWindowLocked(int windowId) {
+ if (DEBUG) {
+ Log.i(LOG_TAG, "Refreshing cached window.");
+ }
+
+ if (windowId == AccessibilityWindowInfo.UNDEFINED_WINDOW_ID) {
+ return;
+ }
+
+ final int displayCounts = mWindowCacheByDisplay.size();
+ for (int i = 0; i < displayCounts; i++) {
+ final SparseArray<AccessibilityWindowInfo> windowsOfDisplay =
+ mWindowCacheByDisplay.valueAt(i);
+ if (windowsOfDisplay == null) {
+ continue;
+ }
+ final AccessibilityWindowInfo window = windowsOfDisplay.get(windowId);
+ if (window == null) {
+ continue;
+ }
+ if (!mAccessibilityNodeRefresher.refreshWindow(window)) {
+ // If we fail to refresh the window, clear all windows.
+ clearWindowCacheLocked();
+ }
+ return;
+ }
+ }
+
/**
* Gets a cached {@link AccessibilityNodeInfo} given the id of the hosting
* window and the accessibility id of the node.
@@ -413,8 +453,10 @@
refreshCachedNodeLocked(windowId, mAccessibilityFocus);
}
mAccessibilityFocus = sourceId;
+ mAccessibilityFocusedWindow = windowId;
} else if (mAccessibilityFocus == sourceId) {
mAccessibilityFocus = AccessibilityNodeInfo.UNDEFINED_ITEM_ID;
+ mAccessibilityFocusedWindow = AccessibilityWindowInfo.UNDEFINED_WINDOW_ID;
}
if (clone.isFocused()) {
mInputFocus = sourceId;
@@ -439,6 +481,8 @@
mAccessibilityFocus = AccessibilityNodeInfo.UNDEFINED_ITEM_ID;
mInputFocus = AccessibilityNodeInfo.UNDEFINED_ITEM_ID;
+
+ mAccessibilityFocusedWindow = AccessibilityWindowInfo.UNDEFINED_WINDOW_ID;
}
}
@@ -653,8 +697,14 @@
// Layer of indirection included to break dependency chain for testing
public static class AccessibilityNodeRefresher {
+ /** Refresh the given AccessibilityNodeInfo object. */
public boolean refreshNode(AccessibilityNodeInfo info, boolean bypassCache) {
return info.refresh(null, bypassCache);
}
+
+ /** Refresh the given AccessibilityWindowInfo object. */
+ public boolean refreshWindow(AccessibilityWindowInfo info) {
+ return info.refresh();
+ }
}
}
diff --git a/core/java/android/view/accessibility/AccessibilityInteractionClient.java b/core/java/android/view/accessibility/AccessibilityInteractionClient.java
index bb10ef1..3866517 100644
--- a/core/java/android/view/accessibility/AccessibilityInteractionClient.java
+++ b/core/java/android/view/accessibility/AccessibilityInteractionClient.java
@@ -223,19 +223,36 @@
* @return The {@link AccessibilityWindowInfo}.
*/
public AccessibilityWindowInfo getWindow(int connectionId, int accessibilityWindowId) {
+ return getWindow(connectionId, accessibilityWindowId, /* bypassCache */ false);
+ }
+
+ /**
+ * Gets the info for a window.
+ *
+ * @param connectionId The id of a connection for interacting with the system.
+ * @param accessibilityWindowId A unique window id. Use
+ * {@link android.view.accessibility.AccessibilityWindowInfo#ACTIVE_WINDOW_ID}
+ * to query the currently active window.
+ * @param bypassCache Whether to bypass the cache.
+ * @return The {@link AccessibilityWindowInfo}.
+ */
+ public AccessibilityWindowInfo getWindow(int connectionId, int accessibilityWindowId,
+ boolean bypassCache) {
try {
IAccessibilityServiceConnection connection = getConnection(connectionId);
if (connection != null) {
- AccessibilityWindowInfo window = sAccessibilityCache.getWindow(
- accessibilityWindowId);
- if (window != null) {
- if (DEBUG) {
- Log.i(LOG_TAG, "Window cache hit");
+ AccessibilityWindowInfo window;
+ if (!bypassCache) {
+ window = sAccessibilityCache.getWindow(accessibilityWindowId);
+ if (window != null) {
+ if (DEBUG) {
+ Log.i(LOG_TAG, "Window cache hit");
+ }
+ return window;
}
- return window;
- }
- if (DEBUG) {
- Log.i(LOG_TAG, "Window cache miss");
+ if (DEBUG) {
+ Log.i(LOG_TAG, "Window cache miss");
+ }
}
final long identityToken = Binder.clearCallingIdentity();
try {
@@ -244,7 +261,9 @@
Binder.restoreCallingIdentity(identityToken);
}
if (window != null) {
- sAccessibilityCache.addWindow(window);
+ if (!bypassCache) {
+ sAccessibilityCache.addWindow(window);
+ }
return window;
}
} else {
diff --git a/core/java/android/view/accessibility/AccessibilityWindowInfo.java b/core/java/android/view/accessibility/AccessibilityWindowInfo.java
index 2cc6e9a..ca5c417 100644
--- a/core/java/android/view/accessibility/AccessibilityWindowInfo.java
+++ b/core/java/android/view/accessibility/AccessibilityWindowInfo.java
@@ -87,6 +87,8 @@
/** @hide */
public static final int ACTIVE_WINDOW_ID = Integer.MAX_VALUE;
/** @hide */
+ public static final int UNDEFINED_CONNECTION_ID = -1;
+ /** @hide */
public static final int UNDEFINED_WINDOW_ID = -1;
/** @hide */
public static final int ANY_WINDOW_ID = -2;
@@ -117,7 +119,7 @@
private CharSequence mTitle;
private long mAnchorId = AccessibilityNodeInfo.UNDEFINED_NODE_ID;
- private int mConnectionId = UNDEFINED_WINDOW_ID;
+ private int mConnectionId = UNDEFINED_CONNECTION_ID;
/**
* Creates a new {@link AccessibilityWindowInfo}.
@@ -539,6 +541,30 @@
}
}
+ /**
+ * Refreshes this window with the latest state of the window it represents.
+ * <p>
+ * <strong>Note:</strong> If this method returns false this info is obsolete
+ * since it represents a window that is no longer exist.
+ * </p>
+ *
+ * @hide
+ */
+ public boolean refresh() {
+ if (mConnectionId == UNDEFINED_CONNECTION_ID || mId == UNDEFINED_WINDOW_ID) {
+ return false;
+ }
+ final AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
+ final AccessibilityWindowInfo refreshedInfo = client.getWindow(mConnectionId,
+ mId, /* bypassCache */true);
+ if (refreshedInfo == null) {
+ return false;
+ }
+ init(refreshedInfo);
+ refreshedInfo.recycle();
+ return true;
+ }
+
@Override
public int describeContents() {
return 0;
@@ -586,6 +612,7 @@
mTitle = other.mTitle;
mAnchorId = other.mAnchorId;
+ if (mChildIds != null) mChildIds.clear();
if (other.mChildIds != null && other.mChildIds.size() > 0) {
if (mChildIds == null) {
mChildIds = other.mChildIds.clone();
diff --git a/core/java/android/widget/RadioButton.java b/core/java/android/widget/RadioButton.java
index d44fbd7..3e26f63 100644
--- a/core/java/android/widget/RadioButton.java
+++ b/core/java/android/widget/RadioButton.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.util.AttributeSet;
+import android.view.accessibility.AccessibilityNodeInfo;
/**
@@ -38,19 +39,19 @@
* guide.</p>
*
* <p><strong>XML attributes</strong></p>
- * <p>
- * See {@link android.R.styleable#CompoundButton CompoundButton Attributes},
- * {@link android.R.styleable#Button Button Attributes},
- * {@link android.R.styleable#TextView TextView Attributes},
+ * <p>
+ * See {@link android.R.styleable#CompoundButton CompoundButton Attributes},
+ * {@link android.R.styleable#Button Button Attributes},
+ * {@link android.R.styleable#TextView TextView Attributes},
* {@link android.R.styleable#View View Attributes}
* </p>
*/
public class RadioButton extends CompoundButton {
-
+
public RadioButton(Context context) {
this(context, null);
}
-
+
public RadioButton(Context context, AttributeSet attrs) {
this(context, attrs, com.android.internal.R.attr.radioButtonStyle);
}
@@ -81,4 +82,20 @@
public CharSequence getAccessibilityClassName() {
return RadioButton.class.getName();
}
+
+ @Override
+ public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
+ super.onInitializeAccessibilityNodeInfo(info);
+ if (getParent() instanceof RadioGroup) {
+ RadioGroup radioGroup = (RadioGroup) getParent();
+ if (radioGroup.getOrientation() == LinearLayout.HORIZONTAL) {
+ info.setCollectionItemInfo(AccessibilityNodeInfo.CollectionItemInfo.obtain(0, 1,
+ radioGroup.getIndexWithinVisibleButtons(this), 1, false, isChecked()));
+ } else {
+ info.setCollectionItemInfo(AccessibilityNodeInfo.CollectionItemInfo.obtain(
+ radioGroup.getIndexWithinVisibleButtons(this), 1, 0, 1,
+ false, isChecked()));
+ }
+ }
+ }
}
diff --git a/core/java/android/widget/RadioGroup.java b/core/java/android/widget/RadioGroup.java
index c62c16c..90bc0a3 100644
--- a/core/java/android/widget/RadioGroup.java
+++ b/core/java/android/widget/RadioGroup.java
@@ -18,6 +18,7 @@
import android.annotation.IdRes;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.res.TypedArray;
@@ -26,6 +27,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStructure;
+import android.view.accessibility.AccessibilityNodeInfo;
import android.view.autofill.AutofillManager;
import android.view.autofill.AutofillValue;
@@ -93,6 +95,7 @@
if (getImportantForAutofill() == IMPORTANT_FOR_AUTOFILL_AUTO) {
setImportantForAutofill(IMPORTANT_FOR_AUTOFILL_YES);
}
+ setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
// retrieve selected radio button as requested by the user in the
// XML layout file
@@ -475,4 +478,50 @@
}
return null;
}
-}
+
+ @Override
+ public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
+ super.onInitializeAccessibilityNodeInfo(info);
+ if (this.getOrientation() == HORIZONTAL) {
+ info.setCollectionInfo(AccessibilityNodeInfo.CollectionInfo.obtain(1,
+ getVisibleChildCount(), false,
+ AccessibilityNodeInfo.CollectionInfo.SELECTION_MODE_SINGLE));
+ } else {
+ info.setCollectionInfo(
+ AccessibilityNodeInfo.CollectionInfo.obtain(getVisibleChildCount(),
+ 1, false,
+ AccessibilityNodeInfo.CollectionInfo.SELECTION_MODE_SINGLE));
+ }
+ }
+
+ private int getVisibleChildCount() {
+ int count = 0;
+ for (int i = 0; i < getChildCount(); i++) {
+ if (this.getChildAt(i) instanceof RadioButton) {
+ if (((RadioButton) this.getChildAt(i)).getVisibility() == VISIBLE) {
+ count++;
+ }
+ }
+ }
+ return count;
+ }
+
+ int getIndexWithinVisibleButtons(@Nullable View child) {
+ if (!(child instanceof RadioButton)) {
+ return -1;
+ }
+ int index = 0;
+ for (int i = 0; i < getChildCount(); i++) {
+ if (this.getChildAt(i) instanceof RadioButton) {
+ RadioButton radioButton = (RadioButton) this.getChildAt(i);
+ if (radioButton == child) {
+ return index;
+ }
+ if (radioButton.getVisibility() == VISIBLE) {
+ index++;
+ }
+ }
+ }
+ return -1;
+ }
+}
\ No newline at end of file
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 7cec440..a6304b1 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -3575,7 +3575,6 @@
@Override
public void onCancel() {
cancel(true);
- mCancelSignal.setOnCancelListener(null);
}
private CancellationSignal startTaskOnExecutor(Executor executor) {
diff --git a/core/java/android/widget/Toast.java b/core/java/android/widget/Toast.java
index bdc2f9a..8f2133f 100644
--- a/core/java/android/widget/Toast.java
+++ b/core/java/android/widget/Toast.java
@@ -401,6 +401,7 @@
params.format = PixelFormat.TRANSLUCENT;
params.windowAnimations = com.android.internal.R.style.Animation_Toast;
params.type = WindowManager.LayoutParams.TYPE_TOAST;
+ params.setFitIgnoreVisibility(true);
params.setTitle("Toast");
params.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
diff --git a/telephony/java/com/android/ims/internal/uce/common/CapInfo.aidl b/core/java/com/android/ims/internal/uce/common/CapInfo.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/common/CapInfo.aidl
rename to core/java/com/android/ims/internal/uce/common/CapInfo.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/common/CapInfo.java b/core/java/com/android/ims/internal/uce/common/CapInfo.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/common/CapInfo.java
rename to core/java/com/android/ims/internal/uce/common/CapInfo.java
diff --git a/telephony/java/com/android/ims/internal/uce/common/StatusCode.aidl b/core/java/com/android/ims/internal/uce/common/StatusCode.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/common/StatusCode.aidl
rename to core/java/com/android/ims/internal/uce/common/StatusCode.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/common/StatusCode.java b/core/java/com/android/ims/internal/uce/common/StatusCode.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/common/StatusCode.java
rename to core/java/com/android/ims/internal/uce/common/StatusCode.java
diff --git a/telephony/java/com/android/ims/internal/uce/common/UceLong.aidl b/core/java/com/android/ims/internal/uce/common/UceLong.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/common/UceLong.aidl
rename to core/java/com/android/ims/internal/uce/common/UceLong.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/common/UceLong.java b/core/java/com/android/ims/internal/uce/common/UceLong.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/common/UceLong.java
rename to core/java/com/android/ims/internal/uce/common/UceLong.java
diff --git a/telephony/java/com/android/ims/internal/uce/options/IOptionsListener.aidl b/core/java/com/android/ims/internal/uce/options/IOptionsListener.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/options/IOptionsListener.aidl
rename to core/java/com/android/ims/internal/uce/options/IOptionsListener.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/options/IOptionsService.aidl b/core/java/com/android/ims/internal/uce/options/IOptionsService.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/options/IOptionsService.aidl
rename to core/java/com/android/ims/internal/uce/options/IOptionsService.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/options/OptionsCapInfo.aidl b/core/java/com/android/ims/internal/uce/options/OptionsCapInfo.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/options/OptionsCapInfo.aidl
rename to core/java/com/android/ims/internal/uce/options/OptionsCapInfo.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/options/OptionsCapInfo.java b/core/java/com/android/ims/internal/uce/options/OptionsCapInfo.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/options/OptionsCapInfo.java
rename to core/java/com/android/ims/internal/uce/options/OptionsCapInfo.java
diff --git a/telephony/java/com/android/ims/internal/uce/options/OptionsCmdId.aidl b/core/java/com/android/ims/internal/uce/options/OptionsCmdId.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/options/OptionsCmdId.aidl
rename to core/java/com/android/ims/internal/uce/options/OptionsCmdId.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/options/OptionsCmdId.java b/core/java/com/android/ims/internal/uce/options/OptionsCmdId.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/options/OptionsCmdId.java
rename to core/java/com/android/ims/internal/uce/options/OptionsCmdId.java
diff --git a/telephony/java/com/android/ims/internal/uce/options/OptionsCmdStatus.aidl b/core/java/com/android/ims/internal/uce/options/OptionsCmdStatus.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/options/OptionsCmdStatus.aidl
rename to core/java/com/android/ims/internal/uce/options/OptionsCmdStatus.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/options/OptionsCmdStatus.java b/core/java/com/android/ims/internal/uce/options/OptionsCmdStatus.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/options/OptionsCmdStatus.java
rename to core/java/com/android/ims/internal/uce/options/OptionsCmdStatus.java
diff --git a/telephony/java/com/android/ims/internal/uce/options/OptionsSipResponse.aidl b/core/java/com/android/ims/internal/uce/options/OptionsSipResponse.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/options/OptionsSipResponse.aidl
rename to core/java/com/android/ims/internal/uce/options/OptionsSipResponse.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/options/OptionsSipResponse.java b/core/java/com/android/ims/internal/uce/options/OptionsSipResponse.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/options/OptionsSipResponse.java
rename to core/java/com/android/ims/internal/uce/options/OptionsSipResponse.java
diff --git a/telephony/java/com/android/ims/internal/uce/presence/IPresenceListener.aidl b/core/java/com/android/ims/internal/uce/presence/IPresenceListener.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/IPresenceListener.aidl
rename to core/java/com/android/ims/internal/uce/presence/IPresenceListener.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/presence/IPresenceService.aidl b/core/java/com/android/ims/internal/uce/presence/IPresenceService.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/IPresenceService.aidl
rename to core/java/com/android/ims/internal/uce/presence/IPresenceService.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresCapInfo.aidl b/core/java/com/android/ims/internal/uce/presence/PresCapInfo.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresCapInfo.aidl
rename to core/java/com/android/ims/internal/uce/presence/PresCapInfo.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresCapInfo.java b/core/java/com/android/ims/internal/uce/presence/PresCapInfo.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresCapInfo.java
rename to core/java/com/android/ims/internal/uce/presence/PresCapInfo.java
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresCmdId.aidl b/core/java/com/android/ims/internal/uce/presence/PresCmdId.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresCmdId.aidl
rename to core/java/com/android/ims/internal/uce/presence/PresCmdId.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresCmdId.java b/core/java/com/android/ims/internal/uce/presence/PresCmdId.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresCmdId.java
rename to core/java/com/android/ims/internal/uce/presence/PresCmdId.java
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresCmdStatus.aidl b/core/java/com/android/ims/internal/uce/presence/PresCmdStatus.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresCmdStatus.aidl
rename to core/java/com/android/ims/internal/uce/presence/PresCmdStatus.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresCmdStatus.java b/core/java/com/android/ims/internal/uce/presence/PresCmdStatus.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresCmdStatus.java
rename to core/java/com/android/ims/internal/uce/presence/PresCmdStatus.java
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresPublishTriggerType.aidl b/core/java/com/android/ims/internal/uce/presence/PresPublishTriggerType.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresPublishTriggerType.aidl
rename to core/java/com/android/ims/internal/uce/presence/PresPublishTriggerType.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresPublishTriggerType.java b/core/java/com/android/ims/internal/uce/presence/PresPublishTriggerType.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresPublishTriggerType.java
rename to core/java/com/android/ims/internal/uce/presence/PresPublishTriggerType.java
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresResInfo.aidl b/core/java/com/android/ims/internal/uce/presence/PresResInfo.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresResInfo.aidl
rename to core/java/com/android/ims/internal/uce/presence/PresResInfo.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresResInfo.java b/core/java/com/android/ims/internal/uce/presence/PresResInfo.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresResInfo.java
rename to core/java/com/android/ims/internal/uce/presence/PresResInfo.java
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresResInstanceInfo.aidl b/core/java/com/android/ims/internal/uce/presence/PresResInstanceInfo.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresResInstanceInfo.aidl
rename to core/java/com/android/ims/internal/uce/presence/PresResInstanceInfo.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresResInstanceInfo.java b/core/java/com/android/ims/internal/uce/presence/PresResInstanceInfo.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresResInstanceInfo.java
rename to core/java/com/android/ims/internal/uce/presence/PresResInstanceInfo.java
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresRlmiInfo.aidl b/core/java/com/android/ims/internal/uce/presence/PresRlmiInfo.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresRlmiInfo.aidl
rename to core/java/com/android/ims/internal/uce/presence/PresRlmiInfo.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresRlmiInfo.java b/core/java/com/android/ims/internal/uce/presence/PresRlmiInfo.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresRlmiInfo.java
rename to core/java/com/android/ims/internal/uce/presence/PresRlmiInfo.java
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresServiceInfo.aidl b/core/java/com/android/ims/internal/uce/presence/PresServiceInfo.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresServiceInfo.aidl
rename to core/java/com/android/ims/internal/uce/presence/PresServiceInfo.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresServiceInfo.java b/core/java/com/android/ims/internal/uce/presence/PresServiceInfo.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresServiceInfo.java
rename to core/java/com/android/ims/internal/uce/presence/PresServiceInfo.java
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresSipResponse.aidl b/core/java/com/android/ims/internal/uce/presence/PresSipResponse.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresSipResponse.aidl
rename to core/java/com/android/ims/internal/uce/presence/PresSipResponse.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresSipResponse.java b/core/java/com/android/ims/internal/uce/presence/PresSipResponse.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresSipResponse.java
rename to core/java/com/android/ims/internal/uce/presence/PresSipResponse.java
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresSubscriptionState.aidl b/core/java/com/android/ims/internal/uce/presence/PresSubscriptionState.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresSubscriptionState.aidl
rename to core/java/com/android/ims/internal/uce/presence/PresSubscriptionState.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresSubscriptionState.java b/core/java/com/android/ims/internal/uce/presence/PresSubscriptionState.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresSubscriptionState.java
rename to core/java/com/android/ims/internal/uce/presence/PresSubscriptionState.java
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresTupleInfo.aidl b/core/java/com/android/ims/internal/uce/presence/PresTupleInfo.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresTupleInfo.aidl
rename to core/java/com/android/ims/internal/uce/presence/PresTupleInfo.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/presence/PresTupleInfo.java b/core/java/com/android/ims/internal/uce/presence/PresTupleInfo.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/presence/PresTupleInfo.java
rename to core/java/com/android/ims/internal/uce/presence/PresTupleInfo.java
diff --git a/telephony/java/com/android/ims/internal/uce/uceservice/IUceListener.aidl b/core/java/com/android/ims/internal/uce/uceservice/IUceListener.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/uceservice/IUceListener.aidl
rename to core/java/com/android/ims/internal/uce/uceservice/IUceListener.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/uceservice/IUceService.aidl b/core/java/com/android/ims/internal/uce/uceservice/IUceService.aidl
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/uceservice/IUceService.aidl
rename to core/java/com/android/ims/internal/uce/uceservice/IUceService.aidl
diff --git a/telephony/java/com/android/ims/internal/uce/uceservice/ImsUceManager.java b/core/java/com/android/ims/internal/uce/uceservice/ImsUceManager.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/uceservice/ImsUceManager.java
rename to core/java/com/android/ims/internal/uce/uceservice/ImsUceManager.java
diff --git a/telephony/java/com/android/ims/internal/uce/uceservice/UceServiceBase.java b/core/java/com/android/ims/internal/uce/uceservice/UceServiceBase.java
similarity index 100%
rename from telephony/java/com/android/ims/internal/uce/uceservice/UceServiceBase.java
rename to core/java/com/android/ims/internal/uce/uceservice/UceServiceBase.java
diff --git a/core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java b/core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java
index 2fd5bfd..c64b705 100644
--- a/core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java
+++ b/core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java
@@ -15,6 +15,7 @@
*/
package com.android.internal.app;
import android.annotation.IntDef;
+import android.annotation.Nullable;
import android.content.Context;
import android.os.UserHandle;
import android.view.View;
@@ -60,7 +61,7 @@
@Override
public void onPageSelected(int position) {
mCurrentPage = position;
- getCurrentListAdapter().rebuildList();
+ getActiveListAdapter().rebuildList();
}
});
viewPager.setAdapter(this);
@@ -89,7 +90,7 @@
}
UserHandle getCurrentUserHandle() {
- return getCurrentListAdapter().mResolverListController.getUserHandle();
+ return getActiveListAdapter().mResolverListController.getUserHandle();
}
@Override
@@ -136,7 +137,17 @@
abstract Object getAdapterForIndex(int pageIndex);
@VisibleForTesting
- public abstract ResolverListAdapter getCurrentListAdapter();
+ public abstract ResolverListAdapter getActiveListAdapter();
+
+ /**
+ * If this is a device with a work profile, returns the {@link ResolverListAdapter} instance
+ * of the profile that is not the active one. Otherwise returns {@code null}. For example,
+ * if the share sheet is launched in the work profile, this method returns the personal
+ * profile {@link ResolverListAdapter}.
+ * @see #getActiveListAdapter()
+ */
+ @VisibleForTesting
+ public abstract @Nullable ResolverListAdapter getInactiveListAdapter();
abstract Object getCurrentRootAdapter();
diff --git a/core/java/com/android/internal/app/AbstractResolverComparator.java b/core/java/com/android/internal/app/AbstractResolverComparator.java
index bb7e4d5..eb74612 100644
--- a/core/java/com/android/internal/app/AbstractResolverComparator.java
+++ b/core/java/com/android/internal/app/AbstractResolverComparator.java
@@ -263,6 +263,7 @@
mHandler.removeMessages(RANKER_SERVICE_RESULT);
mHandler.removeMessages(RANKER_RESULT_TIMEOUT);
afterCompute();
+ mAfterCompute = null;
}
private boolean isDefaultBrowser(ResolveInfo ri) {
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index 1af3926..f361784 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -111,6 +111,7 @@
import com.android.internal.app.ResolverListAdapter.ViewHolder;
import com.android.internal.app.chooser.ChooserTargetInfo;
import com.android.internal.app.chooser.DisplayResolveInfo;
+import com.android.internal.app.chooser.MultiDisplayResolveInfo;
import com.android.internal.app.chooser.NotSelectableTargetInfo;
import com.android.internal.app.chooser.SelectableTargetInfo;
import com.android.internal.app.chooser.SelectableTargetInfo.SelectableTargetInfoCommunicator;
@@ -362,9 +363,7 @@
Log.i(TAG, "Hiding image preview area. Timed out waiting for preview to load"
+ " within " + mImageLoadTimeoutMillis + "ms.");
collapseParentView();
- if (mChooserMultiProfilePagerAdapter.getCurrentRootAdapter() != null) {
- mChooserMultiProfilePagerAdapter.getCurrentRootAdapter().hideContentPreview();
- }
+ hideContentPreview();
mHideParentOnFail = false;
}
}
@@ -431,14 +430,14 @@
logDirectShareTargetReceived(
MetricsEvent.ACTION_DIRECT_SHARE_TARGETS_LOADED_CHOOSER_SERVICE);
sendVoiceChoicesIfNeeded();
- mChooserMultiProfilePagerAdapter.getCurrentListAdapter()
+ mChooserMultiProfilePagerAdapter.getActiveListAdapter()
.completeServiceTargetLoading();
}
}
@Override
public void handleMessage(Message msg) {
- if (mChooserMultiProfilePagerAdapter.getCurrentListAdapter() == null || isDestroyed()) {
+ if (mChooserMultiProfilePagerAdapter.getActiveListAdapter() == null || isDestroyed()) {
return;
}
@@ -455,7 +454,7 @@
if (sri.resultTargets != null) {
// TODO(arangelov): Instead of using getCurrentListAdapter(), pass the
// profileId as part of the message.
- mChooserMultiProfilePagerAdapter.getCurrentListAdapter().addServiceResults(
+ mChooserMultiProfilePagerAdapter.getActiveListAdapter().addServiceResults(
sri.originalTarget, sri.resultTargets, TARGET_TYPE_CHOOSER_TARGET);
}
unbindService(sri.connection);
@@ -479,14 +478,14 @@
Log.d(TAG, "LIST_VIEW_UPDATE_MESSAGE; ");
}
- mChooserMultiProfilePagerAdapter.getCurrentListAdapter().refreshListView();
+ mChooserMultiProfilePagerAdapter.getActiveListAdapter().refreshListView();
break;
case SHORTCUT_MANAGER_SHARE_TARGET_RESULT:
if (DEBUG) Log.d(TAG, "SHORTCUT_MANAGER_SHARE_TARGET_RESULT");
final ServiceResultInfo resultInfo = (ServiceResultInfo) msg.obj;
if (resultInfo.resultTargets != null) {
- mChooserMultiProfilePagerAdapter.getCurrentListAdapter().addServiceResults(
+ mChooserMultiProfilePagerAdapter.getActiveListAdapter().addServiceResults(
resultInfo.originalTarget, resultInfo.resultTargets, msg.arg1);
}
break;
@@ -646,7 +645,7 @@
if (isFinishing() || isDestroyed()) {
return;
}
- if (mChooserMultiProfilePagerAdapter.getCurrentListAdapter().getCount() == 0) {
+ if (mChooserMultiProfilePagerAdapter.getActiveListAdapter().getCount() == 0) {
return;
}
if (resultList.isEmpty()) {
@@ -654,12 +653,12 @@
//TODO(arangelov) queryDirectShareTargets indirectly uses mIntents.
// Investigate implications for work tab.
queryDirectShareTargets(
- mChooserMultiProfilePagerAdapter.getCurrentListAdapter(), true);
+ mChooserMultiProfilePagerAdapter.getActiveListAdapter(), true);
return;
}
final List<DisplayResolveInfo> driList =
getDisplayResolveInfos(
- mChooserMultiProfilePagerAdapter.getCurrentListAdapter());
+ mChooserMultiProfilePagerAdapter.getActiveListAdapter());
final List<ShortcutManager.ShareShortcutInfo> shareShortcutInfos =
new ArrayList<>();
for (AppTarget appTarget : resultList) {
@@ -809,7 +808,7 @@
@Override
protected boolean postRebuildList(boolean rebuildCompleted) {
- mChooserMultiProfilePagerAdapter.getCurrentRootAdapter().maybeLogActionShareWithPreview();
+ updateContentPreview();
return postRebuildListInternal(rebuildCompleted);
}
@@ -862,7 +861,7 @@
public void onSomePackagesChanged() {
// TODO(arangelov): Dispatch this to all adapters when we have the helper methods
// in a follow-up CL
- mChooserMultiProfilePagerAdapter.getCurrentListAdapter().handlePackagesChanged();
+ mChooserMultiProfilePagerAdapter.getActiveListAdapter().handlePackagesChanged();
updateProfileViewButton();
}
};
@@ -952,6 +951,12 @@
}
}
+ private ViewGroup createContentPreviewView(ViewGroup parent) {
+ Intent targetIntent = getTargetIntent();
+ int previewType = findPreferredContentPreview(targetIntent, getContentResolver());
+ return displayContentPreview(previewType, targetIntent, getLayoutInflater(), parent);
+ }
+
private ViewGroup displayContentPreview(@ContentPreviewType int previewType,
Intent targetIntent, LayoutInflater layoutInflater, ViewGroup parent) {
ViewGroup layout = null;
@@ -1319,7 +1324,7 @@
public void onPrepareAdapterView(ResolverListAdapter adapter) {
mChooserMultiProfilePagerAdapter.getCurrentAdapterView().setVisibility(View.VISIBLE);
if (mCallerChooserTargets != null && mCallerChooserTargets.length > 0) {
- mChooserMultiProfilePagerAdapter.getCurrentListAdapter().addServiceResults(
+ mChooserMultiProfilePagerAdapter.getActiveListAdapter().addServiceResults(
/* origTarget */ null,
Lists.newArrayList(mCallerChooserTargets),
TARGET_TYPE_DEFAULT);
@@ -1348,17 +1353,31 @@
return getIntent().getBooleanExtra(Intent.EXTRA_AUTO_LAUNCH_SINGLE_CHOICE, true);
}
- @Override
- public void showTargetDetails(ResolveInfo ri) {
- if (ri == null) {
+ void showTargetDetails(TargetInfo ti) {
+ if (ti == null) {
return;
}
-
- ComponentName name = ri.activityInfo.getComponentName();
+ ComponentName name = ti.getResolveInfo().activityInfo.getComponentName();
boolean pinned = mPinnedSharedPrefs.getBoolean(name.flattenToString(), false);
- ResolverTargetActionsDialogFragment f =
- new ResolverTargetActionsDialogFragment(ri.loadLabel(getPackageManager()),
- name, pinned);
+
+ ResolverTargetActionsDialogFragment f;
+
+ // For multiple targets, include info on all targets
+ if (ti instanceof MultiDisplayResolveInfo) {
+ MultiDisplayResolveInfo mti = (MultiDisplayResolveInfo) ti;
+ List<CharSequence> labels = new ArrayList<>();
+
+ for (TargetInfo innerInfo : mti.getTargets()) {
+ labels.add(innerInfo.getResolveInfo().loadLabel(getPackageManager()));
+ }
+ f = new ResolverTargetActionsDialogFragment(
+ mti.getResolveInfo().loadLabel(getPackageManager()), name, mti.getTargets(),
+ labels);
+ } else {
+ f = new ResolverTargetActionsDialogFragment(
+ ti.getResolveInfo().loadLabel(getPackageManager()), name, pinned);
+ }
+
f.show(getFragmentManager(), TARGET_DETAILS_FRAGMENT_TAG);
}
@@ -1404,7 +1423,7 @@
@Override
public void startSelected(int which, boolean always, boolean filtered) {
ChooserListAdapter currentListAdapter =
- mChooserMultiProfilePagerAdapter.getCurrentListAdapter();
+ mChooserMultiProfilePagerAdapter.getActiveListAdapter();
TargetInfo targetInfo = currentListAdapter
.targetInfoForPosition(which, filtered);
if (targetInfo != null && targetInfo instanceof NotSelectableTargetInfo) {
@@ -1412,8 +1431,26 @@
}
final long selectionCost = System.currentTimeMillis() - mChooserShownTime;
+
+ // Stacked apps get a disambiguation first
+ if (targetInfo instanceof MultiDisplayResolveInfo) {
+ MultiDisplayResolveInfo mti = (MultiDisplayResolveInfo) targetInfo;
+ CharSequence[] labels = new CharSequence[mti.getTargets().size()];
+ int i = 0;
+ for (TargetInfo ti : mti.getTargets()) {
+ labels[i++] = ti.getResolveInfo().loadLabel(getPackageManager());
+ }
+ ChooserStackedAppDialogFragment f = new ChooserStackedAppDialogFragment(
+ targetInfo.getDisplayLabel(),
+ ((MultiDisplayResolveInfo) targetInfo).getTargets(), labels);
+
+ f.show(getFragmentManager(), TARGET_DETAILS_FRAGMENT_TAG);
+ return;
+ }
+
super.startSelected(which, always, filtered);
+
if (currentListAdapter.getCount() > 0) {
// Log the index of which type of target the user picked.
// Lower values mean the ranking was better.
@@ -1487,7 +1524,7 @@
String targetPackageName =
targetInfo.getChooserTarget().getComponentName().getPackageName();
ChooserListAdapter currentListAdapter =
- mChooserMultiProfilePagerAdapter.getCurrentListAdapter();
+ mChooserMultiProfilePagerAdapter.getActiveListAdapter();
int maxRankedResults = Math.min(currentListAdapter.mDisplayList.size(),
MAX_LOG_RANK_POSITION);
@@ -1841,7 +1878,7 @@
Intent targetIntent = getTargetIntent();
if (ri != null && ri.activityInfo != null && targetIntent != null) {
ChooserListAdapter currentListAdapter =
- mChooserMultiProfilePagerAdapter.getCurrentListAdapter();
+ mChooserMultiProfilePagerAdapter.getActiveListAdapter();
if (currentListAdapter != null) {
currentListAdapter.updateModel(info.getResolvedComponentName());
currentListAdapter.updateChooserCounts(ri.activityInfo.packageName, getUserId(),
@@ -2146,8 +2183,7 @@
final int bottomInset = mSystemWindowInsets != null
? mSystemWindowInsets.bottom : 0;
int offset = bottomInset;
- int rowsToShow = gridAdapter.getContentPreviewRowCount()
- + gridAdapter.getProfileRowCount()
+ int rowsToShow = gridAdapter.getProfileRowCount()
+ gridAdapter.getServiceTargetRowCount()
+ gridAdapter.getCallerAndRankedTargetRowCount();
@@ -2159,13 +2195,17 @@
// still zero? then use a default height and leave, which
// can happen when there are no targets to show
- if (rowsToShow == 0) {
+ if (rowsToShow == 0 && !shouldShowContentPreview()) {
offset += getResources().getDimensionPixelSize(
R.dimen.chooser_max_collapsed_height);
mResolverDrawerLayout.setCollapsibleHeightReserved(offset);
return;
}
+ if (shouldShowContentPreview()) {
+ offset += findViewById(R.id.content_preview_container).getHeight();
+ }
+
int directShareHeight = 0;
rowsToShow = Math.min(4, rowsToShow);
for (int i = 0, childCount = recyclerView.getChildCount();
@@ -2216,13 +2256,13 @@
@Override // ResolverListCommunicator
public void onHandlePackagesChanged() {
mServicesRequested.clear();
- mChooserMultiProfilePagerAdapter.getCurrentListAdapter().notifyDataSetChanged();
+ mChooserMultiProfilePagerAdapter.getActiveListAdapter().notifyDataSetChanged();
super.onHandlePackagesChanged();
}
@Override // SelectableTargetInfoCommunicator
public ActivityInfoPresentationGetter makePresentationGetter(ActivityInfo info) {
- return mChooserMultiProfilePagerAdapter.getCurrentListAdapter().makePresentationGetter(info);
+ return mChooserMultiProfilePagerAdapter.getActiveListAdapter().makePresentationGetter(info);
}
@Override // SelectableTargetInfoCommunicator
@@ -2244,22 +2284,21 @@
}
@Override
- public void onListRebuilt() {
- final ChooserListAdapter currentListAdapter =
- mChooserMultiProfilePagerAdapter.getCurrentListAdapter();
- if (currentListAdapter.mDisplayList == null
- || currentListAdapter.mDisplayList.isEmpty()) {
- currentListAdapter.notifyDataSetChanged();
+ public void onListRebuilt(ResolverListAdapter listAdapter) {
+ ChooserListAdapter chooserListAdapter = (ChooserListAdapter) listAdapter;
+ if (chooserListAdapter.mDisplayList == null
+ || chooserListAdapter.mDisplayList.isEmpty()) {
+ chooserListAdapter.notifyDataSetChanged();
} else {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... voids) {
- currentListAdapter.updateAlphabeticalList();
+ chooserListAdapter.updateAlphabeticalList();
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
- currentListAdapter.notifyDataSetChanged();
+ chooserListAdapter.notifyDataSetChanged();
}
}.execute();
}
@@ -2275,14 +2314,14 @@
Log.d(TAG, "querying direct share targets from ShortcutManager");
}
- queryDirectShareTargets(currentListAdapter, false);
+ queryDirectShareTargets(chooserListAdapter, false);
}
if (USE_CHOOSER_TARGET_SERVICE_FOR_DIRECT_TARGETS) {
if (DEBUG) {
Log.d(TAG, "List built querying services");
}
- queryTargetServices(currentListAdapter);
+ queryTargetServices(chooserListAdapter);
}
}
@@ -2304,10 +2343,43 @@
return false;
}
+ private boolean shouldShowContentPreview() {
+ return mMultiProfilePagerAdapter.getActiveListAdapter().getCount() > 0
+ && isSendAction(getTargetIntent());
+ }
+
+ private void updateContentPreview() {
+ if (shouldShowContentPreview()) {
+ showContentPreview();
+ } else {
+ hideContentPreview();
+ }
+ }
+
+ private void showContentPreview() {
+ ViewGroup contentPreviewContainer = findViewById(R.id.content_preview_container);
+ contentPreviewContainer.setVisibility(View.VISIBLE);
+ ViewGroup contentPreviewView = createContentPreviewView(contentPreviewContainer);
+ contentPreviewContainer.addView(contentPreviewView);
+ logActionShareWithPreview();
+ }
+
+ private void hideContentPreview() {
+ ViewGroup contentPreviewContainer = findViewById(R.id.content_preview_container);
+ contentPreviewContainer.removeAllViews();
+ contentPreviewContainer.setVisibility(View.GONE);
+ }
+
+ private void logActionShareWithPreview() {
+ Intent targetIntent = getTargetIntent();
+ int previewType = findPreferredContentPreview(targetIntent, getContentResolver());
+ getMetricsLogger().write(new LogMaker(MetricsEvent.ACTION_SHARE_WITH_PREVIEW)
+ .setSubtype(previewType));
+ }
+
/**
* Used to bind types of individual item including
* {@link ChooserGridAdapter#VIEW_TYPE_NORMAL},
- * {@link ChooserGridAdapter#VIEW_TYPE_CONTENT_PREVIEW},
* {@link ChooserGridAdapter#VIEW_TYPE_PROFILE},
* and {@link ChooserGridAdapter#VIEW_TYPE_AZ_LABEL}.
*/
@@ -2323,8 +2395,8 @@
false/* always */, true/* filterd */));
itemView.setOnLongClickListener(v -> {
showTargetDetails(
- mChooserMultiProfilePagerAdapter.getCurrentListAdapter()
- .resolveInfoForPosition(mListPosition, /* filtered */ true));
+ mChooserMultiProfilePagerAdapter.getActiveListAdapter()
+ .targetInfoForPosition(mListPosition, /* filtered */ true));
return true;
});
}
@@ -2368,15 +2440,13 @@
private int mChooserTargetWidth = 0;
private boolean mShowAzLabelIfPoss;
- private boolean mHideContentPreview = false;
private boolean mLayoutRequested = false;
private static final int VIEW_TYPE_DIRECT_SHARE = 0;
private static final int VIEW_TYPE_NORMAL = 1;
- private static final int VIEW_TYPE_CONTENT_PREVIEW = 2;
- private static final int VIEW_TYPE_PROFILE = 3;
- private static final int VIEW_TYPE_AZ_LABEL = 4;
- private static final int VIEW_TYPE_CALLER_AND_RANK = 5;
+ private static final int VIEW_TYPE_PROFILE = 2;
+ private static final int VIEW_TYPE_AZ_LABEL = 3;
+ private static final int VIEW_TYPE_CALLER_AND_RANK = 4;
private static final int MAX_TARGETS_PER_ROW_PORTRAIT = 4;
private static final int MAX_TARGETS_PER_ROW_LANDSCAPE = 8;
@@ -2433,12 +2503,6 @@
return maxTargets;
}
- public void hideContentPreview() {
- mHideContentPreview = true;
- mLayoutRequested = true;
- notifyDataSetChanged();
- }
-
public boolean consumeLayoutRequest() {
boolean oldValue = mLayoutRequested;
mLayoutRequested = false;
@@ -2447,8 +2511,7 @@
public int getRowCount() {
return (int) (
- getContentPreviewRowCount()
- + getProfileRowCount()
+ getProfileRowCount()
+ getServiceTargetRowCount()
+ getCallerAndRankedTargetRowCount()
+ getAzLabelRowCount()
@@ -2458,19 +2521,6 @@
);
}
- public int getContentPreviewRowCount() {
- if (!isSendAction(getTargetIntent())) {
- return 0;
- }
-
- if (mHideContentPreview || mChooserListAdapter == null
- || mChooserListAdapter.getCount() == 0) {
- return 0;
- }
-
- return 1;
- }
-
public int getProfileRowCount() {
return mChooserListAdapter.getOtherProfile() == null ? 0 : 1;
}
@@ -2499,8 +2549,7 @@
@Override
public int getItemCount() {
return (int) (
- getContentPreviewRowCount()
- + getProfileRowCount()
+ getProfileRowCount()
+ getServiceTargetRowCount()
+ getCallerAndRankedTargetRowCount()
+ getAzLabelRowCount()
@@ -2511,8 +2560,6 @@
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
switch (viewType) {
- case VIEW_TYPE_CONTENT_PREVIEW:
- return new ItemViewHolder(createContentPreviewView(parent), false);
case VIEW_TYPE_PROFILE:
return new ItemViewHolder(createProfileView(parent), false);
case VIEW_TYPE_AZ_LABEL:
@@ -2547,10 +2594,7 @@
public int getItemViewType(int position) {
int count;
- int countSum = (count = getContentPreviewRowCount());
- if (count > 0 && position < countSum) return VIEW_TYPE_CONTENT_PREVIEW;
-
- countSum += (count = getProfileRowCount());
+ int countSum = (count = getProfileRowCount());
if (count > 0 && position < countSum) return VIEW_TYPE_PROFILE;
countSum += (count = getServiceTargetRowCount());
@@ -2569,12 +2613,6 @@
return mChooserListAdapter.getPositionTargetType(getListPosition(position));
}
- private ViewGroup createContentPreviewView(ViewGroup parent) {
- Intent targetIntent = getTargetIntent();
- int previewType = findPreferredContentPreview(targetIntent, getContentResolver());
- return displayContentPreview(previewType, targetIntent, mLayoutInflater, parent);
- }
-
private View createProfileView(ViewGroup parent) {
View profileRow = mLayoutInflater.inflate(R.layout.chooser_profile_row, parent, false);
profileRow.setBackground(
@@ -2610,7 +2648,7 @@
@Override
public boolean onLongClick(View v) {
showTargetDetails(
- mChooserListAdapter.resolveInfoForPosition(
+ mChooserListAdapter.targetInfoForPosition(
holder.getItemIndex(column), true));
return true;
}
@@ -2770,7 +2808,7 @@
}
int getListPosition(int position) {
- position -= getContentPreviewRowCount() + getProfileRowCount();
+ position -= getProfileRowCount();
final int serviceCount = mChooserListAdapter.getServiceTargetCount();
final int serviceRows = (int) Math.ceil((float) serviceCount
@@ -2814,16 +2852,6 @@
return mChooserListAdapter;
}
- void maybeLogActionShareWithPreview() {
- if (getContentPreviewRowCount() == 0) {
- return;
- }
- Intent targetIntent = getTargetIntent();
- int previewType = findPreferredContentPreview(targetIntent, getContentResolver());
- getMetricsLogger().write(new LogMaker(MetricsEvent.ACTION_SHARE_WITH_PREVIEW)
- .setSubtype(previewType));
- }
-
boolean shouldCellSpan(int position) {
return getItemViewType(position) == VIEW_TYPE_NORMAL;
}
@@ -3010,7 +3038,7 @@
// only expand if we have more than maxTargetsPerRow, and delay that decision
// until they start to scroll
- if (mChooserMultiProfilePagerAdapter.getCurrentListAdapter()
+ if (mChooserMultiProfilePagerAdapter.getActiveListAdapter()
.getSelectableServiceTargetCount() <= maxTargetsPerRow) {
mHideDirectShareExpansion = true;
return;
diff --git a/core/java/com/android/internal/app/ChooserListAdapter.java b/core/java/com/android/internal/app/ChooserListAdapter.java
index 4eccf21..a8a676d 100644
--- a/core/java/com/android/internal/app/ChooserListAdapter.java
+++ b/core/java/com/android/internal/app/ChooserListAdapter.java
@@ -38,17 +38,22 @@
import com.android.internal.app.ResolverActivity.ResolvedComponentInfo;
import com.android.internal.app.chooser.ChooserTargetInfo;
import com.android.internal.app.chooser.DisplayResolveInfo;
+import com.android.internal.app.chooser.MultiDisplayResolveInfo;
import com.android.internal.app.chooser.SelectableTargetInfo;
import com.android.internal.app.chooser.TargetInfo;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
public class ChooserListAdapter extends ResolverListAdapter {
private static final String TAG = "ChooserListAdapter";
private static final boolean DEBUG = false;
+ private boolean mEnableStackedApps = true;
+
public static final int NO_POSITION = -1;
public static final int TARGET_BAD = -1;
public static final int TARGET_CALLER = 0;
@@ -218,7 +223,25 @@
void updateAlphabeticalList() {
mSortedList.clear();
- mSortedList.addAll(mDisplayList);
+ if (mEnableStackedApps) {
+ // Consolidate multiple targets from same app.
+ Map<String, DisplayResolveInfo> consolidated = new HashMap<>();
+ for (DisplayResolveInfo info : mDisplayList) {
+ String packageName = info.getResolvedComponentName().getPackageName();
+ if (consolidated.get(packageName) != null) {
+ // create consolidated target
+ MultiDisplayResolveInfo multiDisplayResolveInfo =
+ new MultiDisplayResolveInfo(packageName, info);
+ multiDisplayResolveInfo.addTarget(consolidated.get(packageName));
+ consolidated.put(packageName, multiDisplayResolveInfo);
+ } else {
+ consolidated.put(packageName, info);
+ }
+ }
+ mSortedList.addAll(consolidated.values());
+ } else {
+ mSortedList.addAll(mDisplayList);
+ }
Collections.sort(mSortedList, new ChooserActivity.AzInfoComparator(mContext));
}
@@ -270,7 +293,7 @@
}
int getAlphaTargetCount() {
- int standardCount = super.getCount();
+ int standardCount = mSortedList.size();
return standardCount > mChooserListCommunicator.getMaxRankedTargets() ? standardCount : 0;
}
diff --git a/core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java b/core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java
index aa8ab28..7d856e1 100644
--- a/core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java
+++ b/core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java
@@ -102,11 +102,20 @@
@Override
@VisibleForTesting
- public ChooserListAdapter getCurrentListAdapter() {
+ public ChooserListAdapter getActiveListAdapter() {
return getAdapterForIndex(getCurrentPage()).getListAdapter();
}
@Override
+ @VisibleForTesting
+ public ChooserListAdapter getInactiveListAdapter() {
+ if (getCount() == 1) {
+ return null;
+ }
+ return getAdapterForIndex(1 - getCurrentPage()).getListAdapter();
+ }
+
+ @Override
ChooserActivity.ChooserGridAdapter getCurrentRootAdapter() {
return getAdapterForIndex(getCurrentPage());
}
diff --git a/core/java/com/android/internal/app/ChooserStackedAppDialogFragment.java b/core/java/com/android/internal/app/ChooserStackedAppDialogFragment.java
new file mode 100644
index 0000000..ff6582d
--- /dev/null
+++ b/core/java/com/android/internal/app/ChooserStackedAppDialogFragment.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2019 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 com.android.internal.app;
+
+import android.app.AlertDialog.Builder;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.content.DialogInterface;
+import android.content.res.Configuration;
+import android.os.Bundle;
+
+import com.android.internal.app.chooser.DisplayResolveInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Shows individual actions for a "stacked" app target - such as an app with multiple posting
+ * streams represented in the Sharesheet.
+ */
+public class ChooserStackedAppDialogFragment extends DialogFragment
+ implements DialogInterface.OnClickListener {
+ private static final String TITLE_KEY = "title";
+ private static final String PINNED_KEY = "pinned";
+
+ private List<DisplayResolveInfo> mTargetInfos = new ArrayList<>();
+ private CharSequence[] mLabels;
+
+ public ChooserStackedAppDialogFragment() {
+ }
+
+ public ChooserStackedAppDialogFragment(CharSequence title) {
+ Bundle args = new Bundle();
+ args.putCharSequence(TITLE_KEY, title);
+ setArguments(args);
+ }
+
+ public ChooserStackedAppDialogFragment(CharSequence title,
+ List<DisplayResolveInfo> targets, CharSequence[] labels) {
+ Bundle args = new Bundle();
+ args.putCharSequence(TITLE_KEY, title);
+ mTargetInfos = targets;
+ mLabels = labels;
+ setArguments(args);
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ final Bundle args = getArguments();
+ return new Builder(getContext())
+ .setCancelable(true)
+ .setItems(mLabels, this)
+ .setTitle(args.getCharSequence(TITLE_KEY))
+ .create();
+ }
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ final Bundle args = getArguments();
+ mTargetInfos.get(which).start(getActivity(), null);
+ dismiss();
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ // Dismiss on config changed (eg: rotation)
+ // TODO: Maintain state on config change
+ super.onConfigurationChanged(newConfig);
+ dismiss();
+ }
+}
diff --git a/core/java/com/android/internal/app/ISoundTriggerService.aidl b/core/java/com/android/internal/app/ISoundTriggerService.aidl
index ea24d5f..d94294f 100644
--- a/core/java/com/android/internal/app/ISoundTriggerService.aidl
+++ b/core/java/com/android/internal/app/ISoundTriggerService.aidl
@@ -20,6 +20,7 @@
import android.content.ComponentName;
import android.hardware.soundtrigger.IRecognitionStatusCallback;
import android.hardware.soundtrigger.SoundTrigger;
+import android.hardware.soundtrigger.ModelParams;
import android.os.Bundle;
import android.os.ParcelUuid;
@@ -56,4 +57,16 @@
int getModelState(in ParcelUuid soundModelId);
@nullable SoundTrigger.ModuleProperties getModuleProperties();
+
+ int setParameter(in ParcelUuid soundModelId, in ModelParams modelParam,
+ int value);
+
+ /**
+ * @throws UnsupportedOperationException if hal or model do not support this API.
+ * @throws IllegalArgumentException if invalid model handle or parameter is passed.
+ */
+ int getParameter(in ParcelUuid soundModelId, in ModelParams modelParam);
+
+ @nullable SoundTrigger.ModelParamRange queryParameter(in ParcelUuid soundModelId,
+ in ModelParams modelParam);
}
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index 9cf5e9f..8dc3a07 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -36,7 +36,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.PermissionChecker;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -240,7 +239,7 @@
return new PackageMonitor() {
@Override
public void onSomePackagesChanged() {
- mMultiProfilePagerAdapter.getCurrentListAdapter().handlePackagesChanged();
+ mMultiProfilePagerAdapter.getActiveListAdapter().handlePackagesChanged();
updateProfileViewButton();
}
@@ -372,7 +371,7 @@
}
final Set<String> categories = intent.getCategories();
- MetricsLogger.action(this, mMultiProfilePagerAdapter.getCurrentListAdapter().hasFilteredItem()
+ MetricsLogger.action(this, mMultiProfilePagerAdapter.getActiveListAdapter().hasFilteredItem()
? MetricsProto.MetricsEvent.ACTION_SHOW_APP_DISAMBIG_APP_FEATURED
: MetricsProto.MetricsEvent.ACTION_SHOW_APP_DISAMBIG_NONE_FEATURED,
intent.getAction() + ":" + intent.getType() + ":"
@@ -461,7 +460,7 @@
protected void onProfileClick(View v) {
final DisplayResolveInfo dri =
- mMultiProfilePagerAdapter.getCurrentListAdapter().getOtherProfile();
+ mMultiProfilePagerAdapter.getActiveListAdapter().getOtherProfile();
if (dri == null) {
return;
}
@@ -508,7 +507,7 @@
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
- mMultiProfilePagerAdapter.getCurrentListAdapter().handlePackagesChanged();
+ mMultiProfilePagerAdapter.getActiveListAdapter().handlePackagesChanged();
if (mSystemWindowInsets != null) {
mResolverDrawerLayout.setPadding(mSystemWindowInsets.left, mSystemWindowInsets.top,
@@ -523,10 +522,10 @@
return;
}
- int count = mMultiProfilePagerAdapter.getCurrentListAdapter().getCount();
+ int count = mMultiProfilePagerAdapter.getActiveListAdapter().getCount();
final Option[] options = new Option[count];
for (int i = 0, N = options.length; i < N; i++) {
- TargetInfo target = mMultiProfilePagerAdapter.getCurrentListAdapter().getItem(i);
+ TargetInfo target = mMultiProfilePagerAdapter.getActiveListAdapter().getItem(i);
if (target == null) {
// If this occurs, a new set of targets is being loaded. Let that complete,
// and have the next call to send voice choices proceed instead.
@@ -576,7 +575,7 @@
}
final DisplayResolveInfo dri =
- mMultiProfilePagerAdapter.getCurrentListAdapter().getOtherProfile();
+ mMultiProfilePagerAdapter.getActiveListAdapter().getOtherProfile();
if (dri != null && !ENABLE_TABBED_VIEW) {
mProfileView.setVisibility(View.VISIBLE);
View text = mProfileView.findViewById(R.id.profile_button);
@@ -629,7 +628,7 @@
// While there may already be a filtered item, we can only use it in the title if the list
// is already sorted and all information relevant to it is already in the list.
final boolean named =
- mMultiProfilePagerAdapter.getCurrentListAdapter().getFilteredPosition() >= 0;
+ mMultiProfilePagerAdapter.getActiveListAdapter().getFilteredPosition() >= 0;
if (title == ActionTitle.DEFAULT && defaultTitleRes != 0) {
return getString(defaultTitleRes);
} else if (isHttpSchemeAndViewAction(intent)) {
@@ -638,14 +637,14 @@
String dialogTitle = null;
if (named && !mUseLayoutForBrowsables) {
dialogTitle = getString(ActionTitle.BROWSABLE_APP_TITLE_RES,
- mMultiProfilePagerAdapter.getCurrentListAdapter().getFilteredItem()
+ mMultiProfilePagerAdapter.getActiveListAdapter().getFilteredItem()
.getDisplayLabel());
} else if (named && mUseLayoutForBrowsables) {
dialogTitle = getString(ActionTitle.BROWSABLE_HOST_APP_TITLE_RES,
intent.getData().getHost(),
- mMultiProfilePagerAdapter.getCurrentListAdapter().getFilteredItem()
+ mMultiProfilePagerAdapter.getActiveListAdapter().getFilteredItem()
.getDisplayLabel());
- } else if (mMultiProfilePagerAdapter.getCurrentListAdapter().areAllTargetsBrowsers()) {
+ } else if (mMultiProfilePagerAdapter.getActiveListAdapter().areAllTargetsBrowsers()) {
dialogTitle = getString(ActionTitle.BROWSABLE_TITLE_RES);
} else {
dialogTitle = getString(ActionTitle.BROWSABLE_HOST_TITLE_RES,
@@ -655,7 +654,7 @@
} else {
return named
? getString(title.namedTitleRes, mMultiProfilePagerAdapter
- .getCurrentListAdapter().getFilteredItem().getDisplayLabel())
+ .getActiveListAdapter().getFilteredItem().getDisplayLabel())
: getString(title.titleRes);
}
}
@@ -673,7 +672,7 @@
mPackageMonitor.register(this, getMainLooper(), false);
mRegistered = true;
}
- mMultiProfilePagerAdapter.getCurrentListAdapter().handlePackagesChanged();
+ mMultiProfilePagerAdapter.getActiveListAdapter().handlePackagesChanged();
updateProfileViewButton();
}
@@ -706,8 +705,8 @@
if (!isChangingConfigurations() && mPickOptionRequest != null) {
mPickOptionRequest.cancel();
}
- if (mMultiProfilePagerAdapter.getCurrentListAdapter() != null) {
- mMultiProfilePagerAdapter.getCurrentListAdapter().onDestroy();
+ if (mMultiProfilePagerAdapter.getActiveListAdapter() != null) {
+ mMultiProfilePagerAdapter.getActiveListAdapter().onDestroy();
}
}
@@ -757,7 +756,7 @@
boolean enabled = false;
ResolveInfo ri = null;
if (hasValidSelection) {
- ri = mMultiProfilePagerAdapter.getCurrentListAdapter()
+ ri = mMultiProfilePagerAdapter.getActiveListAdapter()
.resolveInfoForPosition(checkedPos, filtered);
if (ri == null) {
Log.e(TAG, "Invalid position supplied to setAlwaysButtonEnabled");
@@ -780,12 +779,9 @@
ActivityInfo activityInfo = ri.activityInfo;
boolean hasRecordPermission =
- PermissionChecker.checkPermissionForPreflight(
- getApplicationContext(),
- android.Manifest.permission.RECORD_AUDIO, -1,
- activityInfo.applicationInfo.uid,
+ mPm.checkPermission(android.Manifest.permission.RECORD_AUDIO,
activityInfo.packageName)
- == android.content.pm.PackageManager.PERMISSION_GRANTED;
+ == android.content.pm.PackageManager.PERMISSION_GRANTED;
if (!hasRecordPermission) {
// OK, we know the record permission, is this a capture device
@@ -800,7 +796,7 @@
public void onButtonClick(View v) {
final int id = v.getId();
ListView listView = (ListView) mMultiProfilePagerAdapter.getCurrentAdapterView();
- ResolverListAdapter currentListAdapter = mMultiProfilePagerAdapter.getCurrentListAdapter();
+ ResolverListAdapter currentListAdapter = mMultiProfilePagerAdapter.getActiveListAdapter();
int which = currentListAdapter.hasFilteredItem()
? currentListAdapter.getFilteredPosition()
: listView.getCheckedItemPosition();
@@ -836,7 +832,7 @@
if (isFinishing()) {
return;
}
- ResolveInfo ri = mMultiProfilePagerAdapter.getCurrentListAdapter()
+ ResolveInfo ri = mMultiProfilePagerAdapter.getActiveListAdapter()
.resolveInfoForPosition(which, hasIndexBeenFiltered);
if (mResolvingHome && hasManagedProfile() && !supportsManagedProfiles(ri)) {
Toast.makeText(this, String.format(getResources().getString(
@@ -846,7 +842,7 @@
return;
}
- TargetInfo target = mMultiProfilePagerAdapter.getCurrentListAdapter()
+ TargetInfo target = mMultiProfilePagerAdapter.getActiveListAdapter()
.targetInfoForPosition(which, hasIndexBeenFiltered);
if (target == null) {
return;
@@ -863,7 +859,7 @@
this, MetricsProto.MetricsEvent.ACTION_APP_DISAMBIG_TAP);
}
MetricsLogger.action(this,
- mMultiProfilePagerAdapter.getCurrentListAdapter().hasFilteredItem()
+ mMultiProfilePagerAdapter.getActiveListAdapter().hasFilteredItem()
? MetricsProto.MetricsEvent.ACTION_HIDE_APP_DISAMBIG_APP_FEATURED
: MetricsProto.MetricsEvent.ACTION_HIDE_APP_DISAMBIG_NONE_FEATURED);
finish();
@@ -879,18 +875,17 @@
}
@Override // ResolverListCommunicator
- public void onPostListReady() {
+ public void onPostListReady(ResolverListAdapter listAdapter) {
setHeader();
resetButtonBar();
- onListRebuilt();
+ onListRebuilt(listAdapter);
}
- protected void onListRebuilt() {
- int count = mMultiProfilePagerAdapter.getCurrentListAdapter().getUnfilteredCount();
- if (count == 1 && mMultiProfilePagerAdapter.getCurrentListAdapter().getOtherProfile() == null) {
+ protected void onListRebuilt(ResolverListAdapter listAdapter) {
+ int count = listAdapter.getUnfilteredCount();
+ if (count == 1 && listAdapter.getOtherProfile() == null) {
// Only one target, so we're a candidate to auto-launch!
- final TargetInfo target =
- mMultiProfilePagerAdapter.getCurrentListAdapter().targetInfoForPosition(0, false);
+ final TargetInfo target = listAdapter.targetInfoForPosition(0, false);
if (shouldAutoLaunchSingleChoice(target)) {
safelyStartActivity(target);
finish();
@@ -903,8 +898,8 @@
final Intent intent = target != null ? target.getResolvedIntent() : null;
if (intent != null && (mSupportsAlwaysUseOption
- || mMultiProfilePagerAdapter.getCurrentListAdapter().hasFilteredItem())
- && mMultiProfilePagerAdapter.getCurrentListAdapter().getUnfilteredResolveList() != null) {
+ || mMultiProfilePagerAdapter.getActiveListAdapter().hasFilteredItem())
+ && mMultiProfilePagerAdapter.getActiveListAdapter().getUnfilteredResolveList() != null) {
// Build a reasonable intent filter, based on what matched.
IntentFilter filter = new IntentFilter();
Intent filterIntent;
@@ -989,14 +984,14 @@
}
if (filter != null) {
- final int N = mMultiProfilePagerAdapter.getCurrentListAdapter()
+ final int N = mMultiProfilePagerAdapter.getActiveListAdapter()
.getUnfilteredResolveList().size();
ComponentName[] set;
// If we don't add back in the component for forwarding the intent to a managed
// profile, the preferred activity may not be updated correctly (as the set of
// components we tell it we knew about will have changed).
final boolean needToAddBackProfileForwardingComponent =
- mMultiProfilePagerAdapter.getCurrentListAdapter().getOtherProfile() != null;
+ mMultiProfilePagerAdapter.getActiveListAdapter().getOtherProfile() != null;
if (!needToAddBackProfileForwardingComponent) {
set = new ComponentName[N];
} else {
@@ -1005,7 +1000,7 @@
int bestMatch = 0;
for (int i=0; i<N; i++) {
- ResolveInfo r = mMultiProfilePagerAdapter.getCurrentListAdapter()
+ ResolveInfo r = mMultiProfilePagerAdapter.getActiveListAdapter()
.getUnfilteredResolveList().get(i).getResolveInfoAt(0);
set[i] = new ComponentName(r.activityInfo.packageName,
r.activityInfo.name);
@@ -1013,9 +1008,9 @@
}
if (needToAddBackProfileForwardingComponent) {
- set[N] = mMultiProfilePagerAdapter.getCurrentListAdapter()
+ set[N] = mMultiProfilePagerAdapter.getActiveListAdapter()
.getOtherProfile().getResolvedComponentName();
- final int otherProfileMatch = mMultiProfilePagerAdapter.getCurrentListAdapter()
+ final int otherProfileMatch = mMultiProfilePagerAdapter.getActiveListAdapter()
.getOtherProfile().getResolveInfo().match;
if (otherProfileMatch > bestMatch) bestMatch = otherProfileMatch;
}
@@ -1055,7 +1050,7 @@
}
} else {
try {
- mMultiProfilePagerAdapter.getCurrentListAdapter()
+ mMultiProfilePagerAdapter.getActiveListAdapter()
.mResolverListController.setLastChosen(intent, filter, bestMatch);
} catch (RemoteException re) {
Log.d(TAG, "Error calling setLastChosenActivity\n" + re);
@@ -1165,7 +1160,7 @@
return !target.isSuspended();
}
- public void showTargetDetails(ResolveInfo ri) {
+ void showTargetDetails(ResolveInfo ri) {
Intent in = new Intent().setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
.setData(Uri.fromParts("package", ri.activityInfo.packageName, null))
.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
@@ -1200,10 +1195,14 @@
* @return <code>true</code> if the activity is finishing and creation should halt.
*/
private boolean configureContentView() {
- if (mMultiProfilePagerAdapter.getCurrentListAdapter() == null) {
- throw new IllegalStateException("mAdapter cannot be null.");
+ if (mMultiProfilePagerAdapter.getActiveListAdapter() == null) {
+ throw new IllegalStateException("mMultiProfilePagerAdapter.getCurrentListAdapter() "
+ + "cannot be null.");
}
- boolean rebuildCompleted = mMultiProfilePagerAdapter.getCurrentListAdapter().rebuildList();
+ boolean rebuildCompleted = mMultiProfilePagerAdapter.getActiveListAdapter().rebuildList();
+ if (mMultiProfilePagerAdapter.getInactiveListAdapter() != null) {
+ mMultiProfilePagerAdapter.getInactiveListAdapter().rebuildList();
+ }
if (useLayoutWithDefault()) {
mLayoutId = R.layout.resolver_list_with_default;
} else {
@@ -1231,15 +1230,15 @@
*/
final boolean postRebuildListInternal(boolean rebuildCompleted) {
- int count = mMultiProfilePagerAdapter.getCurrentListAdapter().getUnfilteredCount();
+ int count = mMultiProfilePagerAdapter.getActiveListAdapter().getUnfilteredCount();
// We only rebuild asynchronously when we have multiple elements to sort. In the case where
// we're already done, we can check if we should auto-launch immediately.
if (rebuildCompleted) {
if (count == 1
- && mMultiProfilePagerAdapter.getCurrentListAdapter().getOtherProfile() == null) {
+ && mMultiProfilePagerAdapter.getActiveListAdapter().getOtherProfile() == null) {
// Only one target, so we're a candidate to auto-launch!
- final TargetInfo target = mMultiProfilePagerAdapter.getCurrentListAdapter()
+ final TargetInfo target = mMultiProfilePagerAdapter.getActiveListAdapter()
.targetInfoForPosition(0, false);
if (shouldAutoLaunchSingleChoice(target)) {
safelyStartActivity(target);
@@ -1257,12 +1256,12 @@
private void setupViewVisibilities(int count) {
if (count == 0
- && mMultiProfilePagerAdapter.getCurrentListAdapter().getPlaceholderCount() == 0) {
+ && mMultiProfilePagerAdapter.getActiveListAdapter().getPlaceholderCount() == 0) {
final TextView emptyView = findViewById(R.id.empty);
emptyView.setVisibility(View.VISIBLE);
findViewById(R.id.profile_pager).setVisibility(View.GONE);
} else {
- onPrepareAdapterView(mMultiProfilePagerAdapter.getCurrentListAdapter());
+ onPrepareAdapterView(mMultiProfilePagerAdapter.getActiveListAdapter());
}
}
@@ -1295,8 +1294,8 @@
* Configure the area above the app selection list (title, content preview, etc).
*/
public void setHeader() {
- if (mMultiProfilePagerAdapter.getCurrentListAdapter().getCount() == 0
- && mMultiProfilePagerAdapter.getCurrentListAdapter().getPlaceholderCount() == 0) {
+ if (mMultiProfilePagerAdapter.getActiveListAdapter().getCount() == 0
+ && mMultiProfilePagerAdapter.getActiveListAdapter().getPlaceholderCount() == 0) {
final TextView titleView = findViewById(R.id.title);
if (titleView != null) {
titleView.setVisibility(View.GONE);
@@ -1317,7 +1316,7 @@
final ImageView iconView = findViewById(R.id.icon);
if (iconView != null) {
- mMultiProfilePagerAdapter.getCurrentListAdapter().loadFilteredItemIconTaskAsync(iconView);
+ mMultiProfilePagerAdapter.getActiveListAdapter().loadFilteredItemIconTaskAsync(iconView);
}
}
@@ -1345,7 +1344,7 @@
}
private void resetAlwaysOrOnceButtonBar() {
- int filteredPosition = mMultiProfilePagerAdapter.getCurrentListAdapter()
+ int filteredPosition = mMultiProfilePagerAdapter.getActiveListAdapter()
.getFilteredPosition();
if (useLayoutWithDefault() && filteredPosition != ListView.INVALID_POSITION) {
setAlwaysButtonEnabled(true, filteredPosition, false);
@@ -1365,7 +1364,7 @@
@Override // ResolverListCommunicator
public boolean useLayoutWithDefault() {
return mSupportsAlwaysUseOption
- && mMultiProfilePagerAdapter.getCurrentListAdapter().hasFilteredItem();
+ && mMultiProfilePagerAdapter.getActiveListAdapter().hasFilteredItem();
}
/**
@@ -1389,7 +1388,9 @@
@Override // ResolverListCommunicator
public void onHandlePackagesChanged() {
- if (mMultiProfilePagerAdapter.getCurrentListAdapter().getCount() == 0) {
+ ResolverListAdapter activeListAdapter = mMultiProfilePagerAdapter.getActiveListAdapter();
+ activeListAdapter.rebuildList();
+ if (activeListAdapter.getCount() == 0) {
// We no longer have any items... just finish the activity.
finish();
}
@@ -1464,7 +1465,7 @@
return;
}
// If we're still loading, we can't yet enable the buttons.
- if (mMultiProfilePagerAdapter.getCurrentListAdapter()
+ if (mMultiProfilePagerAdapter.getActiveListAdapter()
.resolveInfoForPosition(position, true) == null) {
return;
}
@@ -1497,7 +1498,7 @@
// Header views don't count.
return false;
}
- ResolveInfo ri = mMultiProfilePagerAdapter.getCurrentListAdapter()
+ ResolveInfo ri = mMultiProfilePagerAdapter.getActiveListAdapter()
.resolveInfoForPosition(position, true);
showTargetDetails(ri);
return true;
@@ -1538,7 +1539,7 @@
final ResolverActivity ra = (ResolverActivity) getActivity();
if (ra != null) {
- final TargetInfo ti = ra.mMultiProfilePagerAdapter.getCurrentListAdapter()
+ final TargetInfo ti = ra.mMultiProfilePagerAdapter.getActiveListAdapter()
.getItem(selections[0].getIndex());
if (ra.onTargetSelected(ti, false)) {
ra.mPickOptionRequest = null;
diff --git a/core/java/com/android/internal/app/ResolverListAdapter.java b/core/java/com/android/internal/app/ResolverListAdapter.java
index 48064da..ef7a347 100644
--- a/core/java/com/android/internal/app/ResolverListAdapter.java
+++ b/core/java/com/android/internal/app/ResolverListAdapter.java
@@ -113,7 +113,6 @@
}
public void handlePackagesChanged() {
- rebuildList();
mResolverListCommunicator.onHandlePackagesChanged();
}
@@ -351,12 +350,12 @@
* determine the layout known. We therefore can't update the UI inline and post to the
* handler thread to update after the current task is finished.
*/
- private void postListReadyRunnable() {
+ void postListReadyRunnable() {
if (mPostListReadyRunnable == null) {
mPostListReadyRunnable = new Runnable() {
@Override
public void run() {
- mResolverListCommunicator.onPostListReady();
+ mResolverListCommunicator.onPostListReady(ResolverListAdapter.this);
mPostListReadyRunnable = null;
}
};
@@ -599,7 +598,7 @@
Intent getReplacementIntent(ActivityInfo activityInfo, Intent defIntent);
- void onPostListReady();
+ void onPostListReady(ResolverListAdapter listAdapter);
void sendVoiceChoicesIfNeeded();
diff --git a/core/java/com/android/internal/app/ResolverMultiProfilePagerAdapter.java b/core/java/com/android/internal/app/ResolverMultiProfilePagerAdapter.java
index 9e814ab..d72c52b 100644
--- a/core/java/com/android/internal/app/ResolverMultiProfilePagerAdapter.java
+++ b/core/java/com/android/internal/app/ResolverMultiProfilePagerAdapter.java
@@ -87,13 +87,22 @@
@Override
@VisibleForTesting
- public ResolverListAdapter getCurrentListAdapter() {
+ public ResolverListAdapter getActiveListAdapter() {
return getAdapterForIndex(getCurrentPage());
}
@Override
+ @VisibleForTesting
+ public ResolverListAdapter getInactiveListAdapter() {
+ if (getCount() == 1) {
+ return null;
+ }
+ return getAdapterForIndex(1 - getCurrentPage());
+ }
+
+ @Override
ResolverListAdapter getCurrentRootAdapter() {
- return getCurrentListAdapter();
+ return getActiveListAdapter();
}
@Override
diff --git a/core/java/com/android/internal/app/ResolverTargetActionsDialogFragment.java b/core/java/com/android/internal/app/ResolverTargetActionsDialogFragment.java
index df91c4a..bdbe210 100644
--- a/core/java/com/android/internal/app/ResolverTargetActionsDialogFragment.java
+++ b/core/java/com/android/internal/app/ResolverTargetActionsDialogFragment.java
@@ -24,14 +24,19 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import com.android.internal.R;
+import com.android.internal.app.chooser.DisplayResolveInfo;
+
+import java.util.ArrayList;
+import java.util.List;
/**
- * Shows a dialog with actions to take on a chooser target
+ * Shows a dialog with actions to take on a chooser target.
*/
public class ResolverTargetActionsDialogFragment extends DialogFragment
implements DialogInterface.OnClickListener {
@@ -43,6 +48,10 @@
private static final int TOGGLE_PIN_INDEX = 0;
private static final int APP_INFO_INDEX = 1;
+ private List<DisplayResolveInfo> mTargetInfos = new ArrayList<>();
+ private List<CharSequence> mLabels = new ArrayList<>();
+ private boolean[] mPinned;
+
public ResolverTargetActionsDialogFragment() {
}
@@ -55,15 +64,43 @@
setArguments(args);
}
+ public ResolverTargetActionsDialogFragment(CharSequence title, ComponentName name,
+ List<DisplayResolveInfo> targets, List<CharSequence> labels) {
+ Bundle args = new Bundle();
+ args.putCharSequence(TITLE_KEY, title);
+ args.putParcelable(NAME_KEY, name);
+ mTargetInfos = targets;
+ mLabels = labels;
+ setArguments(args);
+ }
+
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Bundle args = getArguments();
final int itemRes = args.getBoolean(PINNED_KEY, false)
? R.array.resolver_target_actions_unpin
: R.array.resolver_target_actions_pin;
+ String[] defaultActions = getResources().getStringArray(itemRes);
+ CharSequence[] items;
+
+ if (mTargetInfos == null || mTargetInfos.size() < 2) {
+ items = defaultActions;
+ } else {
+ // Pin item for each sub-item
+ items = new CharSequence[mTargetInfos.size() + 1];
+ for (int i = 0; i < mTargetInfos.size(); i++) {
+ items[i] = mTargetInfos.get(i).isPinned()
+ ? getResources().getString(R.string.unpin_specific_target, mLabels.get(i))
+ : getResources().getString(R.string.pin_specific_target, mLabels.get(i));
+ }
+ // "App info"
+ items[mTargetInfos.size()] = defaultActions[1];
+ }
+
+
return new Builder(getContext())
.setCancelable(true)
- .setItems(itemRes, this)
+ .setItems(items, this)
.setTitle(args.getCharSequence(TITLE_KEY))
.create();
}
@@ -72,27 +109,41 @@
public void onClick(DialogInterface dialog, int which) {
final Bundle args = getArguments();
ComponentName name = args.getParcelable(NAME_KEY);
- switch (which) {
- case TOGGLE_PIN_INDEX:
- SharedPreferences sp = ChooserActivity.getPinnedSharedPrefs(getContext());
- final String key = name.flattenToString();
- boolean currentVal = sp.getBoolean(name.flattenToString(), false);
- if (currentVal) {
- sp.edit().remove(key).apply();
- } else {
- sp.edit().putBoolean(key, true).apply();
- }
-
- // Force the chooser to requery and resort things
- getActivity().recreate();
- break;
- case APP_INFO_INDEX:
- Intent in = new Intent().setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
- .setData(Uri.fromParts("package", name.getPackageName(), null))
- .addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
- startActivity(in);
- break;
+ if (which == 0 || (mTargetInfos.size() > 0 && which < mTargetInfos.size())) {
+ if (mTargetInfos == null || mTargetInfos.size() == 0) {
+ pinComponent(name);
+ } else {
+ pinComponent(mTargetInfos.get(which).getResolvedComponentName());
+ }
+ // Force the chooser to requery and resort things
+ getActivity().recreate();
+ } else {
+ // Last item in dialog is App Info
+ Intent in = new Intent().setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
+ .setData(Uri.fromParts("package", name.getPackageName(), null))
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
+ startActivity(in);
}
dismiss();
}
+
+ private void pinComponent(ComponentName name) {
+ SharedPreferences sp = ChooserActivity.getPinnedSharedPrefs(getContext());
+ final String key = name.flattenToString();
+ boolean currentVal = sp.getBoolean(name.flattenToString(), false);
+ if (currentVal) {
+ sp.edit().remove(key).apply();
+ } else {
+ sp.edit().putBoolean(key, true).apply();
+ }
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ // Dismiss on config changed (eg: rotation)
+ // TODO: Maintain state on config change
+ super.onConfigurationChanged(newConfig);
+ dismiss();
+ }
+
}
diff --git a/core/java/com/android/internal/app/chooser/DisplayResolveInfo.java b/core/java/com/android/internal/app/chooser/DisplayResolveInfo.java
index f92637c..86a9af3 100644
--- a/core/java/com/android/internal/app/chooser/DisplayResolveInfo.java
+++ b/core/java/com/android/internal/app/chooser/DisplayResolveInfo.java
@@ -91,6 +91,16 @@
mResolveInfoPresentationGetter = resolveInfoPresentationGetter;
}
+ DisplayResolveInfo(DisplayResolveInfo other) {
+ mSourceIntents.addAll(other.getAllSourceIntents());
+ mResolveInfo = other.mResolveInfo;
+ mDisplayLabel = other.mDisplayLabel;
+ mDisplayIcon = other.mDisplayIcon;
+ mExtendedInfo = other.mExtendedInfo;
+ mResolvedIntent = other.mResolvedIntent;
+ mResolveInfoPresentationGetter = other.mResolveInfoPresentationGetter;
+ }
+
public ResolveInfo getResolveInfo() {
return mResolveInfo;
}
@@ -189,4 +199,5 @@
public void setPinned(boolean pinned) {
mPinned = pinned;
}
+
}
diff --git a/core/java/com/android/internal/app/chooser/MultiDisplayResolveInfo.java b/core/java/com/android/internal/app/chooser/MultiDisplayResolveInfo.java
new file mode 100644
index 0000000..4c52411
--- /dev/null
+++ b/core/java/com/android/internal/app/chooser/MultiDisplayResolveInfo.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2019 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 com.android.internal.app.chooser;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a "stack" of chooser targets for various activities within the same component.
+ */
+public class MultiDisplayResolveInfo extends DisplayResolveInfo {
+
+ List<DisplayResolveInfo> mTargetInfos = new ArrayList<>();
+ String mPackageName;
+ // We'll use this DRI for basic presentation info - eg icon, name.
+ final DisplayResolveInfo mBaseInfo;
+
+ /**
+ * @param firstInfo A representative DRI to use for the main icon, title, etc for this Info.
+ */
+ public MultiDisplayResolveInfo(String packageName, DisplayResolveInfo firstInfo) {
+ super(firstInfo);
+ mBaseInfo = firstInfo;
+ mTargetInfos.add(firstInfo);
+ }
+
+ /**
+ * Add another DisplayResolveInfo to the list included for this target.
+ */
+ public void addTarget(DisplayResolveInfo target) {
+ mTargetInfos.add(target);
+ }
+
+ /**
+ * List of all DisplayResolveInfos included in this target.
+ */
+ public List<DisplayResolveInfo> getTargets() {
+ return mTargetInfos;
+ }
+
+}
diff --git a/core/java/com/android/internal/content/NativeLibraryHelper.java b/core/java/com/android/internal/content/NativeLibraryHelper.java
index f5fae19..22fe31e 100644
--- a/core/java/com/android/internal/content/NativeLibraryHelper.java
+++ b/core/java/com/android/internal/content/NativeLibraryHelper.java
@@ -444,7 +444,7 @@
return sum;
}
- /**
+ /**
* Configure the native library files managed by Incremental Service. Makes sure Incremental
* Service will create native library directories and set up native library binary files in the
* same structure as they are in non-incremental installations.
@@ -458,8 +458,20 @@
*/
public static int configureNativeBinariesForSupportedAbi(AndroidPackage pkg, Handle handle,
File libraryRoot, String[] abiList, boolean useIsaSubdir) {
- // TODO(b/136132412): Implement this.
- return -1;
+ int abi = findSupportedAbi(handle, abiList);
+ if (abi < 0) {
+ Slog.e(TAG, "Failed to find find matching ABI.");
+ return abi;
+ }
+
+ // Currently only support installations that have pre-configured native library files
+ // TODO(b/136132412): implement this after incfs supports file mapping
+ if (!libraryRoot.exists()) {
+ Slog.e(TAG, "Incremental installation currently does not configure native libs");
+ return INSTALL_FAILED_NO_MATCHING_ABIS;
+ }
+
+ return abi;
}
// We don't care about the other return values for now.
diff --git a/core/java/com/android/internal/infra/AndroidFuture.java b/core/java/com/android/internal/infra/AndroidFuture.java
index d78bd73..b250578 100644
--- a/core/java/com/android/internal/infra/AndroidFuture.java
+++ b/core/java/com/android/internal/infra/AndroidFuture.java
@@ -531,6 +531,12 @@
try {
AndroidFuture.this.complete((T) resultContainer.get());
} catch (Throwable t) {
+ // If resultContainer was completed exceptionally, get() wraps the
+ // underlying exception in an ExecutionException. Unwrap it now to avoid
+ // double-layering ExecutionExceptions.
+ if (t instanceof ExecutionException && t.getCause() != null) {
+ t = t.getCause();
+ }
completeExceptionally(t);
}
}
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index bc44fcf..d0a83c4 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -16,6 +16,9 @@
package com.android.internal.os;
+import static android.os.BatteryStatsManager.NUM_WIFI_STATES;
+import static android.os.BatteryStatsManager.NUM_WIFI_SUPPL_STATES;
+
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
@@ -5267,7 +5270,7 @@
// Unknown is included in DATA_CONNECTION_OTHER.
int bin = DATA_CONNECTION_OUT_OF_SERVICE;
if (hasData) {
- if (dataType > 0 && dataType <= TelephonyManager.MAX_NETWORK_TYPE) {
+ if (dataType > 0 && dataType <= TelephonyManager.getAllNetworkTypes().length) {
bin = dataType;
} else {
switch (serviceType) {
diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java
index c33b6dc..29b148c 100644
--- a/core/java/com/android/internal/policy/DecorView.java
+++ b/core/java/com/android/internal/policy/DecorView.java
@@ -22,6 +22,8 @@
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.os.Build.VERSION_CODES.M;
import static android.os.Build.VERSION_CODES.N;
+import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
+import static android.view.InsetsState.ITYPE_STATUS_BAR;
import static android.view.View.MeasureSpec.AT_MOST;
import static android.view.View.MeasureSpec.EXACTLY;
import static android.view.View.MeasureSpec.getMode;
@@ -74,6 +76,8 @@
import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.InputQueue;
+import android.view.InsetsState;
+import android.view.InsetsState.InternalInsetsType;
import android.view.KeyEvent;
import android.view.KeyboardShortcutGroup;
import android.view.LayoutInflater;
@@ -90,6 +94,9 @@
import android.view.Window;
import android.view.WindowCallbacks;
import android.view.WindowInsets;
+import android.view.WindowInsets.Side;
+import android.view.WindowInsets.Type;
+import android.view.WindowInsetsController;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
@@ -134,7 +141,7 @@
Gravity.TOP, Gravity.LEFT, Gravity.RIGHT,
Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME,
com.android.internal.R.id.statusBarBackground,
- FLAG_FULLSCREEN);
+ FLAG_FULLSCREEN, ITYPE_STATUS_BAR);
public static final ColorViewAttributes NAVIGATION_BAR_COLOR_VIEW_ATTRIBUTES =
new ColorViewAttributes(
@@ -142,7 +149,7 @@
Gravity.BOTTOM, Gravity.RIGHT, Gravity.LEFT,
Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME,
com.android.internal.R.id.navigationBarBackground,
- 0 /* hideWindowFlag */);
+ 0 /* hideWindowFlag */, ITYPE_NAVIGATION_BAR);
// This is used to workaround an issue where the PiP shadow can be transparent if the window
// background is transparent
@@ -1085,6 +1092,9 @@
WindowManager.LayoutParams attrs = mWindow.getAttributes();
int sysUiVisibility = attrs.systemUiVisibility | getWindowSystemUiVisibility();
+ final WindowInsetsController controller = getWindowInsetsController();
+ final InsetsState state = controller != null ? controller.getState() : null;
+
// IME is an exceptional floating window that requires color view.
final boolean isImeWindow =
mWindow.getAttributes().type == WindowManager.LayoutParams.TYPE_INPUT_METHOD;
@@ -1133,7 +1143,7 @@
calculateNavigationBarColor(), mWindow.mNavigationBarDividerColor, navBarSize,
navBarToRightEdge || navBarToLeftEdge, navBarToLeftEdge,
0 /* sideInset */, animate && !disallowAnimate,
- mForceWindowDrawsBarBackgrounds);
+ mForceWindowDrawsBarBackgrounds, state);
boolean oldDrawLegacy = mDrawLegacyNavigationBarBackground;
mDrawLegacyNavigationBarBackground = mNavigationColorViewState.visible
&& (mWindow.getAttributes().flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0;
@@ -1154,7 +1164,7 @@
calculateStatusBarColor(), 0, mLastTopInset,
false /* matchVertical */, statusBarNeedsLeftInset, statusBarSideInset,
animate && !disallowAnimate,
- mForceWindowDrawsBarBackgrounds);
+ mForceWindowDrawsBarBackgrounds, state);
}
// When we expand the window with FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS or
@@ -1164,16 +1174,19 @@
// Note: We don't need to check for IN_SCREEN or INSET_DECOR because unlike the status bar,
// these flags wouldn't make the window draw behind the navigation bar, unless
// LAYOUT_HIDE_NAVIGATION was set.
- boolean hideNavigation = (sysUiVisibility & SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0;
+ boolean hideNavigation = (sysUiVisibility & SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0
+ || !(state == null || state.getSource(ITYPE_NAVIGATION_BAR).isVisible());
boolean forceConsumingNavBar = (mForceWindowDrawsBarBackgrounds
&& (attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0
&& (sysUiVisibility & SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) == 0
+ && (attrs.getFitWindowInsetsTypes() & Type.navigationBars()) != 0
&& !hideNavigation)
|| (mLastShouldAlwaysConsumeSystemBars && hideNavigation);
boolean consumingNavBar =
((attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0
&& (sysUiVisibility & SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) == 0
+ && (attrs.getFitWindowInsetsTypes() & Type.navigationBars()) != 0
&& !hideNavigation)
|| forceConsumingNavBar;
@@ -1182,18 +1195,21 @@
// If we should always consume system bars, only consume that if the app wanted to go to
// fullscreen, as othrewise we can expect the app to handle it.
boolean fullscreen = (sysUiVisibility & SYSTEM_UI_FLAG_FULLSCREEN) != 0
- || (attrs.flags & FLAG_FULLSCREEN) != 0;
+ || (attrs.flags & FLAG_FULLSCREEN) != 0
+ || !(state == null || state.getSource(ITYPE_STATUS_BAR).isVisible());
boolean consumingStatusBar = (sysUiVisibility & SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) == 0
&& (attrs.flags & FLAG_LAYOUT_IN_SCREEN) == 0
&& (attrs.flags & FLAG_LAYOUT_INSET_DECOR) == 0
+ && (attrs.getFitWindowInsetsTypes() & Type.statusBars()) != 0
&& mForceWindowDrawsBarBackgrounds
&& mLastTopInset != 0
|| (mLastShouldAlwaysConsumeSystemBars && fullscreen);
- int consumedTop = consumingStatusBar ? mLastTopInset : 0;
- int consumedRight = consumingNavBar ? mLastRightInset : 0;
- int consumedBottom = consumingNavBar ? mLastBottomInset : 0;
- int consumedLeft = consumingNavBar ? mLastLeftInset : 0;
+ int sides = attrs.getFitWindowInsetsSides();
+ int consumedTop = consumingStatusBar && (sides & Side.TOP) != 0 ? mLastTopInset : 0;
+ int consumedRight = consumingNavBar && (sides & Side.RIGHT) != 0 ? mLastRightInset : 0;
+ int consumedBottom = consumingNavBar && (sides & Side.BOTTOM) != 0 ? mLastBottomInset : 0;
+ int consumedLeft = consumingNavBar && (sides & Side.LEFT) != 0 ? mLastLeftInset : 0;
if (mContentRoot != null
&& mContentRoot.getLayoutParams() instanceof MarginLayoutParams) {
@@ -1325,8 +1341,10 @@
*/
private void updateColorViewInt(final ColorViewState state, int sysUiVis, int color,
int dividerColor, int size, boolean verticalBar, boolean seascape, int sideMargin,
- boolean animate, boolean force) {
- state.present = state.attributes.isPresent(sysUiVis, mWindow.getAttributes().flags, force);
+ boolean animate, boolean force, InsetsState insetsState) {
+ state.present = ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL
+ ? state.attributes.isPresent(sysUiVis, mWindow.getAttributes().flags, force)
+ : state.attributes.isPresent(insetsState, mWindow.getAttributes().flags, force);
boolean show = state.attributes.isVisible(state.present, color,
mWindow.getAttributes().flags, force);
boolean showView = show && !isResizing() && size > 0;
@@ -2536,10 +2554,11 @@
final int seascapeGravity;
final String transitionName;
final int hideWindowFlag;
+ final @InternalInsetsType int insetsType;
private ColorViewAttributes(int systemUiHideFlag, int translucentFlag, int verticalGravity,
int horizontalGravity, int seascapeGravity, String transitionName, int id,
- int hideWindowFlag) {
+ int hideWindowFlag, @InternalInsetsType int insetsType) {
this.id = id;
this.systemUiHideFlag = systemUiHideFlag;
this.translucentFlag = translucentFlag;
@@ -2548,8 +2567,10 @@
this.seascapeGravity = seascapeGravity;
this.transitionName = transitionName;
this.hideWindowFlag = hideWindowFlag;
+ this.insetsType = insetsType;
}
+ // TODO(b/118118435): remove after migration
public boolean isPresent(int sysUiVis, int windowFlags, boolean force) {
return (sysUiVis & systemUiHideFlag) == 0
&& (windowFlags & hideWindowFlag) == 0
@@ -2557,16 +2578,27 @@
|| force);
}
+ public boolean isPresent(InsetsState state, int windowFlags, boolean force) {
+ return (state == null || state.getSource(insetsType).isVisible())
+ && ((windowFlags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0 || force);
+ }
+
public boolean isVisible(boolean present, int color, int windowFlags, boolean force) {
return present
&& (color & Color.BLACK) != 0
&& ((windowFlags & translucentFlag) == 0 || force);
}
+ // TODO(b/118118435): remove after migration
public boolean isVisible(int sysUiVis, int color, int windowFlags, boolean force) {
final boolean present = isPresent(sysUiVis, windowFlags, force);
return isVisible(present, color, windowFlags, force);
}
+
+ public boolean isVisible(InsetsState state, int color, int windowFlags, boolean force) {
+ final boolean present = isPresent(state, windowFlags, force);
+ return isVisible(present, color, windowFlags, force);
+ }
}
/**
diff --git a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl
index 2f34aa0..1c71b0a 100644
--- a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl
+++ b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl
@@ -24,6 +24,8 @@
import android.telephony.CellInfo;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.PhoneCapability;
+import android.telephony.PhysicalChannelConfig;
+import android.telephony.PreciseDataConnectionState;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.emergency.EmergencyNumber;
@@ -60,16 +62,10 @@
@UnsupportedAppUsage(maxTargetSdk = 28)
void notifyDataActivity(int state);
void notifyDataActivityForSubscriber(in int subId, int state);
- void notifyDataConnection(int state, boolean isDataConnectivityPossible,
- String apn, String apnType, in LinkProperties linkProperties,
- in NetworkCapabilities networkCapabilities, int networkType, boolean roaming);
- void notifyDataConnectionForSubscriber(int phoneId, int subId, int state,
- boolean isDataConnectivityPossible,
- String apn, String apnType, in LinkProperties linkProperties,
- in NetworkCapabilities networkCapabilities, int networkType, boolean roaming);
+ void notifyDataConnectionForSubscriber(
+ int phoneId, int subId, String apnType, in PreciseDataConnectionState preciseState);
@UnsupportedAppUsage
void notifyDataConnectionFailed(String apnType);
- void notifyDataConnectionFailedForSubscriber(int phoneId, int subId, String apnType);
@UnsupportedAppUsage(maxTargetSdk = 28)
void notifyCellLocation(in Bundle cellLocation);
void notifyCellLocationForSubscriber(in int subId, in Bundle cellLocation);
diff --git a/core/java/com/android/internal/util/CollectionUtils.java b/core/java/com/android/internal/util/CollectionUtils.java
index 4165f20..4dac542 100644
--- a/core/java/com/android/internal/util/CollectionUtils.java
+++ b/core/java/com/android/internal/util/CollectionUtils.java
@@ -308,6 +308,17 @@
}
/**
+ * @see #add(List, Object)
+ */
+ public static @NonNull <K, V> Map<K, V> add(@Nullable Map<K, V> map, K key, V value) {
+ if (map == null || map == Collections.emptyMap()) {
+ map = new ArrayMap<>();
+ }
+ map.put(key, value);
+ return map;
+ }
+
+ /**
* Similar to {@link List#remove}, but with support for list values of {@code null} and
* {@link Collections#emptyList}
*/
diff --git a/core/java/com/android/internal/util/ScreenRecordHelper.java b/core/java/com/android/internal/util/ScreenRecordHelper.java
index 64d0898..ec7ed4e 100644
--- a/core/java/com/android/internal/util/ScreenRecordHelper.java
+++ b/core/java/com/android/internal/util/ScreenRecordHelper.java
@@ -24,10 +24,6 @@
* Helper class to initiate a screen recording
*/
public class ScreenRecordHelper {
- private static final String SYSUI_PACKAGE = "com.android.systemui";
- private static final String SYSUI_SCREENRECORD_LAUNCHER =
- "com.android.systemui.screenrecord.ScreenRecordDialog";
-
private final Context mContext;
/**
@@ -42,8 +38,9 @@
* Show dialog of screen recording options to user.
*/
public void launchRecordPrompt() {
- final ComponentName launcherComponent = new ComponentName(SYSUI_PACKAGE,
- SYSUI_SCREENRECORD_LAUNCHER);
+ final ComponentName launcherComponent = ComponentName.unflattenFromString(
+ mContext.getResources().getString(
+ com.android.internal.R.string.config_screenRecorderComponent));
final Intent intent = new Intent();
intent.setComponent(launcherComponent);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
diff --git a/core/java/com/android/internal/util/ScreenshotHelper.java b/core/java/com/android/internal/util/ScreenshotHelper.java
index f6f187f..8cad5a0 100644
--- a/core/java/com/android/internal/util/ScreenshotHelper.java
+++ b/core/java/com/android/internal/util/ScreenshotHelper.java
@@ -20,12 +20,6 @@
public class ScreenshotHelper {
private static final String TAG = "ScreenshotHelper";
- private static final String SYSUI_PACKAGE = "com.android.systemui";
- private static final String SYSUI_SCREENSHOT_SERVICE =
- "com.android.systemui.screenshot.TakeScreenshotService";
- private static final String SYSUI_SCREENSHOT_ERROR_RECEIVER =
- "com.android.systemui.screenshot.ScreenshotServiceErrorReceiver";
-
// Time until we give up on the screenshot & show an error instead.
private final int SCREENSHOT_TIMEOUT_MS = 10000;
@@ -94,8 +88,9 @@
if (mScreenshotConnection != null) {
return;
}
- final ComponentName serviceComponent = new ComponentName(SYSUI_PACKAGE,
- SYSUI_SCREENSHOT_SERVICE);
+ final ComponentName serviceComponent = ComponentName.unflattenFromString(
+ mContext.getResources().getString(
+ com.android.internal.R.string.config_screenshotServiceComponent));
final Intent serviceIntent = new Intent();
final Runnable mScreenshotTimeout = new Runnable() {
@@ -181,8 +176,9 @@
*/
private void notifyScreenshotError() {
// If the service process is killed, then ask it to clean up after itself
- final ComponentName errorComponent = new ComponentName(SYSUI_PACKAGE,
- SYSUI_SCREENSHOT_ERROR_RECEIVER);
+ final ComponentName errorComponent = ComponentName.unflattenFromString(
+ mContext.getResources().getString(
+ com.android.internal.R.string.config_screenshotErrorReceiverComponent));
// Broadcast needs to have a valid action. We'll just pick
// a generic one, since the receiver here doesn't care.
Intent errorIntent = new Intent(Intent.ACTION_USER_PRESENT);
diff --git a/core/java/com/android/server/SystemConfig.java b/core/java/com/android/server/SystemConfig.java
index 49a73ee..8a59c99 100644
--- a/core/java/com/android/server/SystemConfig.java
+++ b/core/java/com/android/server/SystemConfig.java
@@ -25,6 +25,7 @@
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Environment;
+import android.os.FileUtils;
import android.os.Process;
import android.os.SystemProperties;
import android.os.Trace;
@@ -222,11 +223,13 @@
private ArrayMap<String, Set<String>> mPackageToUserTypeWhitelist = new ArrayMap<>();
private ArrayMap<String, Set<String>> mPackageToUserTypeBlacklist = new ArrayMap<>();
+ private final ArraySet<String> mRollbackWhitelistedPackages = new ArraySet<>();
+
/**
* Map of system pre-defined, uniquely named actors; keys are namespace,
* value maps actor name to package name.
*/
- private ArrayMap<String, ArrayMap<String, String>> mNamedActors = null;
+ private Map<String, Map<String, String>> mNamedActors = null;
public static SystemConfig getInstance() {
if (!isSystemProcess()) {
@@ -382,6 +385,10 @@
return mBugreportWhitelistedPackages;
}
+ public Set<String> getRollbackWhitelistedPackages() {
+ return mRollbackWhitelistedPackages;
+ }
+
/**
* Gets map of packagesNames to userTypes, dictating on which user types each package should be
* initially installed, and then removes this map from SystemConfig.
@@ -406,7 +413,7 @@
}
@NonNull
- public Map<String, ? extends Map<String, String>> getNamedActors() {
+ public Map<String, Map<String, String>> getNamedActors() {
return mNamedActors != null ? mNamedActors : Collections.emptyMap();
}
@@ -492,6 +499,19 @@
Environment.getSystemExtDirectory(), "etc", "sysconfig"), ALLOW_ALL);
readPermissions(Environment.buildPath(
Environment.getSystemExtDirectory(), "etc", "permissions"), ALLOW_ALL);
+
+ // Skip loading configuration from apex if it is not a system process.
+ if (!isSystemProcess()) {
+ return;
+ }
+ // Read configuration of libs from apex module.
+ // TODO: Use a solid way to filter apex module folders?
+ for (File f: FileUtils.listFilesOrEmpty(Environment.getApexDirectory())) {
+ if (f.isFile() || f.getPath().contains("@")) {
+ continue;
+ }
+ readPermissions(Environment.buildPath(f, "etc", "permissions"), ALLOW_LIBS);
+ }
}
@VisibleForTesting
@@ -1063,7 +1083,7 @@
mNamedActors = new ArrayMap<>();
}
- ArrayMap<String, String> nameToPkgMap = mNamedActors.get(namespace);
+ Map<String, String> nameToPkgMap = mNamedActors.get(namespace);
if (nameToPkgMap == null) {
nameToPkgMap = new ArrayMap<>();
mNamedActors.put(namespace, nameToPkgMap);
@@ -1078,6 +1098,16 @@
}
XmlUtils.skipCurrentTag(parser);
} break;
+ case "rollback-whitelisted-app": {
+ String pkgname = parser.getAttributeValue(null, "package");
+ if (pkgname == null) {
+ Slog.w(TAG, "<" + name + "> without package in " + permFile
+ + " at " + parser.getPositionDescription());
+ } else {
+ mRollbackWhitelistedPackages.add(pkgname);
+ }
+ XmlUtils.skipCurrentTag(parser);
+ } break;
default: {
Slog.w(TAG, "Tag " + name + " is unknown in "
+ permFile + " at " + parser.getPositionDescription());
diff --git a/core/jni/android/graphics/AnimatedImageDrawable.cpp b/core/jni/android/graphics/AnimatedImageDrawable.cpp
index 1290026..6c2a5a3 100644
--- a/core/jni/android/graphics/AnimatedImageDrawable.cpp
+++ b/core/jni/android/graphics/AnimatedImageDrawable.cpp
@@ -25,6 +25,7 @@
#include <SkPicture.h>
#include <SkPictureRecorder.h>
#include <hwui/AnimatedImageDrawable.h>
+#include <hwui/ImageDecoder.h>
#include <hwui/Canvas.h>
#include <utils/Looper.h>
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index 3f05c3b..fa64fd1 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -7,7 +7,6 @@
#include "SkAndroidCodec.h"
#include "SkBRDAllocator.h"
#include "SkFrontBufferedStream.h"
-#include "SkMakeUnique.h"
#include "SkMath.h"
#include "SkPixelRef.h"
#include "SkStream.h"
@@ -586,7 +585,7 @@
Asset* asset = reinterpret_cast<Asset*>(native_asset);
// since we know we'll be done with the asset when we return, we can
// just use a simple wrapper
- return doDecode(env, skstd::make_unique<AssetStreamAdaptor>(asset), padding, options,
+ return doDecode(env, std::make_unique<AssetStreamAdaptor>(asset), padding, options,
inBitmapHandle, colorSpaceHandle);
}
@@ -594,7 +593,7 @@
jint offset, jint length, jobject options, jlong inBitmapHandle, jlong colorSpaceHandle) {
AutoJavaByteArray ar(env, byteArray);
- return doDecode(env, skstd::make_unique<SkMemoryStream>(ar.ptr() + offset, length, false),
+ return doDecode(env, std::make_unique<SkMemoryStream>(ar.ptr() + offset, length, false),
nullptr, options, inBitmapHandle, colorSpaceHandle);
}
diff --git a/core/jni/android/graphics/ImageDecoder.cpp b/core/jni/android/graphics/ImageDecoder.cpp
index 4d907f6..627f8f5 100644
--- a/core/jni/android/graphics/ImageDecoder.cpp
+++ b/core/jni/android/graphics/ImageDecoder.cpp
@@ -20,10 +20,12 @@
#include "CreateJavaOutputStreamAdaptor.h"
#include "GraphicsJNI.h"
#include "ImageDecoder.h"
+#include "NinePatchPeeker.h"
#include "Utils.h"
#include "core_jni_helpers.h"
#include <hwui/Bitmap.h>
+#include <hwui/ImageDecoder.h>
#include <HardwareBitmapUploader.h>
#include <SkAndroidCodec.h>
@@ -49,6 +51,28 @@
static jmethodID gCanvas_constructorMethodID;
static jmethodID gCanvas_releaseMethodID;
+// These need to stay in sync with ImageDecoder.java's Allocator constants.
+enum Allocator {
+ kDefault_Allocator = 0,
+ kSoftware_Allocator = 1,
+ kSharedMemory_Allocator = 2,
+ kHardware_Allocator = 3,
+};
+
+// These need to stay in sync with ImageDecoder.java's Error constants.
+enum Error {
+ kSourceException = 1,
+ kSourceIncomplete = 2,
+ kSourceMalformedData = 3,
+};
+
+// These need to stay in sync with PixelFormat.java's Format constants.
+enum PixelFormat {
+ kUnknown = 0,
+ kTranslucent = -3,
+ kOpaque = -1,
+};
+
// Clear and return any pending exception for handling other than throwing directly.
static jthrowable get_and_clear_exception(JNIEnv* env) {
jthrowable jexception = env->ExceptionOccurred();
@@ -59,7 +83,7 @@
}
// Throw a new ImageDecoder.DecodeException. Returns null for convenience.
-static jobject throw_exception(JNIEnv* env, ImageDecoder::Error error, const char* msg,
+static jobject throw_exception(JNIEnv* env, Error error, const char* msg,
jthrowable cause, jobject source) {
jstring jstr = nullptr;
if (msg) {
@@ -81,27 +105,27 @@
static jobject native_create(JNIEnv* env, std::unique_ptr<SkStream> stream,
jobject source, jboolean preferAnimation) {
if (!stream.get()) {
- return throw_exception(env, ImageDecoder::kSourceMalformedData, "Failed to create a stream",
+ return throw_exception(env, kSourceMalformedData, "Failed to create a stream",
nullptr, source);
}
- std::unique_ptr<ImageDecoder> decoder(new ImageDecoder);
+ sk_sp<NinePatchPeeker> peeker(new NinePatchPeeker);
SkCodec::Result result;
auto codec = SkCodec::MakeFromStream(
- std::move(stream), &result, decoder->mPeeker.get(),
+ std::move(stream), &result, peeker.get(),
preferAnimation ? SkCodec::SelectionPolicy::kPreferAnimation
: SkCodec::SelectionPolicy::kPreferStillImage);
if (jthrowable jexception = get_and_clear_exception(env)) {
- return throw_exception(env, ImageDecoder::kSourceException, "", jexception, source);
+ return throw_exception(env, kSourceException, "", jexception, source);
}
if (!codec) {
switch (result) {
case SkCodec::kIncompleteInput:
- return throw_exception(env, ImageDecoder::kSourceIncomplete, "", nullptr, source);
+ return throw_exception(env, kSourceIncomplete, "", nullptr, source);
default:
SkString msg;
msg.printf("Failed to create image decoder with message '%s'",
SkCodec::ResultToString(result));
- return throw_exception(env, ImageDecoder::kSourceMalformedData, msg.c_str(),
+ return throw_exception(env, kSourceMalformedData, msg.c_str(),
nullptr, source);
}
@@ -109,21 +133,22 @@
const bool animated = codec->getFrameCount() > 1;
if (jthrowable jexception = get_and_clear_exception(env)) {
- return throw_exception(env, ImageDecoder::kSourceException, "", jexception, source);
+ return throw_exception(env, kSourceException, "", jexception, source);
}
- decoder->mCodec = SkAndroidCodec::MakeFromCodec(std::move(codec),
+ auto androidCodec = SkAndroidCodec::MakeFromCodec(std::move(codec),
SkAndroidCodec::ExifOrientationBehavior::kRespect);
- if (!decoder->mCodec.get()) {
- return throw_exception(env, ImageDecoder::kSourceMalformedData, "", nullptr, source);
+ if (!androidCodec.get()) {
+ return throw_exception(env, kSourceMalformedData, "", nullptr, source);
}
- const auto& info = decoder->mCodec->getInfo();
+ const auto& info = androidCodec->getInfo();
const int width = info.width();
const int height = info.height();
- const bool isNinePatch = decoder->mPeeker->mPatch != nullptr;
+ const bool isNinePatch = peeker->mPatch != nullptr;
+ ImageDecoder* decoder = new ImageDecoder(std::move(androidCodec), std::move(peeker));
return env->NewObject(gImageDecoder_class, gImageDecoder_constructorMethodID,
- reinterpret_cast<jlong>(decoder.release()), width, height,
+ reinterpret_cast<jlong>(decoder), width, height,
animated, isNinePatch);
}
@@ -133,7 +158,7 @@
struct stat fdStat;
if (fstat(descriptor, &fdStat) == -1) {
- return throw_exception(env, ImageDecoder::kSourceMalformedData,
+ return throw_exception(env, kSourceMalformedData,
"broken file descriptor; fstat returned -1", nullptr, source);
}
@@ -141,7 +166,7 @@
FILE* file = fdopen(dupDescriptor, "r");
if (file == NULL) {
close(dupDescriptor);
- return throw_exception(env, ImageDecoder::kSourceMalformedData, "Could not open file",
+ return throw_exception(env, kSourceMalformedData, "Could not open file",
nullptr, source);
}
@@ -154,7 +179,7 @@
std::unique_ptr<SkStream> stream(CreateJavaInputStreamAdaptor(env, is, storage, false));
if (!stream.get()) {
- return throw_exception(env, ImageDecoder::kSourceMalformedData, "Failed to create a stream",
+ return throw_exception(env, kSourceMalformedData, "Failed to create a stream",
nullptr, source);
}
@@ -177,7 +202,7 @@
std::unique_ptr<SkStream> stream = CreateByteBufferStreamAdaptor(env, jbyteBuffer,
initialPosition, limit);
if (!stream) {
- return throw_exception(env, ImageDecoder::kSourceMalformedData, "Failed to read ByteBuffer",
+ return throw_exception(env, kSourceMalformedData, "Failed to read ByteBuffer",
nullptr, source);
}
return native_create(env, std::move(stream), source, preferAnimation);
@@ -195,7 +220,7 @@
reinterpret_cast<jlong>(canvas.get()));
if (!jcanvas) {
doThrowOOME(env, "Failed to create Java Canvas for PostProcess!");
- return ImageDecoder::kUnknown;
+ return kUnknown;
}
// jcanvas now owns canvas.
@@ -206,43 +231,23 @@
static jobject ImageDecoder_nDecodeBitmap(JNIEnv* env, jobject /*clazz*/, jlong nativePtr,
jobject jdecoder, jboolean jpostProcess,
- jint desiredWidth, jint desiredHeight, jobject jsubset,
+ jint targetWidth, jint targetHeight, jobject jsubset,
jboolean requireMutable, jint allocator,
jboolean requireUnpremul, jboolean preferRamOverQuality,
jboolean asAlphaMask, jlong colorSpaceHandle,
jboolean extended) {
auto* decoder = reinterpret_cast<ImageDecoder*>(nativePtr);
- SkAndroidCodec* codec = decoder->mCodec.get();
- const SkISize desiredSize = SkISize::Make(desiredWidth, desiredHeight);
- SkISize decodeSize = desiredSize;
- const int sampleSize = codec->computeSampleSize(&decodeSize);
- const bool scale = desiredSize != decodeSize;
- SkImageInfo decodeInfo = codec->getInfo().makeWH(decodeSize.width(), decodeSize.height());
- if (scale && requireUnpremul && kOpaque_SkAlphaType != decodeInfo.alphaType()) {
+ if (!decoder->setTargetSize(targetWidth, targetHeight)) {
+ doThrowISE(env, "Could not scale to target size!");
+ return nullptr;
+ }
+ if (requireUnpremul && !decoder->setOutAlphaType(kUnpremul_SkAlphaType)) {
doThrowISE(env, "Cannot scale unpremultiplied pixels!");
return nullptr;
}
- switch (decodeInfo.alphaType()) {
- case kUnpremul_SkAlphaType:
- if (!requireUnpremul) {
- decodeInfo = decodeInfo.makeAlphaType(kPremul_SkAlphaType);
- }
- break;
- case kPremul_SkAlphaType:
- if (requireUnpremul) {
- decodeInfo = decodeInfo.makeAlphaType(kUnpremul_SkAlphaType);
- }
- break;
- case kOpaque_SkAlphaType:
- break;
- case kUnknown_SkAlphaType:
- doThrowIOE(env, "Unknown alpha type");
- return nullptr;
- }
-
SkColorType colorType = kN32_SkColorType;
- if (asAlphaMask && decodeInfo.colorType() == kGray_8_SkColorType) {
+ if (asAlphaMask && decoder->gray()) {
// We have to trick Skia to decode this to a single channel.
colorType = kGray_8_SkColorType;
} else if (preferRamOverQuality) {
@@ -250,12 +255,12 @@
// result incorrect. If we call the postProcess before now and record
// to a picture, we can know whether alpha was added, and if not, we
// can still use 565.
- if (decodeInfo.alphaType() == kOpaque_SkAlphaType && !jpostProcess) {
+ if (decoder->opaque() && !jpostProcess) {
// If the final result will be hardware, decoding to 565 and then
// uploading to the gpu as 8888 will not save memory. This still
// may save us from using F16, but do not go down to 565.
- if (allocator != ImageDecoder::kHardware_Allocator &&
- (allocator != ImageDecoder::kDefault_Allocator || requireMutable)) {
+ if (allocator != kHardware_Allocator &&
+ (allocator != kDefault_Allocator || requireMutable)) {
colorType = kRGB_565_SkColorType;
}
}
@@ -263,12 +268,12 @@
} else if (extended) {
colorType = kRGBA_F16_SkColorType;
} else {
- colorType = codec->computeOutputColorType(colorType);
+ colorType = decoder->mCodec->computeOutputColorType(colorType);
}
const bool isHardware = !requireMutable
- && (allocator == ImageDecoder::kDefault_Allocator ||
- allocator == ImageDecoder::kHardware_Allocator)
+ && (allocator == kDefault_Allocator ||
+ allocator == kHardware_Allocator)
&& colorType != kGray_8_SkColorType;
if (colorType == kRGBA_F16_SkColorType && isHardware &&
@@ -276,12 +281,28 @@
colorType = kN32_SkColorType;
}
- sk_sp<SkColorSpace> colorSpace = GraphicsJNI::getNativeColorSpace(colorSpaceHandle);
- colorSpace = codec->computeOutputColorSpace(colorType, colorSpace);
- decodeInfo = decodeInfo.makeColorType(colorType).makeColorSpace(colorSpace);
+ if (!decoder->setOutColorType(colorType)) {
+ doThrowISE(env, "Failed to set out color type!");
+ return nullptr;
+ }
+
+ {
+ sk_sp<SkColorSpace> colorSpace = GraphicsJNI::getNativeColorSpace(colorSpaceHandle);
+ colorSpace = decoder->mCodec->computeOutputColorSpace(colorType, colorSpace);
+ decoder->setOutColorSpace(std::move(colorSpace));
+ }
+
+ if (jsubset) {
+ SkIRect subset;
+ GraphicsJNI::jrect_to_irect(env, jsubset, &subset);
+ if (!decoder->setCropRect(&subset)) {
+ doThrowISE(env, "Invalid crop rect!");
+ return nullptr;
+ }
+ }
SkBitmap bm;
- auto bitmapInfo = decodeInfo;
+ SkImageInfo bitmapInfo = decoder->getOutputInfo();
if (asAlphaMask && colorType == kGray_8_SkColorType) {
bitmapInfo = bitmapInfo.makeColorType(kAlpha_8_SkColorType);
}
@@ -291,10 +312,7 @@
}
sk_sp<Bitmap> nativeBitmap;
- // If we are going to scale or subset, we will create a new bitmap later on,
- // so use the heap for the temporary.
- // FIXME: Use scanline decoding on only a couple lines to save memory. b/70709380.
- if (allocator == ImageDecoder::kSharedMemory_Allocator && !scale && !jsubset) {
+ if (allocator == kSharedMemory_Allocator) {
nativeBitmap = Bitmap::allocateAshmemBitmap(&bm);
} else {
nativeBitmap = Bitmap::allocateHeapBitmap(&bm);
@@ -302,16 +320,14 @@
if (!nativeBitmap) {
SkString msg;
msg.printf("OOM allocating Bitmap with dimensions %i x %i",
- decodeInfo.width(), decodeInfo.height());
+ bitmapInfo.width(), bitmapInfo.height());
doThrowOOME(env, msg.c_str());
return nullptr;
}
- SkAndroidCodec::AndroidOptions options;
- options.fSampleSize = sampleSize;
- auto result = codec->getAndroidPixels(decodeInfo, bm.getPixels(), bm.rowBytes(), &options);
+ SkCodec::Result result = decoder->decode(bm.getPixels(), bm.rowBytes());
jthrowable jexception = get_and_clear_exception(env);
- int onPartialImageError = jexception ? ImageDecoder::kSourceException
+ int onPartialImageError = jexception ? kSourceException
: 0; // No error.
switch (result) {
case SkCodec::kSuccess:
@@ -321,12 +337,12 @@
break;
case SkCodec::kIncompleteInput:
if (!jexception) {
- onPartialImageError = ImageDecoder::kSourceIncomplete;
+ onPartialImageError = kSourceIncomplete;
}
break;
case SkCodec::kErrorInInput:
if (!jexception) {
- onPartialImageError = ImageDecoder::kSourceMalformedData;
+ onPartialImageError = kSourceMalformedData;
}
break;
default:
@@ -350,20 +366,21 @@
// Ignore ninepatch when post-processing.
if (!jpostProcess) {
// FIXME: Share more code with BitmapFactory.cpp.
- if (decoder->mPeeker->mPatch != nullptr) {
- size_t ninePatchArraySize = decoder->mPeeker->mPatch->serializedSize();
+ auto* peeker = reinterpret_cast<NinePatchPeeker*>(decoder->mPeeker.get());
+ if (peeker->mPatch != nullptr) {
+ size_t ninePatchArraySize = peeker->mPatch->serializedSize();
ninePatchChunk = env->NewByteArray(ninePatchArraySize);
if (ninePatchChunk == nullptr) {
doThrowOOME(env, "Failed to allocate nine patch chunk.");
return nullptr;
}
- env->SetByteArrayRegion(ninePatchChunk, 0, decoder->mPeeker->mPatchSize,
- reinterpret_cast<jbyte*>(decoder->mPeeker->mPatch));
+ env->SetByteArrayRegion(ninePatchChunk, 0, peeker->mPatchSize,
+ reinterpret_cast<jbyte*>(peeker->mPatch));
}
- if (decoder->mPeeker->mHasInsets) {
- ninePatchInsets = decoder->mPeeker->createNinePatchInsets(env, 1.0f);
+ if (peeker->mHasInsets) {
+ ninePatchInsets = peeker->createNinePatchInsets(env, 1.0f);
if (ninePatchInsets == nullptr) {
doThrowOOME(env, "Failed to allocate nine patch insets.");
return nullptr;
@@ -371,58 +388,6 @@
}
}
- if (scale || jsubset) {
- int translateX = 0;
- int translateY = 0;
- SkImageInfo scaledInfo;
- if (jsubset) {
- SkIRect subset;
- GraphicsJNI::jrect_to_irect(env, jsubset, &subset);
-
- translateX = -subset.fLeft;
- translateY = -subset.fTop;
- scaledInfo = bitmapInfo.makeWH(subset.width(), subset.height());
- } else {
- scaledInfo = bitmapInfo.makeWH(desiredWidth, desiredHeight);
- }
- SkBitmap scaledBm;
- if (!scaledBm.setInfo(scaledInfo)) {
- doThrowIOE(env, "Failed scaled setInfo");
- return nullptr;
- }
-
- sk_sp<Bitmap> scaledPixelRef;
- if (allocator == ImageDecoder::kSharedMemory_Allocator) {
- scaledPixelRef = Bitmap::allocateAshmemBitmap(&scaledBm);
- } else {
- scaledPixelRef = Bitmap::allocateHeapBitmap(&scaledBm);
- }
- if (!scaledPixelRef) {
- SkString msg;
- msg.printf("OOM allocating scaled Bitmap with dimensions %i x %i",
- desiredWidth, desiredHeight);
- doThrowOOME(env, msg.c_str());
- return nullptr;
- }
-
- SkPaint paint;
- paint.setBlendMode(SkBlendMode::kSrc);
- paint.setFilterQuality(kLow_SkFilterQuality); // bilinear filtering
-
- SkCanvas canvas(scaledBm, SkCanvas::ColorBehavior::kLegacy);
- canvas.translate(translateX, translateY);
- if (scale) {
- float scaleX = (float) desiredWidth / decodeInfo.width();
- float scaleY = (float) desiredHeight / decodeInfo.height();
- canvas.scale(scaleX, scaleY);
- }
-
- canvas.drawBitmap(bm, 0.0f, 0.0f, &paint);
-
- bm.swap(scaledBm);
- nativeBitmap = std::move(scaledPixelRef);
- }
-
if (jpostProcess) {
std::unique_ptr<Canvas> canvas(Canvas::create_canvas(bm));
@@ -433,12 +398,12 @@
SkAlphaType newAlphaType = bm.alphaType();
switch (pixelFormat) {
- case ImageDecoder::kUnknown:
+ case kUnknown:
break;
- case ImageDecoder::kTranslucent:
+ case kTranslucent:
newAlphaType = kPremul_SkAlphaType;
break;
- case ImageDecoder::kOpaque:
+ case kOpaque:
newAlphaType = kOpaque_SkAlphaType;
break;
default:
@@ -477,7 +442,7 @@
return bitmap::createBitmap(env, hwBitmap.release(), bitmapCreateFlags,
ninePatchChunk, ninePatchInsets);
}
- if (allocator == ImageDecoder::kHardware_Allocator) {
+ if (allocator == kHardware_Allocator) {
doThrowOOME(env, "failed to allocate hardware Bitmap!");
return nullptr;
}
@@ -501,7 +466,7 @@
static void ImageDecoder_nGetPadding(JNIEnv* env, jobject /*clazz*/, jlong nativePtr,
jobject outPadding) {
auto* decoder = reinterpret_cast<ImageDecoder*>(nativePtr);
- decoder->mPeeker->getPadding(env, outPadding);
+ reinterpret_cast<NinePatchPeeker*>(decoder->mPeeker.get())->getPadding(env, outPadding);
}
static void ImageDecoder_nClose(JNIEnv* /*env*/, jobject /*clazz*/, jlong nativePtr) {
diff --git a/core/jni/android/graphics/ImageDecoder.h b/core/jni/android/graphics/ImageDecoder.h
index fd9827b..8a7fa79 100644
--- a/core/jni/android/graphics/ImageDecoder.h
+++ b/core/jni/android/graphics/ImageDecoder.h
@@ -14,48 +14,12 @@
* limitations under the License.
*/
-#include "NinePatchPeeker.h"
-
#include <hwui/Canvas.h>
#include <jni.h>
-class SkAndroidCodec;
-
-using namespace android;
-
-struct ImageDecoder {
- // These need to stay in sync with ImageDecoder.java's Allocator constants.
- enum Allocator {
- kDefault_Allocator = 0,
- kSoftware_Allocator = 1,
- kSharedMemory_Allocator = 2,
- kHardware_Allocator = 3,
- };
-
- // These need to stay in sync with ImageDecoder.java's Error constants.
- enum Error {
- kSourceException = 1,
- kSourceIncomplete = 2,
- kSourceMalformedData = 3,
- };
-
- // These need to stay in sync with PixelFormat.java's Format constants.
- enum PixelFormat {
- kUnknown = 0,
- kTranslucent = -3,
- kOpaque = -1,
- };
-
- std::unique_ptr<SkAndroidCodec> mCodec;
- sk_sp<NinePatchPeeker> mPeeker;
-
- ImageDecoder()
- :mPeeker(new NinePatchPeeker)
- {}
-};
-
// Creates a Java Canvas object from canvas, calls jimageDecoder's PostProcess on it, and then
// releases the Canvas.
// Caller needs to check for exceptions.
-jint postProcessAndRelease(JNIEnv* env, jobject jimageDecoder, std::unique_ptr<Canvas> canvas);
+jint postProcessAndRelease(JNIEnv* env, jobject jimageDecoder,
+ std::unique_ptr<android::Canvas> canvas);
diff --git a/core/jni/android_hardware_SoundTrigger.cpp b/core/jni/android_hardware_SoundTrigger.cpp
index 0002f8b..4376b0b 100644
--- a/core/jni/android_hardware_SoundTrigger.cpp
+++ b/core/jni/android_hardware_SoundTrigger.cpp
@@ -44,6 +44,13 @@
jmethodID toString;
} gUUIDMethods;
+static const char* const kUnsupportedOperationExceptionClassPathName =
+ "java/lang/UnsupportedOperationException";
+static jclass gUnsupportedOperationExceptionClass;
+static const char* const kIllegalArgumentExceptionClassPathName =
+ "java/lang/IllegalArgumentException";
+static jclass gIllegalArgumentExceptionClass;
+
static const char* const kSoundTriggerClassPathName = "android/hardware/soundtrigger/SoundTrigger";
static jclass gSoundTriggerClass;
@@ -91,6 +98,11 @@
jfieldID keyphrases;
} gKeyphraseSoundModelFields;
+static const char* const kModelParamRangeClassPathName =
+ "android/hardware/soundtrigger/SoundTrigger$ModelParamRange";
+static jclass gModelParamRangeClass;
+static jmethodID gModelParamRangeCstor;
+
static const char* const kRecognitionConfigClassPathName =
"android/hardware/soundtrigger/SoundTrigger$RecognitionConfig";
static jclass gRecognitionConfigClass;
@@ -164,6 +176,16 @@
SOUNDTRIGGER_EVENT_SERVICE_STATE_CHANGE = 4,
};
+static jint throwUnsupportedOperationException(JNIEnv *env)
+{
+ return env->ThrowNew(gUnsupportedOperationExceptionClass, nullptr);
+}
+
+static jint throwIllegalArgumentException(JNIEnv *env)
+{
+ return env->ThrowNew(gIllegalArgumentExceptionClass, nullptr);
+}
+
// ----------------------------------------------------------------------------
// ref-counted object for callbacks
class JNISoundTriggerCallback: public SoundTriggerCallback
@@ -822,6 +844,69 @@
return status;
}
+static jint
+android_hardware_SoundTrigger_setParameter(JNIEnv *env, jobject thiz,
+ jint jHandle, jint jModelParam, jint jValue)
+{
+ ALOGV("setParameter");
+ sp<SoundTrigger> module = getSoundTrigger(env, thiz);
+ if (module == NULL) {
+ return SOUNDTRIGGER_STATUS_NO_INIT;
+ }
+ return module->setParameter(jHandle, (sound_trigger_model_parameter_t) jModelParam, jValue);
+}
+
+static jint
+android_hardware_SoundTrigger_getParameter(JNIEnv *env, jobject thiz,
+ jint jHandle, jint jModelParam)
+{
+ ALOGV("getParameter");
+ sp<SoundTrigger> module = getSoundTrigger(env, thiz);
+ if (module == NULL) {
+ throwUnsupportedOperationException(env);
+ return -1;
+ }
+
+ jint nValue;
+ jint status = module->getParameter(jHandle,
+ (sound_trigger_model_parameter_t) jModelParam, &nValue);
+
+ switch (status) {
+ case 0:
+ return nValue;
+ case -EINVAL:
+ throwIllegalArgumentException(env);
+ break;
+ default:
+ throwUnsupportedOperationException(env);
+ break;
+ }
+
+ return -1;
+}
+
+static jobject
+android_hardware_SoundTrigger_queryParameter(JNIEnv *env, jobject thiz,
+ jint jHandle, jint jModelParam)
+{
+ ALOGV("queryParameter");
+ sp<SoundTrigger> module = getSoundTrigger(env, thiz);
+ if (module == nullptr) {
+ return nullptr;
+ }
+
+ sound_trigger_model_parameter_range_t nRange;
+ jint nValue = module->queryParameter(jHandle,
+ (sound_trigger_model_parameter_t) jModelParam, &nRange);
+
+ if (nValue != 0) {
+ ALOGE("failed to query parameter error code: %d", nValue);
+ return nullptr;
+ }
+
+ return env->NewObject(gModelParamRangeClass, gModelParamRangeCstor, nRange.start, nRange.end);
+}
+
static const JNINativeMethod gMethods[] = {
{"listModules",
"(Ljava/lang/String;Ljava/util/ArrayList;)I",
@@ -854,6 +939,15 @@
{"getModelState",
"(I)I",
(void *)android_hardware_SoundTrigger_getModelState},
+ {"setParameter",
+ "(III)I",
+ (void *)android_hardware_SoundTrigger_setParameter},
+ {"getParameter",
+ "(II)I",
+ (void *)android_hardware_SoundTrigger_getParameter},
+ {"queryParameter",
+ "(II)Landroid/hardware/soundtrigger/SoundTrigger$ModelParamRange;",
+ (void *)android_hardware_SoundTrigger_queryParameter}
};
int register_android_hardware_SoundTrigger(JNIEnv *env)
@@ -866,6 +960,12 @@
gUUIDClass = MakeGlobalRefOrDie(env, uuidClass);
gUUIDMethods.toString = GetMethodIDOrDie(env, uuidClass, "toString", "()Ljava/lang/String;");
+ jclass exUClass = FindClassOrDie(env, kUnsupportedOperationExceptionClassPathName);
+ gUnsupportedOperationExceptionClass = MakeGlobalRefOrDie(env, exUClass);
+
+ jclass exIClass = FindClassOrDie(env, kIllegalArgumentExceptionClassPathName);
+ gIllegalArgumentExceptionClass = MakeGlobalRefOrDie(env, exIClass);
+
jclass lClass = FindClassOrDie(env, kSoundTriggerClassPathName);
gSoundTriggerClass = MakeGlobalRefOrDie(env, lClass);
@@ -906,6 +1006,10 @@
"keyphrases",
"[Landroid/hardware/soundtrigger/SoundTrigger$Keyphrase;");
+ jclass modelParamRangeClass = FindClassOrDie(env, kModelParamRangeClassPathName);
+ gModelParamRangeClass = MakeGlobalRefOrDie(env, modelParamRangeClass);
+ gModelParamRangeCstor = GetMethodIDOrDie(env, modelParamRangeClass, "<init>", "(II)V");
+
jclass recognitionEventClass = FindClassOrDie(env, kRecognitionEventClassPathName);
gRecognitionEventClass = MakeGlobalRefOrDie(env, recognitionEventClass);
gRecognitionEventCstor = GetMethodIDOrDie(env, recognitionEventClass, "<init>",
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
index f28c422..c4ac89a 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -74,6 +74,7 @@
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <bionic/malloc.h>
+#include <bionic/page.h>
#include <cutils/fs.h>
#include <cutils/multiuser.h>
#include <cutils/sockets.h>
@@ -1389,9 +1390,14 @@
void* data [[maybe_unused]]) {
// Search for any execute-only segments and mark them read+execute.
for (int i = 0; i < info->dlpi_phnum; i++) {
- if ((info->dlpi_phdr[i].p_type == PT_LOAD) && (info->dlpi_phdr[i].p_flags == PF_X)) {
- mprotect(reinterpret_cast<void*>(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr),
- info->dlpi_phdr[i].p_memsz, PROT_READ | PROT_EXEC);
+ const auto& phdr = info->dlpi_phdr[i];
+ if ((phdr.p_type == PT_LOAD) && (phdr.p_flags == PF_X)) {
+ auto addr = reinterpret_cast<void*>(info->dlpi_addr + PAGE_START(phdr.p_vaddr));
+ size_t len = PAGE_OFFSET(phdr.p_vaddr) + phdr.p_memsz;
+ if (mprotect(addr, len, PROT_READ | PROT_EXEC) == -1) {
+ ALOGE("mprotect(%p, %zu, PROT_READ | PROT_EXEC) failed: %m", addr, len);
+ return -1;
+ }
}
}
// Return non-zero to exit dl_iterate_phdr.
diff --git a/core/jni/fd_utils.cpp b/core/jni/fd_utils.cpp
index 0c21076..8c1ecae 100644
--- a/core/jni/fd_utils.cpp
+++ b/core/jni/fd_utils.cpp
@@ -33,12 +33,15 @@
// Static whitelist of open paths that the zygote is allowed to keep open.
static const char* kPathWhitelist[] = {
+ "/apex/com.android.appsearch/javalib/framework-appsearch.jar",
"/apex/com.android.conscrypt/javalib/conscrypt.jar",
"/apex/com.android.ipsec/javalib/ike.jar",
"/apex/com.android.media/javalib/updatable-media.jar",
+ "/apex/com.android.os.statsd/javalib/framework-statsd.jar",
"/apex/com.android.sdkext/javalib/framework-sdkext.jar",
"/apex/com.android.telephony/javalib/telephony-common.jar",
"/apex/com.android.telephony/javalib/ims-common.jar",
+ "/apex/com.android.wifi/javalib/framework-wifi.jar",
"/dev/null",
"/dev/socket/zygote",
"/dev/socket/zygote_secondary",
diff --git a/core/proto/android/app/settings_enums.proto b/core/proto/android/app/settings_enums.proto
index ab97fdd..0c2129f 100644
--- a/core/proto/android/app/settings_enums.proto
+++ b/core/proto/android/app/settings_enums.proto
@@ -2467,4 +2467,9 @@
// CATEGORY: SETTINGS
// OS: R
ACCOUNT_WORK = 1807;
+
+ // OPEN: Settings > Developer Options > Bug report handler
+ // CATEGORY: SETTINGS
+ // OS: R
+ SETTINGS_BUGREPORT_HANDLER = 1808;
}
diff --git a/core/proto/android/providers/settings/global.proto b/core/proto/android/providers/settings/global.proto
index 31c19ca..a98d7db 100644
--- a/core/proto/android/providers/settings/global.proto
+++ b/core/proto/android/providers/settings/global.proto
@@ -566,6 +566,7 @@
optional LowPowerMode low_power_mode = 70;
optional SettingProto lte_service_forced = 71 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ repeated SettingProto max_error_bytes = 151;
optional SettingProto mdc_initial_max_retry = 72 [ (android.privacy).dest = DEST_AUTOMATIC ];
message Mhl {
@@ -1058,5 +1059,5 @@
// Please insert fields in alphabetical order and group them into messages
// if possible (to avoid reaching the method limit).
- // Next tag = 151;
+ // Next tag = 152;
}
diff --git a/core/proto/android/stats/devicepolicy/device_policy_enums.proto b/core/proto/android/stats/devicepolicy/device_policy_enums.proto
index f8c304c..ee5144c 100644
--- a/core/proto/android/stats/devicepolicy/device_policy_enums.proto
+++ b/core/proto/android/stats/devicepolicy/device_policy_enums.proto
@@ -152,4 +152,5 @@
CROSS_PROFILE_APPS_GET_TARGET_USER_PROFILES = 125;
CROSS_PROFILE_APPS_START_ACTIVITY_AS_USER = 126;
SET_AUTO_TIME = 127;
+ SET_AUTO_TIME_ZONE = 128;
}
diff --git a/core/proto/android/view/windowlayoutparams.proto b/core/proto/android/view/windowlayoutparams.proto
index e7c2827..272a245 100644
--- a/core/proto/android/view/windowlayoutparams.proto
+++ b/core/proto/android/view/windowlayoutparams.proto
@@ -63,4 +63,7 @@
optional uint32 subtree_system_ui_visibility_flags = 28;
optional uint32 appearance = 29;
optional uint32 behavior = 30;
+ optional uint32 fit_insets_types = 31;
+ optional uint32 fit_insets_sides = 32;
+ optional bool fit_ignore_visibility = 33;
}
diff --git a/core/res/res/layout/chooser_grid.xml b/core/res/res/layout/chooser_grid.xml
index 9f296f8f..0c45e45 100644
--- a/core/res/res/layout/chooser_grid.xml
+++ b/core/res/res/layout/chooser_grid.xml
@@ -55,6 +55,12 @@
android:layout_centerHorizontal="true"/>
</RelativeLayout>
+ <FrameLayout
+ android:id="@+id/content_preview_container"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone" />
+
<com.android.internal.widget.ViewPager
android:id="@+id/profile_pager"
android:layout_width="match_parent"
diff --git a/core/res/res/values-mcc510-mnc08/config.xml b/core/res/res/values-mcc510-mnc08/config.xml
index 7b27554..58fbb9e 100644
--- a/core/res/res/values-mcc510-mnc08/config.xml
+++ b/core/res/res/values-mcc510-mnc08/config.xml
@@ -23,4 +23,6 @@
and "333" is used for other purpose -->
<string-array translatable="false" name="config_callBarringMMI">
</string-array>
+ <string-array translatable="false" name="config_callBarringMMI_for_ims">
+ </string-array>
</resources>
diff --git a/core/res/res/values-mcc510-mnc89/config.xml b/core/res/res/values-mcc510-mnc89/config.xml
index 82efecf..c262247 100644
--- a/core/res/res/values-mcc510-mnc89/config.xml
+++ b/core/res/res/values-mcc510-mnc89/config.xml
@@ -23,4 +23,6 @@
and "333" is used for other purpose -->
<string-array translatable="false" name="config_callBarringMMI">
</string-array>
+ <string-array translatable="false" name="config_callBarringMMI_for_ims">
+ </string-array>
</resources>
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index ced5deb..03f8ebd 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2544,6 +2544,28 @@
<string name="config_customAdbPublicKeyConfirmationSecondaryUserComponent"
>com.android.systemui/com.android.systemui.usb.UsbDebuggingSecondaryUserActivity</string>
+ <!-- Component name of the activity that shows the usb containment status. -->
+ <string name="config_usbContaminantActivity" translatable="false"
+ >com.android.systemui/com.android.systemui.usb.UsbContaminantActivity</string>
+
+ <!-- Component name of the activity that shows the request for access to a usb device. -->
+ <string name="config_usbPermissionActivity" translatable="false"
+ >com.android.systemui/com.android.systemui.usb.UsbPermissionActivity</string>
+
+ <!-- Component name of the activity that shows more information about a usb accessory. -->
+ <string name="config_usbAccessoryUriActivity" translatable="false"
+ >com.android.systemui/com.android.systemui.usb.UsbAccessoryUriActivity</string>
+
+ <!-- Component name of the activity that confirms the activity to start when a usb device is
+ plugged in. -->
+ <string name="config_usbConfirmActivity" translatable="false"
+ >com.android.systemui/com.android.systemui.usb.UsbConfirmActivity</string>
+
+ <!-- Component name of the activity to select the activity to start when a usb device is plugged
+ in. -->
+ <string name="config_usbResolverActivity" translatable="false"
+ >com.android.systemui/com.android.systemui.usb.UsbResolverActivity</string>
+
<!-- Name of the dialog that is used to request the user's consent to VPN connection -->
<string name="config_customVpnConfirmDialogComponent" translatable="false"
>com.android.vpndialogs/com.android.vpndialogs.ConfirmDialog</string>
@@ -2630,6 +2652,18 @@
<item>353</item>
</string-array>
+ <!-- Ims supported call barring MMI code -->
+ <string-array translatable="false" name="config_callBarringMMI_for_ims">
+ <item>33</item>
+ <item>331</item>
+ <item>332</item>
+ <item>35</item>
+ <item>351</item>
+ <item>330</item>
+ <item>333</item>
+ <item>353</item>
+ </string-array>
+
<!-- Override the default detection behavior for the framework method
android.view.ViewConfiguration#hasPermanentMenuKey().
Valid settings are:
@@ -2652,11 +2686,6 @@
<!-- Package name for default network scorer app; overridden by product overlays. -->
<string name="config_defaultNetworkScorerPackageName"></string>
- <!-- Feature flag to enable memory efficient task snapshots that are used in recents optimized
- for low memory devices and replace the app transition starting window with the splash
- screen. -->
- <bool name="config_lowRamTaskSnapshotsAndRecents">false</bool>
-
<!-- The amount to scale fullscreen snapshots for Overview and snapshot starting windows. -->
<item name="config_fullTaskSnapshotScale" format="float" type="dimen">1.0</item>
@@ -2667,11 +2696,45 @@
property. If this is false, then the following recents config flags are ignored. -->
<bool name="config_hasRecents">true</bool>
- <!-- Component name for the activity that will be presenting the Recents UI, which will receive special permissions for API related
- to fetching and presenting recent tasks. The default configuration uses Launcehr3QuickStep as default launcher and points to
- the corresponding recents component. When using a different default launcher, change this appropriately or use the default
- systemui implementation: com.android.systemui/.recents.RecentsActivity -->
- <string name="config_recentsComponentName" translatable="false">com.android.launcher3/com.android.quickstep.RecentsActivity</string>
+ <!-- Component name for the activity that will be presenting the Recents UI, which will receive
+ special permissions for API related to fetching and presenting recent tasks. The default
+ configuration uses Launcehr3QuickStep as default launcher and points to the corresponding
+ recents component. When using a different default launcher, change this appropriately or
+ use the default systemui implementation: com.android.systemui/.recents.RecentsActivity -->
+ <string name="config_recentsComponentName" translatable="false"
+ >com.android.launcher3/com.android.quickstep.RecentsActivity</string>
+
+ <!-- SystemUi service component -->
+ <string name="config_systemUIServiceComponent" translatable="false"
+ >com.android.systemui/com.android.systemui.SystemUIService</string>
+
+ <!-- Keyguard component -->
+ <string name="config_keyguardComponent" translatable="false"
+ >com.android.systemui/com.android.systemui.keyguard.KeyguardService</string>
+
+ <!-- Screen record dialog component -->
+ <string name="config_screenRecorderComponent" translatable="false"
+ >com.android.systemui/com.android.systemui.screenrecord.ScreenRecordDialog</string>
+
+ <!-- The component name of a special dock app that merely launches a dream.
+ We don't want to launch this app when docked because it causes an unnecessary
+ activity transition. We just want to start the dream. -->
+ <string name="config_somnambulatorComponent" translatable="false"
+ >com.android.systemui/com.android.systemui.Somnambulator</string>
+
+ <!-- The component name of a special dock app that merely launches a dream.
+ We don't want to launch this app when docked because it causes an unnecessary
+ activity transition. We just want to start the dream.. -->
+ <string name="config_screenshotServiceComponent" translatable="false"
+ >com.android.systemui/com.android.systemui.screenshot.TakeScreenshotService</string>
+
+ <!-- The component notified when there is an error while taking a screenshot. -->
+ <string name="config_screenshotErrorReceiverComponent" translatable="false"
+ >com.android.systemui/com.android.systemui.screenshot.ScreenshotServiceErrorReceiver</string>
+
+ <!-- The component for the activity shown to grant permissions for a slice. -->
+ <string name="config_slicePermissionComponent" translatable="false"
+ >com.android.systemui/com.android.systemui.SlicePermissionActivity</string>
<!-- The minimum number of visible recent tasks to be presented to the user through the
SystemUI. Can be -1 if there is no minimum limit. -->
@@ -2844,10 +2907,6 @@
<!-- Whether to use voip audio mode for ims call -->
<bool name="config_use_voip_mode_for_ims">false</bool>
- <!-- ImsService package name to bind to by default. If none is specified in an overlay, an
- empty string is passed in -->
- <string name="config_ims_package"/>
-
<!-- String array containing numbers that shouldn't be logged. Country-specific. -->
<string-array name="unloggable_phone_numbers" />
@@ -3025,9 +3084,6 @@
<!-- Specifies the maximum burn-in offset vertically. -->
<integer name="config_burnInProtectionMaxVerticalOffset">0</integer>
- <!-- Keyguard component -->
- <string name="config_keyguardComponent" translatable="false">com.android.systemui/com.android.systemui.keyguard.KeyguardService</string>
-
<!-- Limit for the number of face templates per user -->
<integer name="config_faceMaxTemplatesPerUser">1</integer>
@@ -3066,7 +3122,9 @@
The path is assumed to be specified in display coordinates with pixel units and in
the display's native orientation, with the origin of the coordinate system at the
- center top of the display.
+ center top of the display. Optionally, you can append either `@left` or `@right` to the
+ end of the path string, in order to change the path origin to either the top left,
+ or top right of the display.
To facilitate writing device-independent emulation overlays, the marker `@dp` can be
appended after the path string to interpret coordinates in dp instead of px units.
@@ -4100,6 +4158,14 @@
<!-- Which binder services to include in incident reports containing restricted images. -->
<string-array name="config_restrictedImagesServices" translatable="false"/>
+ <!-- List of biometric sensors on the device, in decreasing strength. Consumed by AuthService
+ when registering authenticators with BiometricService. Format must be ID:Modality:Strength,
+ where: IDs are unique per device, Modality as defined in BiometricAuthenticator.java,
+ and Strength as defined in Authenticators.java -->
+ <string-array name="config_biometric_sensors" translatable="false" >
+ <item>0:2:15</item> <!-- ID0:Fingerprint:Strong -->
+ </string-array>
+
<!-- Messages that should not be shown to the user during face auth enrollment. This should be
used to hide messages that may be too chatty or messages that the user can't do much about.
Entries are defined in android.hardware.biometrics.face@1.0 types.hal -->
@@ -4188,15 +4254,15 @@
<!-- The default value used for RawContacts.ACCOUNT_NAME when contacts are inserted without this
column set. These contacts are stored locally on the device and will not be removed even
- if an android.account.Account with this name and type exists. A null string will be used
- if the value is left empty. When this is non-empty then config_rawContactsLocalAccountType
+ if no android.account.Account with this name exists. A null string will be used if the
+ value is left empty. When this is non-empty then config_rawContactsLocalAccountType
should also be non-empty. -->
<string name="config_rawContactsLocalAccountName" translatable="false"></string>
<!-- The default value used for RawContacts.ACCOUNT_TYPE when contacts are inserted without this
column set. These contacts are stored locally on the device and will not be removed even
- if an android.account.Account with this name and type exists. A null string will be used
- if the value is left empty. When this is non-empty then config_rawContactsLocalAccountName
+ if no android.account.Account with this type exists. A null string will be used if the
+ value is left empty. When this is non-empty then config_rawContactsLocalAccountName
should also be non-empty.-->
<string name="config_rawContactsLocalAccountType" translatable="false"></string>
</resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 0f5da39..ab10738 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1011,53 +1011,32 @@
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_readContacts">read your contacts</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
- <string name="permdesc_readContacts" product="tablet">Allows the app to read
- data about your contacts stored on your tablet, including the frequency
- with which you\'ve called, emailed, or communicated in other ways with
- specific individuals. Apps will also have access to the accounts on your
- tablet that have created contacts. This may include accounts created by
- apps you have installed. This permission allows apps to save your contact
- data, and malicious apps may share contact data without your
- knowledge.</string>
+ <string name="permdesc_readContacts" product="tablet">Allows the app to read data about your contacts stored on your tablet.
+ Apps will also have access to the accounts on your tablet that have created contacts.
+ This may include accounts created by apps you have installed.
+ This permission allows apps to save your contact data, and malicious apps may share contact data without your knowledge.</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
- <string name="permdesc_readContacts" product="tv">Allows the app to read
- data about your contacts stored on your Android TV device, including the frequency
- with which you\'ve called, emailed, or communicated in other ways with
- specific individuals. Apps will also have access to the accounts on your
- Android TV device that have created contacts. This may include accounts
- created by apps you have installed. This permission allows apps to save
- your contact data, and malicious apps may share contact data without your
- knowledge.</string>
+ <string name="permdesc_readContacts" product="tv">Allows the app to read data about your contacts stored on your Android TV device.
+ Apps will also have access to the accounts on your Android TV device that have created contacts.
+ This may include accounts created by apps you have installed.
+ This permission allows apps to save your contact data, and malicious apps may share contact data without your knowledge.</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
- <string name="permdesc_readContacts" product="default">Allows the app to
- read data about your contacts stored on your phone, including the
- frequency with which you\'ve called, emailed, or communicated in other ways
- with specific individuals. Apps will also have access to the accounts
- on your phone that have created contacts. This may include accounts
- created by apps you have installed. This permission allows apps to
- save your contact data, and malicious apps may share contact data
- without your knowledge.</string>
+ <string name="permdesc_readContacts" product="default">Allows the app to read data about your contacts stored on your phone.
+ Apps will also have access to the accounts on your phone that have created contacts.
+ This may include accounts created by apps you have installed.
+ This permission allows apps to save your contact data, and malicious apps may share contact data without your knowledge.</string>
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_writeContacts">modify your contacts</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
- <string name="permdesc_writeContacts" product="tablet">Allows the app to
- modify the data about your contacts stored on your tablet, including the
- frequency with which you\'ve called, emailed, or communicated in other ways
- with specific contacts. This permission allows apps to delete contact
- data.</string>
+ <string name="permdesc_writeContacts" product="tablet">Allows the app to modify the data about your contacts stored on your tablet.
+ This permission allows apps to delete contact data.</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
- <string name="permdesc_writeContacts" product="tv">Allows the app to
- modify the data about your contacts stored on your Android TV device, including the
- frequency with which you\'ve called, emailed, or communicated in other ways
- with specific contacts. This permission allows apps to delete contact
- data.</string>
+ <string name="permdesc_writeContacts" product="tv">Allows the app to modify the data about your contacts stored on your Android TV device.
+ This permission allows apps to delete contact data.</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
- <string name="permdesc_writeContacts" product="default">Allows the app to
- modify the data about your contacts stored on your phone, including the
- frequency with which you\'ve called, emailed, or communicated in other ways
- with specific contacts. This permission allows apps to delete contact
- data.</string>
+ <string name="permdesc_writeContacts" product="default">Allows the app to modify the data about your contacts stored on your phone.
+ This permission allows apps to delete contact data.</string>
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_readCallLog">read call log</string>
@@ -1102,6 +1081,7 @@
<string name="permdesc_writeCalendar" product="default">This app can add, remove, or change calendar events on your phone. This app can send messages that may appear to come from calendar owners, or change events without notifying their owners.</string>
<!-- Title of an application permission, listed so the user can choose whether they want to allow the applicatfion to do this. -->
+ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_accessLocationExtraCommands">access extra location provider commands</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permdesc_accessLocationExtraCommands">Allows the app to access
@@ -1111,21 +1091,17 @@
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_accessFineLocation">access precise location only in the foreground</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
- <string name="permdesc_accessFineLocation">This app can get your exact location only when it is in the foreground. These location services must be turned on and available on your phone for the app to be able to use them. This may increase battery consumption.</string>
+ <string name="permdesc_accessFineLocation">This app can get your exact location only when it is in the foreground. Location services must be turned on and available on your device for the app to be able to use them. This may increase battery consumption.</string>
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
- <string name="permlab_accessCoarseLocation">access approximate location (network-based) only in the foreground</string>
+ <string name="permlab_accessCoarseLocation">access approximate location only in the foreground</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
- <string name="permdesc_accessCoarseLocation" product="tablet">This app can get your location based on network sources such as cell towers and Wi-Fi networks, but only when when the app is in the foreground. These location services must be turned on and available on your tablet for the app to be able to use them.</string>
- <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
- <string name="permdesc_accessCoarseLocation" product="tv">This app can get your location based on network sources such as cell towers and Wi-Fi networks, but only when when the app is in the foreground. These location services must be turned on and available on your Android TV device for the app to be able to use them.</string>
- <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
- <string name="permdesc_accessCoarseLocation" product="default">This app can get your location based on network sources such as cell towers and Wi-Fi networks, but only when the app is in the foreground. These location services must be turned on and available on your phone for the app to be able to use them.</string>
+ <string name="permdesc_accessCoarseLocation">This app can get your approximate location only when it is in the foreground. Location services must be turned on and available on your device for the app to be able to use them.</string>
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_accessBackgroundLocation">access location in the background</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
- <string name="permdesc_accessBackgroundLocation">If this is granted additionally to the approximate or precise location access the app can access the location while running in the background.</string>
+ <string name="permdesc_accessBackgroundLocation">This app can access location while running in the background, in addition to foreground location access.</string>
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_modifyAudioSettings">change your audio settings</string>
@@ -4970,8 +4946,12 @@
<!-- Resolver target actions strings -->
<!-- Pin this app to the top of the Sharesheet app list. [CHAR LIMIT=60]-->
<string name="pin_target">Pin</string>
+ <!-- Pin this app to the top of the Sharesheet app list. [CHAR LIMIT=60]-->
+ <string name="pin_specific_target">Pin <xliff:g id="label" example="Tweet">%1$s</xliff:g></string>
<!-- Un-pin this app in the Sharesheet, so that it is sorted normally. [CHAR LIMIT=60]-->
- <string name="unpin_target">Unpin</string>
+ <string name="unpin_target">Unpin </string>
+ <!-- Un-pin this app in the Sharesheet, so that it is sorted normally. [CHAR LIMIT=60]-->
+ <string name="unpin_specific_target">Unpin <xliff:g id="label" example="Tweet">%1$s</xliff:g></string>
<!-- View application info for a target. -->
<string name="app_info">App info</string>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 29b9281..a8d30c1 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -248,6 +248,7 @@
<java-symbol type="id" name="overlay" />
<java-symbol type="id" name="app_ops" />
<java-symbol type="id" name="profile_pager" />
+ <java-symbol type="id" name="content_preview_container" />
<java-symbol type="attr" name="actionModeShareDrawable" />
<java-symbol type="attr" name="alertDialogCenterButtons" />
@@ -294,7 +295,6 @@
<java-symbol type="bool" name="config_enableBurnInProtection" />
<java-symbol type="bool" name="config_hotswapCapable" />
<java-symbol type="bool" name="config_mms_content_disposition_support" />
- <java-symbol type="string" name="config_ims_package" />
<java-symbol type="string" name="config_wwan_network_service_package" />
<java-symbol type="string" name="config_wlan_network_service_package" />
<java-symbol type="string" name="config_wwan_network_service_class" />
@@ -357,9 +357,19 @@
<java-symbol type="bool" name="config_disableUsbPermissionDialogs"/>
<java-symbol type="dimen" name="config_fullTaskSnapshotScale" />
<java-symbol type="bool" name="config_use16BitTaskSnapshotPixelFormat" />
- <java-symbol type="bool" name="config_lowRamTaskSnapshotsAndRecents" />
<java-symbol type="bool" name="config_hasRecents" />
<java-symbol type="string" name="config_recentsComponentName" />
+ <java-symbol type="string" name="config_systemUIServiceComponent" />
+ <java-symbol type="string" name="config_screenRecorderComponent" />
+ <java-symbol type="string" name="config_somnambulatorComponent" />
+ <java-symbol type="string" name="config_screenshotServiceComponent" />
+ <java-symbol type="string" name="config_screenshotErrorReceiverComponent" />
+ <java-symbol type="string" name="config_slicePermissionComponent" />
+ <java-symbol type="string" name="config_usbContaminantActivity" />
+ <java-symbol type="string" name="config_usbPermissionActivity" />
+ <java-symbol type="string" name="config_usbAccessoryUriActivity" />
+ <java-symbol type="string" name="config_usbConfirmActivity" />
+ <java-symbol type="string" name="config_usbResolverActivity" />
<java-symbol type="integer" name="config_minNumVisibleRecentTasks_lowRam" />
<java-symbol type="integer" name="config_maxNumVisibleRecentTasks_lowRam" />
<java-symbol type="integer" name="config_minNumVisibleRecentTasks_grid" />
@@ -441,6 +451,7 @@
<java-symbol type="integer" name="config_multiuserMaxRunningUsers" />
<java-symbol type="bool" name="config_multiuserDelayUserDataLocking" />
<java-symbol type="integer" name="config_userTypePackageWhitelistMode"/>
+ <java-symbol type="xml" name="config_user_types" />
<java-symbol type="integer" name="config_safe_media_volume_index" />
<java-symbol type="integer" name="config_safe_media_volume_usb_mB" />
<java-symbol type="integer" name="config_mobile_mtu" />
@@ -1230,6 +1241,7 @@
<java-symbol type="array" name="config_cdma_dun_supported_types" />
<java-symbol type="array" name="config_disabledUntilUsedPreinstalledImes" />
<java-symbol type="array" name="config_callBarringMMI" />
+ <java-symbol type="array" name="config_callBarringMMI_for_ims" />
<java-symbol type="array" name="config_globalActionsList" />
<java-symbol type="array" name="config_telephonyEuiccDeviceCapabilities" />
<java-symbol type="array" name="config_telephonyHardware" />
@@ -2470,6 +2482,8 @@
<java-symbol type="string" name="face_authenticated_no_confirmation_required" />
<java-symbol type="string" name="face_authenticated_confirmation_required" />
+ <java-symbol type="array" name="config_biometric_sensors" />
+
<java-symbol type="array" name="config_face_acquire_enroll_ignorelist" />
<java-symbol type="array" name="config_face_acquire_vendor_enroll_ignorelist" />
<java-symbol type="array" name="config_face_acquire_keyguard_ignorelist" />
@@ -2943,6 +2957,8 @@
<!-- Resolver target actions -->
<java-symbol type="array" name="resolver_target_actions_pin" />
<java-symbol type="array" name="resolver_target_actions_unpin" />
+ <java-symbol type="string" name="pin_specific_target" />
+ <java-symbol type="string" name="unpin_specific_target" />
<java-symbol type="array" name="non_removable_euicc_slots" />
diff --git a/core/res/res/xml/config_user_types.xml b/core/res/res/xml/config_user_types.xml
new file mode 100644
index 0000000..5fd8a95
--- /dev/null
+++ b/core/res/res/xml/config_user_types.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 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.
+-->
+
+<!--
+This xml file allows customization of Android multiuser user types.
+It is parsed by frameworks/base/services/core/java/com/android/server/pm/UserTypeFactory.java.
+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++ IMPORTANT NOTE ++++++++++++++++++++++++++++++++++++++++
+Although device customization is possible here, it is largely untested.
+In particular, although this file allows new profile types to be created, and allows modifying the
+number of managed profiles allowed on the device, the consequences of doing so is untested.
+OEMs are advised to test very carefully any significant customization.
+Further support is planned for later releases.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+Pre-defined (AOSP) user types can be customized and new types can be defined. The syntax is the
+same in both cases.
+
+Currently, only profiles (not full or system users) can be freely customized/defined.
+Full users (i.e. non-system, non-profile) users cannot be defined, and the only property of them
+that can be customized are the default-restrictions.
+System users cannot be customized here; their default-restrictions must be set using
+com.android.internal.R.array.config_defaultFirstUserRestrictions.
+
+The following example modifies two AOSP user types (the FULL user android.os.usertype.full.SECONDARY
+and the PROFILE user android.os.usertype.profile.MANAGED) and creates a new PROFILE user type
+(com.example.profilename):
+
+<user-types>
+ <full-type name="android.os.usertype.full.SECONDARY" >
+ <default-restrictions no_sms="true" />
+ </full-type>
+
+ <profile-type
+ name='android.os.usertype.profile.MANAGED'
+ max-allowed-per-parent='2'
+ icon-badge='@android:drawable/ic_corp_icon_badge_case'
+ badge-plain='@android:drawable/ic_corp_badge_case'
+ badge-no-background='@android:drawable/ic_corp_badge_no_background' >
+ <badge-labels>
+ <item res='@android:string/managed_profile_label_badge' />
+ <item res='@android:string/managed_profile_label_badge_2' />
+ </badge-labels>
+ <badge-colors>
+ <item res='@android:color/profile_badge_1' />
+ <item res='@android:color/profile_badge_2' />
+ </badge-colors>
+ <default-restrictions no_sms="true" no_outgoing_calls="true" />
+ </profile-type>
+
+ <profile-type
+ name="com.example.profilename"
+ max-allowed-per-parent="2" />
+</user-types>
+
+Mandatory attributes:
+ name
+
+Supported optional properties (to be used as shown in the example above) are as follows.
+For profile and full users:
+ default-restrictions (with values defined in UserRestrictionUtils.USER_RESTRICTIONS)
+For profile users only:
+ max-allowed-per-parent
+ icon-badge
+ badge-plain
+ badge-no-background
+ badge-labels
+ badge-colors
+
+See UserTypeFactory.java and UserTypeDetails.java for the meaning (and default values) of these
+fields.
+
+Any property that is specified overwrites the AOSP default. For example, if there is no
+default-restrictions element, then the AOSP defaults for that user type will be used; however, if
+there is a default-restrictions element, then the AOSP default restrictions will be completely
+ignored and will instead obey this configuration.
+
+If this file is updated, the properties of any pre-existing user types will be updated too.
+Note, however, that default-restrictions refers to the restrictions applied at the time of user
+creation; therefore, the active restrictions of any pre-existing users will not be updated.
+
+-->
+<user-types>
+</user-types>
diff --git a/core/tests/bluetoothtests/src/android/bluetooth/BluetoothTestUtils.java b/core/tests/bluetoothtests/src/android/bluetooth/BluetoothTestUtils.java
index b906d84..ed613c3 100644
--- a/core/tests/bluetoothtests/src/android/bluetooth/BluetoothTestUtils.java
+++ b/core/tests/bluetoothtests/src/android/bluetooth/BluetoothTestUtils.java
@@ -176,14 +176,12 @@
mDevice.setPin(mPin);
break;
case BluetoothDevice.PAIRING_VARIANT_PASSKEY:
- mDevice.setPasskey(mPasskey);
break;
case BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION:
case BluetoothDevice.PAIRING_VARIANT_CONSENT:
mDevice.setPairingConfirmation(true);
break;
case BluetoothDevice.PAIRING_VARIANT_OOB_CONSENT:
- mDevice.setRemoteOutOfBandData();
break;
}
} else if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(intent.getAction())) {
diff --git a/core/tests/coretests/Android.bp b/core/tests/coretests/Android.bp
index c009f58..caae908 100644
--- a/core/tests/coretests/Android.bp
+++ b/core/tests/coretests/Android.bp
@@ -24,6 +24,7 @@
],
static_libs: [
"frameworks-base-testutils",
+ "core-test-rules", // for libcore.dalvik.system.CloseGuardSupport
"core-tests-support",
"android-common",
"frameworks-core-util-lib",
diff --git a/core/tests/coretests/src/android/provider/DeviceConfigTest.java b/core/tests/coretests/src/android/provider/DeviceConfigTest.java
index 8c1c3b5..ae835e4 100644
--- a/core/tests/coretests/src/android/provider/DeviceConfigTest.java
+++ b/core/tests/coretests/src/android/provider/DeviceConfigTest.java
@@ -33,9 +33,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
-import java.util.HashMap;
-import java.util.Map;
-
/** Tests that ensure appropriate settings are backed up. */
@Presubmit
@RunWith(AndroidJUnit4.class)
@@ -488,22 +485,20 @@
}
@Test
- public void setProperties() {
- Map<String, String> keyValues = new HashMap<>();
- keyValues.put(KEY, VALUE);
- keyValues.put(KEY2, VALUE2);
+ public void setProperties() throws DeviceConfig.BadConfigException {
+ Properties properties = new Properties.Builder(NAMESPACE).setString(KEY, VALUE)
+ .setString(KEY2, VALUE2).build();
- DeviceConfig.setProperties(new Properties(NAMESPACE, keyValues));
- Properties properties = DeviceConfig.getProperties(NAMESPACE);
+ DeviceConfig.setProperties(properties);
+ properties = DeviceConfig.getProperties(NAMESPACE);
assertThat(properties.getKeyset()).containsExactly(KEY, KEY2);
assertThat(properties.getString(KEY, DEFAULT_VALUE)).isEqualTo(VALUE);
assertThat(properties.getString(KEY2, DEFAULT_VALUE)).isEqualTo(VALUE2);
- Map<String, String> newKeyValues = new HashMap<>();
- newKeyValues.put(KEY, VALUE2);
- newKeyValues.put(KEY3, VALUE3);
+ properties = new Properties.Builder(NAMESPACE).setString(KEY, VALUE2)
+ .setString(KEY3, VALUE3).build();
- DeviceConfig.setProperties(new Properties(NAMESPACE, newKeyValues));
+ DeviceConfig.setProperties(properties);
properties = DeviceConfig.getProperties(NAMESPACE);
assertThat(properties.getKeyset()).containsExactly(KEY, KEY3);
assertThat(properties.getString(KEY, DEFAULT_VALUE)).isEqualTo(VALUE2);
@@ -514,18 +509,15 @@
}
@Test
- public void setProperties_multipleNamespaces() {
- Map<String, String> keyValues = new HashMap<>();
- keyValues.put(KEY, VALUE);
- keyValues.put(KEY2, VALUE2);
-
- Map<String, String> keyValues2 = new HashMap<>();
- keyValues2.put(KEY2, VALUE);
- keyValues2.put(KEY3, VALUE2);
-
+ public void setProperties_multipleNamespaces() throws DeviceConfig.BadConfigException {
final String namespace2 = "namespace2";
- DeviceConfig.setProperties(new Properties(NAMESPACE, keyValues));
- DeviceConfig.setProperties(new Properties(namespace2, keyValues2));
+ Properties properties1 = new Properties.Builder(NAMESPACE).setString(KEY, VALUE)
+ .setString(KEY2, VALUE2).build();
+ Properties properties2 = new Properties.Builder(namespace2).setString(KEY2, VALUE)
+ .setString(KEY3, VALUE2).build();
+
+ DeviceConfig.setProperties(properties1);
+ DeviceConfig.setProperties(properties2);
Properties properties = DeviceConfig.getProperties(NAMESPACE);
assertThat(properties.getKeyset()).containsExactly(KEY, KEY2);
@@ -549,6 +541,26 @@
deleteViaContentProvider(namespace2, KEY3);
}
+ @Test
+ public void propertiesBuilder() {
+ boolean booleanValue = true;
+ int intValue = 123;
+ float floatValue = 4.56f;
+ long longValue = -789L;
+ String key4 = "key4";
+ String key5 = "key5";
+
+ Properties properties = new Properties.Builder(NAMESPACE).setString(KEY, VALUE)
+ .setBoolean(KEY2, booleanValue).setInt(KEY3, intValue).setLong(key4, longValue)
+ .setFloat(key5, floatValue).build();
+ assertThat(properties.getNamespace()).isEqualTo(NAMESPACE);
+ assertThat(properties.getString(KEY, "defaultValue")).isEqualTo(VALUE);
+ assertThat(properties.getBoolean(KEY2, false)).isEqualTo(booleanValue);
+ assertThat(properties.getInt(KEY3, 0)).isEqualTo(intValue);
+ assertThat(properties.getLong("key4", 0L)).isEqualTo(longValue);
+ assertThat(properties.getFloat("key5", 0f)).isEqualTo(floatValue);
+ }
+
// TODO(mpape): resolve b/142727848 and re-enable listener tests
// @Test
// public void onPropertiesChangedListener_setPropertyCallback() throws InterruptedException {
diff --git a/core/tests/coretests/src/android/util/CloseGuardTest.java b/core/tests/coretests/src/android/util/CloseGuardTest.java
new file mode 100644
index 0000000..d86c7b7
--- /dev/null
+++ b/core/tests/coretests/src/android/util/CloseGuardTest.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2019 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 android.util;
+
+import libcore.dalvik.system.CloseGuardSupport;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+
+/** Unit tests for {@link android.util.CloseGuard} */
+public class CloseGuardTest {
+
+ @Rule
+ public final TestRule rule = CloseGuardSupport.getRule();
+
+ @Test
+ public void testEnabled_NotOpen() throws Throwable {
+ ResourceOwner owner = new ResourceOwner();
+ assertUnreleasedResources(owner, 0);
+ }
+
+ @Test
+ public void testEnabled_OpenNotClosed() throws Throwable {
+ ResourceOwner owner = new ResourceOwner();
+ owner.open();
+ assertUnreleasedResources(owner, 1);
+ }
+
+ @Test
+ public void testEnabled_OpenThenClosed() throws Throwable {
+ ResourceOwner owner = new ResourceOwner();
+ owner.open();
+ owner.close();
+ assertUnreleasedResources(owner, 0);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testOpen_withNullMethodName_throwsNPE() throws Throwable {
+ CloseGuard closeGuard = new CloseGuard();
+ closeGuard.open(null);
+ }
+
+ private void assertUnreleasedResources(ResourceOwner owner, int expectedCount)
+ throws Throwable {
+ try {
+ CloseGuardSupport.getFinalizerChecker().accept(owner, expectedCount);
+ } finally {
+ // Close the resource so that CloseGuard does not generate a warning for real when it
+ // is actually finalized.
+ owner.close();
+ }
+ }
+
+ /**
+ * A test user of {@link CloseGuard}.
+ */
+ private static class ResourceOwner {
+
+ private final CloseGuard mCloseGuard;
+
+ ResourceOwner() {
+ mCloseGuard = new CloseGuard();
+ }
+
+ public void open() {
+ mCloseGuard.open("close");
+ }
+
+ public void close() {
+ mCloseGuard.close();
+ }
+
+ /**
+ * Make finalize public so that it can be tested directly without relying on garbage
+ * collection to trigger it.
+ */
+ @Override
+ public void finalize() throws Throwable {
+ mCloseGuard.warnIfOpen();
+ super.finalize();
+ }
+ }
+}
diff --git a/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java b/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java
index 1a48260..cce38f6 100644
--- a/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java
+++ b/core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java
@@ -19,11 +19,9 @@
import static android.view.InsetsState.ITYPE_NAVIGATION_BAR;
import static android.view.InsetsState.ITYPE_STATUS_BAR;
import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
-import static android.view.WindowInsets.Type.navigationBars;
import static android.view.WindowInsets.Type.systemBars;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.eq;
@@ -118,7 +116,7 @@
consumers.put(ITYPE_NAVIGATION_BAR, navConsumer);
mController = new InsetsAnimationControlImpl(consumers,
new Rect(0, 0, 500, 500), mInsetsState, mMockListener, systemBars(),
- () -> mMockTransactionApplier, mMockController);
+ () -> mMockTransactionApplier, mMockController, 10 /* durationMs */);
}
@Test
@@ -131,7 +129,8 @@
@Test
public void testChangeInsets() {
- mController.changeInsets(Insets.of(0, 30, 40, 0));
+ mController.setInsetsAndAlpha(Insets.of(0, 30, 40, 0), 1f /* alpha */,
+ 0f /* fraction */);
mController.applyChangeInsets(new InsetsState());
assertEquals(Insets.of(0, 30, 40, 0), mController.getCurrentInsets());
@@ -150,24 +149,24 @@
@Test
public void testFinishing() {
when(mMockController.getState()).thenReturn(mInsetsState);
- mController.finish(navigationBars());
+ mController.finish(true /* shown */);
mController.applyChangeInsets(mInsetsState);
- assertFalse(mInsetsState.getSource(ITYPE_STATUS_BAR).isVisible());
+ assertTrue(mInsetsState.getSource(ITYPE_STATUS_BAR).isVisible());
assertTrue(mInsetsState.getSource(ITYPE_NAVIGATION_BAR).isVisible());
- assertEquals(Insets.of(0, 0, 100, 0), mController.getCurrentInsets());
- verify(mMockController).notifyFinished(eq(mController), eq(navigationBars()));
+ assertEquals(Insets.of(0, 100, 100, 0), mController.getCurrentInsets());
+ verify(mMockController).notifyFinished(eq(mController), eq(true /* shown */));
}
@Test
public void testCancelled() {
mController.onCancelled();
try {
- mController.changeInsets(Insets.NONE);
+ mController.setInsetsAndAlpha(Insets.NONE, 1f /*alpha */, 0f /* fraction */);
fail("Expected exception to be thrown");
} catch (IllegalStateException ignored) {
}
verify(mMockListener).onCancelled();
- mController.finish(navigationBars());
+ mController.finish(true /* shown */);
}
private void assertPosition(Matrix m, Rect original, Rect transformed) {
diff --git a/core/tests/coretests/src/android/view/InsetsControllerTest.java b/core/tests/coretests/src/android/view/InsetsControllerTest.java
index e4d8279..a89fc1e 100644
--- a/core/tests/coretests/src/android/view/InsetsControllerTest.java
+++ b/core/tests/coretests/src/android/view/InsetsControllerTest.java
@@ -123,7 +123,7 @@
WindowInsetsAnimationControlListener mockListener =
mock(WindowInsetsAnimationControlListener.class);
- mController.controlWindowInsetsAnimation(statusBars(), mockListener);
+ mController.controlWindowInsetsAnimation(statusBars(), 10 /* durationMs */, mockListener);
verify(mockListener).onReady(any(), anyInt());
mController.onControlsChanged(new InsetsSourceControl[0]);
verify(mockListener).onCancelled();
@@ -135,7 +135,7 @@
mController.getState().setDisplayFrame(new Rect(0, 0, 200, 200));
WindowInsetsAnimationControlListener controlListener =
mock(WindowInsetsAnimationControlListener.class);
- mController.controlWindowInsetsAnimation(0, controlListener);
+ mController.controlWindowInsetsAnimation(0, 0 /* durationMs */, controlListener);
verify(controlListener).onCancelled();
verify(controlListener, never()).onReady(any(), anyInt());
}
@@ -331,12 +331,13 @@
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
WindowInsetsAnimationControlListener mockListener =
mock(WindowInsetsAnimationControlListener.class);
- mController.controlWindowInsetsAnimation(statusBars(), mockListener);
+ mController.controlWindowInsetsAnimation(statusBars(), 0 /* durationMs */,
+ mockListener);
ArgumentCaptor<WindowInsetsAnimationController> controllerCaptor =
ArgumentCaptor.forClass(WindowInsetsAnimationController.class);
verify(mockListener).onReady(controllerCaptor.capture(), anyInt());
- controllerCaptor.getValue().finish(0 /* shownTypes */);
+ controllerCaptor.getValue().finish(false /* shown */);
});
waitUntilNextFrame();
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
diff --git a/core/tests/coretests/src/android/view/ViewRootImplTest.java b/core/tests/coretests/src/android/view/ViewRootImplTest.java
index 9a57847..cf5d079 100644
--- a/core/tests/coretests/src/android/view/ViewRootImplTest.java
+++ b/core/tests/coretests/src/android/view/ViewRootImplTest.java
@@ -16,13 +16,25 @@
package android.view;
+import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
+import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
+import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
+import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
+import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
+import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
+import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
+
import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
+import static org.junit.Assume.assumeTrue;
import android.content.Context;
import android.graphics.Insets;
import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;
+import android.view.WindowInsets.Side;
+import android.view.WindowInsets.Type;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
@@ -55,6 +67,8 @@
@Test
public void negativeInsets_areSetToZero() throws Exception {
+ assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
+
mViewRootImpl.getAttachInfo().getContentInsets().set(-10, -20, -30 , -40);
mViewRootImpl.getAttachInfo().getStableInsets().set(-10, -20, -30 , -40);
final WindowInsets insets = mViewRootImpl.getWindowInsets(true /* forceConstruct */);
@@ -65,6 +79,8 @@
@Test
public void negativeInsets_areSetToZero_positiveAreLeftAsIs() throws Exception {
+ assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
+
mViewRootImpl.getAttachInfo().getContentInsets().set(-10, 20, -30 , 40);
mViewRootImpl.getAttachInfo().getStableInsets().set(10, -20, 30 , -40);
final WindowInsets insets = mViewRootImpl.getWindowInsets(true /* forceConstruct */);
@@ -75,6 +91,8 @@
@Test
public void positiveInsets_areLeftAsIs() throws Exception {
+ assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
+
mViewRootImpl.getAttachInfo().getContentInsets().set(10, 20, 30 , 40);
mViewRootImpl.getAttachInfo().getStableInsets().set(10, 20, 30 , 40);
final WindowInsets insets = mViewRootImpl.getWindowInsets(true /* forceConstruct */);
@@ -83,6 +101,80 @@
assertThat(insets.getStableInsets(), equalTo(Insets.of(10, 20, 30, 40)));
}
+ @Test
+ public void adjustLayoutParamsForInsets_layoutFullscreen() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_APPLICATION);
+ attrs.systemUiVisibility = SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
+ ViewRootImpl.adjustLayoutParamsForCompatibility(attrs);
+
+ assertEquals(0, attrs.getFitWindowInsetsTypes() & Type.statusBars());
+ }
+
+ @Test
+ public void adjustLayoutParamsForInsets_layoutInScreen() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_APPLICATION);
+ attrs.flags = FLAG_LAYOUT_IN_SCREEN;
+ ViewRootImpl.adjustLayoutParamsForCompatibility(attrs);
+
+ assertEquals(0, attrs.getFitWindowInsetsTypes() & Type.statusBars());
+ }
+
+ @Test
+ public void adjustLayoutParamsForInsets_layoutHideNavigation() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_APPLICATION);
+ attrs.systemUiVisibility = SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
+ ViewRootImpl.adjustLayoutParamsForCompatibility(attrs);
+
+ assertEquals(0, attrs.getFitWindowInsetsTypes() & Type.systemBars());
+ }
+
+ @Test
+ public void adjustLayoutParamsForInsets_toast() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_TOAST);
+ ViewRootImpl.adjustLayoutParamsForCompatibility(attrs);
+
+ assertEquals(Type.systemBars(), attrs.getFitWindowInsetsTypes() & Type.systemBars());
+ assertEquals(true, attrs.getFitIgnoreVisibility());
+ }
+
+ @Test
+ public void adjustLayoutParamsForInsets_systemAlert() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_SYSTEM_ALERT);
+ ViewRootImpl.adjustLayoutParamsForCompatibility(attrs);
+
+ assertEquals(Type.systemBars(), attrs.getFitWindowInsetsTypes() & Type.systemBars());
+ assertEquals(true, attrs.getFitIgnoreVisibility());
+ }
+
+ @Test
+ public void adjustLayoutParamsForInsets_noAdjust() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_APPLICATION);
+ final int types = Type.all();
+ final int sides = Side.TOP | Side.LEFT;
+ final boolean fitMaxInsets = true;
+ attrs.flags = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
+ attrs.setFitWindowInsetsTypes(types);
+ attrs.setFitWindowInsetsSides(sides);
+ attrs.setFitIgnoreVisibility(fitMaxInsets);
+ ViewRootImpl.adjustLayoutParamsForCompatibility(attrs);
+
+ assertEquals(types, attrs.getFitWindowInsetsTypes());
+ assertEquals(sides, attrs.getFitWindowInsetsSides());
+ assertEquals(fitMaxInsets, attrs.getFitIgnoreVisibility());
+ }
+
private static class ViewRootImplAccessor {
private final ViewRootImpl mViewRootImpl;
diff --git a/core/tests/coretests/src/android/view/accessibility/AccessibilityCacheTest.java b/core/tests/coretests/src/android/view/accessibility/AccessibilityCacheTest.java
index 6bce651..0d5db6d 100644
--- a/core/tests/coretests/src/android/view/accessibility/AccessibilityCacheTest.java
+++ b/core/tests/coretests/src/android/view/accessibility/AccessibilityCacheTest.java
@@ -436,6 +436,22 @@
}
@Test
+ public void windowsChangedWithWindowsChangeA11yFocusedEvent_dontClearCache() {
+ AccessibilityNodeInfo nodeInfo = getNodeWithA11yAndWindowId(SINGLE_VIEW_ID, WINDOW_ID_1);
+ mAccessibilityCache.add(nodeInfo);
+ AccessibilityEvent event = new AccessibilityEvent(AccessibilityEvent.TYPE_WINDOWS_CHANGED);
+ event.setWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED);
+ mAccessibilityCache.onAccessibilityEvent(event);
+ AccessibilityNodeInfo cachedNode = mAccessibilityCache.getNode(WINDOW_ID_1,
+ nodeInfo.getSourceNodeId());
+ try {
+ assertNotNull(cachedNode);
+ } finally {
+ nodeInfo.recycle();
+ }
+ }
+
+ @Test
public void subTreeChangeEvent_clearsNodeAndChild() {
AccessibilityEvent event = AccessibilityEvent
.obtain(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
diff --git a/core/tests/coretests/src/com/android/internal/app/ChooserWrapperActivity.java b/core/tests/coretests/src/com/android/internal/app/ChooserWrapperActivity.java
index a2e0095..2a10443 100644
--- a/core/tests/coretests/src/com/android/internal/app/ChooserWrapperActivity.java
+++ b/core/tests/coretests/src/com/android/internal/app/ChooserWrapperActivity.java
@@ -48,7 +48,7 @@
private UsageStatsManager mUsm;
ChooserListAdapter getAdapter() {
- return mChooserMultiProfilePagerAdapter.getCurrentListAdapter();
+ return mChooserMultiProfilePagerAdapter.getActiveListAdapter();
}
boolean getIsSelected() { return mIsSuccessfullySelected; }
diff --git a/core/tests/coretests/src/com/android/internal/app/ResolverWrapperActivity.java b/core/tests/coretests/src/com/android/internal/app/ResolverWrapperActivity.java
index 93357af..c5d2cfa 100644
--- a/core/tests/coretests/src/com/android/internal/app/ResolverWrapperActivity.java
+++ b/core/tests/coretests/src/com/android/internal/app/ResolverWrapperActivity.java
@@ -46,7 +46,7 @@
}
ResolverWrapperAdapter getAdapter() {
- return (ResolverWrapperAdapter) mMultiProfilePagerAdapter.getCurrentListAdapter();
+ return (ResolverWrapperAdapter) mMultiProfilePagerAdapter.getActiveListAdapter();
}
@Override
diff --git a/core/tests/coretests/src/com/android/internal/infra/AndroidFutureTest.java b/core/tests/coretests/src/com/android/internal/infra/AndroidFutureTest.java
index 9002c2c..ffc925f 100644
--- a/core/tests/coretests/src/com/android/internal/infra/AndroidFutureTest.java
+++ b/core/tests/coretests/src/com/android/internal/infra/AndroidFutureTest.java
@@ -111,7 +111,7 @@
}
@Test
- public void testWriteToParcel_Exceptionally() throws Exception {
+ public void testWriteToParcel_Exception() throws Exception {
Parcel parcel = Parcel.obtain();
AndroidFuture<Integer> future1 = new AndroidFuture<>();
future1.completeExceptionally(new UnsupportedOperationException());
@@ -123,4 +123,30 @@
expectThrows(ExecutionException.class, future2::get);
assertThat(executionException.getCause()).isInstanceOf(UnsupportedOperationException.class);
}
+
+ @Test
+ public void testWriteToParcel_Incomplete() throws Exception {
+ Parcel parcel = Parcel.obtain();
+ AndroidFuture<Integer> future1 = new AndroidFuture<>();
+ future1.writeToParcel(parcel, 0);
+
+ parcel.setDataPosition(0);
+ AndroidFuture future2 = AndroidFuture.CREATOR.createFromParcel(parcel);
+ future2.complete(5);
+ assertThat(future1.get()).isEqualTo(5);
+ }
+
+ @Test
+ public void testWriteToParcel_Incomplete_Exception() throws Exception {
+ Parcel parcel = Parcel.obtain();
+ AndroidFuture<Integer> future1 = new AndroidFuture<>();
+ future1.writeToParcel(parcel, 0);
+
+ parcel.setDataPosition(0);
+ AndroidFuture future2 = AndroidFuture.CREATOR.createFromParcel(parcel);
+ future2.completeExceptionally(new UnsupportedOperationException());
+ ExecutionException executionException =
+ expectThrows(ExecutionException.class, future1::get);
+ assertThat(executionException.getCause()).isInstanceOf(UnsupportedOperationException.class);
+ }
}
diff --git a/core/tests/screenshothelpertests/src/com/android/internal/util/ScreenshotHelperTest.java b/core/tests/screenshothelpertests/src/com/android/internal/util/ScreenshotHelperTest.java
index e16d1ca..1472b90 100644
--- a/core/tests/screenshothelpertests/src/com/android/internal/util/ScreenshotHelperTest.java
+++ b/core/tests/screenshothelpertests/src/com/android/internal/util/ScreenshotHelperTest.java
@@ -24,8 +24,13 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
import android.content.Context;
+import android.content.res.Resources;
import android.os.Handler;
import android.os.Looper;
@@ -54,9 +59,15 @@
// This raises a `SecurityException` if the device is locked. Calling either `Context`
// method results in a broadcast of `android.intent.action. USER_PRESENT`. Only the system
// process is allowed to broadcast that `Intent`.
+ Resources res = mock(Resources.class);
mContext = Mockito.spy(Context.class);
- Mockito.doNothing().when(mContext).sendBroadcastAsUser(any(), any());
- Mockito.doReturn(true).when(mContext).bindServiceAsUser(any(), any(), anyInt(), any());
+ doNothing().when(mContext).sendBroadcastAsUser(any(), any());
+ doReturn(true).when(mContext).bindServiceAsUser(any(), any(), anyInt(), any());
+ doReturn(res).when(mContext).getResources();
+ doReturn("com.android.systemui/.Service").when(res).getString(
+ eq(com.android.internal.R.string.config_screenshotServiceComponent));
+ doReturn("com.android.systemui/.ErrorReceiver").when(res).getString(
+ eq(com.android.internal.R.string.config_screenshotErrorReceiverComponent));
mHandler = new Handler(Looper.getMainLooper());
mScreenshotHelper = new ScreenshotHelper(mContext);
diff --git a/data/etc/Android.bp b/data/etc/Android.bp
index 43f65e3..183c04e 100644
--- a/data/etc/Android.bp
+++ b/data/etc/Android.bp
@@ -120,7 +120,7 @@
prebuilt_etc {
name: "privapp_whitelist_com.android.storagemanager",
- product_specific: true,
+ system_ext_specific: true,
sub_dir: "permissions",
src: "com.android.storagemanager.xml",
filename_from_src: true,
diff --git a/data/etc/privapp-permissions-platform.xml b/data/etc/privapp-permissions-platform.xml
index 322cbd7..e07edd4 100644
--- a/data/etc/privapp-permissions-platform.xml
+++ b/data/etc/privapp-permissions-platform.xml
@@ -145,7 +145,7 @@
<permission name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/>
<permission name="android.permission.CHANGE_CONFIGURATION"/>
<permission name="android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST"/>
- <permission name="android.permission.CONNECTIVITY_INTERNAL"/>
+ <permission name="android.permission.CONNECTIVITY_USE_RESTRICTED_NETWORKS"/>
<permission name="android.permission.CONTROL_INCALL_EXPERIENCE"/>
<permission name="android.permission.DUMP"/>
<permission name="android.permission.INTERACT_ACROSS_USERS"/>
diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json
index eff353c..3060476 100644
--- a/data/etc/services.core.protolog.json
+++ b/data/etc/services.core.protolog.json
@@ -7,12 +7,6 @@
"group": "WM_DEBUG_KEEP_SCREEN_ON",
"at": "com\/android\/server\/wm\/WindowManagerService.java"
},
- "-2138637148": {
- "message": "Clearing focused app, displayId=%d",
- "level": "VERBOSE",
- "group": "WM_DEBUG_FOCUS_LIGHT",
- "at": "com\/android\/server\/wm\/ActivityDisplay.java"
- },
"-2127842445": {
"message": "Clearing startingData for token=%s",
"level": "VERBOSE",
@@ -709,6 +703,12 @@
"group": "WM_DEBUG_BOOT",
"at": "com\/android\/server\/wm\/WindowManagerService.java"
},
+ "-603199586": {
+ "message": "Clearing focused app, displayId=%d",
+ "level": "VERBOSE",
+ "group": "WM_DEBUG_FOCUS_LIGHT",
+ "at": "com\/android\/server\/wm\/DisplayContent.java"
+ },
"-583031528": {
"message": "%s",
"level": "INFO",
@@ -1315,6 +1315,12 @@
"group": "WM_SHOW_TRANSACTIONS",
"at": "com\/android\/server\/wm\/WindowSurfaceController.java"
},
+ "584499099": {
+ "message": "Set focused app to: %s moveFocusNow=%b displayId=%d",
+ "level": "VERBOSE",
+ "group": "WM_DEBUG_FOCUS_LIGHT",
+ "at": "com\/android\/server\/wm\/DisplayContent.java"
+ },
"585096182": {
"message": "SURFACE isColorSpaceAgnostic=%b: %s",
"level": "INFO",
@@ -1513,12 +1519,6 @@
"group": "WM_DEBUG_ORIENTATION",
"at": "com\/android\/server\/wm\/WindowStateAnimator.java"
},
- "917739349": {
- "message": "Set focused app to: %s moveFocusNow=%b displayId=%d",
- "level": "VERBOSE",
- "group": "WM_DEBUG_FOCUS_LIGHT",
- "at": "com\/android\/server\/wm\/ActivityDisplay.java"
- },
"954470154": {
"message": "FORCED DISPLAY SCALING DISABLED",
"level": "INFO",
diff --git a/framework-jarjar-rules.txt b/framework-jarjar-rules.txt
new file mode 100644
index 0000000..d8af726
--- /dev/null
+++ b/framework-jarjar-rules.txt
@@ -0,0 +1,2 @@
+rule android.hidl.** android.internal.hidl.@1
+rule android.net.wifi.WifiAnnotations* android.internal.wifi.WifiAnnotations@1
diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java
index 45b2de5..c6586ec 100644
--- a/graphics/java/android/graphics/drawable/GradientDrawable.java
+++ b/graphics/java/android/graphics/drawable/GradientDrawable.java
@@ -784,9 +784,7 @@
mFillPaint.setDither(st.mDither);
mFillPaint.setColorFilter(colorFilter);
if (colorFilter != null && st.mSolidColors == null) {
- // If we don't have a solid color and we don't have a gradient,
- // the app is stroking the shape, set the color to transparent
- mFillPaint.setColor(st.mGradientColors != null ? mAlpha << 24 : 0);
+ mFillPaint.setColor(mAlpha << 24);
}
if (haveStroke) {
mStrokePaint.setAlpha(currStrokeAlpha);
diff --git a/jarjar_rules_hidl.txt b/jarjar_rules_hidl.txt
deleted file mode 100644
index 4b2331d..0000000
--- a/jarjar_rules_hidl.txt
+++ /dev/null
@@ -1 +0,0 @@
-rule android.hidl.** android.internal.hidl.@1
diff --git a/keystore/java/android/security/Credentials.java b/keystore/java/android/security/Credentials.java
index 572fa8c..048dee6 100644
--- a/keystore/java/android/security/Credentials.java
+++ b/keystore/java/android/security/Credentials.java
@@ -65,6 +65,9 @@
/** Key prefix for VPN. */
public static final String VPN = "VPN_";
+ /** Key prefix for platform VPNs. */
+ public static final String PLATFORM_VPN = "PLATFORM_VPN_";
+
/** Key prefix for WIFI. */
public static final String WIFI = "WIFI_";
diff --git a/keystore/java/android/security/keystore/AttestationUtils.java b/keystore/java/android/security/keystore/AttestationUtils.java
index 94499ce..8a7b623 100644
--- a/keystore/java/android/security/keystore/AttestationUtils.java
+++ b/keystore/java/android/security/keystore/AttestationUtils.java
@@ -204,10 +204,7 @@
break;
}
case USE_INDIVIDUAL_ATTESTATION: {
- //TODO: Add the Keymaster tag for requesting the use of individual
- //attestation certificate, which should be
- //KeymasterDefs.KM_TAG_DEVICE_UNIQUE_ATTESTATION
- attestArgs.addBoolean(720);
+ attestArgs.addBoolean(KeymasterDefs.KM_TAG_DEVICE_UNIQUE_ATTESTATION);
break;
}
default:
diff --git a/libs/androidfw/LocaleDataTables.cpp b/libs/androidfw/LocaleDataTables.cpp
index c276a23..c462eb7 100644
--- a/libs/androidfw/LocaleDataTables.cpp
+++ b/libs/androidfw/LocaleDataTables.cpp
@@ -10,1439 +10,1466 @@
/* 6 */ {'B', 'a', 's', 's'},
/* 7 */ {'B', 'e', 'n', 'g'},
/* 8 */ {'B', 'r', 'a', 'h'},
- /* 9 */ {'C', 'a', 'n', 's'},
- /* 10 */ {'C', 'a', 'r', 'i'},
- /* 11 */ {'C', 'h', 'a', 'm'},
- /* 12 */ {'C', 'h', 'e', 'r'},
- /* 13 */ {'C', 'o', 'p', 't'},
- /* 14 */ {'C', 'p', 'r', 't'},
- /* 15 */ {'C', 'y', 'r', 'l'},
- /* 16 */ {'D', 'e', 'v', 'a'},
- /* 17 */ {'E', 'g', 'y', 'p'},
- /* 18 */ {'E', 't', 'h', 'i'},
- /* 19 */ {'G', 'e', 'o', 'r'},
- /* 20 */ {'G', 'o', 't', 'h'},
- /* 21 */ {'G', 'r', 'e', 'k'},
- /* 22 */ {'G', 'u', 'j', 'r'},
- /* 23 */ {'G', 'u', 'r', 'u'},
- /* 24 */ {'H', 'a', 'n', 's'},
- /* 25 */ {'H', 'a', 'n', 't'},
- /* 26 */ {'H', 'a', 't', 'r'},
- /* 27 */ {'H', 'e', 'b', 'r'},
- /* 28 */ {'H', 'l', 'u', 'w'},
- /* 29 */ {'H', 'm', 'n', 'g'},
- /* 30 */ {'I', 't', 'a', 'l'},
- /* 31 */ {'J', 'p', 'a', 'n'},
- /* 32 */ {'K', 'a', 'l', 'i'},
- /* 33 */ {'K', 'a', 'n', 'a'},
- /* 34 */ {'K', 'h', 'a', 'r'},
- /* 35 */ {'K', 'h', 'm', 'r'},
- /* 36 */ {'K', 'n', 'd', 'a'},
- /* 37 */ {'K', 'o', 'r', 'e'},
- /* 38 */ {'L', 'a', 'n', 'a'},
- /* 39 */ {'L', 'a', 'o', 'o'},
- /* 40 */ {'L', 'a', 't', 'n'},
- /* 41 */ {'L', 'e', 'p', 'c'},
- /* 42 */ {'L', 'i', 'n', 'a'},
- /* 43 */ {'L', 'i', 's', 'u'},
- /* 44 */ {'L', 'y', 'c', 'i'},
- /* 45 */ {'L', 'y', 'd', 'i'},
- /* 46 */ {'M', 'a', 'n', 'd'},
- /* 47 */ {'M', 'a', 'n', 'i'},
- /* 48 */ {'M', 'e', 'r', 'c'},
- /* 49 */ {'M', 'l', 'y', 'm'},
- /* 50 */ {'M', 'o', 'n', 'g'},
- /* 51 */ {'M', 'r', 'o', 'o'},
- /* 52 */ {'M', 'y', 'm', 'r'},
- /* 53 */ {'N', 'a', 'r', 'b'},
- /* 54 */ {'N', 'k', 'o', 'o'},
- /* 55 */ {'O', 'g', 'a', 'm'},
- /* 56 */ {'O', 'r', 'k', 'h'},
- /* 57 */ {'O', 'r', 'y', 'a'},
- /* 58 */ {'O', 's', 'g', 'e'},
- /* 59 */ {'P', 'a', 'u', 'c'},
- /* 60 */ {'P', 'h', 'l', 'i'},
- /* 61 */ {'P', 'h', 'n', 'x'},
- /* 62 */ {'P', 'l', 'r', 'd'},
- /* 63 */ {'P', 'r', 't', 'i'},
- /* 64 */ {'R', 'u', 'n', 'r'},
- /* 65 */ {'S', 'a', 'm', 'r'},
- /* 66 */ {'S', 'a', 'r', 'b'},
- /* 67 */ {'S', 'a', 'u', 'r'},
- /* 68 */ {'S', 'g', 'n', 'w'},
- /* 69 */ {'S', 'i', 'n', 'h'},
- /* 70 */ {'S', 'o', 'r', 'a'},
- /* 71 */ {'S', 'y', 'r', 'c'},
- /* 72 */ {'T', 'a', 'l', 'e'},
- /* 73 */ {'T', 'a', 'l', 'u'},
- /* 74 */ {'T', 'a', 'm', 'l'},
- /* 75 */ {'T', 'a', 'n', 'g'},
- /* 76 */ {'T', 'a', 'v', 't'},
- /* 77 */ {'T', 'e', 'l', 'u'},
- /* 78 */ {'T', 'f', 'n', 'g'},
- /* 79 */ {'T', 'h', 'a', 'a'},
- /* 80 */ {'T', 'h', 'a', 'i'},
- /* 81 */ {'T', 'i', 'b', 't'},
- /* 82 */ {'U', 'g', 'a', 'r'},
- /* 83 */ {'V', 'a', 'i', 'i'},
- /* 84 */ {'X', 'p', 'e', 'o'},
- /* 85 */ {'X', 's', 'u', 'x'},
- /* 86 */ {'Y', 'i', 'i', 'i'},
- /* 87 */ {'~', '~', '~', 'A'},
- /* 88 */ {'~', '~', '~', 'B'},
+ /* 9 */ {'C', 'a', 'k', 'm'},
+ /* 10 */ {'C', 'a', 'n', 's'},
+ /* 11 */ {'C', 'a', 'r', 'i'},
+ /* 12 */ {'C', 'h', 'a', 'm'},
+ /* 13 */ {'C', 'h', 'e', 'r'},
+ /* 14 */ {'C', 'o', 'p', 't'},
+ /* 15 */ {'C', 'p', 'r', 't'},
+ /* 16 */ {'C', 'y', 'r', 'l'},
+ /* 17 */ {'D', 'e', 'v', 'a'},
+ /* 18 */ {'E', 'g', 'y', 'p'},
+ /* 19 */ {'E', 't', 'h', 'i'},
+ /* 20 */ {'G', 'e', 'o', 'r'},
+ /* 21 */ {'G', 'o', 'n', 'g'},
+ /* 22 */ {'G', 'o', 'n', 'm'},
+ /* 23 */ {'G', 'o', 't', 'h'},
+ /* 24 */ {'G', 'r', 'e', 'k'},
+ /* 25 */ {'G', 'u', 'j', 'r'},
+ /* 26 */ {'G', 'u', 'r', 'u'},
+ /* 27 */ {'H', 'a', 'n', 's'},
+ /* 28 */ {'H', 'a', 'n', 't'},
+ /* 29 */ {'H', 'a', 't', 'r'},
+ /* 30 */ {'H', 'e', 'b', 'r'},
+ /* 31 */ {'H', 'l', 'u', 'w'},
+ /* 32 */ {'H', 'm', 'n', 'g'},
+ /* 33 */ {'H', 'm', 'n', 'p'},
+ /* 34 */ {'I', 't', 'a', 'l'},
+ /* 35 */ {'J', 'p', 'a', 'n'},
+ /* 36 */ {'K', 'a', 'l', 'i'},
+ /* 37 */ {'K', 'a', 'n', 'a'},
+ /* 38 */ {'K', 'h', 'a', 'r'},
+ /* 39 */ {'K', 'h', 'm', 'r'},
+ /* 40 */ {'K', 'n', 'd', 'a'},
+ /* 41 */ {'K', 'o', 'r', 'e'},
+ /* 42 */ {'L', 'a', 'n', 'a'},
+ /* 43 */ {'L', 'a', 'o', 'o'},
+ /* 44 */ {'L', 'a', 't', 'n'},
+ /* 45 */ {'L', 'e', 'p', 'c'},
+ /* 46 */ {'L', 'i', 'n', 'a'},
+ /* 47 */ {'L', 'i', 's', 'u'},
+ /* 48 */ {'L', 'y', 'c', 'i'},
+ /* 49 */ {'L', 'y', 'd', 'i'},
+ /* 50 */ {'M', 'a', 'n', 'd'},
+ /* 51 */ {'M', 'a', 'n', 'i'},
+ /* 52 */ {'M', 'e', 'r', 'c'},
+ /* 53 */ {'M', 'l', 'y', 'm'},
+ /* 54 */ {'M', 'o', 'n', 'g'},
+ /* 55 */ {'M', 'r', 'o', 'o'},
+ /* 56 */ {'M', 'y', 'm', 'r'},
+ /* 57 */ {'N', 'a', 'r', 'b'},
+ /* 58 */ {'N', 'k', 'o', 'o'},
+ /* 59 */ {'N', 's', 'h', 'u'},
+ /* 60 */ {'O', 'g', 'a', 'm'},
+ /* 61 */ {'O', 'r', 'k', 'h'},
+ /* 62 */ {'O', 'r', 'y', 'a'},
+ /* 63 */ {'O', 's', 'g', 'e'},
+ /* 64 */ {'P', 'a', 'u', 'c'},
+ /* 65 */ {'P', 'h', 'l', 'i'},
+ /* 66 */ {'P', 'h', 'n', 'x'},
+ /* 67 */ {'P', 'l', 'r', 'd'},
+ /* 68 */ {'P', 'r', 't', 'i'},
+ /* 69 */ {'R', 'u', 'n', 'r'},
+ /* 70 */ {'S', 'a', 'm', 'r'},
+ /* 71 */ {'S', 'a', 'r', 'b'},
+ /* 72 */ {'S', 'a', 'u', 'r'},
+ /* 73 */ {'S', 'g', 'n', 'w'},
+ /* 74 */ {'S', 'i', 'n', 'h'},
+ /* 75 */ {'S', 'o', 'g', 'd'},
+ /* 76 */ {'S', 'o', 'r', 'a'},
+ /* 77 */ {'S', 'o', 'y', 'o'},
+ /* 78 */ {'S', 'y', 'r', 'c'},
+ /* 79 */ {'T', 'a', 'l', 'e'},
+ /* 80 */ {'T', 'a', 'l', 'u'},
+ /* 81 */ {'T', 'a', 'm', 'l'},
+ /* 82 */ {'T', 'a', 'n', 'g'},
+ /* 83 */ {'T', 'a', 'v', 't'},
+ /* 84 */ {'T', 'e', 'l', 'u'},
+ /* 85 */ {'T', 'f', 'n', 'g'},
+ /* 86 */ {'T', 'h', 'a', 'a'},
+ /* 87 */ {'T', 'h', 'a', 'i'},
+ /* 88 */ {'T', 'i', 'b', 't'},
+ /* 89 */ {'U', 'g', 'a', 'r'},
+ /* 90 */ {'V', 'a', 'i', 'i'},
+ /* 91 */ {'W', 'c', 'h', 'o'},
+ /* 92 */ {'X', 'p', 'e', 'o'},
+ /* 93 */ {'X', 's', 'u', 'x'},
+ /* 94 */ {'Y', 'i', 'i', 'i'},
+ /* 95 */ {'~', '~', '~', 'A'},
+ /* 96 */ {'~', '~', '~', 'B'},
};
const std::unordered_map<uint32_t, uint8_t> LIKELY_SCRIPTS({
- {0x61610000u, 40u}, // aa -> Latn
- {0xA0000000u, 40u}, // aai -> Latn
- {0xA8000000u, 40u}, // aak -> Latn
- {0xD0000000u, 40u}, // aau -> Latn
- {0x61620000u, 15u}, // ab -> Cyrl
- {0xA0200000u, 40u}, // abi -> Latn
- {0xC4200000u, 40u}, // abr -> Latn
- {0xCC200000u, 40u}, // abt -> Latn
- {0xE0200000u, 40u}, // aby -> Latn
- {0x8C400000u, 40u}, // acd -> Latn
- {0x90400000u, 40u}, // ace -> Latn
- {0x9C400000u, 40u}, // ach -> Latn
- {0x80600000u, 40u}, // ada -> Latn
- {0x90600000u, 40u}, // ade -> Latn
- {0xA4600000u, 40u}, // adj -> Latn
- {0xE0600000u, 15u}, // ady -> Cyrl
- {0xE4600000u, 40u}, // adz -> Latn
+ {0x61610000u, 44u}, // aa -> Latn
+ {0xA0000000u, 44u}, // aai -> Latn
+ {0xA8000000u, 44u}, // aak -> Latn
+ {0xD0000000u, 44u}, // aau -> Latn
+ {0x61620000u, 16u}, // ab -> Cyrl
+ {0xA0200000u, 44u}, // abi -> Latn
+ {0xC0200000u, 16u}, // abq -> Cyrl
+ {0xC4200000u, 44u}, // abr -> Latn
+ {0xCC200000u, 44u}, // abt -> Latn
+ {0xE0200000u, 44u}, // aby -> Latn
+ {0x8C400000u, 44u}, // acd -> Latn
+ {0x90400000u, 44u}, // ace -> Latn
+ {0x9C400000u, 44u}, // ach -> Latn
+ {0x80600000u, 44u}, // ada -> Latn
+ {0x90600000u, 44u}, // ade -> Latn
+ {0xA4600000u, 44u}, // adj -> Latn
+ {0xE0600000u, 16u}, // ady -> Cyrl
+ {0xE4600000u, 44u}, // adz -> Latn
{0x61650000u, 4u}, // ae -> Avst
{0x84800000u, 1u}, // aeb -> Arab
- {0xE0800000u, 40u}, // aey -> Latn
- {0x61660000u, 40u}, // af -> Latn
- {0x88C00000u, 40u}, // agc -> Latn
- {0x8CC00000u, 40u}, // agd -> Latn
- {0x98C00000u, 40u}, // agg -> Latn
- {0xB0C00000u, 40u}, // agm -> Latn
- {0xB8C00000u, 40u}, // ago -> Latn
- {0xC0C00000u, 40u}, // agq -> Latn
- {0x80E00000u, 40u}, // aha -> Latn
- {0xACE00000u, 40u}, // ahl -> Latn
+ {0xE0800000u, 44u}, // aey -> Latn
+ {0x61660000u, 44u}, // af -> Latn
+ {0x88C00000u, 44u}, // agc -> Latn
+ {0x8CC00000u, 44u}, // agd -> Latn
+ {0x98C00000u, 44u}, // agg -> Latn
+ {0xB0C00000u, 44u}, // agm -> Latn
+ {0xB8C00000u, 44u}, // ago -> Latn
+ {0xC0C00000u, 44u}, // agq -> Latn
+ {0x80E00000u, 44u}, // aha -> Latn
+ {0xACE00000u, 44u}, // ahl -> Latn
{0xB8E00000u, 0u}, // aho -> Ahom
- {0x99200000u, 40u}, // ajg -> Latn
- {0x616B0000u, 40u}, // ak -> Latn
- {0xA9400000u, 85u}, // akk -> Xsux
- {0x81600000u, 40u}, // ala -> Latn
- {0xA1600000u, 40u}, // ali -> Latn
- {0xB5600000u, 40u}, // aln -> Latn
- {0xCD600000u, 15u}, // alt -> Cyrl
- {0x616D0000u, 18u}, // am -> Ethi
- {0xB1800000u, 40u}, // amm -> Latn
- {0xB5800000u, 40u}, // amn -> Latn
- {0xB9800000u, 40u}, // amo -> Latn
- {0xBD800000u, 40u}, // amp -> Latn
- {0x89A00000u, 40u}, // anc -> Latn
- {0xA9A00000u, 40u}, // ank -> Latn
- {0xB5A00000u, 40u}, // ann -> Latn
- {0xE1A00000u, 40u}, // any -> Latn
- {0xA5C00000u, 40u}, // aoj -> Latn
- {0xB1C00000u, 40u}, // aom -> Latn
- {0xE5C00000u, 40u}, // aoz -> Latn
+ {0x99200000u, 44u}, // ajg -> Latn
+ {0x616B0000u, 44u}, // ak -> Latn
+ {0xA9400000u, 93u}, // akk -> Xsux
+ {0x81600000u, 44u}, // ala -> Latn
+ {0xA1600000u, 44u}, // ali -> Latn
+ {0xB5600000u, 44u}, // aln -> Latn
+ {0xCD600000u, 16u}, // alt -> Cyrl
+ {0x616D0000u, 19u}, // am -> Ethi
+ {0xB1800000u, 44u}, // amm -> Latn
+ {0xB5800000u, 44u}, // amn -> Latn
+ {0xB9800000u, 44u}, // amo -> Latn
+ {0xBD800000u, 44u}, // amp -> Latn
+ {0x89A00000u, 44u}, // anc -> Latn
+ {0xA9A00000u, 44u}, // ank -> Latn
+ {0xB5A00000u, 44u}, // ann -> Latn
+ {0xE1A00000u, 44u}, // any -> Latn
+ {0xA5C00000u, 44u}, // aoj -> Latn
+ {0xB1C00000u, 44u}, // aom -> Latn
+ {0xE5C00000u, 44u}, // aoz -> Latn
{0x89E00000u, 1u}, // apc -> Arab
{0x8DE00000u, 1u}, // apd -> Arab
- {0x91E00000u, 40u}, // ape -> Latn
- {0xC5E00000u, 40u}, // apr -> Latn
- {0xC9E00000u, 40u}, // aps -> Latn
- {0xE5E00000u, 40u}, // apz -> Latn
+ {0x91E00000u, 44u}, // ape -> Latn
+ {0xC5E00000u, 44u}, // apr -> Latn
+ {0xC9E00000u, 44u}, // aps -> Latn
+ {0xE5E00000u, 44u}, // apz -> Latn
{0x61720000u, 1u}, // ar -> Arab
- {0x61725842u, 88u}, // ar-XB -> ~~~B
+ {0x61725842u, 96u}, // ar-XB -> ~~~B
{0x8A200000u, 2u}, // arc -> Armi
- {0x9E200000u, 40u}, // arh -> Latn
- {0xB6200000u, 40u}, // arn -> Latn
- {0xBA200000u, 40u}, // aro -> Latn
+ {0x9E200000u, 44u}, // arh -> Latn
+ {0xB6200000u, 44u}, // arn -> Latn
+ {0xBA200000u, 44u}, // aro -> Latn
{0xC2200000u, 1u}, // arq -> Arab
{0xE2200000u, 1u}, // ary -> Arab
{0xE6200000u, 1u}, // arz -> Arab
{0x61730000u, 7u}, // as -> Beng
- {0x82400000u, 40u}, // asa -> Latn
- {0x92400000u, 68u}, // ase -> Sgnw
- {0x9A400000u, 40u}, // asg -> Latn
- {0xBA400000u, 40u}, // aso -> Latn
- {0xCE400000u, 40u}, // ast -> Latn
- {0x82600000u, 40u}, // ata -> Latn
- {0x9A600000u, 40u}, // atg -> Latn
- {0xA6600000u, 40u}, // atj -> Latn
- {0xE2800000u, 40u}, // auy -> Latn
- {0x61760000u, 15u}, // av -> Cyrl
+ {0x82400000u, 44u}, // asa -> Latn
+ {0x92400000u, 73u}, // ase -> Sgnw
+ {0x9A400000u, 44u}, // asg -> Latn
+ {0xBA400000u, 44u}, // aso -> Latn
+ {0xCE400000u, 44u}, // ast -> Latn
+ {0x82600000u, 44u}, // ata -> Latn
+ {0x9A600000u, 44u}, // atg -> Latn
+ {0xA6600000u, 44u}, // atj -> Latn
+ {0xE2800000u, 44u}, // auy -> Latn
+ {0x61760000u, 16u}, // av -> Cyrl
{0xAEA00000u, 1u}, // avl -> Arab
- {0xB6A00000u, 40u}, // avn -> Latn
- {0xCEA00000u, 40u}, // avt -> Latn
- {0xD2A00000u, 40u}, // avu -> Latn
- {0x82C00000u, 16u}, // awa -> Deva
- {0x86C00000u, 40u}, // awb -> Latn
- {0xBAC00000u, 40u}, // awo -> Latn
- {0xDEC00000u, 40u}, // awx -> Latn
- {0x61790000u, 40u}, // ay -> Latn
- {0x87000000u, 40u}, // ayb -> Latn
- {0x617A0000u, 40u}, // az -> Latn
+ {0xB6A00000u, 44u}, // avn -> Latn
+ {0xCEA00000u, 44u}, // avt -> Latn
+ {0xD2A00000u, 44u}, // avu -> Latn
+ {0x82C00000u, 17u}, // awa -> Deva
+ {0x86C00000u, 44u}, // awb -> Latn
+ {0xBAC00000u, 44u}, // awo -> Latn
+ {0xDEC00000u, 44u}, // awx -> Latn
+ {0x61790000u, 44u}, // ay -> Latn
+ {0x87000000u, 44u}, // ayb -> Latn
+ {0x617A0000u, 44u}, // az -> Latn
{0x617A4951u, 1u}, // az-IQ -> Arab
{0x617A4952u, 1u}, // az-IR -> Arab
- {0x617A5255u, 15u}, // az-RU -> Cyrl
- {0x62610000u, 15u}, // ba -> Cyrl
+ {0x617A5255u, 16u}, // az-RU -> Cyrl
+ {0x62610000u, 16u}, // ba -> Cyrl
{0xAC010000u, 1u}, // bal -> Arab
- {0xB4010000u, 40u}, // ban -> Latn
- {0xBC010000u, 16u}, // bap -> Deva
- {0xC4010000u, 40u}, // bar -> Latn
- {0xC8010000u, 40u}, // bas -> Latn
- {0xD4010000u, 40u}, // bav -> Latn
+ {0xB4010000u, 44u}, // ban -> Latn
+ {0xBC010000u, 17u}, // bap -> Deva
+ {0xC4010000u, 44u}, // bar -> Latn
+ {0xC8010000u, 44u}, // bas -> Latn
+ {0xD4010000u, 44u}, // bav -> Latn
{0xDC010000u, 5u}, // bax -> Bamu
- {0x80210000u, 40u}, // bba -> Latn
- {0x84210000u, 40u}, // bbb -> Latn
- {0x88210000u, 40u}, // bbc -> Latn
- {0x8C210000u, 40u}, // bbd -> Latn
- {0xA4210000u, 40u}, // bbj -> Latn
- {0xBC210000u, 40u}, // bbp -> Latn
- {0xC4210000u, 40u}, // bbr -> Latn
- {0x94410000u, 40u}, // bcf -> Latn
- {0x9C410000u, 40u}, // bch -> Latn
- {0xA0410000u, 40u}, // bci -> Latn
- {0xB0410000u, 40u}, // bcm -> Latn
- {0xB4410000u, 40u}, // bcn -> Latn
- {0xB8410000u, 40u}, // bco -> Latn
- {0xC0410000u, 18u}, // bcq -> Ethi
- {0xD0410000u, 40u}, // bcu -> Latn
- {0x8C610000u, 40u}, // bdd -> Latn
- {0x62650000u, 15u}, // be -> Cyrl
- {0x94810000u, 40u}, // bef -> Latn
- {0x9C810000u, 40u}, // beh -> Latn
+ {0x80210000u, 44u}, // bba -> Latn
+ {0x84210000u, 44u}, // bbb -> Latn
+ {0x88210000u, 44u}, // bbc -> Latn
+ {0x8C210000u, 44u}, // bbd -> Latn
+ {0xA4210000u, 44u}, // bbj -> Latn
+ {0xBC210000u, 44u}, // bbp -> Latn
+ {0xC4210000u, 44u}, // bbr -> Latn
+ {0x94410000u, 44u}, // bcf -> Latn
+ {0x9C410000u, 44u}, // bch -> Latn
+ {0xA0410000u, 44u}, // bci -> Latn
+ {0xB0410000u, 44u}, // bcm -> Latn
+ {0xB4410000u, 44u}, // bcn -> Latn
+ {0xB8410000u, 44u}, // bco -> Latn
+ {0xC0410000u, 19u}, // bcq -> Ethi
+ {0xD0410000u, 44u}, // bcu -> Latn
+ {0x8C610000u, 44u}, // bdd -> Latn
+ {0x62650000u, 16u}, // be -> Cyrl
+ {0x94810000u, 44u}, // bef -> Latn
+ {0x9C810000u, 44u}, // beh -> Latn
{0xA4810000u, 1u}, // bej -> Arab
- {0xB0810000u, 40u}, // bem -> Latn
- {0xCC810000u, 40u}, // bet -> Latn
- {0xD8810000u, 40u}, // bew -> Latn
- {0xDC810000u, 40u}, // bex -> Latn
- {0xE4810000u, 40u}, // bez -> Latn
- {0x8CA10000u, 40u}, // bfd -> Latn
- {0xC0A10000u, 74u}, // bfq -> Taml
+ {0xB0810000u, 44u}, // bem -> Latn
+ {0xCC810000u, 44u}, // bet -> Latn
+ {0xD8810000u, 44u}, // bew -> Latn
+ {0xDC810000u, 44u}, // bex -> Latn
+ {0xE4810000u, 44u}, // bez -> Latn
+ {0x8CA10000u, 44u}, // bfd -> Latn
+ {0xC0A10000u, 81u}, // bfq -> Taml
{0xCCA10000u, 1u}, // bft -> Arab
- {0xE0A10000u, 16u}, // bfy -> Deva
- {0x62670000u, 15u}, // bg -> Cyrl
- {0x88C10000u, 16u}, // bgc -> Deva
+ {0xE0A10000u, 17u}, // bfy -> Deva
+ {0x62670000u, 16u}, // bg -> Cyrl
+ {0x88C10000u, 17u}, // bgc -> Deva
{0xB4C10000u, 1u}, // bgn -> Arab
- {0xDCC10000u, 21u}, // bgx -> Grek
- {0x84E10000u, 16u}, // bhb -> Deva
- {0x98E10000u, 40u}, // bhg -> Latn
- {0xA0E10000u, 16u}, // bhi -> Deva
- {0xA8E10000u, 40u}, // bhk -> Latn
- {0xACE10000u, 40u}, // bhl -> Latn
- {0xB8E10000u, 16u}, // bho -> Deva
- {0xE0E10000u, 40u}, // bhy -> Latn
- {0x62690000u, 40u}, // bi -> Latn
- {0x85010000u, 40u}, // bib -> Latn
- {0x99010000u, 40u}, // big -> Latn
- {0xA9010000u, 40u}, // bik -> Latn
- {0xB1010000u, 40u}, // bim -> Latn
- {0xB5010000u, 40u}, // bin -> Latn
- {0xB9010000u, 40u}, // bio -> Latn
- {0xC1010000u, 40u}, // biq -> Latn
- {0x9D210000u, 40u}, // bjh -> Latn
- {0xA1210000u, 18u}, // bji -> Ethi
- {0xA5210000u, 16u}, // bjj -> Deva
- {0xB5210000u, 40u}, // bjn -> Latn
- {0xB9210000u, 40u}, // bjo -> Latn
- {0xC5210000u, 40u}, // bjr -> Latn
- {0xE5210000u, 40u}, // bjz -> Latn
- {0x89410000u, 40u}, // bkc -> Latn
- {0xB1410000u, 40u}, // bkm -> Latn
- {0xC1410000u, 40u}, // bkq -> Latn
- {0xD1410000u, 40u}, // bku -> Latn
- {0xD5410000u, 40u}, // bkv -> Latn
- {0xCD610000u, 76u}, // blt -> Tavt
- {0x626D0000u, 40u}, // bm -> Latn
- {0x9D810000u, 40u}, // bmh -> Latn
- {0xA9810000u, 40u}, // bmk -> Latn
- {0xC1810000u, 40u}, // bmq -> Latn
- {0xD1810000u, 40u}, // bmu -> Latn
+ {0xDCC10000u, 24u}, // bgx -> Grek
+ {0x84E10000u, 17u}, // bhb -> Deva
+ {0x98E10000u, 44u}, // bhg -> Latn
+ {0xA0E10000u, 17u}, // bhi -> Deva
+ {0xA8E10000u, 44u}, // bhk -> Latn
+ {0xACE10000u, 44u}, // bhl -> Latn
+ {0xB8E10000u, 17u}, // bho -> Deva
+ {0xE0E10000u, 44u}, // bhy -> Latn
+ {0x62690000u, 44u}, // bi -> Latn
+ {0x85010000u, 44u}, // bib -> Latn
+ {0x99010000u, 44u}, // big -> Latn
+ {0xA9010000u, 44u}, // bik -> Latn
+ {0xB1010000u, 44u}, // bim -> Latn
+ {0xB5010000u, 44u}, // bin -> Latn
+ {0xB9010000u, 44u}, // bio -> Latn
+ {0xC1010000u, 44u}, // biq -> Latn
+ {0x9D210000u, 44u}, // bjh -> Latn
+ {0xA1210000u, 19u}, // bji -> Ethi
+ {0xA5210000u, 17u}, // bjj -> Deva
+ {0xB5210000u, 44u}, // bjn -> Latn
+ {0xB9210000u, 44u}, // bjo -> Latn
+ {0xC5210000u, 44u}, // bjr -> Latn
+ {0xCD210000u, 44u}, // bjt -> Latn
+ {0xE5210000u, 44u}, // bjz -> Latn
+ {0x89410000u, 44u}, // bkc -> Latn
+ {0xB1410000u, 44u}, // bkm -> Latn
+ {0xC1410000u, 44u}, // bkq -> Latn
+ {0xD1410000u, 44u}, // bku -> Latn
+ {0xD5410000u, 44u}, // bkv -> Latn
+ {0xCD610000u, 83u}, // blt -> Tavt
+ {0x626D0000u, 44u}, // bm -> Latn
+ {0x9D810000u, 44u}, // bmh -> Latn
+ {0xA9810000u, 44u}, // bmk -> Latn
+ {0xC1810000u, 44u}, // bmq -> Latn
+ {0xD1810000u, 44u}, // bmu -> Latn
{0x626E0000u, 7u}, // bn -> Beng
- {0x99A10000u, 40u}, // bng -> Latn
- {0xB1A10000u, 40u}, // bnm -> Latn
- {0xBDA10000u, 40u}, // bnp -> Latn
- {0x626F0000u, 81u}, // bo -> Tibt
- {0xA5C10000u, 40u}, // boj -> Latn
- {0xB1C10000u, 40u}, // bom -> Latn
- {0xB5C10000u, 40u}, // bon -> Latn
+ {0x99A10000u, 44u}, // bng -> Latn
+ {0xB1A10000u, 44u}, // bnm -> Latn
+ {0xBDA10000u, 44u}, // bnp -> Latn
+ {0x626F0000u, 88u}, // bo -> Tibt
+ {0xA5C10000u, 44u}, // boj -> Latn
+ {0xB1C10000u, 44u}, // bom -> Latn
+ {0xB5C10000u, 44u}, // bon -> Latn
{0xE1E10000u, 7u}, // bpy -> Beng
- {0x8A010000u, 40u}, // bqc -> Latn
+ {0x8A010000u, 44u}, // bqc -> Latn
{0xA2010000u, 1u}, // bqi -> Arab
- {0xBE010000u, 40u}, // bqp -> Latn
- {0xD6010000u, 40u}, // bqv -> Latn
- {0x62720000u, 40u}, // br -> Latn
- {0x82210000u, 16u}, // bra -> Deva
+ {0xBE010000u, 44u}, // bqp -> Latn
+ {0xD6010000u, 44u}, // bqv -> Latn
+ {0x62720000u, 44u}, // br -> Latn
+ {0x82210000u, 17u}, // bra -> Deva
{0x9E210000u, 1u}, // brh -> Arab
- {0xDE210000u, 16u}, // brx -> Deva
- {0xE6210000u, 40u}, // brz -> Latn
- {0x62730000u, 40u}, // bs -> Latn
- {0xA6410000u, 40u}, // bsj -> Latn
+ {0xDE210000u, 17u}, // brx -> Deva
+ {0xE6210000u, 44u}, // brz -> Latn
+ {0x62730000u, 44u}, // bs -> Latn
+ {0xA6410000u, 44u}, // bsj -> Latn
{0xC2410000u, 6u}, // bsq -> Bass
- {0xCA410000u, 40u}, // bss -> Latn
- {0xCE410000u, 18u}, // bst -> Ethi
- {0xBA610000u, 40u}, // bto -> Latn
- {0xCE610000u, 40u}, // btt -> Latn
- {0xD6610000u, 16u}, // btv -> Deva
- {0x82810000u, 15u}, // bua -> Cyrl
- {0x8A810000u, 40u}, // buc -> Latn
- {0x8E810000u, 40u}, // bud -> Latn
- {0x9A810000u, 40u}, // bug -> Latn
- {0xAA810000u, 40u}, // buk -> Latn
- {0xB2810000u, 40u}, // bum -> Latn
- {0xBA810000u, 40u}, // buo -> Latn
- {0xCA810000u, 40u}, // bus -> Latn
- {0xD2810000u, 40u}, // buu -> Latn
- {0x86A10000u, 40u}, // bvb -> Latn
- {0x8EC10000u, 40u}, // bwd -> Latn
- {0xC6C10000u, 40u}, // bwr -> Latn
- {0x9EE10000u, 40u}, // bxh -> Latn
- {0x93010000u, 40u}, // bye -> Latn
- {0xB7010000u, 18u}, // byn -> Ethi
- {0xC7010000u, 40u}, // byr -> Latn
- {0xCB010000u, 40u}, // bys -> Latn
- {0xD7010000u, 40u}, // byv -> Latn
- {0xDF010000u, 40u}, // byx -> Latn
- {0x83210000u, 40u}, // bza -> Latn
- {0x93210000u, 40u}, // bze -> Latn
- {0x97210000u, 40u}, // bzf -> Latn
- {0x9F210000u, 40u}, // bzh -> Latn
- {0xDB210000u, 40u}, // bzw -> Latn
- {0x63610000u, 40u}, // ca -> Latn
- {0xB4020000u, 40u}, // can -> Latn
- {0xA4220000u, 40u}, // cbj -> Latn
- {0x9C420000u, 40u}, // cch -> Latn
- {0xBC420000u, 7u}, // ccp -> Beng
- {0x63650000u, 15u}, // ce -> Cyrl
- {0x84820000u, 40u}, // ceb -> Latn
- {0x80A20000u, 40u}, // cfa -> Latn
- {0x98C20000u, 40u}, // cgg -> Latn
- {0x63680000u, 40u}, // ch -> Latn
- {0xA8E20000u, 40u}, // chk -> Latn
- {0xB0E20000u, 15u}, // chm -> Cyrl
- {0xB8E20000u, 40u}, // cho -> Latn
- {0xBCE20000u, 40u}, // chp -> Latn
- {0xC4E20000u, 12u}, // chr -> Cher
+ {0xCA410000u, 44u}, // bss -> Latn
+ {0xCE410000u, 19u}, // bst -> Ethi
+ {0xBA610000u, 44u}, // bto -> Latn
+ {0xCE610000u, 44u}, // btt -> Latn
+ {0xD6610000u, 17u}, // btv -> Deva
+ {0x82810000u, 16u}, // bua -> Cyrl
+ {0x8A810000u, 44u}, // buc -> Latn
+ {0x8E810000u, 44u}, // bud -> Latn
+ {0x9A810000u, 44u}, // bug -> Latn
+ {0xAA810000u, 44u}, // buk -> Latn
+ {0xB2810000u, 44u}, // bum -> Latn
+ {0xBA810000u, 44u}, // buo -> Latn
+ {0xCA810000u, 44u}, // bus -> Latn
+ {0xD2810000u, 44u}, // buu -> Latn
+ {0x86A10000u, 44u}, // bvb -> Latn
+ {0x8EC10000u, 44u}, // bwd -> Latn
+ {0xC6C10000u, 44u}, // bwr -> Latn
+ {0x9EE10000u, 44u}, // bxh -> Latn
+ {0x93010000u, 44u}, // bye -> Latn
+ {0xB7010000u, 19u}, // byn -> Ethi
+ {0xC7010000u, 44u}, // byr -> Latn
+ {0xCB010000u, 44u}, // bys -> Latn
+ {0xD7010000u, 44u}, // byv -> Latn
+ {0xDF010000u, 44u}, // byx -> Latn
+ {0x83210000u, 44u}, // bza -> Latn
+ {0x93210000u, 44u}, // bze -> Latn
+ {0x97210000u, 44u}, // bzf -> Latn
+ {0x9F210000u, 44u}, // bzh -> Latn
+ {0xDB210000u, 44u}, // bzw -> Latn
+ {0x63610000u, 44u}, // ca -> Latn
+ {0xB4020000u, 44u}, // can -> Latn
+ {0xA4220000u, 44u}, // cbj -> Latn
+ {0x9C420000u, 44u}, // cch -> Latn
+ {0xBC420000u, 9u}, // ccp -> Cakm
+ {0x63650000u, 16u}, // ce -> Cyrl
+ {0x84820000u, 44u}, // ceb -> Latn
+ {0x80A20000u, 44u}, // cfa -> Latn
+ {0x98C20000u, 44u}, // cgg -> Latn
+ {0x63680000u, 44u}, // ch -> Latn
+ {0xA8E20000u, 44u}, // chk -> Latn
+ {0xB0E20000u, 16u}, // chm -> Cyrl
+ {0xB8E20000u, 44u}, // cho -> Latn
+ {0xBCE20000u, 44u}, // chp -> Latn
+ {0xC4E20000u, 13u}, // chr -> Cher
{0x81220000u, 1u}, // cja -> Arab
- {0xB1220000u, 11u}, // cjm -> Cham
- {0xD5220000u, 40u}, // cjv -> Latn
+ {0xB1220000u, 12u}, // cjm -> Cham
+ {0xD5220000u, 44u}, // cjv -> Latn
{0x85420000u, 1u}, // ckb -> Arab
- {0xAD420000u, 40u}, // ckl -> Latn
- {0xB9420000u, 40u}, // cko -> Latn
- {0xE1420000u, 40u}, // cky -> Latn
- {0x81620000u, 40u}, // cla -> Latn
- {0x91820000u, 40u}, // cme -> Latn
- {0x636F0000u, 40u}, // co -> Latn
- {0xBDC20000u, 13u}, // cop -> Copt
- {0xC9E20000u, 40u}, // cps -> Latn
- {0x63720000u, 9u}, // cr -> Cans
- {0xA6220000u, 9u}, // crj -> Cans
- {0xAA220000u, 9u}, // crk -> Cans
- {0xAE220000u, 9u}, // crl -> Cans
- {0xB2220000u, 9u}, // crm -> Cans
- {0xCA220000u, 40u}, // crs -> Latn
- {0x63730000u, 40u}, // cs -> Latn
- {0x86420000u, 40u}, // csb -> Latn
- {0xDA420000u, 9u}, // csw -> Cans
- {0x8E620000u, 59u}, // ctd -> Pauc
- {0x63750000u, 15u}, // cu -> Cyrl
- {0x63760000u, 15u}, // cv -> Cyrl
- {0x63790000u, 40u}, // cy -> Latn
- {0x64610000u, 40u}, // da -> Latn
- {0x8C030000u, 40u}, // dad -> Latn
- {0x94030000u, 40u}, // daf -> Latn
- {0x98030000u, 40u}, // dag -> Latn
- {0x9C030000u, 40u}, // dah -> Latn
- {0xA8030000u, 40u}, // dak -> Latn
- {0xC4030000u, 15u}, // dar -> Cyrl
- {0xD4030000u, 40u}, // dav -> Latn
- {0x8C230000u, 40u}, // dbd -> Latn
- {0xC0230000u, 40u}, // dbq -> Latn
+ {0xAD420000u, 44u}, // ckl -> Latn
+ {0xB9420000u, 44u}, // cko -> Latn
+ {0xE1420000u, 44u}, // cky -> Latn
+ {0x81620000u, 44u}, // cla -> Latn
+ {0x91820000u, 44u}, // cme -> Latn
+ {0x99820000u, 77u}, // cmg -> Soyo
+ {0x636F0000u, 44u}, // co -> Latn
+ {0xBDC20000u, 14u}, // cop -> Copt
+ {0xC9E20000u, 44u}, // cps -> Latn
+ {0x63720000u, 10u}, // cr -> Cans
+ {0x9E220000u, 16u}, // crh -> Cyrl
+ {0xA6220000u, 10u}, // crj -> Cans
+ {0xAA220000u, 10u}, // crk -> Cans
+ {0xAE220000u, 10u}, // crl -> Cans
+ {0xB2220000u, 10u}, // crm -> Cans
+ {0xCA220000u, 44u}, // crs -> Latn
+ {0x63730000u, 44u}, // cs -> Latn
+ {0x86420000u, 44u}, // csb -> Latn
+ {0xDA420000u, 10u}, // csw -> Cans
+ {0x8E620000u, 64u}, // ctd -> Pauc
+ {0x63750000u, 16u}, // cu -> Cyrl
+ {0x63760000u, 16u}, // cv -> Cyrl
+ {0x63790000u, 44u}, // cy -> Latn
+ {0x64610000u, 44u}, // da -> Latn
+ {0x8C030000u, 44u}, // dad -> Latn
+ {0x94030000u, 44u}, // daf -> Latn
+ {0x98030000u, 44u}, // dag -> Latn
+ {0x9C030000u, 44u}, // dah -> Latn
+ {0xA8030000u, 44u}, // dak -> Latn
+ {0xC4030000u, 16u}, // dar -> Cyrl
+ {0xD4030000u, 44u}, // dav -> Latn
+ {0x8C230000u, 44u}, // dbd -> Latn
+ {0xC0230000u, 44u}, // dbq -> Latn
{0x88430000u, 1u}, // dcc -> Arab
- {0xB4630000u, 40u}, // ddn -> Latn
- {0x64650000u, 40u}, // de -> Latn
- {0x8C830000u, 40u}, // ded -> Latn
- {0xB4830000u, 40u}, // den -> Latn
- {0x80C30000u, 40u}, // dga -> Latn
- {0x9CC30000u, 40u}, // dgh -> Latn
- {0xA0C30000u, 40u}, // dgi -> Latn
+ {0xB4630000u, 44u}, // ddn -> Latn
+ {0x64650000u, 44u}, // de -> Latn
+ {0x8C830000u, 44u}, // ded -> Latn
+ {0xB4830000u, 44u}, // den -> Latn
+ {0x80C30000u, 44u}, // dga -> Latn
+ {0x9CC30000u, 44u}, // dgh -> Latn
+ {0xA0C30000u, 44u}, // dgi -> Latn
{0xACC30000u, 1u}, // dgl -> Arab
- {0xC4C30000u, 40u}, // dgr -> Latn
- {0xE4C30000u, 40u}, // dgz -> Latn
- {0x81030000u, 40u}, // dia -> Latn
- {0x91230000u, 40u}, // dje -> Latn
- {0xA5A30000u, 40u}, // dnj -> Latn
- {0x85C30000u, 40u}, // dob -> Latn
+ {0xC4C30000u, 44u}, // dgr -> Latn
+ {0xE4C30000u, 44u}, // dgz -> Latn
+ {0x81030000u, 44u}, // dia -> Latn
+ {0x91230000u, 44u}, // dje -> Latn
+ {0xA5A30000u, 44u}, // dnj -> Latn
+ {0x85C30000u, 44u}, // dob -> Latn
{0xA1C30000u, 1u}, // doi -> Arab
- {0xBDC30000u, 40u}, // dop -> Latn
- {0xD9C30000u, 40u}, // dow -> Latn
- {0xA2230000u, 40u}, // dri -> Latn
- {0xCA230000u, 18u}, // drs -> Ethi
- {0x86430000u, 40u}, // dsb -> Latn
- {0xB2630000u, 40u}, // dtm -> Latn
- {0xBE630000u, 40u}, // dtp -> Latn
- {0xCA630000u, 40u}, // dts -> Latn
- {0xE2630000u, 16u}, // dty -> Deva
- {0x82830000u, 40u}, // dua -> Latn
- {0x8A830000u, 40u}, // duc -> Latn
- {0x8E830000u, 40u}, // dud -> Latn
- {0x9A830000u, 40u}, // dug -> Latn
- {0x64760000u, 79u}, // dv -> Thaa
- {0x82A30000u, 40u}, // dva -> Latn
- {0xDAC30000u, 40u}, // dww -> Latn
- {0xBB030000u, 40u}, // dyo -> Latn
- {0xD3030000u, 40u}, // dyu -> Latn
- {0x647A0000u, 81u}, // dz -> Tibt
- {0x9B230000u, 40u}, // dzg -> Latn
- {0xD0240000u, 40u}, // ebu -> Latn
- {0x65650000u, 40u}, // ee -> Latn
- {0xA0A40000u, 40u}, // efi -> Latn
- {0xACC40000u, 40u}, // egl -> Latn
- {0xE0C40000u, 17u}, // egy -> Egyp
- {0xE1440000u, 32u}, // eky -> Kali
- {0x656C0000u, 21u}, // el -> Grek
- {0x81840000u, 40u}, // ema -> Latn
- {0xA1840000u, 40u}, // emi -> Latn
- {0x656E0000u, 40u}, // en -> Latn
- {0x656E5841u, 87u}, // en-XA -> ~~~A
- {0xB5A40000u, 40u}, // enn -> Latn
- {0xC1A40000u, 40u}, // enq -> Latn
- {0x656F0000u, 40u}, // eo -> Latn
- {0xA2240000u, 40u}, // eri -> Latn
- {0x65730000u, 40u}, // es -> Latn
- {0xD2440000u, 40u}, // esu -> Latn
- {0x65740000u, 40u}, // et -> Latn
- {0xC6640000u, 40u}, // etr -> Latn
- {0xCE640000u, 30u}, // ett -> Ital
- {0xD2640000u, 40u}, // etu -> Latn
- {0xDE640000u, 40u}, // etx -> Latn
- {0x65750000u, 40u}, // eu -> Latn
- {0xBAC40000u, 40u}, // ewo -> Latn
- {0xCEE40000u, 40u}, // ext -> Latn
+ {0xBDC30000u, 44u}, // dop -> Latn
+ {0xD9C30000u, 44u}, // dow -> Latn
+ {0xA2230000u, 44u}, // dri -> Latn
+ {0xCA230000u, 19u}, // drs -> Ethi
+ {0x86430000u, 44u}, // dsb -> Latn
+ {0xB2630000u, 44u}, // dtm -> Latn
+ {0xBE630000u, 44u}, // dtp -> Latn
+ {0xCA630000u, 44u}, // dts -> Latn
+ {0xE2630000u, 17u}, // dty -> Deva
+ {0x82830000u, 44u}, // dua -> Latn
+ {0x8A830000u, 44u}, // duc -> Latn
+ {0x8E830000u, 44u}, // dud -> Latn
+ {0x9A830000u, 44u}, // dug -> Latn
+ {0x64760000u, 86u}, // dv -> Thaa
+ {0x82A30000u, 44u}, // dva -> Latn
+ {0xDAC30000u, 44u}, // dww -> Latn
+ {0xBB030000u, 44u}, // dyo -> Latn
+ {0xD3030000u, 44u}, // dyu -> Latn
+ {0x647A0000u, 88u}, // dz -> Tibt
+ {0x9B230000u, 44u}, // dzg -> Latn
+ {0xD0240000u, 44u}, // ebu -> Latn
+ {0x65650000u, 44u}, // ee -> Latn
+ {0xA0A40000u, 44u}, // efi -> Latn
+ {0xACC40000u, 44u}, // egl -> Latn
+ {0xE0C40000u, 18u}, // egy -> Egyp
+ {0x81440000u, 44u}, // eka -> Latn
+ {0xE1440000u, 36u}, // eky -> Kali
+ {0x656C0000u, 24u}, // el -> Grek
+ {0x81840000u, 44u}, // ema -> Latn
+ {0xA1840000u, 44u}, // emi -> Latn
+ {0x656E0000u, 44u}, // en -> Latn
+ {0x656E5841u, 95u}, // en-XA -> ~~~A
+ {0xB5A40000u, 44u}, // enn -> Latn
+ {0xC1A40000u, 44u}, // enq -> Latn
+ {0x656F0000u, 44u}, // eo -> Latn
+ {0xA2240000u, 44u}, // eri -> Latn
+ {0x65730000u, 44u}, // es -> Latn
+ {0x9A440000u, 22u}, // esg -> Gonm
+ {0xD2440000u, 44u}, // esu -> Latn
+ {0x65740000u, 44u}, // et -> Latn
+ {0xC6640000u, 44u}, // etr -> Latn
+ {0xCE640000u, 34u}, // ett -> Ital
+ {0xD2640000u, 44u}, // etu -> Latn
+ {0xDE640000u, 44u}, // etx -> Latn
+ {0x65750000u, 44u}, // eu -> Latn
+ {0xBAC40000u, 44u}, // ewo -> Latn
+ {0xCEE40000u, 44u}, // ext -> Latn
{0x66610000u, 1u}, // fa -> Arab
- {0x80050000u, 40u}, // faa -> Latn
- {0x84050000u, 40u}, // fab -> Latn
- {0x98050000u, 40u}, // fag -> Latn
- {0xA0050000u, 40u}, // fai -> Latn
- {0xB4050000u, 40u}, // fan -> Latn
- {0x66660000u, 40u}, // ff -> Latn
- {0xA0A50000u, 40u}, // ffi -> Latn
- {0xB0A50000u, 40u}, // ffm -> Latn
- {0x66690000u, 40u}, // fi -> Latn
+ {0x80050000u, 44u}, // faa -> Latn
+ {0x84050000u, 44u}, // fab -> Latn
+ {0x98050000u, 44u}, // fag -> Latn
+ {0xA0050000u, 44u}, // fai -> Latn
+ {0xB4050000u, 44u}, // fan -> Latn
+ {0x66660000u, 44u}, // ff -> Latn
+ {0xA0A50000u, 44u}, // ffi -> Latn
+ {0xB0A50000u, 44u}, // ffm -> Latn
+ {0x66690000u, 44u}, // fi -> Latn
{0x81050000u, 1u}, // fia -> Arab
- {0xAD050000u, 40u}, // fil -> Latn
- {0xCD050000u, 40u}, // fit -> Latn
- {0x666A0000u, 40u}, // fj -> Latn
- {0xC5650000u, 40u}, // flr -> Latn
- {0xBD850000u, 40u}, // fmp -> Latn
- {0x666F0000u, 40u}, // fo -> Latn
- {0x8DC50000u, 40u}, // fod -> Latn
- {0xB5C50000u, 40u}, // fon -> Latn
- {0xC5C50000u, 40u}, // for -> Latn
- {0x91E50000u, 40u}, // fpe -> Latn
- {0xCA050000u, 40u}, // fqs -> Latn
- {0x66720000u, 40u}, // fr -> Latn
- {0x8A250000u, 40u}, // frc -> Latn
- {0xBE250000u, 40u}, // frp -> Latn
- {0xC6250000u, 40u}, // frr -> Latn
- {0xCA250000u, 40u}, // frs -> Latn
+ {0xAD050000u, 44u}, // fil -> Latn
+ {0xCD050000u, 44u}, // fit -> Latn
+ {0x666A0000u, 44u}, // fj -> Latn
+ {0xC5650000u, 44u}, // flr -> Latn
+ {0xBD850000u, 44u}, // fmp -> Latn
+ {0x666F0000u, 44u}, // fo -> Latn
+ {0x8DC50000u, 44u}, // fod -> Latn
+ {0xB5C50000u, 44u}, // fon -> Latn
+ {0xC5C50000u, 44u}, // for -> Latn
+ {0x91E50000u, 44u}, // fpe -> Latn
+ {0xCA050000u, 44u}, // fqs -> Latn
+ {0x66720000u, 44u}, // fr -> Latn
+ {0x8A250000u, 44u}, // frc -> Latn
+ {0xBE250000u, 44u}, // frp -> Latn
+ {0xC6250000u, 44u}, // frr -> Latn
+ {0xCA250000u, 44u}, // frs -> Latn
{0x86850000u, 1u}, // fub -> Arab
- {0x8E850000u, 40u}, // fud -> Latn
- {0x92850000u, 40u}, // fue -> Latn
- {0x96850000u, 40u}, // fuf -> Latn
- {0x9E850000u, 40u}, // fuh -> Latn
- {0xC2850000u, 40u}, // fuq -> Latn
- {0xC6850000u, 40u}, // fur -> Latn
- {0xD6850000u, 40u}, // fuv -> Latn
- {0xE2850000u, 40u}, // fuy -> Latn
- {0xC6A50000u, 40u}, // fvr -> Latn
- {0x66790000u, 40u}, // fy -> Latn
- {0x67610000u, 40u}, // ga -> Latn
- {0x80060000u, 40u}, // gaa -> Latn
- {0x94060000u, 40u}, // gaf -> Latn
- {0x98060000u, 40u}, // gag -> Latn
- {0x9C060000u, 40u}, // gah -> Latn
- {0xA4060000u, 40u}, // gaj -> Latn
- {0xB0060000u, 40u}, // gam -> Latn
- {0xB4060000u, 24u}, // gan -> Hans
- {0xD8060000u, 40u}, // gaw -> Latn
- {0xE0060000u, 40u}, // gay -> Latn
- {0x94260000u, 40u}, // gbf -> Latn
- {0xB0260000u, 16u}, // gbm -> Deva
- {0xE0260000u, 40u}, // gby -> Latn
+ {0x8E850000u, 44u}, // fud -> Latn
+ {0x92850000u, 44u}, // fue -> Latn
+ {0x96850000u, 44u}, // fuf -> Latn
+ {0x9E850000u, 44u}, // fuh -> Latn
+ {0xC2850000u, 44u}, // fuq -> Latn
+ {0xC6850000u, 44u}, // fur -> Latn
+ {0xD6850000u, 44u}, // fuv -> Latn
+ {0xE2850000u, 44u}, // fuy -> Latn
+ {0xC6A50000u, 44u}, // fvr -> Latn
+ {0x66790000u, 44u}, // fy -> Latn
+ {0x67610000u, 44u}, // ga -> Latn
+ {0x80060000u, 44u}, // gaa -> Latn
+ {0x94060000u, 44u}, // gaf -> Latn
+ {0x98060000u, 44u}, // gag -> Latn
+ {0x9C060000u, 44u}, // gah -> Latn
+ {0xA4060000u, 44u}, // gaj -> Latn
+ {0xB0060000u, 44u}, // gam -> Latn
+ {0xB4060000u, 27u}, // gan -> Hans
+ {0xD8060000u, 44u}, // gaw -> Latn
+ {0xE0060000u, 44u}, // gay -> Latn
+ {0x80260000u, 44u}, // gba -> Latn
+ {0x94260000u, 44u}, // gbf -> Latn
+ {0xB0260000u, 17u}, // gbm -> Deva
+ {0xE0260000u, 44u}, // gby -> Latn
{0xE4260000u, 1u}, // gbz -> Arab
- {0xC4460000u, 40u}, // gcr -> Latn
- {0x67640000u, 40u}, // gd -> Latn
- {0x90660000u, 40u}, // gde -> Latn
- {0xB4660000u, 40u}, // gdn -> Latn
- {0xC4660000u, 40u}, // gdr -> Latn
- {0x84860000u, 40u}, // geb -> Latn
- {0xA4860000u, 40u}, // gej -> Latn
- {0xAC860000u, 40u}, // gel -> Latn
- {0xE4860000u, 18u}, // gez -> Ethi
- {0xA8A60000u, 40u}, // gfk -> Latn
- {0xB4C60000u, 16u}, // ggn -> Deva
- {0xC8E60000u, 40u}, // ghs -> Latn
- {0xAD060000u, 40u}, // gil -> Latn
- {0xB1060000u, 40u}, // gim -> Latn
+ {0xC4460000u, 44u}, // gcr -> Latn
+ {0x67640000u, 44u}, // gd -> Latn
+ {0x90660000u, 44u}, // gde -> Latn
+ {0xB4660000u, 44u}, // gdn -> Latn
+ {0xC4660000u, 44u}, // gdr -> Latn
+ {0x84860000u, 44u}, // geb -> Latn
+ {0xA4860000u, 44u}, // gej -> Latn
+ {0xAC860000u, 44u}, // gel -> Latn
+ {0xE4860000u, 19u}, // gez -> Ethi
+ {0xA8A60000u, 44u}, // gfk -> Latn
+ {0xB4C60000u, 17u}, // ggn -> Deva
+ {0xC8E60000u, 44u}, // ghs -> Latn
+ {0xAD060000u, 44u}, // gil -> Latn
+ {0xB1060000u, 44u}, // gim -> Latn
{0xA9260000u, 1u}, // gjk -> Arab
- {0xB5260000u, 40u}, // gjn -> Latn
+ {0xB5260000u, 44u}, // gjn -> Latn
{0xD1260000u, 1u}, // gju -> Arab
- {0xB5460000u, 40u}, // gkn -> Latn
- {0xBD460000u, 40u}, // gkp -> Latn
- {0x676C0000u, 40u}, // gl -> Latn
+ {0xB5460000u, 44u}, // gkn -> Latn
+ {0xBD460000u, 44u}, // gkp -> Latn
+ {0x676C0000u, 44u}, // gl -> Latn
{0xA9660000u, 1u}, // glk -> Arab
- {0xB1860000u, 40u}, // gmm -> Latn
- {0xD5860000u, 18u}, // gmv -> Ethi
- {0x676E0000u, 40u}, // gn -> Latn
- {0x8DA60000u, 40u}, // gnd -> Latn
- {0x99A60000u, 40u}, // gng -> Latn
- {0x8DC60000u, 40u}, // god -> Latn
- {0x95C60000u, 18u}, // gof -> Ethi
- {0xA1C60000u, 40u}, // goi -> Latn
- {0xB1C60000u, 16u}, // gom -> Deva
- {0xB5C60000u, 77u}, // gon -> Telu
- {0xC5C60000u, 40u}, // gor -> Latn
- {0xC9C60000u, 40u}, // gos -> Latn
- {0xCDC60000u, 20u}, // got -> Goth
- {0x8A260000u, 14u}, // grc -> Cprt
+ {0xB1860000u, 44u}, // gmm -> Latn
+ {0xD5860000u, 19u}, // gmv -> Ethi
+ {0x676E0000u, 44u}, // gn -> Latn
+ {0x8DA60000u, 44u}, // gnd -> Latn
+ {0x99A60000u, 44u}, // gng -> Latn
+ {0x8DC60000u, 44u}, // god -> Latn
+ {0x95C60000u, 19u}, // gof -> Ethi
+ {0xA1C60000u, 44u}, // goi -> Latn
+ {0xB1C60000u, 17u}, // gom -> Deva
+ {0xB5C60000u, 84u}, // gon -> Telu
+ {0xC5C60000u, 44u}, // gor -> Latn
+ {0xC9C60000u, 44u}, // gos -> Latn
+ {0xCDC60000u, 23u}, // got -> Goth
+ {0x86260000u, 44u}, // grb -> Latn
+ {0x8A260000u, 15u}, // grc -> Cprt
{0xCE260000u, 7u}, // grt -> Beng
- {0xDA260000u, 40u}, // grw -> Latn
- {0xDA460000u, 40u}, // gsw -> Latn
- {0x67750000u, 22u}, // gu -> Gujr
- {0x86860000u, 40u}, // gub -> Latn
- {0x8A860000u, 40u}, // guc -> Latn
- {0x8E860000u, 40u}, // gud -> Latn
- {0xC6860000u, 40u}, // gur -> Latn
- {0xDA860000u, 40u}, // guw -> Latn
- {0xDE860000u, 40u}, // gux -> Latn
- {0xE6860000u, 40u}, // guz -> Latn
- {0x67760000u, 40u}, // gv -> Latn
- {0x96A60000u, 40u}, // gvf -> Latn
- {0xC6A60000u, 16u}, // gvr -> Deva
- {0xCAA60000u, 40u}, // gvs -> Latn
+ {0xDA260000u, 44u}, // grw -> Latn
+ {0xDA460000u, 44u}, // gsw -> Latn
+ {0x67750000u, 25u}, // gu -> Gujr
+ {0x86860000u, 44u}, // gub -> Latn
+ {0x8A860000u, 44u}, // guc -> Latn
+ {0x8E860000u, 44u}, // gud -> Latn
+ {0xC6860000u, 44u}, // gur -> Latn
+ {0xDA860000u, 44u}, // guw -> Latn
+ {0xDE860000u, 44u}, // gux -> Latn
+ {0xE6860000u, 44u}, // guz -> Latn
+ {0x67760000u, 44u}, // gv -> Latn
+ {0x96A60000u, 44u}, // gvf -> Latn
+ {0xC6A60000u, 17u}, // gvr -> Deva
+ {0xCAA60000u, 44u}, // gvs -> Latn
{0x8AC60000u, 1u}, // gwc -> Arab
- {0xA2C60000u, 40u}, // gwi -> Latn
+ {0xA2C60000u, 44u}, // gwi -> Latn
{0xCEC60000u, 1u}, // gwt -> Arab
- {0xA3060000u, 40u}, // gyi -> Latn
- {0x68610000u, 40u}, // ha -> Latn
+ {0xA3060000u, 44u}, // gyi -> Latn
+ {0x68610000u, 44u}, // ha -> Latn
{0x6861434Du, 1u}, // ha-CM -> Arab
{0x68615344u, 1u}, // ha-SD -> Arab
- {0x98070000u, 40u}, // hag -> Latn
- {0xA8070000u, 24u}, // hak -> Hans
- {0xB0070000u, 40u}, // ham -> Latn
- {0xD8070000u, 40u}, // haw -> Latn
+ {0x98070000u, 44u}, // hag -> Latn
+ {0xA8070000u, 27u}, // hak -> Hans
+ {0xB0070000u, 44u}, // ham -> Latn
+ {0xD8070000u, 44u}, // haw -> Latn
{0xE4070000u, 1u}, // haz -> Arab
- {0x84270000u, 40u}, // hbb -> Latn
- {0xE0670000u, 18u}, // hdy -> Ethi
- {0x68650000u, 27u}, // he -> Hebr
- {0xE0E70000u, 40u}, // hhy -> Latn
- {0x68690000u, 16u}, // hi -> Deva
- {0x81070000u, 40u}, // hia -> Latn
- {0x95070000u, 40u}, // hif -> Latn
- {0x99070000u, 40u}, // hig -> Latn
- {0x9D070000u, 40u}, // hih -> Latn
- {0xAD070000u, 40u}, // hil -> Latn
- {0x81670000u, 40u}, // hla -> Latn
- {0xD1670000u, 28u}, // hlu -> Hluw
- {0x8D870000u, 62u}, // hmd -> Plrd
- {0xCD870000u, 40u}, // hmt -> Latn
+ {0x84270000u, 44u}, // hbb -> Latn
+ {0xE0670000u, 19u}, // hdy -> Ethi
+ {0x68650000u, 30u}, // he -> Hebr
+ {0xE0E70000u, 44u}, // hhy -> Latn
+ {0x68690000u, 17u}, // hi -> Deva
+ {0x81070000u, 44u}, // hia -> Latn
+ {0x95070000u, 44u}, // hif -> Latn
+ {0x99070000u, 44u}, // hig -> Latn
+ {0x9D070000u, 44u}, // hih -> Latn
+ {0xAD070000u, 44u}, // hil -> Latn
+ {0x81670000u, 44u}, // hla -> Latn
+ {0xD1670000u, 31u}, // hlu -> Hluw
+ {0x8D870000u, 67u}, // hmd -> Plrd
+ {0xCD870000u, 44u}, // hmt -> Latn
{0x8DA70000u, 1u}, // hnd -> Arab
- {0x91A70000u, 16u}, // hne -> Deva
- {0xA5A70000u, 29u}, // hnj -> Hmng
- {0xB5A70000u, 40u}, // hnn -> Latn
+ {0x91A70000u, 17u}, // hne -> Deva
+ {0xA5A70000u, 32u}, // hnj -> Hmng
+ {0xB5A70000u, 44u}, // hnn -> Latn
{0xB9A70000u, 1u}, // hno -> Arab
- {0x686F0000u, 40u}, // ho -> Latn
- {0x89C70000u, 16u}, // hoc -> Deva
- {0xA5C70000u, 16u}, // hoj -> Deva
- {0xCDC70000u, 40u}, // hot -> Latn
- {0x68720000u, 40u}, // hr -> Latn
- {0x86470000u, 40u}, // hsb -> Latn
- {0xB6470000u, 24u}, // hsn -> Hans
- {0x68740000u, 40u}, // ht -> Latn
- {0x68750000u, 40u}, // hu -> Latn
- {0xA2870000u, 40u}, // hui -> Latn
+ {0x686F0000u, 44u}, // ho -> Latn
+ {0x89C70000u, 17u}, // hoc -> Deva
+ {0xA5C70000u, 17u}, // hoj -> Deva
+ {0xCDC70000u, 44u}, // hot -> Latn
+ {0x68720000u, 44u}, // hr -> Latn
+ {0x86470000u, 44u}, // hsb -> Latn
+ {0xB6470000u, 27u}, // hsn -> Hans
+ {0x68740000u, 44u}, // ht -> Latn
+ {0x68750000u, 44u}, // hu -> Latn
+ {0xA2870000u, 44u}, // hui -> Latn
{0x68790000u, 3u}, // hy -> Armn
- {0x687A0000u, 40u}, // hz -> Latn
- {0x69610000u, 40u}, // ia -> Latn
- {0xB4080000u, 40u}, // ian -> Latn
- {0xC4080000u, 40u}, // iar -> Latn
- {0x80280000u, 40u}, // iba -> Latn
- {0x84280000u, 40u}, // ibb -> Latn
- {0xE0280000u, 40u}, // iby -> Latn
- {0x80480000u, 40u}, // ica -> Latn
- {0x9C480000u, 40u}, // ich -> Latn
- {0x69640000u, 40u}, // id -> Latn
- {0x8C680000u, 40u}, // idd -> Latn
- {0xA0680000u, 40u}, // idi -> Latn
- {0xD0680000u, 40u}, // idu -> Latn
- {0x69670000u, 40u}, // ig -> Latn
- {0x84C80000u, 40u}, // igb -> Latn
- {0x90C80000u, 40u}, // ige -> Latn
- {0x69690000u, 86u}, // ii -> Yiii
- {0xA5280000u, 40u}, // ijj -> Latn
- {0x696B0000u, 40u}, // ik -> Latn
- {0xA9480000u, 40u}, // ikk -> Latn
- {0xCD480000u, 40u}, // ikt -> Latn
- {0xD9480000u, 40u}, // ikw -> Latn
- {0xDD480000u, 40u}, // ikx -> Latn
- {0xB9680000u, 40u}, // ilo -> Latn
- {0xB9880000u, 40u}, // imo -> Latn
- {0x696E0000u, 40u}, // in -> Latn
- {0x9DA80000u, 15u}, // inh -> Cyrl
- {0xD1C80000u, 40u}, // iou -> Latn
- {0xA2280000u, 40u}, // iri -> Latn
- {0x69730000u, 40u}, // is -> Latn
- {0x69740000u, 40u}, // it -> Latn
- {0x69750000u, 9u}, // iu -> Cans
- {0x69770000u, 27u}, // iw -> Hebr
- {0xB2C80000u, 40u}, // iwm -> Latn
- {0xCAC80000u, 40u}, // iws -> Latn
- {0x9F280000u, 40u}, // izh -> Latn
- {0xA3280000u, 40u}, // izi -> Latn
- {0x6A610000u, 31u}, // ja -> Jpan
- {0x84090000u, 40u}, // jab -> Latn
- {0xB0090000u, 40u}, // jam -> Latn
- {0xD0290000u, 40u}, // jbu -> Latn
- {0xB4890000u, 40u}, // jen -> Latn
- {0xA8C90000u, 40u}, // jgk -> Latn
- {0xB8C90000u, 40u}, // jgo -> Latn
- {0x6A690000u, 27u}, // ji -> Hebr
- {0x85090000u, 40u}, // jib -> Latn
- {0x89890000u, 40u}, // jmc -> Latn
- {0xAD890000u, 16u}, // jml -> Deva
- {0x82290000u, 40u}, // jra -> Latn
- {0xCE890000u, 40u}, // jut -> Latn
- {0x6A760000u, 40u}, // jv -> Latn
- {0x6A770000u, 40u}, // jw -> Latn
- {0x6B610000u, 19u}, // ka -> Geor
- {0x800A0000u, 15u}, // kaa -> Cyrl
- {0x840A0000u, 40u}, // kab -> Latn
- {0x880A0000u, 40u}, // kac -> Latn
- {0x8C0A0000u, 40u}, // kad -> Latn
- {0xA00A0000u, 40u}, // kai -> Latn
- {0xA40A0000u, 40u}, // kaj -> Latn
- {0xB00A0000u, 40u}, // kam -> Latn
- {0xB80A0000u, 40u}, // kao -> Latn
- {0x8C2A0000u, 15u}, // kbd -> Cyrl
- {0xB02A0000u, 40u}, // kbm -> Latn
- {0xBC2A0000u, 40u}, // kbp -> Latn
- {0xC02A0000u, 40u}, // kbq -> Latn
- {0xDC2A0000u, 40u}, // kbx -> Latn
+ {0x687A0000u, 44u}, // hz -> Latn
+ {0x69610000u, 44u}, // ia -> Latn
+ {0xB4080000u, 44u}, // ian -> Latn
+ {0xC4080000u, 44u}, // iar -> Latn
+ {0x80280000u, 44u}, // iba -> Latn
+ {0x84280000u, 44u}, // ibb -> Latn
+ {0xE0280000u, 44u}, // iby -> Latn
+ {0x80480000u, 44u}, // ica -> Latn
+ {0x9C480000u, 44u}, // ich -> Latn
+ {0x69640000u, 44u}, // id -> Latn
+ {0x8C680000u, 44u}, // idd -> Latn
+ {0xA0680000u, 44u}, // idi -> Latn
+ {0xD0680000u, 44u}, // idu -> Latn
+ {0x90A80000u, 44u}, // ife -> Latn
+ {0x69670000u, 44u}, // ig -> Latn
+ {0x84C80000u, 44u}, // igb -> Latn
+ {0x90C80000u, 44u}, // ige -> Latn
+ {0x69690000u, 94u}, // ii -> Yiii
+ {0xA5280000u, 44u}, // ijj -> Latn
+ {0x696B0000u, 44u}, // ik -> Latn
+ {0xA9480000u, 44u}, // ikk -> Latn
+ {0xCD480000u, 44u}, // ikt -> Latn
+ {0xD9480000u, 44u}, // ikw -> Latn
+ {0xDD480000u, 44u}, // ikx -> Latn
+ {0xB9680000u, 44u}, // ilo -> Latn
+ {0xB9880000u, 44u}, // imo -> Latn
+ {0x696E0000u, 44u}, // in -> Latn
+ {0x9DA80000u, 16u}, // inh -> Cyrl
+ {0x696F0000u, 44u}, // io -> Latn
+ {0xD1C80000u, 44u}, // iou -> Latn
+ {0xA2280000u, 44u}, // iri -> Latn
+ {0x69730000u, 44u}, // is -> Latn
+ {0x69740000u, 44u}, // it -> Latn
+ {0x69750000u, 10u}, // iu -> Cans
+ {0x69770000u, 30u}, // iw -> Hebr
+ {0xB2C80000u, 44u}, // iwm -> Latn
+ {0xCAC80000u, 44u}, // iws -> Latn
+ {0x9F280000u, 44u}, // izh -> Latn
+ {0xA3280000u, 44u}, // izi -> Latn
+ {0x6A610000u, 35u}, // ja -> Jpan
+ {0x84090000u, 44u}, // jab -> Latn
+ {0xB0090000u, 44u}, // jam -> Latn
+ {0xB8290000u, 44u}, // jbo -> Latn
+ {0xD0290000u, 44u}, // jbu -> Latn
+ {0xB4890000u, 44u}, // jen -> Latn
+ {0xA8C90000u, 44u}, // jgk -> Latn
+ {0xB8C90000u, 44u}, // jgo -> Latn
+ {0x6A690000u, 30u}, // ji -> Hebr
+ {0x85090000u, 44u}, // jib -> Latn
+ {0x89890000u, 44u}, // jmc -> Latn
+ {0xAD890000u, 17u}, // jml -> Deva
+ {0x82290000u, 44u}, // jra -> Latn
+ {0xCE890000u, 44u}, // jut -> Latn
+ {0x6A760000u, 44u}, // jv -> Latn
+ {0x6A770000u, 44u}, // jw -> Latn
+ {0x6B610000u, 20u}, // ka -> Geor
+ {0x800A0000u, 16u}, // kaa -> Cyrl
+ {0x840A0000u, 44u}, // kab -> Latn
+ {0x880A0000u, 44u}, // kac -> Latn
+ {0x8C0A0000u, 44u}, // kad -> Latn
+ {0xA00A0000u, 44u}, // kai -> Latn
+ {0xA40A0000u, 44u}, // kaj -> Latn
+ {0xB00A0000u, 44u}, // kam -> Latn
+ {0xB80A0000u, 44u}, // kao -> Latn
+ {0x8C2A0000u, 16u}, // kbd -> Cyrl
+ {0xB02A0000u, 44u}, // kbm -> Latn
+ {0xBC2A0000u, 44u}, // kbp -> Latn
+ {0xC02A0000u, 44u}, // kbq -> Latn
+ {0xDC2A0000u, 44u}, // kbx -> Latn
{0xE02A0000u, 1u}, // kby -> Arab
- {0x984A0000u, 40u}, // kcg -> Latn
- {0xA84A0000u, 40u}, // kck -> Latn
- {0xAC4A0000u, 40u}, // kcl -> Latn
- {0xCC4A0000u, 40u}, // kct -> Latn
- {0x906A0000u, 40u}, // kde -> Latn
+ {0x984A0000u, 44u}, // kcg -> Latn
+ {0xA84A0000u, 44u}, // kck -> Latn
+ {0xAC4A0000u, 44u}, // kcl -> Latn
+ {0xCC4A0000u, 44u}, // kct -> Latn
+ {0x906A0000u, 44u}, // kde -> Latn
{0x9C6A0000u, 1u}, // kdh -> Arab
- {0xAC6A0000u, 40u}, // kdl -> Latn
- {0xCC6A0000u, 80u}, // kdt -> Thai
- {0x808A0000u, 40u}, // kea -> Latn
- {0xB48A0000u, 40u}, // ken -> Latn
- {0xE48A0000u, 40u}, // kez -> Latn
- {0xB8AA0000u, 40u}, // kfo -> Latn
- {0xC4AA0000u, 16u}, // kfr -> Deva
- {0xE0AA0000u, 16u}, // kfy -> Deva
- {0x6B670000u, 40u}, // kg -> Latn
- {0x90CA0000u, 40u}, // kge -> Latn
- {0x94CA0000u, 40u}, // kgf -> Latn
- {0xBCCA0000u, 40u}, // kgp -> Latn
- {0x80EA0000u, 40u}, // kha -> Latn
- {0x84EA0000u, 73u}, // khb -> Talu
- {0xB4EA0000u, 16u}, // khn -> Deva
- {0xC0EA0000u, 40u}, // khq -> Latn
- {0xC8EA0000u, 40u}, // khs -> Latn
- {0xCCEA0000u, 52u}, // kht -> Mymr
+ {0xAC6A0000u, 44u}, // kdl -> Latn
+ {0xCC6A0000u, 87u}, // kdt -> Thai
+ {0x808A0000u, 44u}, // kea -> Latn
+ {0xB48A0000u, 44u}, // ken -> Latn
+ {0xE48A0000u, 44u}, // kez -> Latn
+ {0xB8AA0000u, 44u}, // kfo -> Latn
+ {0xC4AA0000u, 17u}, // kfr -> Deva
+ {0xE0AA0000u, 17u}, // kfy -> Deva
+ {0x6B670000u, 44u}, // kg -> Latn
+ {0x90CA0000u, 44u}, // kge -> Latn
+ {0x94CA0000u, 44u}, // kgf -> Latn
+ {0xBCCA0000u, 44u}, // kgp -> Latn
+ {0x80EA0000u, 44u}, // kha -> Latn
+ {0x84EA0000u, 80u}, // khb -> Talu
+ {0xB4EA0000u, 17u}, // khn -> Deva
+ {0xC0EA0000u, 44u}, // khq -> Latn
+ {0xC8EA0000u, 44u}, // khs -> Latn
+ {0xCCEA0000u, 56u}, // kht -> Mymr
{0xD8EA0000u, 1u}, // khw -> Arab
- {0xE4EA0000u, 40u}, // khz -> Latn
- {0x6B690000u, 40u}, // ki -> Latn
- {0xA50A0000u, 40u}, // kij -> Latn
- {0xD10A0000u, 40u}, // kiu -> Latn
- {0xD90A0000u, 40u}, // kiw -> Latn
- {0x6B6A0000u, 40u}, // kj -> Latn
- {0x8D2A0000u, 40u}, // kjd -> Latn
- {0x992A0000u, 39u}, // kjg -> Laoo
- {0xC92A0000u, 40u}, // kjs -> Latn
- {0xE12A0000u, 40u}, // kjy -> Latn
- {0x6B6B0000u, 15u}, // kk -> Cyrl
+ {0xE4EA0000u, 44u}, // khz -> Latn
+ {0x6B690000u, 44u}, // ki -> Latn
+ {0xA50A0000u, 44u}, // kij -> Latn
+ {0xD10A0000u, 44u}, // kiu -> Latn
+ {0xD90A0000u, 44u}, // kiw -> Latn
+ {0x6B6A0000u, 44u}, // kj -> Latn
+ {0x8D2A0000u, 44u}, // kjd -> Latn
+ {0x992A0000u, 43u}, // kjg -> Laoo
+ {0xC92A0000u, 44u}, // kjs -> Latn
+ {0xE12A0000u, 44u}, // kjy -> Latn
+ {0x6B6B0000u, 16u}, // kk -> Cyrl
{0x6B6B4146u, 1u}, // kk-AF -> Arab
{0x6B6B434Eu, 1u}, // kk-CN -> Arab
{0x6B6B4952u, 1u}, // kk-IR -> Arab
{0x6B6B4D4Eu, 1u}, // kk-MN -> Arab
- {0x894A0000u, 40u}, // kkc -> Latn
- {0xA54A0000u, 40u}, // kkj -> Latn
- {0x6B6C0000u, 40u}, // kl -> Latn
- {0xB56A0000u, 40u}, // kln -> Latn
- {0xC16A0000u, 40u}, // klq -> Latn
- {0xCD6A0000u, 40u}, // klt -> Latn
- {0xDD6A0000u, 40u}, // klx -> Latn
- {0x6B6D0000u, 35u}, // km -> Khmr
- {0x858A0000u, 40u}, // kmb -> Latn
- {0x9D8A0000u, 40u}, // kmh -> Latn
- {0xB98A0000u, 40u}, // kmo -> Latn
- {0xC98A0000u, 40u}, // kms -> Latn
- {0xD18A0000u, 40u}, // kmu -> Latn
- {0xD98A0000u, 40u}, // kmw -> Latn
- {0x6B6E0000u, 36u}, // kn -> Knda
- {0xBDAA0000u, 40u}, // knp -> Latn
- {0x6B6F0000u, 37u}, // ko -> Kore
- {0xA1CA0000u, 15u}, // koi -> Cyrl
- {0xA9CA0000u, 16u}, // kok -> Deva
- {0xADCA0000u, 40u}, // kol -> Latn
- {0xC9CA0000u, 40u}, // kos -> Latn
- {0xE5CA0000u, 40u}, // koz -> Latn
- {0x91EA0000u, 40u}, // kpe -> Latn
- {0x95EA0000u, 40u}, // kpf -> Latn
- {0xB9EA0000u, 40u}, // kpo -> Latn
- {0xC5EA0000u, 40u}, // kpr -> Latn
- {0xDDEA0000u, 40u}, // kpx -> Latn
- {0x860A0000u, 40u}, // kqb -> Latn
- {0x960A0000u, 40u}, // kqf -> Latn
- {0xCA0A0000u, 40u}, // kqs -> Latn
- {0xE20A0000u, 18u}, // kqy -> Ethi
- {0x8A2A0000u, 15u}, // krc -> Cyrl
- {0xA22A0000u, 40u}, // kri -> Latn
- {0xA62A0000u, 40u}, // krj -> Latn
- {0xAE2A0000u, 40u}, // krl -> Latn
- {0xCA2A0000u, 40u}, // krs -> Latn
- {0xD22A0000u, 16u}, // kru -> Deva
+ {0x894A0000u, 44u}, // kkc -> Latn
+ {0xA54A0000u, 44u}, // kkj -> Latn
+ {0x6B6C0000u, 44u}, // kl -> Latn
+ {0xB56A0000u, 44u}, // kln -> Latn
+ {0xC16A0000u, 44u}, // klq -> Latn
+ {0xCD6A0000u, 44u}, // klt -> Latn
+ {0xDD6A0000u, 44u}, // klx -> Latn
+ {0x6B6D0000u, 39u}, // km -> Khmr
+ {0x858A0000u, 44u}, // kmb -> Latn
+ {0x9D8A0000u, 44u}, // kmh -> Latn
+ {0xB98A0000u, 44u}, // kmo -> Latn
+ {0xC98A0000u, 44u}, // kms -> Latn
+ {0xD18A0000u, 44u}, // kmu -> Latn
+ {0xD98A0000u, 44u}, // kmw -> Latn
+ {0x6B6E0000u, 40u}, // kn -> Knda
+ {0x95AA0000u, 44u}, // knf -> Latn
+ {0xBDAA0000u, 44u}, // knp -> Latn
+ {0x6B6F0000u, 41u}, // ko -> Kore
+ {0xA1CA0000u, 16u}, // koi -> Cyrl
+ {0xA9CA0000u, 17u}, // kok -> Deva
+ {0xADCA0000u, 44u}, // kol -> Latn
+ {0xC9CA0000u, 44u}, // kos -> Latn
+ {0xE5CA0000u, 44u}, // koz -> Latn
+ {0x91EA0000u, 44u}, // kpe -> Latn
+ {0x95EA0000u, 44u}, // kpf -> Latn
+ {0xB9EA0000u, 44u}, // kpo -> Latn
+ {0xC5EA0000u, 44u}, // kpr -> Latn
+ {0xDDEA0000u, 44u}, // kpx -> Latn
+ {0x860A0000u, 44u}, // kqb -> Latn
+ {0x960A0000u, 44u}, // kqf -> Latn
+ {0xCA0A0000u, 44u}, // kqs -> Latn
+ {0xE20A0000u, 19u}, // kqy -> Ethi
+ {0x6B720000u, 44u}, // kr -> Latn
+ {0x8A2A0000u, 16u}, // krc -> Cyrl
+ {0xA22A0000u, 44u}, // kri -> Latn
+ {0xA62A0000u, 44u}, // krj -> Latn
+ {0xAE2A0000u, 44u}, // krl -> Latn
+ {0xCA2A0000u, 44u}, // krs -> Latn
+ {0xD22A0000u, 17u}, // kru -> Deva
{0x6B730000u, 1u}, // ks -> Arab
- {0x864A0000u, 40u}, // ksb -> Latn
- {0x8E4A0000u, 40u}, // ksd -> Latn
- {0x964A0000u, 40u}, // ksf -> Latn
- {0x9E4A0000u, 40u}, // ksh -> Latn
- {0xA64A0000u, 40u}, // ksj -> Latn
- {0xC64A0000u, 40u}, // ksr -> Latn
- {0x866A0000u, 18u}, // ktb -> Ethi
- {0xB26A0000u, 40u}, // ktm -> Latn
- {0xBA6A0000u, 40u}, // kto -> Latn
- {0x6B750000u, 40u}, // ku -> Latn
+ {0x864A0000u, 44u}, // ksb -> Latn
+ {0x8E4A0000u, 44u}, // ksd -> Latn
+ {0x964A0000u, 44u}, // ksf -> Latn
+ {0x9E4A0000u, 44u}, // ksh -> Latn
+ {0xA64A0000u, 44u}, // ksj -> Latn
+ {0xC64A0000u, 44u}, // ksr -> Latn
+ {0x866A0000u, 19u}, // ktb -> Ethi
+ {0xB26A0000u, 44u}, // ktm -> Latn
+ {0xBA6A0000u, 44u}, // kto -> Latn
+ {0x6B750000u, 44u}, // ku -> Latn
{0x6B754952u, 1u}, // ku-IR -> Arab
{0x6B754C42u, 1u}, // ku-LB -> Arab
- {0x868A0000u, 40u}, // kub -> Latn
- {0x8E8A0000u, 40u}, // kud -> Latn
- {0x928A0000u, 40u}, // kue -> Latn
- {0xA68A0000u, 40u}, // kuj -> Latn
- {0xB28A0000u, 15u}, // kum -> Cyrl
- {0xB68A0000u, 40u}, // kun -> Latn
- {0xBE8A0000u, 40u}, // kup -> Latn
- {0xCA8A0000u, 40u}, // kus -> Latn
- {0x6B760000u, 15u}, // kv -> Cyrl
- {0x9AAA0000u, 40u}, // kvg -> Latn
- {0xC6AA0000u, 40u}, // kvr -> Latn
+ {0x868A0000u, 44u}, // kub -> Latn
+ {0x8E8A0000u, 44u}, // kud -> Latn
+ {0x928A0000u, 44u}, // kue -> Latn
+ {0xA68A0000u, 44u}, // kuj -> Latn
+ {0xB28A0000u, 16u}, // kum -> Cyrl
+ {0xB68A0000u, 44u}, // kun -> Latn
+ {0xBE8A0000u, 44u}, // kup -> Latn
+ {0xCA8A0000u, 44u}, // kus -> Latn
+ {0x6B760000u, 16u}, // kv -> Cyrl
+ {0x9AAA0000u, 44u}, // kvg -> Latn
+ {0xC6AA0000u, 44u}, // kvr -> Latn
{0xDEAA0000u, 1u}, // kvx -> Arab
- {0x6B770000u, 40u}, // kw -> Latn
- {0xA6CA0000u, 40u}, // kwj -> Latn
- {0xBACA0000u, 40u}, // kwo -> Latn
- {0x82EA0000u, 40u}, // kxa -> Latn
- {0x8AEA0000u, 18u}, // kxc -> Ethi
- {0xB2EA0000u, 80u}, // kxm -> Thai
+ {0x6B770000u, 44u}, // kw -> Latn
+ {0xA6CA0000u, 44u}, // kwj -> Latn
+ {0xBACA0000u, 44u}, // kwo -> Latn
+ {0x82EA0000u, 44u}, // kxa -> Latn
+ {0x8AEA0000u, 19u}, // kxc -> Ethi
+ {0xB2EA0000u, 87u}, // kxm -> Thai
{0xBEEA0000u, 1u}, // kxp -> Arab
- {0xDAEA0000u, 40u}, // kxw -> Latn
- {0xE6EA0000u, 40u}, // kxz -> Latn
- {0x6B790000u, 15u}, // ky -> Cyrl
+ {0xDAEA0000u, 44u}, // kxw -> Latn
+ {0xE6EA0000u, 44u}, // kxz -> Latn
+ {0x6B790000u, 16u}, // ky -> Cyrl
{0x6B79434Eu, 1u}, // ky-CN -> Arab
- {0x6B795452u, 40u}, // ky-TR -> Latn
- {0x930A0000u, 40u}, // kye -> Latn
- {0xDF0A0000u, 40u}, // kyx -> Latn
- {0xC72A0000u, 40u}, // kzr -> Latn
- {0x6C610000u, 40u}, // la -> Latn
- {0x840B0000u, 42u}, // lab -> Lina
- {0x8C0B0000u, 27u}, // lad -> Hebr
- {0x980B0000u, 40u}, // lag -> Latn
+ {0x6B795452u, 44u}, // ky-TR -> Latn
+ {0x930A0000u, 44u}, // kye -> Latn
+ {0xDF0A0000u, 44u}, // kyx -> Latn
+ {0xC72A0000u, 44u}, // kzr -> Latn
+ {0x6C610000u, 44u}, // la -> Latn
+ {0x840B0000u, 46u}, // lab -> Lina
+ {0x8C0B0000u, 30u}, // lad -> Hebr
+ {0x980B0000u, 44u}, // lag -> Latn
{0x9C0B0000u, 1u}, // lah -> Arab
- {0xA40B0000u, 40u}, // laj -> Latn
- {0xC80B0000u, 40u}, // las -> Latn
- {0x6C620000u, 40u}, // lb -> Latn
- {0x902B0000u, 15u}, // lbe -> Cyrl
- {0xD02B0000u, 40u}, // lbu -> Latn
- {0xD82B0000u, 40u}, // lbw -> Latn
- {0xB04B0000u, 40u}, // lcm -> Latn
- {0xBC4B0000u, 80u}, // lcp -> Thai
- {0x846B0000u, 40u}, // ldb -> Latn
- {0x8C8B0000u, 40u}, // led -> Latn
- {0x908B0000u, 40u}, // lee -> Latn
- {0xB08B0000u, 40u}, // lem -> Latn
- {0xBC8B0000u, 41u}, // lep -> Lepc
- {0xC08B0000u, 40u}, // leq -> Latn
- {0xD08B0000u, 40u}, // leu -> Latn
- {0xE48B0000u, 15u}, // lez -> Cyrl
- {0x6C670000u, 40u}, // lg -> Latn
- {0x98CB0000u, 40u}, // lgg -> Latn
- {0x6C690000u, 40u}, // li -> Latn
- {0x810B0000u, 40u}, // lia -> Latn
- {0x8D0B0000u, 40u}, // lid -> Latn
- {0x950B0000u, 16u}, // lif -> Deva
- {0x990B0000u, 40u}, // lig -> Latn
- {0x9D0B0000u, 40u}, // lih -> Latn
- {0xA50B0000u, 40u}, // lij -> Latn
- {0xC90B0000u, 43u}, // lis -> Lisu
- {0xBD2B0000u, 40u}, // ljp -> Latn
+ {0xA40B0000u, 44u}, // laj -> Latn
+ {0xC80B0000u, 44u}, // las -> Latn
+ {0x6C620000u, 44u}, // lb -> Latn
+ {0x902B0000u, 16u}, // lbe -> Cyrl
+ {0xD02B0000u, 44u}, // lbu -> Latn
+ {0xD82B0000u, 44u}, // lbw -> Latn
+ {0xB04B0000u, 44u}, // lcm -> Latn
+ {0xBC4B0000u, 87u}, // lcp -> Thai
+ {0x846B0000u, 44u}, // ldb -> Latn
+ {0x8C8B0000u, 44u}, // led -> Latn
+ {0x908B0000u, 44u}, // lee -> Latn
+ {0xB08B0000u, 44u}, // lem -> Latn
+ {0xBC8B0000u, 45u}, // lep -> Lepc
+ {0xC08B0000u, 44u}, // leq -> Latn
+ {0xD08B0000u, 44u}, // leu -> Latn
+ {0xE48B0000u, 16u}, // lez -> Cyrl
+ {0x6C670000u, 44u}, // lg -> Latn
+ {0x98CB0000u, 44u}, // lgg -> Latn
+ {0x6C690000u, 44u}, // li -> Latn
+ {0x810B0000u, 44u}, // lia -> Latn
+ {0x8D0B0000u, 44u}, // lid -> Latn
+ {0x950B0000u, 17u}, // lif -> Deva
+ {0x990B0000u, 44u}, // lig -> Latn
+ {0x9D0B0000u, 44u}, // lih -> Latn
+ {0xA50B0000u, 44u}, // lij -> Latn
+ {0xC90B0000u, 47u}, // lis -> Lisu
+ {0xBD2B0000u, 44u}, // ljp -> Latn
{0xA14B0000u, 1u}, // lki -> Arab
- {0xCD4B0000u, 40u}, // lkt -> Latn
- {0x916B0000u, 40u}, // lle -> Latn
- {0xB56B0000u, 40u}, // lln -> Latn
- {0xB58B0000u, 77u}, // lmn -> Telu
- {0xB98B0000u, 40u}, // lmo -> Latn
- {0xBD8B0000u, 40u}, // lmp -> Latn
- {0x6C6E0000u, 40u}, // ln -> Latn
- {0xC9AB0000u, 40u}, // lns -> Latn
- {0xD1AB0000u, 40u}, // lnu -> Latn
- {0x6C6F0000u, 39u}, // lo -> Laoo
- {0xA5CB0000u, 40u}, // loj -> Latn
- {0xA9CB0000u, 40u}, // lok -> Latn
- {0xADCB0000u, 40u}, // lol -> Latn
- {0xC5CB0000u, 40u}, // lor -> Latn
- {0xC9CB0000u, 40u}, // los -> Latn
- {0xE5CB0000u, 40u}, // loz -> Latn
+ {0xCD4B0000u, 44u}, // lkt -> Latn
+ {0x916B0000u, 44u}, // lle -> Latn
+ {0xB56B0000u, 44u}, // lln -> Latn
+ {0xB58B0000u, 84u}, // lmn -> Telu
+ {0xB98B0000u, 44u}, // lmo -> Latn
+ {0xBD8B0000u, 44u}, // lmp -> Latn
+ {0x6C6E0000u, 44u}, // ln -> Latn
+ {0xC9AB0000u, 44u}, // lns -> Latn
+ {0xD1AB0000u, 44u}, // lnu -> Latn
+ {0x6C6F0000u, 43u}, // lo -> Laoo
+ {0xA5CB0000u, 44u}, // loj -> Latn
+ {0xA9CB0000u, 44u}, // lok -> Latn
+ {0xADCB0000u, 44u}, // lol -> Latn
+ {0xC5CB0000u, 44u}, // lor -> Latn
+ {0xC9CB0000u, 44u}, // los -> Latn
+ {0xE5CB0000u, 44u}, // loz -> Latn
{0x8A2B0000u, 1u}, // lrc -> Arab
- {0x6C740000u, 40u}, // lt -> Latn
- {0x9A6B0000u, 40u}, // ltg -> Latn
- {0x6C750000u, 40u}, // lu -> Latn
- {0x828B0000u, 40u}, // lua -> Latn
- {0xBA8B0000u, 40u}, // luo -> Latn
- {0xE28B0000u, 40u}, // luy -> Latn
+ {0x6C740000u, 44u}, // lt -> Latn
+ {0x9A6B0000u, 44u}, // ltg -> Latn
+ {0x6C750000u, 44u}, // lu -> Latn
+ {0x828B0000u, 44u}, // lua -> Latn
+ {0xBA8B0000u, 44u}, // luo -> Latn
+ {0xE28B0000u, 44u}, // luy -> Latn
{0xE68B0000u, 1u}, // luz -> Arab
- {0x6C760000u, 40u}, // lv -> Latn
- {0xAECB0000u, 80u}, // lwl -> Thai
- {0x9F2B0000u, 24u}, // lzh -> Hans
- {0xE72B0000u, 40u}, // lzz -> Latn
- {0x8C0C0000u, 40u}, // mad -> Latn
- {0x940C0000u, 40u}, // maf -> Latn
- {0x980C0000u, 16u}, // mag -> Deva
- {0xA00C0000u, 16u}, // mai -> Deva
- {0xA80C0000u, 40u}, // mak -> Latn
- {0xB40C0000u, 40u}, // man -> Latn
- {0xB40C474Eu, 54u}, // man-GN -> Nkoo
- {0xC80C0000u, 40u}, // mas -> Latn
- {0xD80C0000u, 40u}, // maw -> Latn
- {0xE40C0000u, 40u}, // maz -> Latn
- {0x9C2C0000u, 40u}, // mbh -> Latn
- {0xB82C0000u, 40u}, // mbo -> Latn
- {0xC02C0000u, 40u}, // mbq -> Latn
- {0xD02C0000u, 40u}, // mbu -> Latn
- {0xD82C0000u, 40u}, // mbw -> Latn
- {0xA04C0000u, 40u}, // mci -> Latn
- {0xBC4C0000u, 40u}, // mcp -> Latn
- {0xC04C0000u, 40u}, // mcq -> Latn
- {0xC44C0000u, 40u}, // mcr -> Latn
- {0xD04C0000u, 40u}, // mcu -> Latn
- {0x806C0000u, 40u}, // mda -> Latn
+ {0x6C760000u, 44u}, // lv -> Latn
+ {0xAECB0000u, 87u}, // lwl -> Thai
+ {0x9F2B0000u, 27u}, // lzh -> Hans
+ {0xE72B0000u, 44u}, // lzz -> Latn
+ {0x8C0C0000u, 44u}, // mad -> Latn
+ {0x940C0000u, 44u}, // maf -> Latn
+ {0x980C0000u, 17u}, // mag -> Deva
+ {0xA00C0000u, 17u}, // mai -> Deva
+ {0xA80C0000u, 44u}, // mak -> Latn
+ {0xB40C0000u, 44u}, // man -> Latn
+ {0xB40C474Eu, 58u}, // man-GN -> Nkoo
+ {0xC80C0000u, 44u}, // mas -> Latn
+ {0xD80C0000u, 44u}, // maw -> Latn
+ {0xE40C0000u, 44u}, // maz -> Latn
+ {0x9C2C0000u, 44u}, // mbh -> Latn
+ {0xB82C0000u, 44u}, // mbo -> Latn
+ {0xC02C0000u, 44u}, // mbq -> Latn
+ {0xD02C0000u, 44u}, // mbu -> Latn
+ {0xD82C0000u, 44u}, // mbw -> Latn
+ {0xA04C0000u, 44u}, // mci -> Latn
+ {0xBC4C0000u, 44u}, // mcp -> Latn
+ {0xC04C0000u, 44u}, // mcq -> Latn
+ {0xC44C0000u, 44u}, // mcr -> Latn
+ {0xD04C0000u, 44u}, // mcu -> Latn
+ {0x806C0000u, 44u}, // mda -> Latn
{0x906C0000u, 1u}, // mde -> Arab
- {0x946C0000u, 15u}, // mdf -> Cyrl
- {0x9C6C0000u, 40u}, // mdh -> Latn
- {0xA46C0000u, 40u}, // mdj -> Latn
- {0xC46C0000u, 40u}, // mdr -> Latn
- {0xDC6C0000u, 18u}, // mdx -> Ethi
- {0x8C8C0000u, 40u}, // med -> Latn
- {0x908C0000u, 40u}, // mee -> Latn
- {0xA88C0000u, 40u}, // mek -> Latn
- {0xB48C0000u, 40u}, // men -> Latn
- {0xC48C0000u, 40u}, // mer -> Latn
- {0xCC8C0000u, 40u}, // met -> Latn
- {0xD08C0000u, 40u}, // meu -> Latn
+ {0x946C0000u, 16u}, // mdf -> Cyrl
+ {0x9C6C0000u, 44u}, // mdh -> Latn
+ {0xA46C0000u, 44u}, // mdj -> Latn
+ {0xC46C0000u, 44u}, // mdr -> Latn
+ {0xDC6C0000u, 19u}, // mdx -> Ethi
+ {0x8C8C0000u, 44u}, // med -> Latn
+ {0x908C0000u, 44u}, // mee -> Latn
+ {0xA88C0000u, 44u}, // mek -> Latn
+ {0xB48C0000u, 44u}, // men -> Latn
+ {0xC48C0000u, 44u}, // mer -> Latn
+ {0xCC8C0000u, 44u}, // met -> Latn
+ {0xD08C0000u, 44u}, // meu -> Latn
{0x80AC0000u, 1u}, // mfa -> Arab
- {0x90AC0000u, 40u}, // mfe -> Latn
- {0xB4AC0000u, 40u}, // mfn -> Latn
- {0xB8AC0000u, 40u}, // mfo -> Latn
- {0xC0AC0000u, 40u}, // mfq -> Latn
- {0x6D670000u, 40u}, // mg -> Latn
- {0x9CCC0000u, 40u}, // mgh -> Latn
- {0xACCC0000u, 40u}, // mgl -> Latn
- {0xB8CC0000u, 40u}, // mgo -> Latn
- {0xBCCC0000u, 16u}, // mgp -> Deva
- {0xE0CC0000u, 40u}, // mgy -> Latn
- {0x6D680000u, 40u}, // mh -> Latn
- {0xA0EC0000u, 40u}, // mhi -> Latn
- {0xACEC0000u, 40u}, // mhl -> Latn
- {0x6D690000u, 40u}, // mi -> Latn
- {0x950C0000u, 40u}, // mif -> Latn
- {0xB50C0000u, 40u}, // min -> Latn
- {0xC90C0000u, 26u}, // mis -> Hatr
- {0xD90C0000u, 40u}, // miw -> Latn
- {0x6D6B0000u, 15u}, // mk -> Cyrl
+ {0x90AC0000u, 44u}, // mfe -> Latn
+ {0xB4AC0000u, 44u}, // mfn -> Latn
+ {0xB8AC0000u, 44u}, // mfo -> Latn
+ {0xC0AC0000u, 44u}, // mfq -> Latn
+ {0x6D670000u, 44u}, // mg -> Latn
+ {0x9CCC0000u, 44u}, // mgh -> Latn
+ {0xACCC0000u, 44u}, // mgl -> Latn
+ {0xB8CC0000u, 44u}, // mgo -> Latn
+ {0xBCCC0000u, 17u}, // mgp -> Deva
+ {0xE0CC0000u, 44u}, // mgy -> Latn
+ {0x6D680000u, 44u}, // mh -> Latn
+ {0xA0EC0000u, 44u}, // mhi -> Latn
+ {0xACEC0000u, 44u}, // mhl -> Latn
+ {0x6D690000u, 44u}, // mi -> Latn
+ {0x950C0000u, 44u}, // mif -> Latn
+ {0xB50C0000u, 44u}, // min -> Latn
+ {0xC90C0000u, 29u}, // mis -> Hatr
+ {0xD90C0000u, 44u}, // miw -> Latn
+ {0x6D6B0000u, 16u}, // mk -> Cyrl
{0xA14C0000u, 1u}, // mki -> Arab
- {0xAD4C0000u, 40u}, // mkl -> Latn
- {0xBD4C0000u, 40u}, // mkp -> Latn
- {0xD94C0000u, 40u}, // mkw -> Latn
- {0x6D6C0000u, 49u}, // ml -> Mlym
- {0x916C0000u, 40u}, // mle -> Latn
- {0xBD6C0000u, 40u}, // mlp -> Latn
- {0xC96C0000u, 40u}, // mls -> Latn
- {0xB98C0000u, 40u}, // mmo -> Latn
- {0xD18C0000u, 40u}, // mmu -> Latn
- {0xDD8C0000u, 40u}, // mmx -> Latn
- {0x6D6E0000u, 15u}, // mn -> Cyrl
- {0x6D6E434Eu, 50u}, // mn-CN -> Mong
- {0x81AC0000u, 40u}, // mna -> Latn
- {0x95AC0000u, 40u}, // mnf -> Latn
+ {0xAD4C0000u, 44u}, // mkl -> Latn
+ {0xBD4C0000u, 44u}, // mkp -> Latn
+ {0xD94C0000u, 44u}, // mkw -> Latn
+ {0x6D6C0000u, 53u}, // ml -> Mlym
+ {0x916C0000u, 44u}, // mle -> Latn
+ {0xBD6C0000u, 44u}, // mlp -> Latn
+ {0xC96C0000u, 44u}, // mls -> Latn
+ {0xB98C0000u, 44u}, // mmo -> Latn
+ {0xD18C0000u, 44u}, // mmu -> Latn
+ {0xDD8C0000u, 44u}, // mmx -> Latn
+ {0x6D6E0000u, 16u}, // mn -> Cyrl
+ {0x6D6E434Eu, 54u}, // mn-CN -> Mong
+ {0x81AC0000u, 44u}, // mna -> Latn
+ {0x95AC0000u, 44u}, // mnf -> Latn
{0xA1AC0000u, 7u}, // mni -> Beng
- {0xD9AC0000u, 52u}, // mnw -> Mymr
- {0x81CC0000u, 40u}, // moa -> Latn
- {0x91CC0000u, 40u}, // moe -> Latn
- {0x9DCC0000u, 40u}, // moh -> Latn
- {0xC9CC0000u, 40u}, // mos -> Latn
- {0xDDCC0000u, 40u}, // mox -> Latn
- {0xBDEC0000u, 40u}, // mpp -> Latn
- {0xC9EC0000u, 40u}, // mps -> Latn
- {0xCDEC0000u, 40u}, // mpt -> Latn
- {0xDDEC0000u, 40u}, // mpx -> Latn
- {0xAE0C0000u, 40u}, // mql -> Latn
- {0x6D720000u, 16u}, // mr -> Deva
- {0x8E2C0000u, 16u}, // mrd -> Deva
- {0xA62C0000u, 15u}, // mrj -> Cyrl
- {0xBA2C0000u, 51u}, // mro -> Mroo
- {0x6D730000u, 40u}, // ms -> Latn
+ {0xD9AC0000u, 56u}, // mnw -> Mymr
+ {0x81CC0000u, 44u}, // moa -> Latn
+ {0x91CC0000u, 44u}, // moe -> Latn
+ {0x9DCC0000u, 44u}, // moh -> Latn
+ {0xC9CC0000u, 44u}, // mos -> Latn
+ {0xDDCC0000u, 44u}, // mox -> Latn
+ {0xBDEC0000u, 44u}, // mpp -> Latn
+ {0xC9EC0000u, 44u}, // mps -> Latn
+ {0xCDEC0000u, 44u}, // mpt -> Latn
+ {0xDDEC0000u, 44u}, // mpx -> Latn
+ {0xAE0C0000u, 44u}, // mql -> Latn
+ {0x6D720000u, 17u}, // mr -> Deva
+ {0x8E2C0000u, 17u}, // mrd -> Deva
+ {0xA62C0000u, 16u}, // mrj -> Cyrl
+ {0xBA2C0000u, 55u}, // mro -> Mroo
+ {0x6D730000u, 44u}, // ms -> Latn
{0x6D734343u, 1u}, // ms-CC -> Arab
{0x6D734944u, 1u}, // ms-ID -> Arab
- {0x6D740000u, 40u}, // mt -> Latn
- {0x8A6C0000u, 40u}, // mtc -> Latn
- {0x966C0000u, 40u}, // mtf -> Latn
- {0xA26C0000u, 40u}, // mti -> Latn
- {0xC66C0000u, 16u}, // mtr -> Deva
- {0x828C0000u, 40u}, // mua -> Latn
- {0xC68C0000u, 40u}, // mur -> Latn
- {0xCA8C0000u, 40u}, // mus -> Latn
- {0x82AC0000u, 40u}, // mva -> Latn
- {0xB6AC0000u, 40u}, // mvn -> Latn
+ {0x6D740000u, 44u}, // mt -> Latn
+ {0x8A6C0000u, 44u}, // mtc -> Latn
+ {0x966C0000u, 44u}, // mtf -> Latn
+ {0xA26C0000u, 44u}, // mti -> Latn
+ {0xC66C0000u, 17u}, // mtr -> Deva
+ {0x828C0000u, 44u}, // mua -> Latn
+ {0xC68C0000u, 44u}, // mur -> Latn
+ {0xCA8C0000u, 44u}, // mus -> Latn
+ {0x82AC0000u, 44u}, // mva -> Latn
+ {0xB6AC0000u, 44u}, // mvn -> Latn
{0xE2AC0000u, 1u}, // mvy -> Arab
- {0xAACC0000u, 40u}, // mwk -> Latn
- {0xC6CC0000u, 16u}, // mwr -> Deva
- {0xD6CC0000u, 40u}, // mwv -> Latn
- {0x8AEC0000u, 40u}, // mxc -> Latn
- {0xB2EC0000u, 40u}, // mxm -> Latn
- {0x6D790000u, 52u}, // my -> Mymr
- {0xAB0C0000u, 40u}, // myk -> Latn
- {0xB30C0000u, 18u}, // mym -> Ethi
- {0xD70C0000u, 15u}, // myv -> Cyrl
- {0xDB0C0000u, 40u}, // myw -> Latn
- {0xDF0C0000u, 40u}, // myx -> Latn
- {0xE70C0000u, 46u}, // myz -> Mand
- {0xAB2C0000u, 40u}, // mzk -> Latn
- {0xB32C0000u, 40u}, // mzm -> Latn
+ {0xAACC0000u, 44u}, // mwk -> Latn
+ {0xC6CC0000u, 17u}, // mwr -> Deva
+ {0xD6CC0000u, 44u}, // mwv -> Latn
+ {0xDACC0000u, 33u}, // mww -> Hmnp
+ {0x8AEC0000u, 44u}, // mxc -> Latn
+ {0xB2EC0000u, 44u}, // mxm -> Latn
+ {0x6D790000u, 56u}, // my -> Mymr
+ {0xAB0C0000u, 44u}, // myk -> Latn
+ {0xB30C0000u, 19u}, // mym -> Ethi
+ {0xD70C0000u, 16u}, // myv -> Cyrl
+ {0xDB0C0000u, 44u}, // myw -> Latn
+ {0xDF0C0000u, 44u}, // myx -> Latn
+ {0xE70C0000u, 50u}, // myz -> Mand
+ {0xAB2C0000u, 44u}, // mzk -> Latn
+ {0xB32C0000u, 44u}, // mzm -> Latn
{0xB72C0000u, 1u}, // mzn -> Arab
- {0xBF2C0000u, 40u}, // mzp -> Latn
- {0xDB2C0000u, 40u}, // mzw -> Latn
- {0xE72C0000u, 40u}, // mzz -> Latn
- {0x6E610000u, 40u}, // na -> Latn
- {0x880D0000u, 40u}, // nac -> Latn
- {0x940D0000u, 40u}, // naf -> Latn
- {0xA80D0000u, 40u}, // nak -> Latn
- {0xB40D0000u, 24u}, // nan -> Hans
- {0xBC0D0000u, 40u}, // nap -> Latn
- {0xC00D0000u, 40u}, // naq -> Latn
- {0xC80D0000u, 40u}, // nas -> Latn
- {0x6E620000u, 40u}, // nb -> Latn
- {0x804D0000u, 40u}, // nca -> Latn
- {0x904D0000u, 40u}, // nce -> Latn
- {0x944D0000u, 40u}, // ncf -> Latn
- {0x9C4D0000u, 40u}, // nch -> Latn
- {0xB84D0000u, 40u}, // nco -> Latn
- {0xD04D0000u, 40u}, // ncu -> Latn
- {0x6E640000u, 40u}, // nd -> Latn
- {0x886D0000u, 40u}, // ndc -> Latn
- {0xC86D0000u, 40u}, // nds -> Latn
- {0x6E650000u, 16u}, // ne -> Deva
- {0x848D0000u, 40u}, // neb -> Latn
- {0xD88D0000u, 16u}, // new -> Deva
- {0xDC8D0000u, 40u}, // nex -> Latn
- {0xC4AD0000u, 40u}, // nfr -> Latn
- {0x6E670000u, 40u}, // ng -> Latn
- {0x80CD0000u, 40u}, // nga -> Latn
- {0x84CD0000u, 40u}, // ngb -> Latn
- {0xACCD0000u, 40u}, // ngl -> Latn
- {0x84ED0000u, 40u}, // nhb -> Latn
- {0x90ED0000u, 40u}, // nhe -> Latn
- {0xD8ED0000u, 40u}, // nhw -> Latn
- {0x950D0000u, 40u}, // nif -> Latn
- {0xA10D0000u, 40u}, // nii -> Latn
- {0xA50D0000u, 40u}, // nij -> Latn
- {0xB50D0000u, 40u}, // nin -> Latn
- {0xD10D0000u, 40u}, // niu -> Latn
- {0xE10D0000u, 40u}, // niy -> Latn
- {0xE50D0000u, 40u}, // niz -> Latn
- {0xB92D0000u, 40u}, // njo -> Latn
- {0x994D0000u, 40u}, // nkg -> Latn
- {0xB94D0000u, 40u}, // nko -> Latn
- {0x6E6C0000u, 40u}, // nl -> Latn
- {0x998D0000u, 40u}, // nmg -> Latn
- {0xE58D0000u, 40u}, // nmz -> Latn
- {0x6E6E0000u, 40u}, // nn -> Latn
- {0x95AD0000u, 40u}, // nnf -> Latn
- {0x9DAD0000u, 40u}, // nnh -> Latn
- {0xA9AD0000u, 40u}, // nnk -> Latn
- {0xB1AD0000u, 40u}, // nnm -> Latn
- {0x6E6F0000u, 40u}, // no -> Latn
- {0x8DCD0000u, 38u}, // nod -> Lana
- {0x91CD0000u, 16u}, // noe -> Deva
- {0xB5CD0000u, 64u}, // non -> Runr
- {0xBDCD0000u, 40u}, // nop -> Latn
- {0xD1CD0000u, 40u}, // nou -> Latn
- {0xBA0D0000u, 54u}, // nqo -> Nkoo
- {0x6E720000u, 40u}, // nr -> Latn
- {0x862D0000u, 40u}, // nrb -> Latn
- {0xAA4D0000u, 9u}, // nsk -> Cans
- {0xB64D0000u, 40u}, // nsn -> Latn
- {0xBA4D0000u, 40u}, // nso -> Latn
- {0xCA4D0000u, 40u}, // nss -> Latn
- {0xB26D0000u, 40u}, // ntm -> Latn
- {0xC66D0000u, 40u}, // ntr -> Latn
- {0xA28D0000u, 40u}, // nui -> Latn
- {0xBE8D0000u, 40u}, // nup -> Latn
- {0xCA8D0000u, 40u}, // nus -> Latn
- {0xD68D0000u, 40u}, // nuv -> Latn
- {0xDE8D0000u, 40u}, // nux -> Latn
- {0x6E760000u, 40u}, // nv -> Latn
- {0x86CD0000u, 40u}, // nwb -> Latn
- {0xC2ED0000u, 40u}, // nxq -> Latn
- {0xC6ED0000u, 40u}, // nxr -> Latn
- {0x6E790000u, 40u}, // ny -> Latn
- {0xB30D0000u, 40u}, // nym -> Latn
- {0xB70D0000u, 40u}, // nyn -> Latn
- {0xA32D0000u, 40u}, // nzi -> Latn
- {0x6F630000u, 40u}, // oc -> Latn
- {0x88CE0000u, 40u}, // ogc -> Latn
- {0xC54E0000u, 40u}, // okr -> Latn
- {0xD54E0000u, 40u}, // okv -> Latn
- {0x6F6D0000u, 40u}, // om -> Latn
- {0x99AE0000u, 40u}, // ong -> Latn
- {0xB5AE0000u, 40u}, // onn -> Latn
- {0xC9AE0000u, 40u}, // ons -> Latn
- {0xB1EE0000u, 40u}, // opm -> Latn
- {0x6F720000u, 57u}, // or -> Orya
- {0xBA2E0000u, 40u}, // oro -> Latn
+ {0xBF2C0000u, 44u}, // mzp -> Latn
+ {0xDB2C0000u, 44u}, // mzw -> Latn
+ {0xE72C0000u, 44u}, // mzz -> Latn
+ {0x6E610000u, 44u}, // na -> Latn
+ {0x880D0000u, 44u}, // nac -> Latn
+ {0x940D0000u, 44u}, // naf -> Latn
+ {0xA80D0000u, 44u}, // nak -> Latn
+ {0xB40D0000u, 27u}, // nan -> Hans
+ {0xBC0D0000u, 44u}, // nap -> Latn
+ {0xC00D0000u, 44u}, // naq -> Latn
+ {0xC80D0000u, 44u}, // nas -> Latn
+ {0x6E620000u, 44u}, // nb -> Latn
+ {0x804D0000u, 44u}, // nca -> Latn
+ {0x904D0000u, 44u}, // nce -> Latn
+ {0x944D0000u, 44u}, // ncf -> Latn
+ {0x9C4D0000u, 44u}, // nch -> Latn
+ {0xB84D0000u, 44u}, // nco -> Latn
+ {0xD04D0000u, 44u}, // ncu -> Latn
+ {0x6E640000u, 44u}, // nd -> Latn
+ {0x886D0000u, 44u}, // ndc -> Latn
+ {0xC86D0000u, 44u}, // nds -> Latn
+ {0x6E650000u, 17u}, // ne -> Deva
+ {0x848D0000u, 44u}, // neb -> Latn
+ {0xD88D0000u, 17u}, // new -> Deva
+ {0xDC8D0000u, 44u}, // nex -> Latn
+ {0xC4AD0000u, 44u}, // nfr -> Latn
+ {0x6E670000u, 44u}, // ng -> Latn
+ {0x80CD0000u, 44u}, // nga -> Latn
+ {0x84CD0000u, 44u}, // ngb -> Latn
+ {0xACCD0000u, 44u}, // ngl -> Latn
+ {0x84ED0000u, 44u}, // nhb -> Latn
+ {0x90ED0000u, 44u}, // nhe -> Latn
+ {0xD8ED0000u, 44u}, // nhw -> Latn
+ {0x950D0000u, 44u}, // nif -> Latn
+ {0xA10D0000u, 44u}, // nii -> Latn
+ {0xA50D0000u, 44u}, // nij -> Latn
+ {0xB50D0000u, 44u}, // nin -> Latn
+ {0xD10D0000u, 44u}, // niu -> Latn
+ {0xE10D0000u, 44u}, // niy -> Latn
+ {0xE50D0000u, 44u}, // niz -> Latn
+ {0xB92D0000u, 44u}, // njo -> Latn
+ {0x994D0000u, 44u}, // nkg -> Latn
+ {0xB94D0000u, 44u}, // nko -> Latn
+ {0x6E6C0000u, 44u}, // nl -> Latn
+ {0x998D0000u, 44u}, // nmg -> Latn
+ {0xE58D0000u, 44u}, // nmz -> Latn
+ {0x6E6E0000u, 44u}, // nn -> Latn
+ {0x95AD0000u, 44u}, // nnf -> Latn
+ {0x9DAD0000u, 44u}, // nnh -> Latn
+ {0xA9AD0000u, 44u}, // nnk -> Latn
+ {0xB1AD0000u, 44u}, // nnm -> Latn
+ {0xBDAD0000u, 91u}, // nnp -> Wcho
+ {0x6E6F0000u, 44u}, // no -> Latn
+ {0x8DCD0000u, 42u}, // nod -> Lana
+ {0x91CD0000u, 17u}, // noe -> Deva
+ {0xB5CD0000u, 69u}, // non -> Runr
+ {0xBDCD0000u, 44u}, // nop -> Latn
+ {0xD1CD0000u, 44u}, // nou -> Latn
+ {0xBA0D0000u, 58u}, // nqo -> Nkoo
+ {0x6E720000u, 44u}, // nr -> Latn
+ {0x862D0000u, 44u}, // nrb -> Latn
+ {0xAA4D0000u, 10u}, // nsk -> Cans
+ {0xB64D0000u, 44u}, // nsn -> Latn
+ {0xBA4D0000u, 44u}, // nso -> Latn
+ {0xCA4D0000u, 44u}, // nss -> Latn
+ {0xB26D0000u, 44u}, // ntm -> Latn
+ {0xC66D0000u, 44u}, // ntr -> Latn
+ {0xA28D0000u, 44u}, // nui -> Latn
+ {0xBE8D0000u, 44u}, // nup -> Latn
+ {0xCA8D0000u, 44u}, // nus -> Latn
+ {0xD68D0000u, 44u}, // nuv -> Latn
+ {0xDE8D0000u, 44u}, // nux -> Latn
+ {0x6E760000u, 44u}, // nv -> Latn
+ {0x86CD0000u, 44u}, // nwb -> Latn
+ {0xC2ED0000u, 44u}, // nxq -> Latn
+ {0xC6ED0000u, 44u}, // nxr -> Latn
+ {0x6E790000u, 44u}, // ny -> Latn
+ {0xB30D0000u, 44u}, // nym -> Latn
+ {0xB70D0000u, 44u}, // nyn -> Latn
+ {0xA32D0000u, 44u}, // nzi -> Latn
+ {0x6F630000u, 44u}, // oc -> Latn
+ {0x88CE0000u, 44u}, // ogc -> Latn
+ {0xC54E0000u, 44u}, // okr -> Latn
+ {0xD54E0000u, 44u}, // okv -> Latn
+ {0x6F6D0000u, 44u}, // om -> Latn
+ {0x99AE0000u, 44u}, // ong -> Latn
+ {0xB5AE0000u, 44u}, // onn -> Latn
+ {0xC9AE0000u, 44u}, // ons -> Latn
+ {0xB1EE0000u, 44u}, // opm -> Latn
+ {0x6F720000u, 62u}, // or -> Orya
+ {0xBA2E0000u, 44u}, // oro -> Latn
{0xD22E0000u, 1u}, // oru -> Arab
- {0x6F730000u, 15u}, // os -> Cyrl
- {0x824E0000u, 58u}, // osa -> Osge
+ {0x6F730000u, 16u}, // os -> Cyrl
+ {0x824E0000u, 63u}, // osa -> Osge
{0x826E0000u, 1u}, // ota -> Arab
- {0xAA6E0000u, 56u}, // otk -> Orkh
- {0xB32E0000u, 40u}, // ozm -> Latn
- {0x70610000u, 23u}, // pa -> Guru
+ {0xAA6E0000u, 61u}, // otk -> Orkh
+ {0xB32E0000u, 44u}, // ozm -> Latn
+ {0x70610000u, 26u}, // pa -> Guru
{0x7061504Bu, 1u}, // pa-PK -> Arab
- {0x980F0000u, 40u}, // pag -> Latn
- {0xAC0F0000u, 60u}, // pal -> Phli
- {0xB00F0000u, 40u}, // pam -> Latn
- {0xBC0F0000u, 40u}, // pap -> Latn
- {0xD00F0000u, 40u}, // pau -> Latn
- {0xA02F0000u, 40u}, // pbi -> Latn
- {0x8C4F0000u, 40u}, // pcd -> Latn
- {0xB04F0000u, 40u}, // pcm -> Latn
- {0x886F0000u, 40u}, // pdc -> Latn
- {0xCC6F0000u, 40u}, // pdt -> Latn
- {0x8C8F0000u, 40u}, // ped -> Latn
- {0xB88F0000u, 84u}, // peo -> Xpeo
- {0xDC8F0000u, 40u}, // pex -> Latn
- {0xACAF0000u, 40u}, // pfl -> Latn
+ {0x980F0000u, 44u}, // pag -> Latn
+ {0xAC0F0000u, 65u}, // pal -> Phli
+ {0xB00F0000u, 44u}, // pam -> Latn
+ {0xBC0F0000u, 44u}, // pap -> Latn
+ {0xD00F0000u, 44u}, // pau -> Latn
+ {0xA02F0000u, 44u}, // pbi -> Latn
+ {0x8C4F0000u, 44u}, // pcd -> Latn
+ {0xB04F0000u, 44u}, // pcm -> Latn
+ {0x886F0000u, 44u}, // pdc -> Latn
+ {0xCC6F0000u, 44u}, // pdt -> Latn
+ {0x8C8F0000u, 44u}, // ped -> Latn
+ {0xB88F0000u, 92u}, // peo -> Xpeo
+ {0xDC8F0000u, 44u}, // pex -> Latn
+ {0xACAF0000u, 44u}, // pfl -> Latn
{0xACEF0000u, 1u}, // phl -> Arab
- {0xB4EF0000u, 61u}, // phn -> Phnx
- {0xAD0F0000u, 40u}, // pil -> Latn
- {0xBD0F0000u, 40u}, // pip -> Latn
+ {0xB4EF0000u, 66u}, // phn -> Phnx
+ {0xAD0F0000u, 44u}, // pil -> Latn
+ {0xBD0F0000u, 44u}, // pip -> Latn
{0x814F0000u, 8u}, // pka -> Brah
- {0xB94F0000u, 40u}, // pko -> Latn
- {0x706C0000u, 40u}, // pl -> Latn
- {0x816F0000u, 40u}, // pla -> Latn
- {0xC98F0000u, 40u}, // pms -> Latn
- {0x99AF0000u, 40u}, // png -> Latn
- {0xB5AF0000u, 40u}, // pnn -> Latn
- {0xCDAF0000u, 21u}, // pnt -> Grek
- {0xB5CF0000u, 40u}, // pon -> Latn
- {0xB9EF0000u, 40u}, // ppo -> Latn
- {0x822F0000u, 34u}, // pra -> Khar
+ {0xB94F0000u, 44u}, // pko -> Latn
+ {0x706C0000u, 44u}, // pl -> Latn
+ {0x816F0000u, 44u}, // pla -> Latn
+ {0xC98F0000u, 44u}, // pms -> Latn
+ {0x99AF0000u, 44u}, // png -> Latn
+ {0xB5AF0000u, 44u}, // pnn -> Latn
+ {0xCDAF0000u, 24u}, // pnt -> Grek
+ {0xB5CF0000u, 44u}, // pon -> Latn
+ {0xB9EF0000u, 44u}, // ppo -> Latn
+ {0x822F0000u, 38u}, // pra -> Khar
{0x8E2F0000u, 1u}, // prd -> Arab
- {0x9A2F0000u, 40u}, // prg -> Latn
+ {0x9A2F0000u, 44u}, // prg -> Latn
{0x70730000u, 1u}, // ps -> Arab
- {0xCA4F0000u, 40u}, // pss -> Latn
- {0x70740000u, 40u}, // pt -> Latn
- {0xBE6F0000u, 40u}, // ptp -> Latn
- {0xD28F0000u, 40u}, // puu -> Latn
- {0x82CF0000u, 40u}, // pwa -> Latn
- {0x71750000u, 40u}, // qu -> Latn
- {0x8A900000u, 40u}, // quc -> Latn
- {0x9A900000u, 40u}, // qug -> Latn
- {0xA0110000u, 40u}, // rai -> Latn
- {0xA4110000u, 16u}, // raj -> Deva
- {0xB8110000u, 40u}, // rao -> Latn
- {0x94510000u, 40u}, // rcf -> Latn
- {0xA4910000u, 40u}, // rej -> Latn
- {0xAC910000u, 40u}, // rel -> Latn
- {0xC8910000u, 40u}, // res -> Latn
- {0xB4D10000u, 40u}, // rgn -> Latn
+ {0xCA4F0000u, 44u}, // pss -> Latn
+ {0x70740000u, 44u}, // pt -> Latn
+ {0xBE6F0000u, 44u}, // ptp -> Latn
+ {0xD28F0000u, 44u}, // puu -> Latn
+ {0x82CF0000u, 44u}, // pwa -> Latn
+ {0x71750000u, 44u}, // qu -> Latn
+ {0x8A900000u, 44u}, // quc -> Latn
+ {0x9A900000u, 44u}, // qug -> Latn
+ {0xA0110000u, 44u}, // rai -> Latn
+ {0xA4110000u, 17u}, // raj -> Deva
+ {0xB8110000u, 44u}, // rao -> Latn
+ {0x94510000u, 44u}, // rcf -> Latn
+ {0xA4910000u, 44u}, // rej -> Latn
+ {0xAC910000u, 44u}, // rel -> Latn
+ {0xC8910000u, 44u}, // res -> Latn
+ {0xB4D10000u, 44u}, // rgn -> Latn
{0x98F10000u, 1u}, // rhg -> Arab
- {0x81110000u, 40u}, // ria -> Latn
- {0x95110000u, 78u}, // rif -> Tfng
- {0x95114E4Cu, 40u}, // rif-NL -> Latn
- {0xC9310000u, 16u}, // rjs -> Deva
+ {0x81110000u, 44u}, // ria -> Latn
+ {0x95110000u, 85u}, // rif -> Tfng
+ {0x95114E4Cu, 44u}, // rif-NL -> Latn
+ {0xC9310000u, 17u}, // rjs -> Deva
{0xCD510000u, 7u}, // rkt -> Beng
- {0x726D0000u, 40u}, // rm -> Latn
- {0x95910000u, 40u}, // rmf -> Latn
- {0xB9910000u, 40u}, // rmo -> Latn
+ {0x726D0000u, 44u}, // rm -> Latn
+ {0x95910000u, 44u}, // rmf -> Latn
+ {0xB9910000u, 44u}, // rmo -> Latn
{0xCD910000u, 1u}, // rmt -> Arab
- {0xD1910000u, 40u}, // rmu -> Latn
- {0x726E0000u, 40u}, // rn -> Latn
- {0x81B10000u, 40u}, // rna -> Latn
- {0x99B10000u, 40u}, // rng -> Latn
- {0x726F0000u, 40u}, // ro -> Latn
- {0x85D10000u, 40u}, // rob -> Latn
- {0x95D10000u, 40u}, // rof -> Latn
- {0xB9D10000u, 40u}, // roo -> Latn
- {0xBA310000u, 40u}, // rro -> Latn
- {0xB2710000u, 40u}, // rtm -> Latn
- {0x72750000u, 15u}, // ru -> Cyrl
- {0x92910000u, 15u}, // rue -> Cyrl
- {0x9A910000u, 40u}, // rug -> Latn
- {0x72770000u, 40u}, // rw -> Latn
- {0xAAD10000u, 40u}, // rwk -> Latn
- {0xBAD10000u, 40u}, // rwo -> Latn
- {0xD3110000u, 33u}, // ryu -> Kana
- {0x73610000u, 16u}, // sa -> Deva
- {0x94120000u, 40u}, // saf -> Latn
- {0x9C120000u, 15u}, // sah -> Cyrl
- {0xC0120000u, 40u}, // saq -> Latn
- {0xC8120000u, 40u}, // sas -> Latn
- {0xCC120000u, 40u}, // sat -> Latn
- {0xE4120000u, 67u}, // saz -> Saur
- {0x80320000u, 40u}, // sba -> Latn
- {0x90320000u, 40u}, // sbe -> Latn
- {0xBC320000u, 40u}, // sbp -> Latn
- {0x73630000u, 40u}, // sc -> Latn
- {0xA8520000u, 16u}, // sck -> Deva
+ {0xD1910000u, 44u}, // rmu -> Latn
+ {0x726E0000u, 44u}, // rn -> Latn
+ {0x81B10000u, 44u}, // rna -> Latn
+ {0x99B10000u, 44u}, // rng -> Latn
+ {0x726F0000u, 44u}, // ro -> Latn
+ {0x85D10000u, 44u}, // rob -> Latn
+ {0x95D10000u, 44u}, // rof -> Latn
+ {0xB9D10000u, 44u}, // roo -> Latn
+ {0xBA310000u, 44u}, // rro -> Latn
+ {0xB2710000u, 44u}, // rtm -> Latn
+ {0x72750000u, 16u}, // ru -> Cyrl
+ {0x92910000u, 16u}, // rue -> Cyrl
+ {0x9A910000u, 44u}, // rug -> Latn
+ {0x72770000u, 44u}, // rw -> Latn
+ {0xAAD10000u, 44u}, // rwk -> Latn
+ {0xBAD10000u, 44u}, // rwo -> Latn
+ {0xD3110000u, 37u}, // ryu -> Kana
+ {0x73610000u, 17u}, // sa -> Deva
+ {0x94120000u, 44u}, // saf -> Latn
+ {0x9C120000u, 16u}, // sah -> Cyrl
+ {0xC0120000u, 44u}, // saq -> Latn
+ {0xC8120000u, 44u}, // sas -> Latn
+ {0xCC120000u, 44u}, // sat -> Latn
+ {0xD4120000u, 44u}, // sav -> Latn
+ {0xE4120000u, 72u}, // saz -> Saur
+ {0x80320000u, 44u}, // sba -> Latn
+ {0x90320000u, 44u}, // sbe -> Latn
+ {0xBC320000u, 44u}, // sbp -> Latn
+ {0x73630000u, 44u}, // sc -> Latn
+ {0xA8520000u, 17u}, // sck -> Deva
{0xAC520000u, 1u}, // scl -> Arab
- {0xB4520000u, 40u}, // scn -> Latn
- {0xB8520000u, 40u}, // sco -> Latn
- {0xC8520000u, 40u}, // scs -> Latn
+ {0xB4520000u, 44u}, // scn -> Latn
+ {0xB8520000u, 44u}, // sco -> Latn
+ {0xC8520000u, 44u}, // scs -> Latn
{0x73640000u, 1u}, // sd -> Arab
- {0x88720000u, 40u}, // sdc -> Latn
+ {0x88720000u, 44u}, // sdc -> Latn
{0x9C720000u, 1u}, // sdh -> Arab
- {0x73650000u, 40u}, // se -> Latn
- {0x94920000u, 40u}, // sef -> Latn
- {0x9C920000u, 40u}, // seh -> Latn
- {0xA0920000u, 40u}, // sei -> Latn
- {0xC8920000u, 40u}, // ses -> Latn
- {0x73670000u, 40u}, // sg -> Latn
- {0x80D20000u, 55u}, // sga -> Ogam
- {0xC8D20000u, 40u}, // sgs -> Latn
- {0xD8D20000u, 18u}, // sgw -> Ethi
- {0xE4D20000u, 40u}, // sgz -> Latn
- {0x73680000u, 40u}, // sh -> Latn
- {0xA0F20000u, 78u}, // shi -> Tfng
- {0xA8F20000u, 40u}, // shk -> Latn
- {0xB4F20000u, 52u}, // shn -> Mymr
+ {0x73650000u, 44u}, // se -> Latn
+ {0x94920000u, 44u}, // sef -> Latn
+ {0x9C920000u, 44u}, // seh -> Latn
+ {0xA0920000u, 44u}, // sei -> Latn
+ {0xC8920000u, 44u}, // ses -> Latn
+ {0x73670000u, 44u}, // sg -> Latn
+ {0x80D20000u, 60u}, // sga -> Ogam
+ {0xC8D20000u, 44u}, // sgs -> Latn
+ {0xD8D20000u, 19u}, // sgw -> Ethi
+ {0xE4D20000u, 44u}, // sgz -> Latn
+ {0x73680000u, 44u}, // sh -> Latn
+ {0xA0F20000u, 85u}, // shi -> Tfng
+ {0xA8F20000u, 44u}, // shk -> Latn
+ {0xB4F20000u, 56u}, // shn -> Mymr
{0xD0F20000u, 1u}, // shu -> Arab
- {0x73690000u, 69u}, // si -> Sinh
- {0x8D120000u, 40u}, // sid -> Latn
- {0x99120000u, 40u}, // sig -> Latn
- {0xAD120000u, 40u}, // sil -> Latn
- {0xB1120000u, 40u}, // sim -> Latn
- {0xC5320000u, 40u}, // sjr -> Latn
- {0x736B0000u, 40u}, // sk -> Latn
- {0x89520000u, 40u}, // skc -> Latn
+ {0x73690000u, 74u}, // si -> Sinh
+ {0x8D120000u, 44u}, // sid -> Latn
+ {0x99120000u, 44u}, // sig -> Latn
+ {0xAD120000u, 44u}, // sil -> Latn
+ {0xB1120000u, 44u}, // sim -> Latn
+ {0xC5320000u, 44u}, // sjr -> Latn
+ {0x736B0000u, 44u}, // sk -> Latn
+ {0x89520000u, 44u}, // skc -> Latn
{0xC5520000u, 1u}, // skr -> Arab
- {0xC9520000u, 40u}, // sks -> Latn
- {0x736C0000u, 40u}, // sl -> Latn
- {0x8D720000u, 40u}, // sld -> Latn
- {0xA1720000u, 40u}, // sli -> Latn
- {0xAD720000u, 40u}, // sll -> Latn
- {0xE1720000u, 40u}, // sly -> Latn
- {0x736D0000u, 40u}, // sm -> Latn
- {0x81920000u, 40u}, // sma -> Latn
- {0xA5920000u, 40u}, // smj -> Latn
- {0xB5920000u, 40u}, // smn -> Latn
- {0xBD920000u, 65u}, // smp -> Samr
- {0xC1920000u, 40u}, // smq -> Latn
- {0xC9920000u, 40u}, // sms -> Latn
- {0x736E0000u, 40u}, // sn -> Latn
- {0x89B20000u, 40u}, // snc -> Latn
- {0xA9B20000u, 40u}, // snk -> Latn
- {0xBDB20000u, 40u}, // snp -> Latn
- {0xDDB20000u, 40u}, // snx -> Latn
- {0xE1B20000u, 40u}, // sny -> Latn
- {0x736F0000u, 40u}, // so -> Latn
- {0xA9D20000u, 40u}, // sok -> Latn
- {0xC1D20000u, 40u}, // soq -> Latn
- {0xD1D20000u, 80u}, // sou -> Thai
- {0xE1D20000u, 40u}, // soy -> Latn
- {0x8DF20000u, 40u}, // spd -> Latn
- {0xADF20000u, 40u}, // spl -> Latn
- {0xC9F20000u, 40u}, // sps -> Latn
- {0x73710000u, 40u}, // sq -> Latn
- {0x73720000u, 15u}, // sr -> Cyrl
- {0x73724D45u, 40u}, // sr-ME -> Latn
- {0x7372524Fu, 40u}, // sr-RO -> Latn
- {0x73725255u, 40u}, // sr-RU -> Latn
- {0x73725452u, 40u}, // sr-TR -> Latn
- {0x86320000u, 70u}, // srb -> Sora
- {0xB6320000u, 40u}, // srn -> Latn
- {0xC6320000u, 40u}, // srr -> Latn
- {0xDE320000u, 16u}, // srx -> Deva
- {0x73730000u, 40u}, // ss -> Latn
- {0x8E520000u, 40u}, // ssd -> Latn
- {0x9A520000u, 40u}, // ssg -> Latn
- {0xE2520000u, 40u}, // ssy -> Latn
- {0x73740000u, 40u}, // st -> Latn
- {0xAA720000u, 40u}, // stk -> Latn
- {0xC2720000u, 40u}, // stq -> Latn
- {0x73750000u, 40u}, // su -> Latn
- {0x82920000u, 40u}, // sua -> Latn
- {0x92920000u, 40u}, // sue -> Latn
- {0xAA920000u, 40u}, // suk -> Latn
- {0xC6920000u, 40u}, // sur -> Latn
- {0xCA920000u, 40u}, // sus -> Latn
- {0x73760000u, 40u}, // sv -> Latn
- {0x73770000u, 40u}, // sw -> Latn
+ {0xC9520000u, 44u}, // sks -> Latn
+ {0x736C0000u, 44u}, // sl -> Latn
+ {0x8D720000u, 44u}, // sld -> Latn
+ {0xA1720000u, 44u}, // sli -> Latn
+ {0xAD720000u, 44u}, // sll -> Latn
+ {0xE1720000u, 44u}, // sly -> Latn
+ {0x736D0000u, 44u}, // sm -> Latn
+ {0x81920000u, 44u}, // sma -> Latn
+ {0xA5920000u, 44u}, // smj -> Latn
+ {0xB5920000u, 44u}, // smn -> Latn
+ {0xBD920000u, 70u}, // smp -> Samr
+ {0xC1920000u, 44u}, // smq -> Latn
+ {0xC9920000u, 44u}, // sms -> Latn
+ {0x736E0000u, 44u}, // sn -> Latn
+ {0x89B20000u, 44u}, // snc -> Latn
+ {0xA9B20000u, 44u}, // snk -> Latn
+ {0xBDB20000u, 44u}, // snp -> Latn
+ {0xDDB20000u, 44u}, // snx -> Latn
+ {0xE1B20000u, 44u}, // sny -> Latn
+ {0x736F0000u, 44u}, // so -> Latn
+ {0x99D20000u, 75u}, // sog -> Sogd
+ {0xA9D20000u, 44u}, // sok -> Latn
+ {0xC1D20000u, 44u}, // soq -> Latn
+ {0xD1D20000u, 87u}, // sou -> Thai
+ {0xE1D20000u, 44u}, // soy -> Latn
+ {0x8DF20000u, 44u}, // spd -> Latn
+ {0xADF20000u, 44u}, // spl -> Latn
+ {0xC9F20000u, 44u}, // sps -> Latn
+ {0x73710000u, 44u}, // sq -> Latn
+ {0x73720000u, 16u}, // sr -> Cyrl
+ {0x73724D45u, 44u}, // sr-ME -> Latn
+ {0x7372524Fu, 44u}, // sr-RO -> Latn
+ {0x73725255u, 44u}, // sr-RU -> Latn
+ {0x73725452u, 44u}, // sr-TR -> Latn
+ {0x86320000u, 76u}, // srb -> Sora
+ {0xB6320000u, 44u}, // srn -> Latn
+ {0xC6320000u, 44u}, // srr -> Latn
+ {0xDE320000u, 17u}, // srx -> Deva
+ {0x73730000u, 44u}, // ss -> Latn
+ {0x8E520000u, 44u}, // ssd -> Latn
+ {0x9A520000u, 44u}, // ssg -> Latn
+ {0xE2520000u, 44u}, // ssy -> Latn
+ {0x73740000u, 44u}, // st -> Latn
+ {0xAA720000u, 44u}, // stk -> Latn
+ {0xC2720000u, 44u}, // stq -> Latn
+ {0x73750000u, 44u}, // su -> Latn
+ {0x82920000u, 44u}, // sua -> Latn
+ {0x92920000u, 44u}, // sue -> Latn
+ {0xAA920000u, 44u}, // suk -> Latn
+ {0xC6920000u, 44u}, // sur -> Latn
+ {0xCA920000u, 44u}, // sus -> Latn
+ {0x73760000u, 44u}, // sv -> Latn
+ {0x73770000u, 44u}, // sw -> Latn
{0x86D20000u, 1u}, // swb -> Arab
- {0x8AD20000u, 40u}, // swc -> Latn
- {0x9AD20000u, 40u}, // swg -> Latn
- {0xBED20000u, 40u}, // swp -> Latn
- {0xD6D20000u, 16u}, // swv -> Deva
- {0xB6F20000u, 40u}, // sxn -> Latn
- {0xDAF20000u, 40u}, // sxw -> Latn
+ {0x8AD20000u, 44u}, // swc -> Latn
+ {0x9AD20000u, 44u}, // swg -> Latn
+ {0xBED20000u, 44u}, // swp -> Latn
+ {0xD6D20000u, 17u}, // swv -> Deva
+ {0xB6F20000u, 44u}, // sxn -> Latn
+ {0xDAF20000u, 44u}, // sxw -> Latn
{0xAF120000u, 7u}, // syl -> Beng
- {0xC7120000u, 71u}, // syr -> Syrc
- {0xAF320000u, 40u}, // szl -> Latn
- {0x74610000u, 74u}, // ta -> Taml
- {0xA4130000u, 16u}, // taj -> Deva
- {0xAC130000u, 40u}, // tal -> Latn
- {0xB4130000u, 40u}, // tan -> Latn
- {0xC0130000u, 40u}, // taq -> Latn
- {0x88330000u, 40u}, // tbc -> Latn
- {0x8C330000u, 40u}, // tbd -> Latn
- {0x94330000u, 40u}, // tbf -> Latn
- {0x98330000u, 40u}, // tbg -> Latn
- {0xB8330000u, 40u}, // tbo -> Latn
- {0xD8330000u, 40u}, // tbw -> Latn
- {0xE4330000u, 40u}, // tbz -> Latn
- {0xA0530000u, 40u}, // tci -> Latn
- {0xE0530000u, 36u}, // tcy -> Knda
- {0x8C730000u, 72u}, // tdd -> Tale
- {0x98730000u, 16u}, // tdg -> Deva
- {0x9C730000u, 16u}, // tdh -> Deva
- {0x74650000u, 77u}, // te -> Telu
- {0x8C930000u, 40u}, // ted -> Latn
- {0xB0930000u, 40u}, // tem -> Latn
- {0xB8930000u, 40u}, // teo -> Latn
- {0xCC930000u, 40u}, // tet -> Latn
- {0xA0B30000u, 40u}, // tfi -> Latn
- {0x74670000u, 15u}, // tg -> Cyrl
+ {0xC7120000u, 78u}, // syr -> Syrc
+ {0xAF320000u, 44u}, // szl -> Latn
+ {0x74610000u, 81u}, // ta -> Taml
+ {0xA4130000u, 17u}, // taj -> Deva
+ {0xAC130000u, 44u}, // tal -> Latn
+ {0xB4130000u, 44u}, // tan -> Latn
+ {0xC0130000u, 44u}, // taq -> Latn
+ {0x88330000u, 44u}, // tbc -> Latn
+ {0x8C330000u, 44u}, // tbd -> Latn
+ {0x94330000u, 44u}, // tbf -> Latn
+ {0x98330000u, 44u}, // tbg -> Latn
+ {0xB8330000u, 44u}, // tbo -> Latn
+ {0xD8330000u, 44u}, // tbw -> Latn
+ {0xE4330000u, 44u}, // tbz -> Latn
+ {0xA0530000u, 44u}, // tci -> Latn
+ {0xE0530000u, 40u}, // tcy -> Knda
+ {0x8C730000u, 79u}, // tdd -> Tale
+ {0x98730000u, 17u}, // tdg -> Deva
+ {0x9C730000u, 17u}, // tdh -> Deva
+ {0x74650000u, 84u}, // te -> Telu
+ {0x8C930000u, 44u}, // ted -> Latn
+ {0xB0930000u, 44u}, // tem -> Latn
+ {0xB8930000u, 44u}, // teo -> Latn
+ {0xCC930000u, 44u}, // tet -> Latn
+ {0xA0B30000u, 44u}, // tfi -> Latn
+ {0x74670000u, 16u}, // tg -> Cyrl
{0x7467504Bu, 1u}, // tg-PK -> Arab
- {0x88D30000u, 40u}, // tgc -> Latn
- {0xB8D30000u, 40u}, // tgo -> Latn
- {0xD0D30000u, 40u}, // tgu -> Latn
- {0x74680000u, 80u}, // th -> Thai
- {0xACF30000u, 16u}, // thl -> Deva
- {0xC0F30000u, 16u}, // thq -> Deva
- {0xC4F30000u, 16u}, // thr -> Deva
- {0x74690000u, 18u}, // ti -> Ethi
- {0x95130000u, 40u}, // tif -> Latn
- {0x99130000u, 18u}, // tig -> Ethi
- {0xA9130000u, 40u}, // tik -> Latn
- {0xB1130000u, 40u}, // tim -> Latn
- {0xB9130000u, 40u}, // tio -> Latn
- {0xD5130000u, 40u}, // tiv -> Latn
- {0x746B0000u, 40u}, // tk -> Latn
- {0xAD530000u, 40u}, // tkl -> Latn
- {0xC5530000u, 40u}, // tkr -> Latn
- {0xCD530000u, 16u}, // tkt -> Deva
- {0x746C0000u, 40u}, // tl -> Latn
- {0x95730000u, 40u}, // tlf -> Latn
- {0xDD730000u, 40u}, // tlx -> Latn
- {0xE1730000u, 40u}, // tly -> Latn
- {0x9D930000u, 40u}, // tmh -> Latn
- {0xE1930000u, 40u}, // tmy -> Latn
- {0x746E0000u, 40u}, // tn -> Latn
- {0x9DB30000u, 40u}, // tnh -> Latn
- {0x746F0000u, 40u}, // to -> Latn
- {0x95D30000u, 40u}, // tof -> Latn
- {0x99D30000u, 40u}, // tog -> Latn
- {0xC1D30000u, 40u}, // toq -> Latn
- {0xA1F30000u, 40u}, // tpi -> Latn
- {0xB1F30000u, 40u}, // tpm -> Latn
- {0xE5F30000u, 40u}, // tpz -> Latn
- {0xBA130000u, 40u}, // tqo -> Latn
- {0x74720000u, 40u}, // tr -> Latn
- {0xD2330000u, 40u}, // tru -> Latn
- {0xD6330000u, 40u}, // trv -> Latn
+ {0x88D30000u, 44u}, // tgc -> Latn
+ {0xB8D30000u, 44u}, // tgo -> Latn
+ {0xD0D30000u, 44u}, // tgu -> Latn
+ {0x74680000u, 87u}, // th -> Thai
+ {0xACF30000u, 17u}, // thl -> Deva
+ {0xC0F30000u, 17u}, // thq -> Deva
+ {0xC4F30000u, 17u}, // thr -> Deva
+ {0x74690000u, 19u}, // ti -> Ethi
+ {0x95130000u, 44u}, // tif -> Latn
+ {0x99130000u, 19u}, // tig -> Ethi
+ {0xA9130000u, 44u}, // tik -> Latn
+ {0xB1130000u, 44u}, // tim -> Latn
+ {0xB9130000u, 44u}, // tio -> Latn
+ {0xD5130000u, 44u}, // tiv -> Latn
+ {0x746B0000u, 44u}, // tk -> Latn
+ {0xAD530000u, 44u}, // tkl -> Latn
+ {0xC5530000u, 44u}, // tkr -> Latn
+ {0xCD530000u, 17u}, // tkt -> Deva
+ {0x746C0000u, 44u}, // tl -> Latn
+ {0x95730000u, 44u}, // tlf -> Latn
+ {0xDD730000u, 44u}, // tlx -> Latn
+ {0xE1730000u, 44u}, // tly -> Latn
+ {0x9D930000u, 44u}, // tmh -> Latn
+ {0xE1930000u, 44u}, // tmy -> Latn
+ {0x746E0000u, 44u}, // tn -> Latn
+ {0x9DB30000u, 44u}, // tnh -> Latn
+ {0x746F0000u, 44u}, // to -> Latn
+ {0x95D30000u, 44u}, // tof -> Latn
+ {0x99D30000u, 44u}, // tog -> Latn
+ {0xC1D30000u, 44u}, // toq -> Latn
+ {0xA1F30000u, 44u}, // tpi -> Latn
+ {0xB1F30000u, 44u}, // tpm -> Latn
+ {0xE5F30000u, 44u}, // tpz -> Latn
+ {0xBA130000u, 44u}, // tqo -> Latn
+ {0x74720000u, 44u}, // tr -> Latn
+ {0xD2330000u, 44u}, // tru -> Latn
+ {0xD6330000u, 44u}, // trv -> Latn
{0xDA330000u, 1u}, // trw -> Arab
- {0x74730000u, 40u}, // ts -> Latn
- {0x8E530000u, 21u}, // tsd -> Grek
- {0x96530000u, 16u}, // tsf -> Deva
- {0x9A530000u, 40u}, // tsg -> Latn
- {0xA6530000u, 81u}, // tsj -> Tibt
- {0xDA530000u, 40u}, // tsw -> Latn
- {0x74740000u, 15u}, // tt -> Cyrl
- {0x8E730000u, 40u}, // ttd -> Latn
- {0x92730000u, 40u}, // tte -> Latn
- {0xA6730000u, 40u}, // ttj -> Latn
- {0xC6730000u, 40u}, // ttr -> Latn
- {0xCA730000u, 80u}, // tts -> Thai
- {0xCE730000u, 40u}, // ttt -> Latn
- {0x9E930000u, 40u}, // tuh -> Latn
- {0xAE930000u, 40u}, // tul -> Latn
- {0xB2930000u, 40u}, // tum -> Latn
- {0xC2930000u, 40u}, // tuq -> Latn
- {0x8EB30000u, 40u}, // tvd -> Latn
- {0xAEB30000u, 40u}, // tvl -> Latn
- {0xD2B30000u, 40u}, // tvu -> Latn
- {0x9ED30000u, 40u}, // twh -> Latn
- {0xC2D30000u, 40u}, // twq -> Latn
- {0x9AF30000u, 75u}, // txg -> Tang
- {0x74790000u, 40u}, // ty -> Latn
- {0x83130000u, 40u}, // tya -> Latn
- {0xD7130000u, 15u}, // tyv -> Cyrl
- {0xB3330000u, 40u}, // tzm -> Latn
- {0xD0340000u, 40u}, // ubu -> Latn
- {0xB0740000u, 15u}, // udm -> Cyrl
+ {0x74730000u, 44u}, // ts -> Latn
+ {0x8E530000u, 24u}, // tsd -> Grek
+ {0x96530000u, 17u}, // tsf -> Deva
+ {0x9A530000u, 44u}, // tsg -> Latn
+ {0xA6530000u, 88u}, // tsj -> Tibt
+ {0xDA530000u, 44u}, // tsw -> Latn
+ {0x74740000u, 16u}, // tt -> Cyrl
+ {0x8E730000u, 44u}, // ttd -> Latn
+ {0x92730000u, 44u}, // tte -> Latn
+ {0xA6730000u, 44u}, // ttj -> Latn
+ {0xC6730000u, 44u}, // ttr -> Latn
+ {0xCA730000u, 87u}, // tts -> Thai
+ {0xCE730000u, 44u}, // ttt -> Latn
+ {0x9E930000u, 44u}, // tuh -> Latn
+ {0xAE930000u, 44u}, // tul -> Latn
+ {0xB2930000u, 44u}, // tum -> Latn
+ {0xC2930000u, 44u}, // tuq -> Latn
+ {0x8EB30000u, 44u}, // tvd -> Latn
+ {0xAEB30000u, 44u}, // tvl -> Latn
+ {0xD2B30000u, 44u}, // tvu -> Latn
+ {0x9ED30000u, 44u}, // twh -> Latn
+ {0xC2D30000u, 44u}, // twq -> Latn
+ {0x9AF30000u, 82u}, // txg -> Tang
+ {0x74790000u, 44u}, // ty -> Latn
+ {0x83130000u, 44u}, // tya -> Latn
+ {0xD7130000u, 16u}, // tyv -> Cyrl
+ {0xB3330000u, 44u}, // tzm -> Latn
+ {0xD0340000u, 44u}, // ubu -> Latn
+ {0xB0740000u, 16u}, // udm -> Cyrl
{0x75670000u, 1u}, // ug -> Arab
- {0x75674B5Au, 15u}, // ug-KZ -> Cyrl
- {0x75674D4Eu, 15u}, // ug-MN -> Cyrl
- {0x80D40000u, 82u}, // uga -> Ugar
- {0x756B0000u, 15u}, // uk -> Cyrl
- {0xA1740000u, 40u}, // uli -> Latn
- {0x85940000u, 40u}, // umb -> Latn
+ {0x75674B5Au, 16u}, // ug-KZ -> Cyrl
+ {0x75674D4Eu, 16u}, // ug-MN -> Cyrl
+ {0x80D40000u, 89u}, // uga -> Ugar
+ {0x756B0000u, 16u}, // uk -> Cyrl
+ {0xA1740000u, 44u}, // uli -> Latn
+ {0x85940000u, 44u}, // umb -> Latn
{0xC5B40000u, 7u}, // unr -> Beng
- {0xC5B44E50u, 16u}, // unr-NP -> Deva
+ {0xC5B44E50u, 17u}, // unr-NP -> Deva
{0xDDB40000u, 7u}, // unx -> Beng
{0x75720000u, 1u}, // ur -> Arab
- {0xA2340000u, 40u}, // uri -> Latn
- {0xCE340000u, 40u}, // urt -> Latn
- {0xDA340000u, 40u}, // urw -> Latn
- {0x82540000u, 40u}, // usa -> Latn
- {0xC6740000u, 40u}, // utr -> Latn
- {0x9EB40000u, 40u}, // uvh -> Latn
- {0xAEB40000u, 40u}, // uvl -> Latn
- {0x757A0000u, 40u}, // uz -> Latn
+ {0xA2340000u, 44u}, // uri -> Latn
+ {0xCE340000u, 44u}, // urt -> Latn
+ {0xDA340000u, 44u}, // urw -> Latn
+ {0x82540000u, 44u}, // usa -> Latn
+ {0xC6740000u, 44u}, // utr -> Latn
+ {0x9EB40000u, 44u}, // uvh -> Latn
+ {0xAEB40000u, 44u}, // uvl -> Latn
+ {0x757A0000u, 44u}, // uz -> Latn
{0x757A4146u, 1u}, // uz-AF -> Arab
- {0x757A434Eu, 15u}, // uz-CN -> Cyrl
- {0x98150000u, 40u}, // vag -> Latn
- {0xA0150000u, 83u}, // vai -> Vaii
- {0xB4150000u, 40u}, // van -> Latn
- {0x76650000u, 40u}, // ve -> Latn
- {0x88950000u, 40u}, // vec -> Latn
- {0xBC950000u, 40u}, // vep -> Latn
- {0x76690000u, 40u}, // vi -> Latn
- {0x89150000u, 40u}, // vic -> Latn
- {0xD5150000u, 40u}, // viv -> Latn
- {0xC9750000u, 40u}, // vls -> Latn
- {0x95950000u, 40u}, // vmf -> Latn
- {0xD9950000u, 40u}, // vmw -> Latn
- {0x766F0000u, 40u}, // vo -> Latn
- {0xCDD50000u, 40u}, // vot -> Latn
- {0xBA350000u, 40u}, // vro -> Latn
- {0xB6950000u, 40u}, // vun -> Latn
- {0xCE950000u, 40u}, // vut -> Latn
- {0x77610000u, 40u}, // wa -> Latn
- {0x90160000u, 40u}, // wae -> Latn
- {0xA4160000u, 40u}, // waj -> Latn
- {0xAC160000u, 18u}, // wal -> Ethi
- {0xB4160000u, 40u}, // wan -> Latn
- {0xC4160000u, 40u}, // war -> Latn
- {0xBC360000u, 40u}, // wbp -> Latn
- {0xC0360000u, 77u}, // wbq -> Telu
- {0xC4360000u, 16u}, // wbr -> Deva
- {0xA0560000u, 40u}, // wci -> Latn
- {0xC4960000u, 40u}, // wer -> Latn
- {0xA0D60000u, 40u}, // wgi -> Latn
- {0x98F60000u, 40u}, // whg -> Latn
- {0x85160000u, 40u}, // wib -> Latn
- {0xD1160000u, 40u}, // wiu -> Latn
- {0xD5160000u, 40u}, // wiv -> Latn
- {0x81360000u, 40u}, // wja -> Latn
- {0xA1360000u, 40u}, // wji -> Latn
- {0xC9760000u, 40u}, // wls -> Latn
- {0xB9960000u, 40u}, // wmo -> Latn
- {0x89B60000u, 40u}, // wnc -> Latn
+ {0x757A434Eu, 16u}, // uz-CN -> Cyrl
+ {0x98150000u, 44u}, // vag -> Latn
+ {0xA0150000u, 90u}, // vai -> Vaii
+ {0xB4150000u, 44u}, // van -> Latn
+ {0x76650000u, 44u}, // ve -> Latn
+ {0x88950000u, 44u}, // vec -> Latn
+ {0xBC950000u, 44u}, // vep -> Latn
+ {0x76690000u, 44u}, // vi -> Latn
+ {0x89150000u, 44u}, // vic -> Latn
+ {0xD5150000u, 44u}, // viv -> Latn
+ {0xC9750000u, 44u}, // vls -> Latn
+ {0x95950000u, 44u}, // vmf -> Latn
+ {0xD9950000u, 44u}, // vmw -> Latn
+ {0x766F0000u, 44u}, // vo -> Latn
+ {0xCDD50000u, 44u}, // vot -> Latn
+ {0xBA350000u, 44u}, // vro -> Latn
+ {0xB6950000u, 44u}, // vun -> Latn
+ {0xCE950000u, 44u}, // vut -> Latn
+ {0x77610000u, 44u}, // wa -> Latn
+ {0x90160000u, 44u}, // wae -> Latn
+ {0xA4160000u, 44u}, // waj -> Latn
+ {0xAC160000u, 19u}, // wal -> Ethi
+ {0xB4160000u, 44u}, // wan -> Latn
+ {0xC4160000u, 44u}, // war -> Latn
+ {0xBC360000u, 44u}, // wbp -> Latn
+ {0xC0360000u, 84u}, // wbq -> Telu
+ {0xC4360000u, 17u}, // wbr -> Deva
+ {0xA0560000u, 44u}, // wci -> Latn
+ {0xC4960000u, 44u}, // wer -> Latn
+ {0xA0D60000u, 44u}, // wgi -> Latn
+ {0x98F60000u, 44u}, // whg -> Latn
+ {0x85160000u, 44u}, // wib -> Latn
+ {0xD1160000u, 44u}, // wiu -> Latn
+ {0xD5160000u, 44u}, // wiv -> Latn
+ {0x81360000u, 44u}, // wja -> Latn
+ {0xA1360000u, 44u}, // wji -> Latn
+ {0xC9760000u, 44u}, // wls -> Latn
+ {0xB9960000u, 44u}, // wmo -> Latn
+ {0x89B60000u, 44u}, // wnc -> Latn
{0xA1B60000u, 1u}, // wni -> Arab
- {0xD1B60000u, 40u}, // wnu -> Latn
- {0x776F0000u, 40u}, // wo -> Latn
- {0x85D60000u, 40u}, // wob -> Latn
- {0xC9D60000u, 40u}, // wos -> Latn
- {0xCA360000u, 40u}, // wrs -> Latn
- {0xAA560000u, 40u}, // wsk -> Latn
- {0xB2760000u, 16u}, // wtm -> Deva
- {0xD2960000u, 24u}, // wuu -> Hans
- {0xD6960000u, 40u}, // wuv -> Latn
- {0x82D60000u, 40u}, // wwa -> Latn
- {0xD4170000u, 40u}, // xav -> Latn
- {0xA0370000u, 40u}, // xbi -> Latn
- {0xC4570000u, 10u}, // xcr -> Cari
- {0xC8970000u, 40u}, // xes -> Latn
- {0x78680000u, 40u}, // xh -> Latn
- {0x81770000u, 40u}, // xla -> Latn
- {0x89770000u, 44u}, // xlc -> Lyci
- {0x8D770000u, 45u}, // xld -> Lydi
- {0x95970000u, 19u}, // xmf -> Geor
- {0xB5970000u, 47u}, // xmn -> Mani
- {0xC5970000u, 48u}, // xmr -> Merc
- {0x81B70000u, 53u}, // xna -> Narb
- {0xC5B70000u, 16u}, // xnr -> Deva
- {0x99D70000u, 40u}, // xog -> Latn
- {0xB5D70000u, 40u}, // xon -> Latn
- {0xC5F70000u, 63u}, // xpr -> Prti
- {0x86370000u, 40u}, // xrb -> Latn
- {0x82570000u, 66u}, // xsa -> Sarb
- {0xA2570000u, 40u}, // xsi -> Latn
- {0xB2570000u, 40u}, // xsm -> Latn
- {0xC6570000u, 16u}, // xsr -> Deva
- {0x92D70000u, 40u}, // xwe -> Latn
- {0xB0180000u, 40u}, // yam -> Latn
- {0xB8180000u, 40u}, // yao -> Latn
- {0xBC180000u, 40u}, // yap -> Latn
- {0xC8180000u, 40u}, // yas -> Latn
- {0xCC180000u, 40u}, // yat -> Latn
- {0xD4180000u, 40u}, // yav -> Latn
- {0xE0180000u, 40u}, // yay -> Latn
- {0xE4180000u, 40u}, // yaz -> Latn
- {0x80380000u, 40u}, // yba -> Latn
- {0x84380000u, 40u}, // ybb -> Latn
- {0xE0380000u, 40u}, // yby -> Latn
- {0xC4980000u, 40u}, // yer -> Latn
- {0xC4D80000u, 40u}, // ygr -> Latn
- {0xD8D80000u, 40u}, // ygw -> Latn
- {0x79690000u, 27u}, // yi -> Hebr
- {0xB9580000u, 40u}, // yko -> Latn
- {0x91780000u, 40u}, // yle -> Latn
- {0x99780000u, 40u}, // ylg -> Latn
- {0xAD780000u, 40u}, // yll -> Latn
- {0xAD980000u, 40u}, // yml -> Latn
- {0x796F0000u, 40u}, // yo -> Latn
- {0xB5D80000u, 40u}, // yon -> Latn
- {0x86380000u, 40u}, // yrb -> Latn
- {0x92380000u, 40u}, // yre -> Latn
- {0xAE380000u, 40u}, // yrl -> Latn
- {0xCA580000u, 40u}, // yss -> Latn
- {0x82980000u, 40u}, // yua -> Latn
- {0x92980000u, 25u}, // yue -> Hant
- {0x9298434Eu, 24u}, // yue-CN -> Hans
- {0xA6980000u, 40u}, // yuj -> Latn
- {0xCE980000u, 40u}, // yut -> Latn
- {0xDA980000u, 40u}, // yuw -> Latn
- {0x7A610000u, 40u}, // za -> Latn
- {0x98190000u, 40u}, // zag -> Latn
+ {0xD1B60000u, 44u}, // wnu -> Latn
+ {0x776F0000u, 44u}, // wo -> Latn
+ {0x85D60000u, 44u}, // wob -> Latn
+ {0xC9D60000u, 44u}, // wos -> Latn
+ {0xCA360000u, 44u}, // wrs -> Latn
+ {0x9A560000u, 21u}, // wsg -> Gong
+ {0xAA560000u, 44u}, // wsk -> Latn
+ {0xB2760000u, 17u}, // wtm -> Deva
+ {0xD2960000u, 27u}, // wuu -> Hans
+ {0xD6960000u, 44u}, // wuv -> Latn
+ {0x82D60000u, 44u}, // wwa -> Latn
+ {0xD4170000u, 44u}, // xav -> Latn
+ {0xA0370000u, 44u}, // xbi -> Latn
+ {0xC4570000u, 11u}, // xcr -> Cari
+ {0xC8970000u, 44u}, // xes -> Latn
+ {0x78680000u, 44u}, // xh -> Latn
+ {0x81770000u, 44u}, // xla -> Latn
+ {0x89770000u, 48u}, // xlc -> Lyci
+ {0x8D770000u, 49u}, // xld -> Lydi
+ {0x95970000u, 20u}, // xmf -> Geor
+ {0xB5970000u, 51u}, // xmn -> Mani
+ {0xC5970000u, 52u}, // xmr -> Merc
+ {0x81B70000u, 57u}, // xna -> Narb
+ {0xC5B70000u, 17u}, // xnr -> Deva
+ {0x99D70000u, 44u}, // xog -> Latn
+ {0xB5D70000u, 44u}, // xon -> Latn
+ {0xC5F70000u, 68u}, // xpr -> Prti
+ {0x86370000u, 44u}, // xrb -> Latn
+ {0x82570000u, 71u}, // xsa -> Sarb
+ {0xA2570000u, 44u}, // xsi -> Latn
+ {0xB2570000u, 44u}, // xsm -> Latn
+ {0xC6570000u, 17u}, // xsr -> Deva
+ {0x92D70000u, 44u}, // xwe -> Latn
+ {0xB0180000u, 44u}, // yam -> Latn
+ {0xB8180000u, 44u}, // yao -> Latn
+ {0xBC180000u, 44u}, // yap -> Latn
+ {0xC8180000u, 44u}, // yas -> Latn
+ {0xCC180000u, 44u}, // yat -> Latn
+ {0xD4180000u, 44u}, // yav -> Latn
+ {0xE0180000u, 44u}, // yay -> Latn
+ {0xE4180000u, 44u}, // yaz -> Latn
+ {0x80380000u, 44u}, // yba -> Latn
+ {0x84380000u, 44u}, // ybb -> Latn
+ {0xE0380000u, 44u}, // yby -> Latn
+ {0xC4980000u, 44u}, // yer -> Latn
+ {0xC4D80000u, 44u}, // ygr -> Latn
+ {0xD8D80000u, 44u}, // ygw -> Latn
+ {0x79690000u, 30u}, // yi -> Hebr
+ {0xB9580000u, 44u}, // yko -> Latn
+ {0x91780000u, 44u}, // yle -> Latn
+ {0x99780000u, 44u}, // ylg -> Latn
+ {0xAD780000u, 44u}, // yll -> Latn
+ {0xAD980000u, 44u}, // yml -> Latn
+ {0x796F0000u, 44u}, // yo -> Latn
+ {0xB5D80000u, 44u}, // yon -> Latn
+ {0x86380000u, 44u}, // yrb -> Latn
+ {0x92380000u, 44u}, // yre -> Latn
+ {0xAE380000u, 44u}, // yrl -> Latn
+ {0xCA580000u, 44u}, // yss -> Latn
+ {0x82980000u, 44u}, // yua -> Latn
+ {0x92980000u, 28u}, // yue -> Hant
+ {0x9298434Eu, 27u}, // yue-CN -> Hans
+ {0xA6980000u, 44u}, // yuj -> Latn
+ {0xCE980000u, 44u}, // yut -> Latn
+ {0xDA980000u, 44u}, // yuw -> Latn
+ {0x7A610000u, 44u}, // za -> Latn
+ {0x98190000u, 44u}, // zag -> Latn
{0xA4790000u, 1u}, // zdj -> Arab
- {0x80990000u, 40u}, // zea -> Latn
- {0x9CD90000u, 78u}, // zgh -> Tfng
- {0x7A680000u, 24u}, // zh -> Hans
- {0x7A684155u, 25u}, // zh-AU -> Hant
- {0x7A68424Eu, 25u}, // zh-BN -> Hant
- {0x7A684742u, 25u}, // zh-GB -> Hant
- {0x7A684746u, 25u}, // zh-GF -> Hant
- {0x7A68484Bu, 25u}, // zh-HK -> Hant
- {0x7A684944u, 25u}, // zh-ID -> Hant
- {0x7A684D4Fu, 25u}, // zh-MO -> Hant
- {0x7A684D59u, 25u}, // zh-MY -> Hant
- {0x7A685041u, 25u}, // zh-PA -> Hant
- {0x7A685046u, 25u}, // zh-PF -> Hant
- {0x7A685048u, 25u}, // zh-PH -> Hant
- {0x7A685352u, 25u}, // zh-SR -> Hant
- {0x7A685448u, 25u}, // zh-TH -> Hant
- {0x7A685457u, 25u}, // zh-TW -> Hant
- {0x7A685553u, 25u}, // zh-US -> Hant
- {0x7A68564Eu, 25u}, // zh-VN -> Hant
- {0x81190000u, 40u}, // zia -> Latn
- {0xB1790000u, 40u}, // zlm -> Latn
- {0xA1990000u, 40u}, // zmi -> Latn
- {0x91B90000u, 40u}, // zne -> Latn
- {0x7A750000u, 40u}, // zu -> Latn
- {0x83390000u, 40u}, // zza -> Latn
+ {0x80990000u, 44u}, // zea -> Latn
+ {0x9CD90000u, 85u}, // zgh -> Tfng
+ {0x7A680000u, 27u}, // zh -> Hans
+ {0x7A684155u, 28u}, // zh-AU -> Hant
+ {0x7A68424Eu, 28u}, // zh-BN -> Hant
+ {0x7A684742u, 28u}, // zh-GB -> Hant
+ {0x7A684746u, 28u}, // zh-GF -> Hant
+ {0x7A68484Bu, 28u}, // zh-HK -> Hant
+ {0x7A684944u, 28u}, // zh-ID -> Hant
+ {0x7A684D4Fu, 28u}, // zh-MO -> Hant
+ {0x7A684D59u, 28u}, // zh-MY -> Hant
+ {0x7A685041u, 28u}, // zh-PA -> Hant
+ {0x7A685046u, 28u}, // zh-PF -> Hant
+ {0x7A685048u, 28u}, // zh-PH -> Hant
+ {0x7A685352u, 28u}, // zh-SR -> Hant
+ {0x7A685448u, 28u}, // zh-TH -> Hant
+ {0x7A685457u, 28u}, // zh-TW -> Hant
+ {0x7A685553u, 28u}, // zh-US -> Hant
+ {0x7A68564Eu, 28u}, // zh-VN -> Hant
+ {0xDCF90000u, 59u}, // zhx -> Nshu
+ {0x81190000u, 44u}, // zia -> Latn
+ {0xB1790000u, 44u}, // zlm -> Latn
+ {0xA1990000u, 44u}, // zmi -> Latn
+ {0x91B90000u, 44u}, // zne -> Latn
+ {0x7A750000u, 44u}, // zu -> Latn
+ {0x83390000u, 44u}, // zza -> Latn
});
std::unordered_set<uint64_t> REPRESENTATIVE_LOCALES({
@@ -1517,6 +1544,7 @@
0xB5014E474C61746ELLU, // bin_Latn_NG
0xA521494E44657661LLU, // bjj_Deva_IN
0xB52149444C61746ELLU, // bjn_Latn_ID
+ 0xCD21534E4C61746ELLU, // bjt_Latn_SN
0xB141434D4C61746ELLU, // bkm_Latn_CM
0xD14150484C61746ELLU, // bku_Latn_PH
0xCD61564E54617674LLU, // blt_Tavt_VN
@@ -1546,7 +1574,6 @@
0x93214D4C4C61746ELLU, // bze_Latn_ML
0x636145534C61746ELLU, // ca_Latn_ES
0x9C424E474C61746ELLU, // cch_Latn_NG
- 0xBC42494E42656E67LLU, // ccp_Beng_IN
0xBC42424443616B6DLLU, // ccp_Cakm_BD
0x636552554379726CLLU, // ce_Cyrl_RU
0x848250484C61746ELLU, // ceb_Latn_PH
@@ -1560,10 +1587,12 @@
0x81224B4841726162LLU, // cja_Arab_KH
0xB122564E4368616DLLU, // cjm_Cham_VN
0x8542495141726162LLU, // ckb_Arab_IQ
+ 0x99824D4E536F796FLLU, // cmg_Soyo_MN
0x636F46524C61746ELLU, // co_Latn_FR
0xBDC24547436F7074LLU, // cop_Copt_EG
0xC9E250484C61746ELLU, // cps_Latn_PH
0x6372434143616E73LLU, // cr_Cans_CA
+ 0x9E2255414379726CLLU, // crh_Cyrl_UA
0xA622434143616E73LLU, // crj_Cans_CA
0xAA22434143616E73LLU, // crk_Cans_CA
0xAE22434143616E73LLU, // crl_Cans_CA
@@ -1610,6 +1639,7 @@
0x657345534C61746ELLU, // es_Latn_ES
0x65734D584C61746ELLU, // es_Latn_MX
0x657355534C61746ELLU, // es_Latn_US
+ 0x9A44494E476F6E6DLLU, // esg_Gonm_IN
0xD24455534C61746ELLU, // esu_Latn_US
0x657445454C61746ELLU, // et_Latn_EE
0xCE6449544974616CLLU, // ett_Ital_IT
@@ -1700,10 +1730,10 @@
0x687548554C61746ELLU, // hu_Latn_HU
0x6879414D41726D6ELLU, // hy_Armn_AM
0x687A4E414C61746ELLU, // hz_Latn_NA
- 0x696146524C61746ELLU, // ia_Latn_FR
0x80284D594C61746ELLU, // iba_Latn_MY
0x84284E474C61746ELLU, // ibb_Latn_NG
0x696449444C61746ELLU, // id_Latn_ID
+ 0x90A854474C61746ELLU, // ife_Latn_TG
0x69674E474C61746ELLU, // ig_Latn_NG
0x6969434E59696969LLU, // ii_Yiii_CN
0x696B55534C61746ELLU, // ik_Latn_US
@@ -1764,6 +1794,7 @@
0x6B6D4B484B686D72LLU, // km_Khmr_KH
0x858A414F4C61746ELLU, // kmb_Latn_AO
0x6B6E494E4B6E6461LLU, // kn_Knda_IN
+ 0x95AA47574C61746ELLU, // knf_Latn_GW
0x6B6F4B524B6F7265LLU, // ko_Kore_KR
0xA1CA52554379726CLLU, // koi_Cyrl_RU
0xA9CA494E44657661LLU, // kok_Deva_IN
@@ -1854,6 +1885,7 @@
0x6D694E5A4C61746ELLU, // mi_Latn_NZ
0xB50C49444C61746ELLU, // min_Latn_ID
0xC90C495148617472LLU, // mis_Hatr_IQ
+ 0xC90C4E474D656466LLU, // mis_Medf_NG
0x6D6B4D4B4379726CLLU, // mk_Cyrl_MK
0x6D6C494E4D6C796DLLU, // ml_Mlym_IN
0xC96C53444C61746ELLU, // mls_Latn_SD
@@ -1877,6 +1909,7 @@
0xAACC4D4C4C61746ELLU, // mwk_Latn_ML
0xC6CC494E44657661LLU, // mwr_Deva_IN
0xD6CC49444C61746ELLU, // mwv_Latn_ID
+ 0xDACC5553486D6E70LLU, // mww_Hmnp_US
0x8AEC5A574C61746ELLU, // mxc_Latn_ZW
0x6D794D4D4D796D72LLU, // my_Mymr_MM
0xD70C52554379726CLLU, // myv_Cyrl_RU
@@ -1905,6 +1938,7 @@
0x998D434D4C61746ELLU, // nmg_Latn_CM
0x6E6E4E4F4C61746ELLU, // nn_Latn_NO
0x9DAD434D4C61746ELLU, // nnh_Latn_CM
+ 0xBDAD494E5763686FLLU, // nnp_Wcho_IN
0x6E6F4E4F4C61746ELLU, // no_Latn_NO
0x8DCD54484C616E61LLU, // nod_Lana_TH
0x91CD494E44657661LLU, // noe_Deva_IN
@@ -1959,6 +1993,7 @@
0x945152454C61746ELLU, // rcf_Latn_RE
0xA49149444C61746ELLU, // rej_Latn_ID
0xB4D149544C61746ELLU, // rgn_Latn_IT
+ 0x98F14D4D41726162LLU, // rhg_Arab_MM
0x8111494E4C61746ELLU, // ria_Latn_IN
0x95114D4154666E67LLU, // rif_Tfng_MA
0xC9314E5044657661LLU, // rjs_Deva_NP
@@ -1986,6 +2021,7 @@
0xC0124B454C61746ELLU, // saq_Latn_KE
0xC81249444C61746ELLU, // sas_Latn_ID
0xCC12494E4C61746ELLU, // sat_Latn_IN
+ 0xD412534E4C61746ELLU, // sav_Latn_SN
0xE412494E53617572LLU, // saz_Saur_IN
0xBC32545A4C61746ELLU, // sbp_Latn_TZ
0x736349544C61746ELLU, // sc_Latn_IT
@@ -2025,6 +2061,7 @@
0x736E5A574C61746ELLU, // sn_Latn_ZW
0xA9B24D4C4C61746ELLU, // snk_Latn_ML
0x736F534F4C61746ELLU, // so_Latn_SO
+ 0x99D2555A536F6764LLU, // sog_Sogd_UZ
0xD1D2544854686169LLU, // sou_Thai_TH
0x7371414C4C61746ELLU, // sq_Latn_AL
0x737252534379726CLLU, // sr_Cyrl_RS
@@ -2135,6 +2172,7 @@
0xC97657464C61746ELLU, // wls_Latn_WF
0xA1B64B4D41726162LLU, // wni_Arab_KM
0x776F534E4C61746ELLU, // wo_Latn_SN
+ 0x9A56494E476F6E67LLU, // wsg_Gong_IN
0xB276494E44657661LLU, // wtm_Deva_IN
0xD296434E48616E73LLU, // wuu_Hans_CN
0xD41742524C61746ELLU, // xav_Latn_BR
@@ -2169,6 +2207,7 @@
0x7A68545748616E62LLU, // zh_Hanb_TW
0x7A68434E48616E73LLU, // zh_Hans_CN
0x7A68545748616E74LLU, // zh_Hant_TW
+ 0xDCF9434E4E736875LLU, // zhx_Nshu_CN
0xB17954474C61746ELLU, // zlm_Latn_TG
0xA1994D594C61746ELLU, // zmi_Latn_MY
0x7A755A414C61746ELLU, // zu_Latn_ZA
@@ -2194,7 +2233,7 @@
{0x656E4154u, 0x656E80A1u}, // en-AT -> en-150
{0x656E4155u, 0x656E8400u}, // en-AU -> en-001
{0x656E4242u, 0x656E8400u}, // en-BB -> en-001
- {0x656E4245u, 0x656E8400u}, // en-BE -> en-001
+ {0x656E4245u, 0x656E80A1u}, // en-BE -> en-150
{0x656E424Du, 0x656E8400u}, // en-BM -> en-001
{0x656E4253u, 0x656E8400u}, // en-BS -> en-001
{0x656E4257u, 0x656E8400u}, // en-BW -> en-001
@@ -2285,6 +2324,7 @@
{0x65734152u, 0x6573A424u}, // es-AR -> es-419
{0x6573424Fu, 0x6573A424u}, // es-BO -> es-419
{0x65734252u, 0x6573A424u}, // es-BR -> es-419
+ {0x6573425Au, 0x6573A424u}, // es-BZ -> es-419
{0x6573434Cu, 0x6573A424u}, // es-CL -> es-419
{0x6573434Fu, 0x6573A424u}, // es-CO -> es-419
{0x65734352u, 0x6573A424u}, // es-CR -> es-419
@@ -2315,6 +2355,10 @@
{0x7074544Cu, 0x70745054u}, // pt-TL -> pt-PT
});
+const std::unordered_map<uint32_t, uint32_t> ___B_PARENTS({
+ {0x61725842u, 0x61729420u}, // ar-XB -> ar-015
+});
+
const struct {
const char script[4];
const std::unordered_map<uint32_t, uint32_t>* map;
@@ -2322,6 +2366,7 @@
{{'A', 'r', 'a', 'b'}, &ARAB_PARENTS},
{{'H', 'a', 'n', 't'}, &HANT_PARENTS},
{{'L', 'a', 't', 'n'}, &LATN_PARENTS},
+ {{'~', '~', '~', 'B'}, &___B_PARENTS},
};
const size_t MAX_PARENT_DEPTH = 3;
diff --git a/libs/hwui/Android.bp b/libs/hwui/Android.bp
index f670cf9..d945fc4 100644
--- a/libs/hwui/Android.bp
+++ b/libs/hwui/Android.bp
@@ -176,6 +176,7 @@
"hwui/AnimatedImageThread.cpp",
"hwui/Bitmap.cpp",
"hwui/Canvas.cpp",
+ "hwui/ImageDecoder.cpp",
"hwui/MinikinSkia.cpp",
"hwui/MinikinUtils.cpp",
"hwui/PaintImpl.cpp",
diff --git a/libs/hwui/hwui/Bitmap.cpp b/libs/hwui/hwui/Bitmap.cpp
index 2ba6fbe..f4149b9 100644
--- a/libs/hwui/hwui/Bitmap.cpp
+++ b/libs/hwui/hwui/Bitmap.cpp
@@ -44,9 +44,7 @@
namespace android {
-// returns true if rowBytes * height can be represented by a positive int32_t value
-// and places that value in size.
-static bool computeAllocationSize(size_t rowBytes, int height, size_t* size) {
+bool Bitmap::computeAllocationSize(size_t rowBytes, int height, size_t* size) {
return 0 <= height && height <= std::numeric_limits<size_t>::max() &&
!__builtin_mul_overflow(rowBytes, (size_t)height, size) &&
*size <= std::numeric_limits<int32_t>::max();
@@ -66,7 +64,7 @@
// we must respect the rowBytes value already set on the bitmap instead of
// attempting to compute our own.
const size_t rowBytes = bitmap->rowBytes();
- if (!computeAllocationSize(rowBytes, bitmap->height(), &size)) {
+ if (!Bitmap::computeAllocationSize(rowBytes, bitmap->height(), &size)) {
return nullptr;
}
diff --git a/libs/hwui/hwui/Bitmap.h b/libs/hwui/hwui/Bitmap.h
index 00733c6..1cda046 100644
--- a/libs/hwui/hwui/Bitmap.h
+++ b/libs/hwui/hwui/Bitmap.h
@@ -138,6 +138,10 @@
return mPalette;
}
+ // returns true if rowBytes * height can be represented by a positive int32_t value
+ // and places that value in size.
+ static bool computeAllocationSize(size_t rowBytes, int height, size_t* size);
+
private:
static sk_sp<Bitmap> allocateAshmemBitmap(size_t size, const SkImageInfo& i, size_t rowBytes);
static sk_sp<Bitmap> allocateHeapBitmap(size_t size, const SkImageInfo& i, size_t rowBytes);
diff --git a/libs/hwui/hwui/ImageDecoder.cpp b/libs/hwui/hwui/ImageDecoder.cpp
new file mode 100644
index 0000000..4f2027d
--- /dev/null
+++ b/libs/hwui/hwui/ImageDecoder.cpp
@@ -0,0 +1,213 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#include "ImageDecoder.h"
+
+#include <hwui/Bitmap.h>
+
+#include <SkAndroidCodec.h>
+#include <SkCanvas.h>
+#include <SkPaint.h>
+
+using namespace android;
+
+ImageDecoder::ImageDecoder(std::unique_ptr<SkAndroidCodec> codec, sk_sp<SkPngChunkReader> peeker)
+ : mCodec(std::move(codec))
+ , mPeeker(std::move(peeker))
+ , mTargetSize(mCodec->getInfo().dimensions())
+ , mDecodeSize(mTargetSize)
+ , mOutColorType(mCodec->computeOutputColorType(kN32_SkColorType))
+ , mOutAlphaType(mCodec->getInfo().isOpaque() ?
+ kOpaque_SkAlphaType : kPremul_SkAlphaType)
+ , mOutColorSpace(mCodec->getInfo().refColorSpace())
+ , mSampleSize(1)
+{
+}
+
+bool ImageDecoder::setTargetSize(int width, int height) {
+ if (width <= 0 || height <= 0) {
+ return false;
+ }
+
+ auto info = SkImageInfo::Make(width, height, mOutColorType, mOutAlphaType);
+ size_t rowBytes = info.minRowBytes();
+ if (rowBytes == 0) {
+ // This would have overflowed.
+ return false;
+ }
+
+ size_t pixelMemorySize;
+ if (!Bitmap::computeAllocationSize(rowBytes, height, &pixelMemorySize)) {
+ return false;
+ }
+
+ if (mCropRect) {
+ if (mCropRect->right() > width || mCropRect->bottom() > height) {
+ return false;
+ }
+ }
+
+ SkISize targetSize = { width, height }, decodeSize = targetSize;
+ int sampleSize = mCodec->computeSampleSize(&decodeSize);
+
+ if (decodeSize != targetSize && mOutAlphaType == kUnpremul_SkAlphaType
+ && !mCodec->getInfo().isOpaque()) {
+ return false;
+ }
+
+ mTargetSize = targetSize;
+ mDecodeSize = decodeSize;
+ mSampleSize = sampleSize;
+ return true;
+}
+
+bool ImageDecoder::setCropRect(const SkIRect* crop) {
+ if (!crop) {
+ mCropRect.reset();
+ return true;
+ }
+
+ if (crop->left() >= crop->right() || crop->top() >= crop->bottom()) {
+ return false;
+ }
+
+ const auto& size = mTargetSize;
+ if (crop->left() < 0 || crop->top() < 0
+ || crop->right() > size.width() || crop->bottom() > size.height()) {
+ return false;
+ }
+
+ mCropRect.emplace(*crop);
+ return true;
+}
+
+bool ImageDecoder::setOutColorType(SkColorType colorType) {
+ switch (colorType) {
+ case kRGB_565_SkColorType:
+ if (!opaque()) {
+ return false;
+ }
+ break;
+ case kGray_8_SkColorType:
+ if (!gray()) {
+ return false;
+ }
+ mOutColorSpace = nullptr;
+ break;
+ case kN32_SkColorType:
+ break;
+ case kRGBA_F16_SkColorType:
+ break;
+ default:
+ return false;
+ }
+
+ mOutColorType = colorType;
+ return true;
+}
+
+bool ImageDecoder::setOutAlphaType(SkAlphaType alpha) {
+ switch (alpha) {
+ case kOpaque_SkAlphaType:
+ return opaque();
+ case kPremul_SkAlphaType:
+ if (opaque()) {
+ // Opaque can be treated as premul.
+ return true;
+ }
+ break;
+ case kUnpremul_SkAlphaType:
+ if (opaque()) {
+ // Opaque can be treated as unpremul.
+ return true;
+ }
+ if (mDecodeSize != mTargetSize) {
+ return false;
+ }
+ break;
+ default:
+ return false;
+ }
+ mOutAlphaType = alpha;
+ return true;
+}
+
+void ImageDecoder::setOutColorSpace(sk_sp<SkColorSpace> colorSpace) {
+ mOutColorSpace = std::move(colorSpace);
+}
+
+SkImageInfo ImageDecoder::getOutputInfo() const {
+ SkISize size = mCropRect ? mCropRect->size() : mTargetSize;
+ return SkImageInfo::Make(size, mOutColorType, mOutAlphaType, mOutColorSpace);
+}
+
+bool ImageDecoder::opaque() const {
+ return mOutAlphaType == kOpaque_SkAlphaType;
+}
+
+bool ImageDecoder::gray() const {
+ return mCodec->getInfo().colorType() == kGray_8_SkColorType;
+}
+
+SkCodec::Result ImageDecoder::decode(void* pixels, size_t rowBytes) {
+ void* decodePixels = pixels;
+ size_t decodeRowBytes = rowBytes;
+ auto decodeInfo = SkImageInfo::Make(mDecodeSize, mOutColorType, mOutAlphaType, mOutColorSpace);
+ // Used if we need a temporary before scaling or subsetting.
+ // FIXME: Use scanline decoding on only a couple lines to save memory. b/70709380.
+ SkBitmap tmp;
+ const bool scale = mDecodeSize != mTargetSize;
+ if (scale || mCropRect) {
+ if (!tmp.setInfo(decodeInfo)) {
+ return SkCodec::kInternalError;
+ }
+ if (!Bitmap::allocateHeapBitmap(&tmp)) {
+ return SkCodec::kInternalError;
+ }
+ decodePixels = tmp.getPixels();
+ decodeRowBytes = tmp.rowBytes();
+ }
+
+ SkAndroidCodec::AndroidOptions options;
+ options.fSampleSize = mSampleSize;
+ auto result = mCodec->getAndroidPixels(decodeInfo, decodePixels, decodeRowBytes, &options);
+
+ if (scale || mCropRect) {
+ SkBitmap scaledBm;
+ if (!scaledBm.installPixels(getOutputInfo(), pixels, rowBytes)) {
+ return SkCodec::kInternalError;
+ }
+
+ SkPaint paint;
+ paint.setBlendMode(SkBlendMode::kSrc);
+ paint.setFilterQuality(kLow_SkFilterQuality); // bilinear filtering
+
+ SkCanvas canvas(scaledBm, SkCanvas::ColorBehavior::kLegacy);
+ if (mCropRect) {
+ canvas.translate(-mCropRect->fLeft, -mCropRect->fTop);
+ }
+ if (scale) {
+ float scaleX = (float) mTargetSize.width() / mDecodeSize.width();
+ float scaleY = (float) mTargetSize.height() / mDecodeSize.height();
+ canvas.scale(scaleX, scaleY);
+ }
+
+ canvas.drawBitmap(tmp, 0.0f, 0.0f, &paint);
+ }
+
+ return result;
+}
+
diff --git a/libs/hwui/hwui/ImageDecoder.h b/libs/hwui/hwui/ImageDecoder.h
new file mode 100644
index 0000000..b956f4a
--- /dev/null
+++ b/libs/hwui/hwui/ImageDecoder.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+#pragma once
+
+#include <SkCodec.h>
+#include <SkImageInfo.h>
+#include <SkPngChunkReader.h>
+#include <SkRect.h>
+#include <SkSize.h>
+#include <cutils/compiler.h>
+
+#include <optional>
+
+class SkAndroidCodec;
+
+namespace android {
+
+class ANDROID_API ImageDecoder {
+public:
+ std::unique_ptr<SkAndroidCodec> mCodec;
+ sk_sp<SkPngChunkReader> mPeeker;
+
+ ImageDecoder(std::unique_ptr<SkAndroidCodec> codec,
+ sk_sp<SkPngChunkReader> peeker = nullptr);
+
+ bool setTargetSize(int width, int height);
+ bool setCropRect(const SkIRect*);
+
+ bool setOutColorType(SkColorType outColorType);
+
+ bool setOutAlphaType(SkAlphaType outAlphaType);
+
+ void setOutColorSpace(sk_sp<SkColorSpace> cs);
+
+ // The size is the final size after scaling and cropping.
+ SkImageInfo getOutputInfo() const;
+ SkColorType getOutColorType() const { return mOutColorType; }
+ SkAlphaType getOutAlphaType() const { return mOutAlphaType; }
+
+ bool opaque() const;
+ bool gray() const;
+
+ SkCodec::Result decode(void* pixels, size_t rowBytes);
+
+private:
+ SkISize mTargetSize;
+ SkISize mDecodeSize;
+ SkColorType mOutColorType;
+ SkAlphaType mOutAlphaType;
+ sk_sp<SkColorSpace> mOutColorSpace;
+ int mSampleSize;
+ std::optional<SkIRect> mCropRect;
+
+ ImageDecoder(const ImageDecoder&) = delete;
+ ImageDecoder& operator=(const ImageDecoder&) = delete;
+};
+
+} // namespace android
diff --git a/media/Android.bp b/media/Android.bp
index 1912930..4b50b7a 100644
--- a/media/Android.bp
+++ b/media/Android.bp
@@ -77,20 +77,13 @@
path: "apex/java"
}
-metalava_updatable_media_args = " --error UnhiddenSystemApi " +
- "--hide RequiresPermission " +
- "--hide MissingPermission --hide BroadcastBehavior " +
- "--hide HiddenSuperclass --hide DeprecationMismatch --hide UnavailableSymbol " +
- "--hide SdkConstant --hide HiddenTypeParameter --hide Todo --hide Typo " +
- "--hide HiddenTypedefConstant --show-annotation android.annotation.SystemApi "
-
droidstubs {
name: "updatable-media-stubs",
srcs: [
":updatable-media-srcs",
":framework-media-annotation-srcs",
],
- args: metalava_updatable_media_args,
+ defaults: [ "framework-module-stubs-defaults-systemapi" ],
aidl: {
// TODO(b/135922046) remove this
include_dirs: ["frameworks/base/core/java"],
diff --git a/media/apex/java/android/media/MediaParser.java b/media/apex/java/android/media/MediaParser.java
index b83f445..ac66d1b 100644
--- a/media/apex/java/android/media/MediaParser.java
+++ b/media/apex/java/android/media/MediaParser.java
@@ -102,7 +102,8 @@
* public void onSeekMap(int i, @NonNull MediaFormat mediaFormat) { \/* Do nothing. *\/ }
*
* \@Override
- * public void onFormat(int i, @NonNull MediaFormat mediaFormat) {
+ * public void onTrackData(int i, @NonNull TrackData trackData) {
+ * MediaFormat mediaFormat = trackData.mediaFormat;
* if (videoTrackIndex == -1 && mediaFormat
* .getString(MediaFormat.KEY_MIME, \/* defaultValue= *\/ "").startsWith("video/")) {
* videoTrackIndex = i;
@@ -200,6 +201,24 @@
}
}
+ /** Holds information associated with a track. */
+ public static final class TrackData {
+
+ /** Holds {@link MediaFormat} information for the track. */
+ @NonNull public final MediaFormat mediaFormat;
+
+ /**
+ * Holds {@link DrmInitData} necessary to acquire keys associated with the track, or null if
+ * the track has no encryption data.
+ */
+ @Nullable public final DrmInitData drmInitData;
+
+ private TrackData(MediaFormat mediaFormat, DrmInitData drmInitData) {
+ this.mediaFormat = mediaFormat;
+ this.drmInitData = drmInitData;
+ }
+ }
+
/** Defines a seek point in a media stream. */
public static final class SeekPoint {
@@ -308,12 +327,12 @@
void onTracksFound(int numberOfTracks);
/**
- * Called when the {@link MediaFormat} of the track is extracted from the stream.
+ * Called when new {@link TrackData} is extracted from the stream.
*
- * @param trackIndex The index of the track for which the {@link MediaFormat} was found.
- * @param format The extracted {@link MediaFormat}.
+ * @param trackIndex The index of the track for which the {@link TrackData} was extracted.
+ * @param trackData The extracted {@link TrackData}.
*/
- void onFormat(int trackIndex, @NonNull MediaFormat format);
+ void onTrackData(int trackIndex, @NonNull TrackData trackData);
/**
* Called to write sample data to the output.
@@ -674,7 +693,10 @@
@Override
public void format(Format format) {
- mOutputConsumer.onFormat(mTrackIndex, toMediaFormat(format));
+ mOutputConsumer.onTrackData(
+ mTrackIndex,
+ new TrackData(
+ toMediaFormat(format), toFrameworkDrmInitData(format.drmInitData)));
}
@Override
@@ -846,6 +868,12 @@
return 0;
}
+ private static DrmInitData toFrameworkDrmInitData(
+ com.google.android.exoplayer2.drm.DrmInitData drmInitData) {
+ // TODO: Implement.
+ return null;
+ }
+
private static MediaCodec.CryptoInfo toCryptoInfo(TrackOutput.CryptoData encryptionData) {
// TODO: Implement.
return null;
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index 066bf25..33ec46a 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -25,6 +25,7 @@
import android.content.pm.PackageManager;
import android.media.audiofx.AudioEffect;
import android.media.audiopolicy.AudioMix;
+import android.telephony.TelephonyManager;
import android.util.Log;
import java.lang.annotation.Retention;
@@ -902,6 +903,18 @@
}
}
+ /**
+ * Returns a human readable name for a given device type
+ * @param device a native device type, NOT an AudioDeviceInfo type
+ * @return a string describing the device type
+ */
+ public static @NonNull String getDeviceName(int device) {
+ if ((device & DEVICE_BIT_IN) != 0) {
+ return getInputDeviceName(device);
+ }
+ return getOutputDeviceName(device);
+ }
+
// phone state, match audio_mode???
public static final int PHONE_STATE_OFFCALL = 0;
public static final int PHONE_STATE_RINGING = 1;
@@ -1288,7 +1301,8 @@
* </ul>
*/
public static int getPlatformType(Context context) {
- if (context.getResources().getBoolean(com.android.internal.R.bool.config_voice_capable)) {
+ if (((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE))
+ .isVoiceCapable()) {
return PLATFORM_VOICE;
} else if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
return PLATFORM_TELEVISION;
diff --git a/media/java/android/media/session/ICallback.aidl b/media/java/android/media/session/ICallback.aidl
deleted file mode 100644
index 322bffa..0000000
--- a/media/java/android/media/session/ICallback.aidl
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (C) 2016 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 android.media.session;
-
-import android.app.PendingIntent;
-import android.content.ComponentName;
-import android.media.session.MediaSession;
-import android.view.KeyEvent;
-
-/**
- * @hide
- */
-oneway interface ICallback {
- void onMediaKeyEventDispatchedToMediaSession(in KeyEvent event,
- in MediaSession.Token sessionToken);
- void onMediaKeyEventDispatchedToMediaButtonReceiver(in KeyEvent event,
- in ComponentName mediaButtonReceiver);
-
- void onAddressedPlayerChangedToMediaSession(in MediaSession.Token sessionToken);
- void onAddressedPlayerChangedToMediaButtonReceiver(in ComponentName mediaButtonReceiver);
-}
-
diff --git a/media/java/android/media/session/IOnMediaKeyEventDispatchedListener.aidl b/media/java/android/media/session/IOnMediaKeyEventDispatchedListener.aidl
new file mode 100644
index 0000000..90d9134
--- /dev/null
+++ b/media/java/android/media/session/IOnMediaKeyEventDispatchedListener.aidl
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2019 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 android.media.session;
+
+import android.media.session.MediaSession;
+import android.view.KeyEvent;
+
+/**
+ * @hide
+ */
+oneway interface IOnMediaKeyEventDispatchedListener {
+ void onMediaKeyEventDispatched(in KeyEvent event, in String packageName,
+ in MediaSession.Token sessionToken);
+}
diff --git a/media/java/android/media/session/IOnMediaKeyEventSessionChangedListener.aidl b/media/java/android/media/session/IOnMediaKeyEventSessionChangedListener.aidl
new file mode 100644
index 0000000..9566e75
--- /dev/null
+++ b/media/java/android/media/session/IOnMediaKeyEventSessionChangedListener.aidl
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2019 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 android.media.session;
+
+import android.media.session.MediaSession;
+
+/**
+ * @hide
+ */
+oneway interface IOnMediaKeyEventSessionChangedListener {
+ void onMediaKeyEventSessionChanged(in String packageName,
+ in MediaSession.Token mediaKeyEventSessionToken);
+}
+
diff --git a/media/java/android/media/session/ISessionManager.aidl b/media/java/android/media/session/ISessionManager.aidl
index 01e6ed5..c8502a5 100644
--- a/media/java/android/media/session/ISessionManager.aidl
+++ b/media/java/android/media/session/ISessionManager.aidl
@@ -20,7 +20,8 @@
import android.media.IRemoteVolumeController;
import android.media.Session2Token;
import android.media.session.IActiveSessionsListener;
-import android.media.session.ICallback;
+import android.media.session.IOnMediaKeyEventDispatchedListener;
+import android.media.session.IOnMediaKeyEventSessionChangedListener;
import android.media.session.IOnMediaKeyListener;
import android.media.session.IOnVolumeKeyLongPressListener;
import android.media.session.ISession;
@@ -62,8 +63,12 @@
// For PhoneWindowManager to precheck media keys
boolean isGlobalPriorityActive();
- void registerCallback(in ICallback callback);
- void unregisterCallback(in ICallback callback);
+ void addOnMediaKeyEventDispatchedListener(in IOnMediaKeyEventDispatchedListener listener);
+ void removeOnMediaKeyEventDispatchedListener(in IOnMediaKeyEventDispatchedListener listener);
+ void addOnMediaKeyEventSessionChangedListener(
+ in IOnMediaKeyEventSessionChangedListener listener);
+ void removeOnMediaKeyEventSessionChangedListener(
+ in IOnMediaKeyEventSessionChangedListener listener);
void setOnVolumeKeyLongPressListener(in IOnVolumeKeyLongPressListener listener);
void setOnMediaKeyListener(in IOnMediaKeyListener listener);
diff --git a/media/java/android/media/session/MediaSessionManager.java b/media/java/android/media/session/MediaSessionManager.java
index 92fb31b..a89dc5f 100644
--- a/media/java/android/media/session/MediaSessionManager.java
+++ b/media/java/android/media/session/MediaSessionManager.java
@@ -32,7 +32,6 @@
import android.media.Session2Token;
import android.os.Bundle;
import android.os.Handler;
-import android.os.HandlerExecutor;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ResultReceiver;
@@ -78,29 +77,33 @@
*/
public static final int RESULT_MEDIA_KEY_HANDLED = 1;
private final ISessionManager mService;
+ private final OnMediaKeyEventDispatchedListenerStub mOnMediaKeyEventDispatchedListenerStub =
+ new OnMediaKeyEventDispatchedListenerStub();
+ private final OnMediaKeyEventSessionChangedListenerStub
+ mOnMediaKeyEventSessionChangedListenerStub =
+ new OnMediaKeyEventSessionChangedListenerStub();
private final Object mLock = new Object();
@GuardedBy("mLock")
- private final ArrayMap<OnActiveSessionsChangedListener, SessionsChangedWrapper> mListeners
- = new ArrayMap<OnActiveSessionsChangedListener, SessionsChangedWrapper>();
+ private final ArrayMap<OnActiveSessionsChangedListener, SessionsChangedWrapper> mListeners =
+ new ArrayMap<OnActiveSessionsChangedListener, SessionsChangedWrapper>();
@GuardedBy("mLock")
private final ArrayMap<OnSession2TokensChangedListener, Session2TokensChangedWrapper>
mSession2TokensListeners = new ArrayMap<>();
@GuardedBy("mLock")
- private final CallbackStub mCbStub = new CallbackStub();
+ private final Map<OnMediaKeyEventDispatchedListener, Executor>
+ mOnMediaKeyEventDispatchedListeners = new HashMap<>();
@GuardedBy("mLock")
- private final Map<Callback, Executor> mCallbacks = new HashMap<>();
+ private final Map<OnMediaKeyEventSessionChangedListener, Executor>
+ mMediaKeyEventSessionChangedCallbacks = new HashMap<>();
@GuardedBy("mLock")
- private MediaSession.Token mCurMediaButtonSession;
+ private String mCurMediaKeyEventSessionPackage;
@GuardedBy("mLock")
- private ComponentName mCurMediaButtonReceiver;
+ private MediaSession.Token mCurMediaKeyEventSession;
private Context mContext;
private OnVolumeKeyLongPressListenerImpl mOnVolumeKeyLongPressListener;
private OnMediaKeyListenerImpl mOnMediaKeyListener;
- // TODO: Remove mLegacyCallback once Bluetooth app stop calling setCallback() method.
- @GuardedBy("mLock")
- private Callback mLegacyCallback;
/**
* @hide
@@ -756,89 +759,118 @@
}
/**
- * Set a {@link Callback}.
- *
- * <p>System can only have a single callback, and the callback can only be set by
- * Bluetooth service process.
- *
- * @param callback A {@link Callback}. {@code null} to reset.
- * @param handler The handler on which the callback should be invoked, or {@code null}
- * if the callback should be invoked on the calling thread's looper.
- * @hide
- */
- // TODO: Remove this method once Bluetooth app stop calling it.
- public void setCallback(@Nullable Callback callback, @Nullable Handler handler) {
- if (handler == null) {
- handler = new Handler();
- }
- synchronized (mLock) {
- if (mLegacyCallback != null) {
- unregisterCallback(mLegacyCallback);
- }
- mLegacyCallback = callback;
- if (callback != null) {
- registerCallback(new HandlerExecutor(handler), callback);
- }
- }
- }
-
- /**
- * Register a {@link Callback}.
+ * Add a {@link OnMediaKeyEventDispatchedListener}.
*
* @param executor The executor on which the callback should be invoked
- * @param callback A {@link Callback}.
+ * @param listener A {@link OnMediaKeyEventDispatchedListener}.
* @hide
*/
@SystemApi
@RequiresPermission(value = android.Manifest.permission.MEDIA_CONTENT_CONTROL)
- public void registerCallback(@NonNull @CallbackExecutor Executor executor,
- @NonNull Callback callback) {
+ public void addOnMediaKeyEventDispatchedListener(
+ @NonNull @CallbackExecutor Executor executor,
+ @NonNull OnMediaKeyEventDispatchedListener listener) {
if (executor == null) {
throw new NullPointerException("executor shouldn't be null");
}
- if (callback == null) {
- throw new NullPointerException("callback shouldn't be null");
+ if (listener == null) {
+ throw new NullPointerException("listener shouldn't be null");
}
synchronized (mLock) {
try {
- mCallbacks.put(callback, executor);
- if (mCurMediaButtonSession != null) {
- executor.execute(
- () -> callback.onAddressedPlayerChanged(mCurMediaButtonSession));
- } else if (mCurMediaButtonReceiver != null) {
- executor.execute(
- () -> callback.onAddressedPlayerChanged(mCurMediaButtonReceiver));
- }
-
- if (mCallbacks.size() == 1) {
- mService.registerCallback(mCbStub);
+ mOnMediaKeyEventDispatchedListeners.put(listener, executor);
+ if (mOnMediaKeyEventDispatchedListeners.size() == 1) {
+ mService.addOnMediaKeyEventDispatchedListener(
+ mOnMediaKeyEventDispatchedListenerStub);
}
} catch (RemoteException e) {
- Log.e(TAG, "Failed to set media key callback", e);
+ Log.e(TAG, "Failed to set media key listener", e);
}
}
}
/**
- * Unregister a {@link Callback}.
+ * Remove a {@link OnMediaKeyEventDispatchedListener}.
*
- * @param callback A {@link Callback}.
+ * @param listener A {@link OnMediaKeyEventDispatchedListener}.
* @hide
*/
@SystemApi
@RequiresPermission(value = android.Manifest.permission.MEDIA_CONTENT_CONTROL)
- public void unregisterCallback(@NonNull Callback callback) {
- if (callback == null) {
- throw new NullPointerException("callback shouldn't be null");
+ public void removeOnMediaKeyEventDispatchedListener(
+ @NonNull OnMediaKeyEventDispatchedListener listener) {
+ if (listener == null) {
+ throw new NullPointerException("listener shouldn't be null");
}
synchronized (mLock) {
try {
- mCallbacks.remove(callback);
- if (mCallbacks.size() == 0) {
- mService.unregisterCallback(mCbStub);
+ mOnMediaKeyEventDispatchedListeners.remove(listener);
+ if (mOnMediaKeyEventDispatchedListeners.size() == 0) {
+ mService.removeOnMediaKeyEventDispatchedListener(
+ mOnMediaKeyEventDispatchedListenerStub);
}
} catch (RemoteException e) {
- Log.e(TAG, "Failed to set media key callback", e);
+ Log.e(TAG, "Failed to set media key event dispatched listener", e);
+ }
+ }
+ }
+
+ /**
+ * Add a {@link OnMediaKeyEventDispatchedListener}.
+ *
+ * @param executor The executor on which the callback should be invoked
+ * @param listener A {@link OnMediaKeyEventSessionChangedListener}.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(value = android.Manifest.permission.MEDIA_CONTENT_CONTROL)
+ public void addOnMediaKeyEventSessionChangedListener(
+ @NonNull @CallbackExecutor Executor executor,
+ @NonNull OnMediaKeyEventSessionChangedListener listener) {
+ if (executor == null) {
+ throw new NullPointerException("executor shouldn't be null");
+ }
+ if (listener == null) {
+ throw new NullPointerException("listener shouldn't be null");
+ }
+ synchronized (mLock) {
+ try {
+ mMediaKeyEventSessionChangedCallbacks.put(listener, executor);
+ executor.execute(
+ () -> listener.onMediaKeyEventSessionChanged(
+ mCurMediaKeyEventSessionPackage, mCurMediaKeyEventSession));
+ if (mMediaKeyEventSessionChangedCallbacks.size() == 1) {
+ mService.addOnMediaKeyEventSessionChangedListener(
+ mOnMediaKeyEventSessionChangedListenerStub);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to set media key listener", e);
+ }
+ }
+ }
+
+ /**
+ * Remove a {@link OnMediaKeyEventSessionChangedListener}.
+ *
+ * @param listener A {@link OnMediaKeyEventSessionChangedListener}.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(value = android.Manifest.permission.MEDIA_CONTENT_CONTROL)
+ public void removeOnMediaKeyEventSessionChangedListener(
+ @NonNull OnMediaKeyEventSessionChangedListener listener) {
+ if (listener == null) {
+ throw new NullPointerException("listener shouldn't be null");
+ }
+ synchronized (mLock) {
+ try {
+ mMediaKeyEventSessionChangedCallbacks.remove(listener);
+ if (mMediaKeyEventSessionChangedCallbacks.size() == 0) {
+ mService.removeOnMediaKeyEventSessionChangedListener(
+ mOnMediaKeyEventSessionChangedListenerStub);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to set media key listener", e);
}
}
}
@@ -900,54 +932,46 @@
}
/**
- * Callbacks for the media session service.
- *
- * <p>Called when a media key event is dispatched or the addressed player is changed.
- * The addressed player is either the media session or the media button receiver that will
- * receive media key events.
+ * Listener to receive when the media session service
* @hide
*/
@SystemApi
- public static abstract class Callback {
+ public interface OnMediaKeyEventDispatchedListener {
/**
- * Called when a media key event is dispatched to the media session
- * through the media session service.
+ * Called when a media key event is dispatched through the media session service. The
+ * session token can be {@link null} if the framework has sent the media key event to the
+ * media button receiver to revive the media app's playback.
+ *
+ * the session is dead when , but the framework sent
*
* @param event Dispatched media key event.
- * @param sessionToken The media session's token.
+ * @param packageName Package
+ * @param sessionToken The media session's token. Can be {@code null}.
*/
- public abstract void onMediaKeyEventDispatched(KeyEvent event,
- MediaSession.Token sessionToken);
+ default void onMediaKeyEventDispatched(@NonNull KeyEvent event, @NonNull String packageName,
+ @NonNull MediaSession.Token sessionToken) { }
+ }
+ /**
+ * Listener to receive changes in the media key event session, which would receive the media key
+ * event unless specified.
+ * @hide
+ */
+ @SystemApi
+ public interface OnMediaKeyEventSessionChangedListener {
/**
- * Called when a media key event is dispatched to the media button receiver
- * through the media session service.
- * <p>MediaSessionService may broadcast key events to the media button receiver
- * when reviving playback after the media session is released.
+ * Called when the media key session is changed to the given media session. The key event
+ * session is the media session which would receive key event by default, unless the caller
+ * has specified the target.
+ * <p>
+ * The session token can be {@link null} if the media button session is unset. In that case,
+ * framework would dispatch to the last sessions's media button receiver.
*
- * @param event Dispatched media key event.
- * @param mediaButtonReceiver The media button receiver.
+ * @param packageName The package name who would receive the media key event. Can be empty.
+ * @param sessionToken The media session's token. Can be {@code null.}
*/
- public abstract void onMediaKeyEventDispatched(KeyEvent event,
- ComponentName mediaButtonReceiver);
-
- /**
- * Called when the addressed player is changed to a media session.
- * <p>One of the {@ #onAddressedPlayerChanged} will be also called immediately after
- * {@link #registerCallback} if the addressed player exists.
- *
- * @param sessionToken The media session's token.
- */
- public abstract void onAddressedPlayerChanged(MediaSession.Token sessionToken);
-
- /**
- * Called when the addressed player is changed to the media button receiver.
- * <p>One of the {@ #onAddressedPlayerChanged} will be also called immediately after
- * {@link #registerCallback} if the addressed player exists.
- *
- * @param mediaButtonReceiver The media button receiver.
- */
- public abstract void onAddressedPlayerChanged(ComponentName mediaButtonReceiver);
+ default void onMediaKeyEventSessionChanged(@NonNull String packageName,
+ @Nullable MediaSession.Token sessionToken) { }
}
/**
@@ -1149,50 +1173,35 @@
}
}
- private final class CallbackStub extends ICallback.Stub {
+ private final class OnMediaKeyEventDispatchedListenerStub
+ extends IOnMediaKeyEventDispatchedListener.Stub {
@Override
- public void onMediaKeyEventDispatchedToMediaSession(KeyEvent event,
+ public void onMediaKeyEventDispatched(KeyEvent event, String packageName,
MediaSession.Token sessionToken) {
synchronized (mLock) {
- for (Map.Entry<Callback, Executor> e : mCallbacks.entrySet()) {
+ for (Map.Entry<OnMediaKeyEventDispatchedListener, Executor> e
+ : mOnMediaKeyEventDispatchedListeners.entrySet()) {
e.getValue().execute(
- () -> e.getKey().onMediaKeyEventDispatched(event, sessionToken));
+ () -> e.getKey().onMediaKeyEventDispatched(event, packageName,
+ sessionToken));
}
}
}
+ }
+ private final class OnMediaKeyEventSessionChangedListenerStub
+ extends IOnMediaKeyEventSessionChangedListener.Stub {
@Override
- public void onMediaKeyEventDispatchedToMediaButtonReceiver(KeyEvent event,
- ComponentName mediaButtonReceiver) {
+ public void onMediaKeyEventSessionChanged(String packageName,
+ MediaSession.Token sessionToken) {
synchronized (mLock) {
- for (Map.Entry<Callback, Executor> e : mCallbacks.entrySet()) {
- e.getValue().execute(
- () -> e.getKey().onMediaKeyEventDispatched(event, mediaButtonReceiver));
- }
- }
- }
-
- @Override
- public void onAddressedPlayerChangedToMediaSession(MediaSession.Token sessionToken) {
- synchronized (mLock) {
- mCurMediaButtonSession = sessionToken;
- mCurMediaButtonReceiver = null;
- for (Map.Entry<Callback, Executor> e : mCallbacks.entrySet()) {
- e.getValue().execute(() -> e.getKey().onAddressedPlayerChanged(sessionToken));
- }
- }
- }
-
- @Override
- public void onAddressedPlayerChangedToMediaButtonReceiver(
- ComponentName mediaButtonReceiver) {
- synchronized (mLock) {
- mCurMediaButtonSession = null;
- mCurMediaButtonReceiver = mediaButtonReceiver;
- for (Map.Entry<Callback, Executor> e : mCallbacks.entrySet()) {
- e.getValue().execute(() -> e.getKey().onAddressedPlayerChanged(
- mediaButtonReceiver));
+ mCurMediaKeyEventSessionPackage = packageName;
+ mCurMediaKeyEventSession = sessionToken;
+ for (Map.Entry<OnMediaKeyEventSessionChangedListener, Executor> e
+ : mMediaKeyEventSessionChangedCallbacks.entrySet()) {
+ e.getValue().execute(() -> e.getKey().onMediaKeyEventSessionChanged(packageName,
+ sessionToken));
}
}
}
diff --git a/media/java/android/media/soundtrigger/SoundTriggerManager.java b/media/java/android/media/soundtrigger/SoundTriggerManager.java
index dc400ad..61b3e76 100644
--- a/media/java/android/media/soundtrigger/SoundTriggerManager.java
+++ b/media/java/android/media/soundtrigger/SoundTriggerManager.java
@@ -26,9 +26,11 @@
import android.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.Context;
+import android.hardware.soundtrigger.ModelParams;
import android.hardware.soundtrigger.SoundTrigger;
import android.hardware.soundtrigger.SoundTrigger.GenericSoundModel;
import android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel;
+import android.hardware.soundtrigger.SoundTrigger.ModelParamRange;
import android.hardware.soundtrigger.SoundTrigger.RecognitionConfig;
import android.hardware.soundtrigger.SoundTrigger.SoundModel;
import android.os.Bundle;
@@ -67,7 +69,7 @@
/**
* @hide
*/
- public SoundTriggerManager(Context context, ISoundTriggerService soundTriggerService ) {
+ public SoundTriggerManager(Context context, ISoundTriggerService soundTriggerService) {
if (DBG) {
Slog.i(TAG, "SoundTriggerManager created.");
}
@@ -89,14 +91,22 @@
}
/**
- * Returns the sound trigger model represented by the given UUID. An instance of {@link Model}
- * is returned.
+ * Get {@link SoundTriggerManager.Model} which is registered with the passed UUID
+ *
+ * @param soundModelId UUID associated with a loaded model
+ * @return {@link SoundTriggerManager.Model} associated with UUID soundModelId
*/
@RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER)
+ @Nullable
public Model getModel(UUID soundModelId) {
try {
- return new Model(mSoundTriggerService.getSoundModel(
- new ParcelUuid(soundModelId)));
+ GenericSoundModel model =
+ mSoundTriggerService.getSoundModel(new ParcelUuid(soundModelId));
+ if (model == null) {
+ return null;
+ }
+
+ return new Model(model);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -399,4 +409,80 @@
throw e.rethrowFromSystemServer();
}
}
+
+ /**
+ * Set a model specific {@link ModelParams} with the given value. This
+ * parameter will keep its value for the duration the model is loaded regardless of starting and
+ * stopping recognition. Once the model is unloaded, the value will be lost.
+ * {@link SoundTriggerManager#queryParameter} should be checked first before calling this
+ * method.
+ *
+ * @param soundModelId UUID of model to apply the parameter value to.
+ * @param modelParam {@link ModelParams}
+ * @param value Value to set
+ * @return - {@link SoundTrigger#STATUS_OK} in case of success
+ * - {@link SoundTrigger#STATUS_NO_INIT} if the native service cannot be reached
+ * - {@link SoundTrigger#STATUS_BAD_VALUE} invalid input parameter
+ * - {@link SoundTrigger#STATUS_INVALID_OPERATION} if the call is out of sequence or
+ * if API is not supported by HAL
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER)
+ public int setParameter(@Nullable UUID soundModelId,
+ @ModelParams int modelParam, int value)
+ throws UnsupportedOperationException, IllegalArgumentException {
+ try {
+ return mSoundTriggerService.setParameter(new ParcelUuid(soundModelId), modelParam,
+ value);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Get a model specific {@link ModelParams}. This parameter will keep its value
+ * for the duration the model is loaded regardless of starting and stopping recognition.
+ * Once the model is unloaded, the value will be lost. If the value is not set, a default
+ * value is returned. See {@link ModelParams} for parameter default values.
+ * {@link SoundTriggerManager#queryParameter} should be checked first before
+ * calling this method. Otherwise, an exception can be thrown.
+ *
+ * @param soundModelId UUID of model to get parameter
+ * @param modelParam {@link ModelParams}
+ * @return value of parameter
+ * @throws UnsupportedOperationException if hal or model do not support this API.
+ * {@link SoundTriggerManager#queryParameter} should be checked first.
+ * @throws IllegalArgumentException if invalid model handle or parameter is passed.
+ * {@link SoundTriggerManager#queryParameter} should be checked first.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER)
+ public int getParameter(@NonNull UUID soundModelId,
+ @ModelParams int modelParam)
+ throws UnsupportedOperationException, IllegalArgumentException {
+ try {
+ return mSoundTriggerService.getParameter(new ParcelUuid(soundModelId), modelParam);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Determine if parameter control is supported for the given model handle.
+ * This method should be checked prior to calling {@link SoundTriggerManager#setParameter} or
+ * {@link SoundTriggerManager#getParameter}.
+ *
+ * @param soundModelId handle of model to get parameter
+ * @param modelParam {@link ModelParams}
+ * @return supported range of parameter, null if not supported
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER)
+ @Nullable
+ public ModelParamRange queryParameter(@Nullable UUID soundModelId,
+ @ModelParams int modelParam) {
+ try {
+ return mSoundTriggerService.queryParameter(new ParcelUuid(soundModelId),
+ modelParam);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
}
diff --git a/media/java/android/media/tv/ITvInputService.aidl b/media/java/android/media/tv/ITvInputService.aidl
old mode 100644
new mode 100755
index bd05184..f90c504
--- a/media/java/android/media/tv/ITvInputService.aidl
+++ b/media/java/android/media/tv/ITvInputService.aidl
@@ -38,4 +38,5 @@
void notifyHardwareRemoved(in TvInputHardwareInfo hardwareInfo);
void notifyHdmiDeviceAdded(in HdmiDeviceInfo deviceInfo);
void notifyHdmiDeviceRemoved(in HdmiDeviceInfo deviceInfo);
+ void notifyHdmiDeviceUpdated(in HdmiDeviceInfo deviceInfo);
}
diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java
old mode 100644
new mode 100755
index ff69779..5c11ed9b
--- a/media/java/android/media/tv/TvInputService.java
+++ b/media/java/android/media/tv/TvInputService.java
@@ -173,6 +173,12 @@
mServiceHandler.obtainMessage(ServiceHandler.DO_REMOVE_HDMI_INPUT,
deviceInfo).sendToTarget();
}
+
+ @Override
+ public void notifyHdmiDeviceUpdated(HdmiDeviceInfo deviceInfo) {
+ mServiceHandler.obtainMessage(ServiceHandler.DO_UPDATE_HDMI_INPUT,
+ deviceInfo).sendToTarget();
+ }
};
}
@@ -257,6 +263,24 @@
return null;
}
+ /**
+ * Called when {@code deviceInfo} is updated.
+ *
+ * <p>The changes are usually cuased by the corresponding HDMI-CEC logical device.
+ *
+ * <p>The default behavior ignores all changes.
+ *
+ * <p>The TV input service responsible for {@code deviceInfo} can update the {@link TvInputInfo}
+ * object based on the updated {@code deviceInfo} (e.g. update the label based on the preferred
+ * device OSD name).
+ *
+ * @param deviceInfo the updated {@link HdmiDeviceInfo} object.
+ * @hide
+ */
+ @SystemApi
+ public void onHdmiDeviceUpdated(@NonNull HdmiDeviceInfo deviceInfo) {
+ }
+
private boolean isPassthroughInput(String inputId) {
if (mTvInputManager == null) {
mTvInputManager = (TvInputManager) getSystemService(Context.TV_INPUT_SERVICE);
@@ -1962,6 +1986,7 @@
private static final int DO_REMOVE_HARDWARE_INPUT = 5;
private static final int DO_ADD_HDMI_INPUT = 6;
private static final int DO_REMOVE_HDMI_INPUT = 7;
+ private static final int DO_UPDATE_HDMI_INPUT = 8;
private void broadcastAddHardwareInput(int deviceId, TvInputInfo inputInfo) {
int n = mCallbacks.beginBroadcast();
@@ -2131,6 +2156,11 @@
}
return;
}
+ case DO_UPDATE_HDMI_INPUT: {
+ HdmiDeviceInfo deviceInfo = (HdmiDeviceInfo) msg.obj;
+ onHdmiDeviceUpdated(deviceInfo);
+ return;
+ }
default: {
Log.w(TAG, "Unhandled message code: " + msg.what);
return;
diff --git a/media/java/android/mtp/MtpDatabase.java b/media/java/android/mtp/MtpDatabase.java
index 16ba63b..0f402eb 100755
--- a/media/java/android/mtp/MtpDatabase.java
+++ b/media/java/android/mtp/MtpDatabase.java
@@ -577,7 +577,7 @@
try {
// note - we are relying on a special case in MediaProvider.update() to update
// the paths for all children in the case where this is a directory.
- final Uri objectsUri = MediaStore.Files.getMtpObjectsUri(obj.getVolumeName());
+ final Uri objectsUri = MediaStore.Files.getContentUri(obj.getVolumeName());
mMediaProvider.update(objectsUri, values, PATH_WHERE, whereArgs);
} catch (RemoteException e) {
Log.e(TAG, "RemoteException in mMediaProvider.update", e);
@@ -658,7 +658,7 @@
// Old parent exists in MediaProvider - perform a move
// note - we are relying on a special case in MediaProvider.update() to update
// the paths for all children in the case where this is a directory.
- final Uri objectsUri = MediaStore.Files.getMtpObjectsUri(obj.getVolumeName());
+ final Uri objectsUri = MediaStore.Files.getContentUri(obj.getVolumeName());
mMediaProvider.update(objectsUri, values, PATH_WHERE, whereArgs);
} else {
// Old parent doesn't exist - add the object
@@ -873,7 +873,7 @@
}
private int findInMedia(MtpStorageManager.MtpObject obj, Path path) {
- final Uri objectsUri = MediaStore.Files.getMtpObjectsUri(obj.getVolumeName());
+ final Uri objectsUri = MediaStore.Files.getContentUri(obj.getVolumeName());
int ret = -1;
Cursor c = null;
@@ -893,7 +893,7 @@
}
private void deleteFromMedia(MtpStorageManager.MtpObject obj, Path path, boolean isDir) {
- final Uri objectsUri = MediaStore.Files.getMtpObjectsUri(obj.getVolumeName());
+ final Uri objectsUri = MediaStore.Files.getContentUri(obj.getVolumeName());
try {
// Delete the object(s) from MediaProvider, but ignore errors.
if (isDir) {
@@ -921,71 +921,12 @@
@VisibleForNative
private int[] getObjectReferences(int handle) {
- MtpStorageManager.MtpObject obj = mManager.getObject(handle);
- if (obj == null)
- return null;
- // Translate this handle to the MediaProvider Handle
- handle = findInMedia(obj, obj.getPath());
- if (handle == -1)
- return null;
- Uri uri = Files.getMtpReferencesUri(obj.getVolumeName(), handle);
- Cursor c = null;
- try {
- c = mMediaProvider.query(uri, PATH_PROJECTION, null, null, null, null);
- if (c == null) {
- return null;
- }
- ArrayList<Integer> result = new ArrayList<>();
- while (c.moveToNext()) {
- // Translate result handles back into handles for this session.
- String refPath = c.getString(0);
- MtpStorageManager.MtpObject refObj = mManager.getByPath(refPath);
- if (refObj != null) {
- result.add(refObj.getId());
- }
- }
- return result.stream().mapToInt(Integer::intValue).toArray();
- } catch (RemoteException e) {
- Log.e(TAG, "RemoteException in getObjectList", e);
- } finally {
- if (c != null) {
- c.close();
- }
- }
return null;
}
@VisibleForNative
private int setObjectReferences(int handle, int[] references) {
- MtpStorageManager.MtpObject obj = mManager.getObject(handle);
- if (obj == null)
- return MtpConstants.RESPONSE_INVALID_OBJECT_HANDLE;
- // Translate this handle to the MediaProvider Handle
- handle = findInMedia(obj, obj.getPath());
- if (handle == -1)
- return MtpConstants.RESPONSE_GENERAL_ERROR;
- Uri uri = Files.getMtpReferencesUri(obj.getVolumeName(), handle);
- ArrayList<ContentValues> valuesList = new ArrayList<>();
- for (int id : references) {
- // Translate each reference id to the MediaProvider Id
- MtpStorageManager.MtpObject refObj = mManager.getObject(id);
- if (refObj == null)
- continue;
- int refHandle = findInMedia(refObj, refObj.getPath());
- if (refHandle == -1)
- continue;
- ContentValues values = new ContentValues();
- values.put(Files.FileColumns._ID, refHandle);
- valuesList.add(values);
- }
- try {
- if (mMediaProvider.bulkInsert(uri, valuesList.toArray(new ContentValues[0])) > 0) {
- return MtpConstants.RESPONSE_OK;
- }
- } catch (RemoteException e) {
- Log.e(TAG, "RemoteException in setObjectReferences", e);
- }
- return MtpConstants.RESPONSE_GENERAL_ERROR;
+ return MtpConstants.RESPONSE_OPERATION_NOT_SUPPORTED;
}
@VisibleForNative
diff --git a/media/jni/soundpool/StreamManager.cpp b/media/jni/soundpool/StreamManager.cpp
index c8f0ff1..79e4d8a 100644
--- a/media/jni/soundpool/StreamManager.cpp
+++ b/media/jni/soundpool/StreamManager.cpp
@@ -38,7 +38,7 @@
// kPlayOnCallingThread = true prior to R.
// Changing to false means calls to play() are almost instantaneous instead of taking around
// ~10ms to launch the AudioTrack. It is perhaps 100x faster.
-static constexpr bool kPlayOnCallingThread = false;
+static constexpr bool kPlayOnCallingThread = true;
// Amount of time for a StreamManager thread to wait before closing.
static constexpr int64_t kWaitTimeBeforeCloseNs = 9 * NANOS_PER_SECOND;
@@ -170,6 +170,7 @@
if (stream->getSoundID() == soundID) {
ALOGV("%s: found soundID %d in restart queue", __func__, soundID);
newStream = stream;
+ fromAvailableQueue = false;
break;
} else if (newStream == nullptr) {
ALOGV("%s: found stream in restart queue", __func__);
diff --git a/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java
index 08ab492..998d2b9 100644
--- a/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java
+++ b/packages/CarSystemUI/src/com/android/systemui/navigationbar/car/CarNavigationBar.java
@@ -278,6 +278,7 @@
leftlp.windowAnimations = 0;
leftlp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR;
leftlp.gravity = Gravity.LEFT;
+ leftlp.setFitWindowInsetsTypes(0 /* types */);
mWindowManager.addView(mLeftNavigationBarWindow, leftlp);
}
if (mRightNavigationBarWindow != null) {
@@ -295,6 +296,7 @@
rightlp.windowAnimations = 0;
rightlp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR;
rightlp.gravity = Gravity.RIGHT;
+ rightlp.setFitWindowInsetsTypes(0 /* types */);
mWindowManager.addView(mRightNavigationBarWindow, rightlp);
}
}
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
index 0d6701d..fbc03c0 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
@@ -563,7 +563,12 @@
mCarUxRestrictionManagerWrapper = new CarUxRestrictionManagerWrapper();
mNotificationDataManager = new NotificationDataManager();
- mNotificationDataManager.setOnUnseenCountUpdateListener(this::onUnseenCountUpdate);
+
+ mNotificationDataManager.setOnUnseenCountUpdateListener(() -> {
+ if (mNotificationDataManager != null) {
+ onUseenCountUpdate(mNotificationDataManager.getUnseenNotificationCount());
+ }
+ });
mEnableHeadsUpNotificationWhenNotificationShadeOpen = mContext.getResources().getBoolean(
R.bool.config_enableHeadsUpNotificationWhenNotificationShadeOpen);
@@ -685,15 +690,13 @@
}
/**
- * This method is called whenever there is an update to the number of unseen notifications.
- * This method can be extended by OEMs to customize the desired logic.
+ * This method is automatically called whenever there is an update to the number of unseen
+ * notifications. This method can be extended by OEMs to customize the desired logic.
*/
- protected void onUnseenCountUpdate() {
- if (mNotificationDataManager != null) {
- boolean hasUnseen = mNotificationDataManager.getUnseenNotificationCount() > 0;
- mCarNavigationBarController.toggleAllNotificationsUnseenIndicator(
- mDeviceProvisionedController.isCurrentUserSetup(), hasUnseen);
- }
+ protected void onUseenCountUpdate(int unseenNotificationCount) {
+ boolean hasUnseen = unseenNotificationCount > 0;
+ mCarNavigationBarController.toggleAllNotificationsUnseenIndicator(
+ mDeviceProvisionedController.isCurrentUserSetup(), hasUnseen);
}
/**
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java
index ec46433..2d57be1 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java
@@ -240,7 +240,7 @@
}
private WindowManager.LayoutParams createLayoutParams() {
- return new WindowManager.LayoutParams(
+ final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG,
@@ -249,6 +249,8 @@
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
PixelFormat.TRANSLUCENT
);
+ attrs.setFitWindowInsetsTypes(0 /* types */);
+ return attrs;
}
private void logd(String message) {
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
index 291cdd5..3d74868 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
@@ -131,10 +131,7 @@
private void showDialogForInitialUser() {
int initialUser = mCarUserManagerHelper.getInitialUser();
UserInfo initialUserInfo = mUserManager.getUserInfo(initialUser);
- mSelectedUser = new UserRecord(initialUserInfo,
- /* isStartGuestSession= */ false,
- /* isAddUser= */ false,
- /* isForeground= */ true);
+ mSelectedUser = new UserRecord(initialUserInfo, UserRecord.FOREGROUND_USER);
// If the initial user has screen lock and trusted device, display the unlock dialog on the
// keyguard.
@@ -180,12 +177,14 @@
*/
private void onUserSelected(UserGridRecyclerView.UserRecord record) {
mSelectedUser = record;
- if (hasScreenLock(record.mInfo.id) && hasTrustedDevice(record.mInfo.id)) {
- mUnlockDialogHelper.showUnlockDialog(record.mInfo.id, mOnHideListener);
- return;
- }
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "no trusted device enrolled for uid: " + record.mInfo.id);
+ if (record.mInfo != null) {
+ if (hasScreenLock(record.mInfo.id) && hasTrustedDevice(record.mInfo.id)) {
+ mUnlockDialogHelper.showUnlockDialog(record.mInfo.id, mOnHideListener);
+ return;
+ }
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "no trusted device enrolled for uid: " + record.mInfo.id);
+ }
}
dismissUserSwitcher();
}
@@ -195,7 +194,7 @@
Log.e(TAG, "Request to dismiss user switcher, but no user selected");
return;
}
- if (mSelectedUser.mIsForeground) {
+ if (mSelectedUser.mType == UserRecord.FOREGROUND_USER) {
hide();
mStatusBar.dismissKeyguard();
return;
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java
index 0a5f80f..cdabeeb 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/UserGridRecyclerView.java
@@ -21,6 +21,7 @@
import static android.os.UserManager.DISALLOW_ADD_USER;
import static android.os.UserManager.SWITCHABILITY_STATUS_OK;
+import android.annotation.IntDef;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.AlertDialog;
@@ -54,6 +55,8 @@
import com.android.systemui.R;
import com.android.systemui.statusbar.phone.SystemUIDialog;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@@ -142,8 +145,8 @@
}
boolean isForeground = fgUserId == userInfo.id;
- UserRecord record = new UserRecord(userInfo, false /* isStartGuestSession */,
- false /* isAddUser */, isForeground);
+ UserRecord record = new UserRecord(userInfo,
+ isForeground ? UserRecord.FOREGROUND_USER : UserRecord.BACKGROUND_USER);
userRecords.add(record);
}
@@ -160,27 +163,21 @@
private UserRecord createForegroundUserRecord() {
return new UserRecord(mUserManager.getUserInfo(ActivityManager.getCurrentUser()),
- false /* isStartGuestSession */, false /* isAddUser */, true /* isForeground */);
+ UserRecord.FOREGROUND_USER);
}
/**
* Create guest user record
*/
private UserRecord createStartGuestUserRecord() {
- UserInfo userInfo = new UserInfo();
- userInfo.name = mContext.getString(R.string.start_guest_session);
- return new UserRecord(userInfo, true /* isStartGuestSession */, false /* isAddUser */,
- false /* isForeground */);
+ return new UserRecord(null /* userInfo */, UserRecord.START_GUEST);
}
/**
* Create add user record
*/
private UserRecord createAddUserRecord() {
- UserInfo userInfo = new UserInfo();
- userInfo.name = mContext.getString(R.string.car_add_user);
- return new UserRecord(userInfo, false /* isStartGuestSession */,
- true /* isAddUser */, false /* isForeground */);
+ return new UserRecord(null /* userInfo */, UserRecord.ADD_USER);
}
public void setUserSelectionListener(UserSelectionListener userSelectionListener) {
@@ -258,35 +255,36 @@
UserRecord userRecord = mUsers.get(position);
RoundedBitmapDrawable circleIcon = getCircularUserRecordIcon(userRecord);
holder.mUserAvatarImageView.setImageDrawable(circleIcon);
- holder.mUserNameTextView.setText(userRecord.mInfo.name);
+ holder.mUserNameTextView.setText(getUserRecordName(userRecord));
holder.mView.setOnClickListener(v -> {
if (userRecord == null) {
return;
}
- if (userRecord.mIsStartGuestSession) {
- notifyUserSelected(userRecord);
- UserInfo guest = createNewOrFindExistingGuest(mContext);
- if (guest != null) {
- mCarUserManagerHelper.switchToUser(guest);
- }
- return;
- }
+ switch (userRecord.mType) {
+ case UserRecord.START_GUEST:
+ notifyUserSelected(userRecord);
+ UserInfo guest = createNewOrFindExistingGuest(mContext);
+ if (guest != null) {
+ mCarUserManagerHelper.switchToUser(guest);
+ }
+ break;
+ case UserRecord.ADD_USER:
+ // If the user wants to add a user, show dialog to confirm adding a user
+ // Disable button so it cannot be clicked multiple times
+ mAddUserView = holder.mView;
+ mAddUserView.setEnabled(false);
+ mAddUserRecord = userRecord;
- // If the user wants to add a user, show dialog to confirm adding a user
- if (userRecord.mIsAddUser) {
- // Disable button so it cannot be clicked multiple times
- mAddUserView = holder.mView;
- mAddUserView.setEnabled(false);
- mAddUserRecord = userRecord;
-
- handleAddUserClicked();
- return;
+ handleAddUserClicked();
+ break;
+ default:
+ // If the user doesn't want to be a guest or add a user, switch to the user
+ // selected
+ notifyUserSelected(userRecord);
+ mCarUserManagerHelper.switchToUser(userRecord.mInfo);
}
- // If the user doesn't want to be a guest or add a user, switch to the user selected
- notifyUserSelected(userRecord);
- mCarUserManagerHelper.switchToUser(userRecord.mInfo);
});
}
@@ -372,19 +370,44 @@
private RoundedBitmapDrawable getCircularUserRecordIcon(UserRecord userRecord) {
Resources resources = mContext.getResources();
RoundedBitmapDrawable circleIcon;
- if (userRecord.mIsStartGuestSession) {
- circleIcon = mUserIconProvider.getRoundedGuestDefaultIcon(resources);
- } else if (userRecord.mIsAddUser) {
- circleIcon = RoundedBitmapDrawableFactory.create(mRes, UserIcons.convertToBitmap(
- mContext.getDrawable(R.drawable.car_add_circle_round)));
- circleIcon.setCircular(true);
- } else {
- circleIcon = mUserIconProvider.getRoundedUserIcon(userRecord.mInfo, mContext);
+ switch (userRecord.mType) {
+ case UserRecord.START_GUEST:
+ circleIcon = mUserIconProvider.getRoundedGuestDefaultIcon(resources);
+ break;
+ case UserRecord.ADD_USER:
+ circleIcon = getCircularAddUserIcon();
+ break;
+ default:
+ circleIcon = mUserIconProvider.getRoundedUserIcon(userRecord.mInfo, mContext);
+ break;
}
-
return circleIcon;
}
+ private RoundedBitmapDrawable getCircularAddUserIcon() {
+ RoundedBitmapDrawable circleIcon =
+ RoundedBitmapDrawableFactory.create(mRes, UserIcons.convertToBitmap(
+ mContext.getDrawable(R.drawable.car_add_circle_round)));
+ circleIcon.setCircular(true);
+ return circleIcon;
+ }
+
+ private String getUserRecordName(UserRecord userRecord) {
+ String recordName;
+ switch (userRecord.mType) {
+ case UserRecord.START_GUEST:
+ recordName = mContext.getString(R.string.start_guest_session);
+ break;
+ case UserRecord.ADD_USER:
+ recordName = mContext.getString(R.string.car_add_user);
+ break;
+ default:
+ recordName = userRecord.mInfo.name;
+ break;
+ }
+ return recordName;
+ }
+
/**
* Finds the existing Guest user, or creates one if it doesn't exist.
* @param context App context
@@ -468,18 +491,21 @@
* guest profile, add user profile, or the foreground user.
*/
public static final class UserRecord {
-
public final UserInfo mInfo;
- public final boolean mIsStartGuestSession;
- public final boolean mIsAddUser;
- public final boolean mIsForeground;
+ public final @UserRecordType int mType;
- public UserRecord(UserInfo userInfo, boolean isStartGuestSession, boolean isAddUser,
- boolean isForeground) {
+ public static final int START_GUEST = 0;
+ public static final int ADD_USER = 1;
+ public static final int FOREGROUND_USER = 2;
+ public static final int BACKGROUND_USER = 3;
+
+ @IntDef({START_GUEST, ADD_USER, FOREGROUND_USER, BACKGROUND_USER})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface UserRecordType{}
+
+ public UserRecord(@Nullable UserInfo userInfo, @UserRecordType int recordType) {
mInfo = userInfo;
- mIsStartGuestSession = isStartGuestSession;
- mIsAddUser = isAddUser;
- mIsForeground = isForeground;
+ mType = recordType;
}
}
diff --git a/packages/CarrierDefaultApp/src/com/android/carrierdefaultapp/CarrierActionUtils.java b/packages/CarrierDefaultApp/src/com/android/carrierdefaultapp/CarrierActionUtils.java
index 3258d57..2697a10 100644
--- a/packages/CarrierDefaultApp/src/com/android/carrierdefaultapp/CarrierActionUtils.java
+++ b/packages/CarrierDefaultApp/src/com/android/carrierdefaultapp/CarrierActionUtils.java
@@ -29,6 +29,7 @@
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
+
import com.android.internal.telephony.PhoneConstants;
/**
@@ -138,7 +139,7 @@
SubscriptionManager.getDefaultVoiceSubscriptionId());
logd("onRegisterDefaultNetworkAvail subId: " + subId);
final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class);
- telephonyMgr.carrierActionReportDefaultNetworkStatus(subId, true);
+ telephonyMgr.createForSubscriptionId(subId).reportDefaultNetworkStatus(true);
}
private static void onDeregisterDefaultNetworkAvail(Intent intent, Context context) {
@@ -146,7 +147,7 @@
SubscriptionManager.getDefaultVoiceSubscriptionId());
logd("onDeregisterDefaultNetworkAvail subId: " + subId);
final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class);
- telephonyMgr.carrierActionReportDefaultNetworkStatus(subId, false);
+ telephonyMgr.createForSubscriptionId(subId).reportDefaultNetworkStatus(false);
}
private static void onDisableRadio(Intent intent, Context context) {
@@ -154,7 +155,7 @@
SubscriptionManager.getDefaultVoiceSubscriptionId());
logd("onDisableRadio subId: " + subId);
final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class);
- telephonyMgr.carrierActionSetRadioEnabled(subId, !ENABLE);
+ telephonyMgr.createForSubscriptionId(subId).setRadioEnabled(!ENABLE);
}
private static void onEnableRadio(Intent intent, Context context) {
@@ -162,7 +163,7 @@
SubscriptionManager.getDefaultVoiceSubscriptionId());
logd("onEnableRadio subId: " + subId);
final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class);
- telephonyMgr.carrierActionSetRadioEnabled(subId, ENABLE);
+ telephonyMgr.createForSubscriptionId(subId).setRadioEnabled(ENABLE);
}
private static void onShowCaptivePortalNotification(Intent intent, Context context) {
@@ -205,7 +206,7 @@
SubscriptionManager.getDefaultVoiceSubscriptionId());
logd("onResetAllCarrierActions subId: " + subId);
final TelephonyManager telephonyMgr = context.getSystemService(TelephonyManager.class);
- telephonyMgr.carrierActionResetAll(subId);
+ telephonyMgr.createForSubscriptionId(subId).resetAllCarrierActions();
}
private static Notification getNotification(Context context, int titleId, int textId,
diff --git a/packages/Incremental/NativeAdbDataLoader/Android.bp b/packages/Incremental/NativeAdbDataLoader/Android.bp
new file mode 100644
index 0000000..5d7b5b6
--- /dev/null
+++ b/packages/Incremental/NativeAdbDataLoader/Android.bp
@@ -0,0 +1,22 @@
+// Copyright 2019, 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.
+
+android_app {
+ name: "NativeAdbDataLoaderService",
+ srcs: ["src/**/*.java"],
+ jni_libs: [ "libnativeadbdataloaderservice_jni"],
+ privileged: true,
+ certificate: "platform",
+ platform_apis: true,
+}
diff --git a/packages/Incremental/NativeAdbDataLoader/AndroidManifest.xml b/packages/Incremental/NativeAdbDataLoader/AndroidManifest.xml
new file mode 100644
index 0000000..a06dc54
--- /dev/null
+++ b/packages/Incremental/NativeAdbDataLoader/AndroidManifest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2019, 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.
+*/
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ coreApp="true"
+ package="com.android.incremental.nativeadb"
+ android:sharedUserId="android.uid.system">
+ <uses-permission android:name="android.permission.INTERNET" />
+
+ <application android:label="@string/app_name"
+ android:directBootAware="true">
+
+ <service android:enabled="true"
+ android:name="com.android.incremental.nativeadb.NativeAdbDataLoaderService"
+ android:label="@string/app_name"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="android.intent.action.LOAD_DATA" />
+ </intent-filter>
+ </service>
+ </application>
+
+</manifest>
diff --git a/packages/Incremental/NativeAdbDataLoader/jni/Android.bp b/packages/Incremental/NativeAdbDataLoader/jni/Android.bp
new file mode 100644
index 0000000..0fcfd28
--- /dev/null
+++ b/packages/Incremental/NativeAdbDataLoader/jni/Android.bp
@@ -0,0 +1,37 @@
+// Copyright 2019, 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.
+
+cc_library_shared {
+ name: "libnativeadbdataloaderservice_jni",
+ cpp_std: "c++2a",
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wunused",
+ "-Wunreachable-code",
+ "-Wno-unused-parameter",
+ ],
+
+ srcs: ["com_android_incremental_nativeadb_DataLoaderService.cpp"],
+
+ shared_libs: [
+ "libbase",
+ "libcutils",
+ "libincfs",
+ "libdataloader",
+ "liblog",
+ "libnativehelper",
+ "libutils",
+ ],
+}
diff --git a/packages/Incremental/NativeAdbDataLoader/jni/com_android_incremental_nativeadb_DataLoaderService.cpp b/packages/Incremental/NativeAdbDataLoader/jni/com_android_incremental_nativeadb_DataLoaderService.cpp
new file mode 100644
index 0000000..de92fcd5
--- /dev/null
+++ b/packages/Incremental/NativeAdbDataLoader/jni/com_android_incremental_nativeadb_DataLoaderService.cpp
@@ -0,0 +1,519 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#define ATRACE_TAG ATRACE_TAG_ADB
+#define LOG_TAG "NativeAdbDataLoaderService"
+
+#include <android-base/file.h>
+#include <android-base/logging.h>
+#include <android-base/properties.h>
+#include <android-base/stringprintf.h>
+#include <android-base/thread_annotations.h>
+#include <android-base/unique_fd.h>
+#include <cutils/trace.h>
+#include <fcntl.h>
+#include <sys/eventfd.h>
+#include <sys/poll.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <utils/Log.h>
+
+#include <charconv>
+#include <string>
+#include <thread>
+#include <type_traits>
+#include <unordered_map>
+#include <unordered_set>
+
+#include "dataloader.h"
+
+#ifndef _WIN32
+#include <endian.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#else
+#define be32toh(x) _byteswap_ulong(x)
+#define be16toh(x) _byteswap_ushort(x)
+#endif
+
+namespace {
+
+using android::base::unique_fd;
+
+using namespace std::literals;
+
+using BlockSize = int16_t;
+using FileId = int16_t;
+using BlockIdx = int32_t;
+using NumBlocks = int32_t;
+using CompressionType = int16_t;
+using RequestType = int16_t;
+
+static constexpr int COMMAND_SIZE = 2 + 2 + 4; // bytes
+static constexpr int HEADER_SIZE = 2 + 2 + 4 + 2; // bytes
+static constexpr std::string_view OKAY = "OKAY"sv;
+
+static constexpr auto PollTimeoutMs = 5000;
+
+static constexpr auto ReadLogBufferSize = 128 * 1024 * 1024;
+static constexpr auto ReadLogMaxEntrySize = 128;
+
+struct BlockHeader {
+ FileId fileId = -1;
+ CompressionType compressionType = -1;
+ BlockIdx blockIdx = -1;
+ BlockSize blockSize = -1;
+} __attribute__((packed));
+
+static_assert(sizeof(BlockHeader) == HEADER_SIZE);
+
+static constexpr RequestType EXIT = 0;
+static constexpr RequestType BLOCK_MISSING = 1;
+static constexpr RequestType PREFETCH = 2;
+
+struct RequestCommand {
+ RequestType requestType;
+ FileId fileId;
+ BlockIdx blockIdx;
+} __attribute__((packed));
+
+static_assert(COMMAND_SIZE == sizeof(RequestCommand));
+
+static bool sendRequest(int fd,
+ RequestType requestType,
+ FileId fileId = -1,
+ BlockIdx blockIdx = -1) {
+ const RequestCommand command{
+ .requestType = static_cast<int16_t>(be16toh(requestType)),
+ .fileId = static_cast<int16_t>(be16toh(fileId)),
+ .blockIdx = static_cast<int32_t>(be32toh(blockIdx))};
+ return android::base::WriteFully(fd, &command, sizeof(command));
+}
+
+static int waitForDataOrSignal(int fd, int event_fd) {
+ struct pollfd pfds[2] = {{fd, POLLIN, 0}, {event_fd, POLLIN, 0}};
+ // Wait indefinitely until either data is ready or stop signal is received
+ int res = poll(pfds, 2, PollTimeoutMs);
+ if (res <= 0) {
+ return res;
+ }
+ // First check if there is a stop signal
+ if (pfds[1].revents == POLLIN) {
+ return event_fd;
+ }
+ // Otherwise check if incoming data is ready
+ if (pfds[0].revents == POLLIN) {
+ return fd;
+ }
+ return -1;
+}
+
+static bool readChunk(int fd, std::vector<uint8_t>& data) {
+ int32_t size;
+ if (!android::base::ReadFully(fd, &size, sizeof(size))) {
+ return false;
+ }
+ size = int32_t(be32toh(size));
+ if (size <= 0) {
+ return false;
+ }
+ data.resize(size);
+ return android::base::ReadFully(fd, data.data(), data.size());
+}
+
+static BlockHeader readHeader(std::span<uint8_t>& data) {
+ BlockHeader header;
+ if (data.size() < sizeof(header)) {
+ return header;
+ }
+
+ header.fileId = static_cast<FileId>(
+ be16toh(*reinterpret_cast<uint16_t*>(&data[0])));
+ header.compressionType = static_cast<CompressionType>(
+ be16toh(*reinterpret_cast<uint16_t*>(&data[2])));
+ header.blockIdx = static_cast<BlockIdx>(
+ be32toh(*reinterpret_cast<uint32_t*>(&data[4])));
+ header.blockSize = static_cast<BlockSize>(
+ be16toh(*reinterpret_cast<uint16_t*>(&data[8])));
+ data = data.subspan(sizeof(header));
+
+ return header;
+}
+
+static std::string extractPackageName(const std::string& staticArgs) {
+ static constexpr auto kPrefix = "package="sv;
+ static constexpr auto kSuffix = "&"sv;
+
+ const auto startPos = staticArgs.find(kPrefix);
+ if (startPos == staticArgs.npos || startPos + kPrefix.size() >= staticArgs.size()) {
+ return {};
+ }
+ const auto endPos = staticArgs.find(kSuffix, startPos + kPrefix.size());
+ return staticArgs.substr(startPos + kPrefix.size(),
+ endPos == staticArgs.npos ? staticArgs.npos
+ : (endPos - (startPos + kPrefix.size())));
+}
+
+class AdbDataLoader : public android::dataloader::DataLoader {
+private:
+ // Lifecycle.
+ bool onCreate(const android::dataloader::DataLoaderParams& params,
+ android::dataloader::FilesystemConnectorPtr ifs,
+ android::dataloader::StatusListenerPtr statusListener,
+ android::dataloader::ServiceConnectorPtr,
+ android::dataloader::ServiceParamsPtr) final {
+ CHECK(ifs) << "ifs can't be null";
+ CHECK(statusListener) << "statusListener can't be null";
+ ALOGE("[AdbDataLoader] onCreate: %s/%s/%d", params.staticArgs().c_str(),
+ params.packageName().c_str(), (int)params.dynamicArgs().size());
+
+ if (params.dynamicArgs().empty()) {
+ ALOGE("[AdbDataLoader] Invalid DataLoaderParams. Need in/out FDs.");
+ return false;
+ }
+ for (auto const& namedFd : params.dynamicArgs()) {
+ if (namedFd.name == "inFd") {
+ mInFd.reset(dup(namedFd.fd));
+ }
+ if (namedFd.name == "outFd") {
+ mOutFd.reset(dup(namedFd.fd));
+ }
+ }
+ if (mInFd < 0 || mOutFd < 0) {
+ ALOGE("[AdbDataLoader] Failed to dup FDs.");
+ return false;
+ }
+
+ mEventFd.reset(eventfd(0, EFD_CLOEXEC));
+ if (mEventFd < 0) {
+ ALOGE("[AdbDataLoader] Failed to create eventfd.");
+ return false;
+ }
+
+ std::string logFile;
+ if (const auto packageName = extractPackageName(params.staticArgs()); !packageName.empty()) {
+ logFile = android::base::GetProperty("adb.readlog." + packageName, "");
+ }
+ if (logFile.empty()) {
+ logFile = android::base::GetProperty("adb.readlog", "");
+ }
+ if (!logFile.empty()) {
+ int flags = O_WRONLY | O_CREAT | O_CLOEXEC;
+ mReadLogFd.reset(
+ TEMP_FAILURE_RETRY(open(logFile.c_str(), flags, 0666)));
+ }
+
+ mIfs = ifs;
+ mStatusListener = statusListener;
+ ALOGE("[AdbDataLoader] Successfully created data loader.");
+ return true;
+ }
+
+ bool onStart() final {
+ char okay_buf[OKAY.size()];
+ if (!android::base::ReadFully(mInFd, okay_buf, OKAY.size())) {
+ ALOGE("[AdbDataLoader] Failed to receive OKAY. Abort.");
+ return false;
+ }
+ if (std::string_view(okay_buf, OKAY.size()) != OKAY) {
+ ALOGE("[AdbDataLoader] Received '%.*s', expecting '%.*s'",
+ (int)OKAY.size(), okay_buf, (int)OKAY.size(), OKAY.data());
+ return false;
+ }
+
+ mReceiverThread = std::thread([this]() { receiver(); });
+ ALOGI("[AdbDataLoader] started loading...");
+ return true;
+ }
+
+ void onStop() final {
+ mStopReceiving = true;
+ eventfd_write(mEventFd, 1);
+ if (mReceiverThread.joinable()) {
+ mReceiverThread.join();
+ }
+ }
+
+ void onDestroy() final {
+ ALOGE("[AdbDataLoader] Sending EXIT to server.");
+ sendRequest(mOutFd, EXIT);
+ // Make sure the receiver thread was stopped
+ CHECK(!mReceiverThread.joinable());
+
+ mInFd.reset();
+ mOutFd.reset();
+
+ mNodeToMetaMap.clear();
+ mIdToNodeMap.clear();
+
+ flushReadLog();
+ mReadLogFd.reset();
+ }
+
+ // IFS callbacks.
+ void onPendingReads(const android::dataloader::PendingReads& pendingReads) final {
+ std::lock_guard lock{mMapsMutex};
+ CHECK(mIfs);
+ for (auto&& pendingRead : pendingReads) {
+ const android::dataloader::Inode ino = pendingRead.file_ino;
+ const auto blockIdx =
+ static_cast<BlockIdx>(pendingRead.block_index);
+ /*
+ ALOGI("[AdbDataLoader] Missing: %d", (int) blockIdx);
+ */
+ auto fileIdOr = getFileId(ino);
+ if (!fileIdOr) {
+ ALOGE("[AdbDataLoader] Failed to handle event for inode=%d. "
+ "Ignore.",
+ static_cast<int>(ino));
+ continue;
+ }
+ const FileId fileId = *fileIdOr;
+ if (mRequestedFiles.insert(fileId).second) {
+ if (!sendRequest(mOutFd, PREFETCH, fileId, blockIdx)) {
+ ALOGE("[AdbDataLoader] Failed to request prefetch for "
+ "inode=%d. Ignore.",
+ static_cast<int>(ino));
+ mRequestedFiles.erase(fileId);
+ mStatusListener->reportStatus(
+ INCREMENTAL_DATA_LOADER_NO_CONNECTION);
+ }
+ }
+ sendRequest(mOutFd, BLOCK_MISSING, fileId, blockIdx);
+ }
+ }
+
+ struct TracedRead {
+ uint64_t timestampUs;
+ uint64_t fileIno;
+ uint32_t firstBlockIdx;
+ uint32_t count;
+ };
+ void onPageReads(const android::dataloader::PageReads& pageReads) final {
+ auto trace = atrace_is_tag_enabled(ATRACE_TAG);
+ auto log = mReadLogFd != -1;
+ if (CC_LIKELY(!(trace || log))) {
+ return;
+ }
+
+ TracedRead last = {0, 0, 0, 0};
+ std::lock_guard lock{mMapsMutex};
+ for (auto&& read : pageReads) {
+ if (read.file_ino != last.fileIno ||
+ read.block_index != last.firstBlockIdx + last.count) {
+ traceOrLogRead(last, trace, log);
+ last = {read.timestamp_us, read.file_ino, read.block_index, 1};
+ } else {
+ ++last.count;
+ }
+ }
+ traceOrLogRead(last, trace, log);
+ }
+ void onFileCreated(android::dataloader::Inode inode, const android::dataloader::RawMetadata& metadata) {
+ }
+
+private:
+ void receiver() {
+ std::vector<uint8_t> data;
+ std::vector<incfs_new_data_block> instructions;
+ while (!mStopReceiving) {
+ const int res = waitForDataOrSignal(mInFd, mEventFd);
+ if (res == 0) {
+ flushReadLog();
+ continue;
+ }
+ if (res < 0) {
+ ALOGE("[AdbDataLoader] failed to poll. Abort.");
+ mStatusListener->reportStatus(INCREMENTAL_DATA_LOADER_NO_CONNECTION);
+ break;
+ }
+ if (res == mEventFd) {
+ ALOGE("[AdbDataLoader] received stop signal. Exit.");
+ break;
+ }
+ if (!readChunk(mInFd, data)) {
+ ALOGE("[AdbDataLoader] failed to read a message. Abort.");
+ mStatusListener->reportStatus(INCREMENTAL_DATA_LOADER_NO_CONNECTION);
+ break;
+ }
+ auto remainingData = std::span(data);
+ while (!remainingData.empty()) {
+ auto header = readHeader(remainingData);
+ if (header.fileId == -1 && header.compressionType == 0 &&
+ header.blockIdx == 0 && header.blockSize == 0) {
+ ALOGI("[AdbDataLoader] stop signal received. Sending "
+ "exit command (remaining bytes: %d).",
+ int(remainingData.size()));
+
+ sendRequest(mOutFd, EXIT);
+ mStopReceiving = true;
+ break;
+ }
+ if (header.fileId < 0 || header.blockSize <= 0 ||
+ header.compressionType < 0 || header.blockIdx < 0) {
+ ALOGE("[AdbDataLoader] invalid header received. Abort.");
+ mStopReceiving = true;
+ break;
+ }
+ const android::dataloader::Inode ino = mIdToNodeMap[header.fileId];
+ if (!ino) {
+ ALOGE("Unknown data destination for file ID %d. "
+ "Ignore.",
+ header.fileId);
+ continue;
+ }
+ auto inst = incfs_new_data_block{
+ .file_ino = static_cast<__aligned_u64>(ino),
+ .block_index = static_cast<uint32_t>(header.blockIdx),
+ .data_len = static_cast<uint16_t>(header.blockSize),
+ .data = reinterpret_cast<uint64_t>(
+ remainingData.data()),
+ .compression =
+ static_cast<uint8_t>(header.compressionType)};
+ instructions.push_back(inst);
+ remainingData = remainingData.subspan(header.blockSize);
+ }
+ writeInstructions(instructions);
+ }
+ writeInstructions(instructions);
+ flushReadLog();
+ }
+
+ void writeInstructions(std::vector<incfs_new_data_block>& instructions) {
+ auto res = this->mIfs->writeBlocks(instructions.data(),
+ instructions.size());
+ if (res != instructions.size()) {
+ ALOGE("[AdbDataLoader] failed to write data to Incfs (res=%d when "
+ "expecting %d)",
+ res, int(instructions.size()));
+ }
+ instructions.clear();
+ }
+
+ struct MetaPair {
+ android::dataloader::RawMetadata meta;
+ FileId fileId;
+ };
+
+ MetaPair* updateMapsForFile(android::dataloader::Inode ino) {
+ android::dataloader::RawMetadata meta = mIfs->getRawMetadata(ino);
+ FileId fileId;
+ auto res =
+ std::from_chars(meta.data(), meta.data() + meta.size(), fileId);
+ if (res.ec != std::errc{} || fileId < 0) {
+ ALOGE("[AdbDataLoader] Invalid metadata for inode=%d (%s)",
+ static_cast<int>(ino), meta.data());
+ return nullptr;
+ }
+ mIdToNodeMap[fileId] = ino;
+ auto& metaPair = mNodeToMetaMap[ino];
+ metaPair.meta = std::move(meta);
+ metaPair.fileId = fileId;
+ return &metaPair;
+ }
+
+ android::dataloader::RawMetadata* getMeta(android::dataloader::Inode ino) {
+ auto it = mNodeToMetaMap.find(ino);
+ if (it != mNodeToMetaMap.end()) {
+ return &it->second.meta;
+ }
+
+ auto metaPair = updateMapsForFile(ino);
+ if (!metaPair) {
+ return nullptr;
+ }
+
+ return &metaPair->meta;
+ }
+
+ FileId* getFileId(android::dataloader::Inode ino) {
+ auto it = mNodeToMetaMap.find(ino);
+ if (it != mNodeToMetaMap.end()) {
+ return &it->second.fileId;
+ }
+
+ auto* metaPair = updateMapsForFile(ino);
+ if (!metaPair) {
+ return nullptr;
+ }
+
+ return &metaPair->fileId;
+ }
+
+ void traceOrLogRead(const TracedRead& read, bool trace, bool log) {
+ if (!read.count) {
+ return;
+ }
+ if (trace) {
+ auto* meta = getMeta(read.fileIno);
+ auto str = android::base::StringPrintf(
+ "page_read: index=%lld count=%lld meta=%.*s",
+ static_cast<long long>(read.firstBlockIdx),
+ static_cast<long long>(read.count),
+ meta ? int(meta->size()) : 0, meta ? meta->data() : "");
+ ATRACE_BEGIN(str.c_str());
+ ATRACE_END();
+ }
+ if (log) {
+ mReadLog.reserve(ReadLogBufferSize);
+
+ auto fileId = getFileId(read.fileIno);
+ android::base::StringAppendF(
+ &mReadLog, "%lld:%lld:%lld:%lld\n",
+ static_cast<long long>(read.timestampUs),
+ static_cast<long long>(fileId ? *fileId : -1),
+ static_cast<long long>(read.firstBlockIdx),
+ static_cast<long long>(read.count));
+
+ if (mReadLog.size() >= mReadLog.capacity() - ReadLogMaxEntrySize) {
+ flushReadLog();
+ }
+ }
+ }
+
+ void flushReadLog() {
+ if (mReadLog.empty() || mReadLogFd == -1) {
+ return;
+ }
+
+ android::base::WriteStringToFd(mReadLog, mReadLogFd);
+ mReadLog.clear();
+ }
+
+private:
+ android::dataloader::FilesystemConnectorPtr mIfs = nullptr;
+ android::dataloader::StatusListenerPtr mStatusListener = nullptr;
+ android::base::unique_fd mInFd;
+ android::base::unique_fd mOutFd;
+ android::base::unique_fd mEventFd;
+ android::base::unique_fd mReadLogFd;
+ std::string mReadLog;
+ std::thread mReceiverThread;
+ std::mutex mMapsMutex;
+ std::unordered_map<android::dataloader::Inode, MetaPair> mNodeToMetaMap GUARDED_BY(mMapsMutex);
+ std::unordered_map<FileId, android::dataloader::Inode> mIdToNodeMap GUARDED_BY(mMapsMutex);
+ /** Tracks which files have been requested */
+ std::unordered_set<FileId> mRequestedFiles;
+ std::atomic<bool> mStopReceiving = false;
+};
+
+} // namespace
+
+int JNI_OnLoad(JavaVM* jvm, void* /* reserved */) {
+ android::dataloader::DataLoader::initialize(
+ [](auto) { return std::make_unique<AdbDataLoader>(); });
+ return JNI_VERSION_1_6;
+}
diff --git a/packages/Incremental/NativeAdbDataLoader/res/values/strings.xml b/packages/Incremental/NativeAdbDataLoader/res/values/strings.xml
new file mode 100644
index 0000000..9921ae6
--- /dev/null
+++ b/packages/Incremental/NativeAdbDataLoader/res/values/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 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.
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Name of the Data Loader Service. [CHAR LIMIT=40] -->
+ <string name="app_name">Native Adb Data Loader Service</string>
+</resources>
diff --git a/packages/Incremental/NativeAdbDataLoader/src/com/android/incremental/nativeadb/NativeAdbDataLoaderService.java b/packages/Incremental/NativeAdbDataLoader/src/com/android/incremental/nativeadb/NativeAdbDataLoaderService.java
new file mode 100644
index 0000000..1f88114
--- /dev/null
+++ b/packages/Incremental/NativeAdbDataLoader/src/com/android/incremental/nativeadb/NativeAdbDataLoaderService.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2019 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 com.android.incremental.nativeadb;
+
+import android.service.incremental.IncrementalDataLoaderService;
+
+/** This code is used for testing only. */
+public class NativeAdbDataLoaderService extends IncrementalDataLoaderService {
+ public static final String TAG = "NativeAdbDataLoaderService";
+ static {
+ System.loadLibrary("nativeadbdataloaderservice_jni");
+ }
+
+ @Override
+ public DataLoader onCreateDataLoader() {
+ return null;
+ }
+}
diff --git a/packages/SettingsLib/res/values/arrays.xml b/packages/SettingsLib/res/values/arrays.xml
index 39c55fd..9b4a6d6 100644
--- a/packages/SettingsLib/res/values/arrays.xml
+++ b/packages/SettingsLib/res/values/arrays.xml
@@ -140,8 +140,6 @@
<item><xliff:g id="qualcomm">Qualcomm®</xliff:g> <xliff:g id="aptx">aptX™</xliff:g> audio</item>
<item><xliff:g id="qualcomm">Qualcomm®</xliff:g> <xliff:g id="aptx_hd">aptX™ HD</xliff:g> audio</item>
<item>LDAC</item>
- <item>Enable Optional Codecs</item>
- <item>Disable Optional Codecs</item>
</string-array>
<!-- Values for Bluetooth Audio Codec selection preference. -->
@@ -152,8 +150,6 @@
<item>2</item>
<item>3</item>
<item>4</item>
- <item>5</item>
- <item>6</item>
</string-array>
<!-- Summaries for Bluetooth Audio Codec selection preference. [CHAR LIMIT=50]-->
@@ -164,8 +160,6 @@
<item><xliff:g id="qualcomm">Qualcomm®</xliff:g> <xliff:g id="aptx">aptX™</xliff:g> audio</item>
<item><xliff:g id="qualcomm">Qualcomm®</xliff:g> <xliff:g id="aptx_hd">aptX™ HD</xliff:g> audio</item>
<item>LDAC</item>
- <item>Enable Optional Codecs</item>
- <item>Disable Optional Codecs</item>
</string-array>
<!-- Titles for Bluetooth Audio Codec Sample Rate selection preference. [CHAR LIMIT=50] -->
diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml
index ade292f..f40105d 100644
--- a/packages/SettingsLib/res/values/strings.xml
+++ b/packages/SettingsLib/res/values/strings.xml
@@ -598,6 +598,8 @@
<string name="bluetooth_show_devices_without_names">Show Bluetooth devices without names</string>
<!-- Setting Checkbox title for disabling Bluetooth absolute volume -->
<string name="bluetooth_disable_absolute_volume">Disable absolute volume</string>
+ <!-- Setting Checkbox title for enabling Bluetooth Gabeldorsche. [CHAR LIMIT=40] -->
+ <string name="bluetooth_enable_gabeldorsche">Enable Gabeldorsche</string>
<!-- UI debug setting: Select Bluetooth AVRCP Version -->
<string name="bluetooth_select_avrcp_version_string">Bluetooth AVRCP Version</string>
@@ -696,6 +698,8 @@
<string name="bluetooth_show_devices_without_names_summary">Bluetooth devices without names (MAC addresses only) will be displayed</string>
<!-- Summary of checkbox for disabling Bluetooth absolute volume -->
<string name="bluetooth_disable_absolute_volume_summary">Disables the Bluetooth absolute volume feature in case of volume issues with remote devices such as unacceptably loud volume or lack of control.</string>
+ <!-- Summary of checkbox for enabling Bluetooth Gabeldorche features [CHAR LIMIT=none] -->
+ <string name="bluetooth_enable_gabeldorsche_summary">Enables the Bluetooth Gabeldorche feature stack.</string>
<!-- Title of checkbox setting that enables the terminal app. [CHAR LIMIT=32] -->
<string name="enable_terminal_title">Local terminal</string>
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java
index 9c896c8..bc03c34 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/A2dpSinkProfile.java
@@ -164,13 +164,13 @@
}
}
- boolean isA2dpPlaying() {
+ boolean isAudioPlaying() {
if (mService == null) {
return false;
}
List<BluetoothDevice> srcs = mService.getConnectedDevices();
if (!srcs.isEmpty()) {
- if (mService.isA2dpPlaying(srcs.get(0))) {
+ if (mService.isAudioPlaying(srcs.get(0))) {
return true;
}
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java
index e660e43..d3f9cd4 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java
@@ -116,7 +116,7 @@
}
return new Pair<>(
getBluetoothDrawable(context,
- com.android.internal.R.drawable.ic_settings_bluetooth),
+ com.android.internal.R.drawable.ic_settings_bluetooth).mutate(),
context.getString(R.string.bluetooth_talkback_bluetooth));
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
index 0666596..747ceb1 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
@@ -721,12 +721,8 @@
refresh();
- if (bondState == BluetoothDevice.BOND_BONDED) {
- if (mDevice.isBluetoothDock()) {
- onBondingDockConnect();
- } else if (mDevice.isBondingInitiatedLocally()) {
- connect(false);
- }
+ if (bondState == BluetoothDevice.BOND_BONDED && mDevice.isBondingInitiatedLocally()) {
+ connect(false);
}
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java
index 8f40ab4..80b03a4 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java
@@ -175,7 +175,7 @@
return;
}
A2dpSinkProfile a2dpSink = mProfileManager.getA2dpSinkProfile();
- if ((a2dpSink != null) && (a2dpSink.isA2dpPlaying())){
+ if ((a2dpSink != null) && (a2dpSink.isAudioPlaying())) {
return;
}
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/OWNERS b/packages/SettingsLib/src/com/android/settingslib/bluetooth/OWNERS
index 7162121..387bae1 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/OWNERS
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/OWNERS
@@ -1,8 +1,7 @@
# Default reviewers for this and subdirectories.
-asapperstein@google.com
-asargent@google.com
-eisenbach@google.com
-jackqdyulei@google.com
siyuanh@google.com
+hughchen@google.com
+timhypeng@google.com
+robertluo@google.com
-# Emergency approvers in case the above are not available
\ No newline at end of file
+# Emergency approvers in case the above are not available
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapServerProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapServerProfile.java
index d91226e..3f920a8 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapServerProfile.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/PbapServerProfile.java
@@ -16,6 +16,7 @@
package com.android.settingslib.bluetooth;
+import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothPbap;
@@ -52,14 +53,16 @@
// These callbacks run on the main thread.
private final class PbapServiceListener
- implements BluetoothPbap.ServiceListener {
+ implements BluetoothProfile.ServiceListener {
- public void onServiceConnected(BluetoothPbap proxy) {
+ @Override
+ public void onServiceConnected(int profile, BluetoothProfile proxy) {
mService = (BluetoothPbap) proxy;
mIsProfileReady=true;
}
- public void onServiceDisconnected() {
+ @Override
+ public void onServiceDisconnected(int profile) {
mIsProfileReady=false;
}
}
@@ -74,7 +77,8 @@
}
PbapServerProfile(Context context) {
- BluetoothPbap pbap = new BluetoothPbap(context, new PbapServiceListener());
+ BluetoothAdapter.getDefaultAdapter().getProfileProxy(context, new PbapServiceListener(),
+ BluetoothProfile.PBAP);
}
public boolean accessProfileEnabled() {
@@ -97,13 +101,8 @@
}
public int getConnectionStatus(BluetoothDevice device) {
- if (mService == null) {
- return BluetoothProfile.STATE_DISCONNECTED;
- }
- if (mService.isConnected(device))
- return BluetoothProfile.STATE_CONNECTED;
- else
- return BluetoothProfile.STATE_DISCONNECTED;
+ if (mService == null) return BluetoothProfile.STATE_DISCONNECTED;
+ return mService.getConnectionState(device);
}
public boolean isPreferred(BluetoothDevice device) {
@@ -142,7 +141,8 @@
Log.d(TAG, "finalize()");
if (mService != null) {
try {
- mService.close();
+ BluetoothAdapter.getDefaultAdapter().closeProfileProxy(BluetoothProfile.PBAP,
+ mService);
mService = null;
}catch (Throwable t) {
Log.w(TAG, "Error cleaning up PBAP proxy", t);
diff --git a/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/MetricsFeatureProvider.java b/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/MetricsFeatureProvider.java
index 5cf44e1..a82231a 100644
--- a/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/MetricsFeatureProvider.java
+++ b/packages/SettingsLib/src/com/android/settingslib/core/instrumentation/MetricsFeatureProvider.java
@@ -23,6 +23,9 @@
import android.text.TextUtils;
import android.util.Pair;
+import androidx.annotation.NonNull;
+import androidx.preference.Preference;
+
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import java.util.ArrayList;
@@ -132,34 +135,44 @@
return ((Instrumentable) object).getMetricsCategory();
}
- public void logDashboardStartIntent(Context context, Intent intent,
- int sourceMetricsCategory) {
+ /**
+ * Logs an event when the preference is clicked.
+ *
+ * @return true if the preference is loggable, otherwise false
+ */
+ public boolean logClickedPreference(@NonNull Preference preference, int sourceMetricsCategory) {
+ if (preference == null) {
+ return false;
+ }
+ return logSettingsTileClick(preference.getKey(), sourceMetricsCategory)
+ || logStartedIntent(preference.getIntent(), sourceMetricsCategory)
+ || logSettingsTileClick(preference.getFragment(), sourceMetricsCategory);
+ }
+
+ /**
+ * Logs an event when the intent is started.
+ *
+ * @return true if the intent is loggable, otherwise false
+ */
+ public boolean logStartedIntent(Intent intent, int sourceMetricsCategory) {
if (intent == null) {
- return;
+ return false;
}
final ComponentName cn = intent.getComponent();
- if (cn == null) {
- final String action = intent.getAction();
- if (TextUtils.isEmpty(action)) {
- // Not loggable
- return;
- }
- action(sourceMetricsCategory,
- MetricsEvent.ACTION_SETTINGS_TILE_CLICK,
- SettingsEnums.PAGE_UNKNOWN,
- action,
- 0);
- return;
- } else if (TextUtils.equals(cn.getPackageName(), context.getPackageName())) {
- // Going to a Setting internal page, skip click logging in favor of page's own
- // visibility logging.
- return;
+ return logSettingsTileClick(cn != null ? cn.flattenToString() : intent.getAction(),
+ sourceMetricsCategory);
+ }
+
+ private boolean logSettingsTileClick(String logKey, int sourceMetricsCategory) {
+ if (TextUtils.isEmpty(logKey)) {
+ // Not loggable
+ return false;
}
action(sourceMetricsCategory,
MetricsEvent.ACTION_SETTINGS_TILE_CLICK,
SettingsEnums.PAGE_UNKNOWN,
- cn.flattenToString(),
+ logKey,
0);
+ return true;
}
-
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationApps.java b/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationApps.java
index 104cc8f..d3315ef 100644
--- a/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationApps.java
+++ b/packages/SettingsLib/src/com/android/settingslib/location/RecentLocationApps.java
@@ -235,7 +235,7 @@
public final CharSequence contentDescription;
public final long requestFinishTime;
- private Request(String packageName, UserHandle userHandle, Drawable icon,
+ public Request(String packageName, UserHandle userHandle, Drawable icon,
CharSequence label, boolean isHighBattery, CharSequence contentDescription,
long requestFinishTime) {
this.packageName = packageName;
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
index 49e214b..443543b 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
@@ -1395,7 +1395,7 @@
mConfig = new WifiConfiguration();
mConfig.SSID = AccessPoint.convertToQuotedString(ssid);
- if (security == SECURITY_NONE || !getWifiManager().isEasyConnectSupported()) {
+ if (security == SECURITY_NONE) {
mConfig.allowedKeyManagement.set(KeyMgmt.NONE);
} else {
mConfig.allowedKeyManagement.set(KeyMgmt.OWE);
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiEntryPreference.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiEntryPreference.java
index 22f47f1..440315f 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiEntryPreference.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiEntryPreference.java
@@ -152,6 +152,14 @@
// TODO(b/70983952): Fill this method in
}
+ /**
+ * Result of the sign-in request indecated by the WifiEntry.SIGNIN_STATUS constants
+ */
+ public void onSignInResult(int status) {
+ // TODO(b/70983952): Fill this method in
+ }
+
+
private void updateIcon(int level) {
if (level == -1) {
setIcon(null);
diff --git a/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/AccessPointTest.java b/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/AccessPointTest.java
index 2a70506..3818057 100644
--- a/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/AccessPointTest.java
+++ b/packages/SettingsLib/tests/integ/src/com/android/settingslib/wifi/AccessPointTest.java
@@ -1713,4 +1713,21 @@
.setScanResults(new ArrayList<ScanResult>(Arrays.asList(scanResult)))
.build();
}
+
+ @Test
+ public void testGenerateOpenNetworkConfig_oweNotSupported_shouldGetCorrectSecurity() {
+ when(mMockContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mMockWifiManager);
+ AccessPoint oweAccessPoint = new TestAccessPointBuilder(mMockContext)
+ .setSecurity(AccessPoint.SECURITY_OWE).build();
+ AccessPoint noneAccessPoint = new TestAccessPointBuilder(mMockContext)
+ .setSecurity(AccessPoint.SECURITY_NONE).build();
+
+ oweAccessPoint.generateOpenNetworkConfig();
+ noneAccessPoint.generateOpenNetworkConfig();
+
+ assertThat(oweAccessPoint.getConfig().allowedKeyManagement.get(KeyMgmt.NONE)).isFalse();
+ assertThat(oweAccessPoint.getConfig().allowedKeyManagement.get(KeyMgmt.OWE)).isTrue();
+ assertThat(noneAccessPoint.getConfig().allowedKeyManagement.get(KeyMgmt.NONE)).isTrue();
+ assertThat(noneAccessPoint.getConfig().allowedKeyManagement.get(KeyMgmt.OWE)).isFalse();
+ }
}
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/MetricsFeatureProviderTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/MetricsFeatureProviderTest.java
index 8a0ae91..ed0857c 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/MetricsFeatureProviderTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/core/instrumentation/MetricsFeatureProviderTest.java
@@ -26,6 +26,8 @@
import android.content.Context;
import android.content.Intent;
+import androidx.preference.Preference;
+
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import org.junit.Before;
@@ -60,19 +62,42 @@
}
@Test
- public void logDashboardStartIntent_intentEmpty_shouldNotLog() {
- mProvider.logDashboardStartIntent(mContext, null /* intent */,
+ public void logClickedPreference_preferenceEmpty_shouldNotLog() {
+ final boolean loggable = mProvider.logClickedPreference(null /* preference */,
MetricsEvent.SETTINGS_GESTURES);
+ assertThat(loggable).isFalse();
verifyNoMoreInteractions(mLogWriter);
}
@Test
- public void logDashboardStartIntent_intentHasNoComponent_shouldLog() {
+ public void logClickedPreference_preferenceHasKey_shouldLog() {
+ final String key = "abc";
+ final Preference preference = new Preference(mContext);
+ preference.setKey(key);
+
+ final boolean loggable = mProvider.logClickedPreference(preference,
+ MetricsEvent.SETTINGS_GESTURES);
+
+ assertThat(loggable).isTrue();
+ verify(mLogWriter).action(
+ MetricsEvent.SETTINGS_GESTURES,
+ MetricsEvent.ACTION_SETTINGS_TILE_CLICK,
+ SettingsEnums.PAGE_UNKNOWN,
+ key,
+ 0);
+ }
+
+ @Test
+ public void logClickedPreference_preferenceHasIntent_shouldLog() {
+ final Preference preference = new Preference(mContext);
final Intent intent = new Intent(Intent.ACTION_ASSIST);
+ preference.setIntent(intent);
- mProvider.logDashboardStartIntent(mContext, intent, MetricsEvent.SETTINGS_GESTURES);
+ final boolean loggable = mProvider.logClickedPreference(preference,
+ MetricsEvent.SETTINGS_GESTURES);
+ assertThat(loggable).isTrue();
verify(mLogWriter).action(
MetricsEvent.SETTINGS_GESTURES,
MetricsEvent.ACTION_SETTINGS_TILE_CLICK,
@@ -82,11 +107,54 @@
}
@Test
- public void logDashboardStartIntent_intentIsExternal_shouldLog() {
+ public void logClickedPreference_preferenceHasFragment_shouldLog() {
+ final Preference preference = new Preference(mContext);
+ final String fragment = "com.android.settings.tts.TextToSpeechSettings";
+ preference.setFragment(fragment);
+
+ final boolean loggable = mProvider.logClickedPreference(preference,
+ MetricsEvent.SETTINGS_GESTURES);
+
+ assertThat(loggable).isTrue();
+ verify(mLogWriter).action(
+ MetricsEvent.SETTINGS_GESTURES,
+ MetricsEvent.ACTION_SETTINGS_TILE_CLICK,
+ SettingsEnums.PAGE_UNKNOWN,
+ fragment,
+ 0);
+ }
+
+ @Test
+ public void logStartedIntent_intentEmpty_shouldNotLog() {
+ final boolean loggable = mProvider.logStartedIntent(null /* intent */,
+ MetricsEvent.SETTINGS_GESTURES);
+
+ assertThat(loggable).isFalse();
+ verifyNoMoreInteractions(mLogWriter);
+ }
+
+ @Test
+ public void logStartedIntent_intentHasNoComponent_shouldLog() {
+ final Intent intent = new Intent(Intent.ACTION_ASSIST);
+
+ final boolean loggable = mProvider.logStartedIntent(intent, MetricsEvent.SETTINGS_GESTURES);
+
+ assertThat(loggable).isTrue();
+ verify(mLogWriter).action(
+ MetricsEvent.SETTINGS_GESTURES,
+ MetricsEvent.ACTION_SETTINGS_TILE_CLICK,
+ SettingsEnums.PAGE_UNKNOWN,
+ Intent.ACTION_ASSIST,
+ 0);
+ }
+
+ @Test
+ public void logStartedIntent_intentIsExternal_shouldLog() {
final Intent intent = new Intent().setComponent(new ComponentName("pkg", "cls"));
- mProvider.logDashboardStartIntent(mContext, intent, MetricsEvent.SETTINGS_GESTURES);
+ final boolean loggable = mProvider.logStartedIntent(intent, MetricsEvent.SETTINGS_GESTURES);
+ assertThat(loggable).isTrue();
verify(mLogWriter).action(
MetricsEvent.SETTINGS_GESTURES,
MetricsEvent.ACTION_SETTINGS_TILE_CLICK,
diff --git a/packages/SettingsProvider/res/values-af/strings.xml b/packages/SettingsProvider/res/values-af/strings.xml
index 2c45484..8c2f8b3 100644
--- a/packages/SettingsProvider/res/values-af/strings.xml
+++ b/packages/SettingsProvider/res/values-af/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Instellingsberging"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Veranderings aan jou warmkolinstellings"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Jou warmkolband het verander."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Hierdie toestel steun nie jou voorkeur vir net 5 GHz nie. Hierdie toestel sal pleks daarvan die 5 GHz-band gebruik wanneer dit beskikbaar is."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-am/strings.xml b/packages/SettingsProvider/res/values-am/strings.xml
index 0630560..640301a 100644
--- a/packages/SettingsProvider/res/values-am/strings.xml
+++ b/packages/SettingsProvider/res/values-am/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"የቅንብሮች ማከማቻ"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"በእርስዎ ሆትስፖት ቅንብሮች ላይ ለውጦች"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"የእርስዎ ሆትስፖት ባንድ ተለውጧል።"</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"ይህ መሣሪያ የእርስዎን ምርጫ ለ5GHz ብቻ አይደግፍም። በምትኩ፣ ይህ መሣሪያ ሲገኝ 5GHz ባንድ ይጠቀማል።"</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-ar/strings.xml b/packages/SettingsProvider/res/values-ar/strings.xml
index 19306a6..2675839 100644
--- a/packages/SettingsProvider/res/values-ar/strings.xml
+++ b/packages/SettingsProvider/res/values-ar/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"تخزين الإعدادات"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"التغييرات التي طرأت على إعدادات نقطة الاتصال"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"تمّ تغيير نطاق نقطة الاتصال الخاصة بك."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"لا يتوافق هذا الجهاز مع إعدادك المفضّل الخاص باستخدام النطاق 5 غيغاهرتز فقط. وسيستخدم الجهاز بدلاً من ذلك النطاق 5 غيغاهرتز عندما يكون متاحًا."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-as/strings.xml b/packages/SettingsProvider/res/values-as/strings.xml
index 13b90d6..b70146a 100644
--- a/packages/SettingsProvider/res/values-as/strings.xml
+++ b/packages/SettingsProvider/res/values-as/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"ছেটিংছসমূহৰ সঞ্চয়াগাৰ"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"আপোনাৰ হটস্পট ছেটিংসমূহত হোৱা সালসলনিসমূহ"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"আপোনাৰ হটস্পটৰ বেণ্ড সলনি কৰা হৈছে।"</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"আপোনাৰ কেৱল ৫ গিগাহাৰ্টজৰ প্ৰতি অগ্ৰাধিকাৰ এই ডিভাচইচটোৱে সমৰ্থন নকৰে। ইয়াৰ পৰিৱৰ্তে, ডিভাচইচটোৱে যেতিয়া ৫ গিগাহাৰ্টজ বেণ্ড উপলব্ধ হ’ব তেতিয়া তাক ব্যৱহাৰ কৰিব।"</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-az/strings.xml b/packages/SettingsProvider/res/values-az/strings.xml
index 4737a1e..8b4f75b 100644
--- a/packages/SettingsProvider/res/values-az/strings.xml
+++ b/packages/SettingsProvider/res/values-az/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Ayarlar Deposu"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Hotspot ayarlarınızda dəyişiklik"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Hotspot diapazonu dəyişib."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Bu cihaz yalnız 5GHz üçün tərcihinizi dəstəkləmir. Əvəzində, əlçatan olduqda bu cihaz 5GHz diapazonundan istifadə edəcək."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-b+sr+Latn/strings.xml b/packages/SettingsProvider/res/values-b+sr+Latn/strings.xml
index 032dbc5..9c3a00e 100644
--- a/packages/SettingsProvider/res/values-b+sr+Latn/strings.xml
+++ b/packages/SettingsProvider/res/values-b+sr+Latn/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Podešavanja skladišta"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Promene podešavanja za hotspot"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Opseg hotspota je promenjen."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Ovaj uređaj ne podržava podešavanje samo za 5 GHz. Uređaj će koristiti opseg od 5 GHz kada bude dostupan."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-be/strings.xml b/packages/SettingsProvider/res/values-be/strings.xml
index 60bdb2d..0e098e7 100644
--- a/packages/SettingsProvider/res/values-be/strings.xml
+++ b/packages/SettingsProvider/res/values-be/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Сховішча налад"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Змяненні ў наладах хот-спота"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Частата хот-спота змянілася."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Прылада не можа працаваць толькі на частаце 5 ГГц. Гэта частата будзе выкарыстоўвацца, калі гэта магчыма."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-bg/strings.xml b/packages/SettingsProvider/res/values-bg/strings.xml
index c3a994b..30526f2 100644
--- a/packages/SettingsProvider/res/values-bg/strings.xml
+++ b/packages/SettingsProvider/res/values-bg/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Настройки за хранилище"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Промени в настройките ви за точка за достъп"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Честотната лента на точката ви за достъп е променена."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Това устройство не поддържа предпочитанието ви за използване само на честотната лента от 5 ГХц. Вместо това то ще я ползва, когато е възможно."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-bn/strings.xml b/packages/SettingsProvider/res/values-bn/strings.xml
index 71ee99b..8fc6bbb 100644
--- a/packages/SettingsProvider/res/values-bn/strings.xml
+++ b/packages/SettingsProvider/res/values-bn/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"সেটিংস স্টোরেজ"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"আপনার হটস্পট সেটিংসে করা পরিবর্তনগুলি"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"আপনার হটস্পট ব্যান্ড পরিবর্তন করা হয়েছে।"</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"এই ডিভাইসটি শুধুমাত্র 5GHz এর জন্য আপনার পছন্দ সমর্থন করে না। পরিবর্তে, এই ডিভাইসটি 5GHz ব্যান্ড ব্যবহার করবে।"</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-bs/strings.xml b/packages/SettingsProvider/res/values-bs/strings.xml
index 09d4c68..ddacb32 100644
--- a/packages/SettingsProvider/res/values-bs/strings.xml
+++ b/packages/SettingsProvider/res/values-bs/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Postavke za pohranu podataka"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Promjene postavki pristupne tačke"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Opseg pristupne tačke je promijenjen."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Ovaj uređaj ne podržava vašu postavku za mreže od isključivo 5 GHz. Uređaj će koristiti opseg of 5 GHz kada bude dostupan."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-ca/strings.xml b/packages/SettingsProvider/res/values-ca/strings.xml
index ee6b51e..0c2ad73 100644
--- a/packages/SettingsProvider/res/values-ca/strings.xml
+++ b/packages/SettingsProvider/res/values-ca/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Configuració de l\'emmagatzematge"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Canvis en la configuració del punt d\'accés Wi‑Fi"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Ha canviat la teva banda del punt d\'accés Wi‑Fi."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Aquest dispositiu no admet utilitzar exclusivament una banda de 5 GHz. El dispositiu utilitzarà una banda de 5 GHz quan estigui disponible."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-cs/strings.xml b/packages/SettingsProvider/res/values-cs/strings.xml
index f134e05..ab474b1 100644
--- a/packages/SettingsProvider/res/values-cs/strings.xml
+++ b/packages/SettingsProvider/res/values-cs/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Paměť pro nastavení"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Změny nastavení hotspotu"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Pásmo hotspotu se změnilo."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Toto zařízení nepodporuje vaše nastavení jen 5GHz pásma. Zařízení použije pásmo 5 GHz, jen když bude dostupné."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-da/strings.xml b/packages/SettingsProvider/res/values-da/strings.xml
index 99988a5..719614c 100644
--- a/packages/SettingsProvider/res/values-da/strings.xml
+++ b/packages/SettingsProvider/res/values-da/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Lagring af indstillinger"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Ændringer af dine indstillinger for hotspot"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Dit hotspotbånd er ændret."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Denne enhed understøtter ikke din præference om kun 5 GHz. Denne enhed vil i stedet bruge 5 GHz-båndet, når det er muligt."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-de/strings.xml b/packages/SettingsProvider/res/values-de/strings.xml
index ddcabaa..6e253e0 100644
--- a/packages/SettingsProvider/res/values-de/strings.xml
+++ b/packages/SettingsProvider/res/values-de/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Einstellungsspeicher"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Änderungen an deinen Hotspot-Einstellungen"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Dein Hotspot-Band hat sich geändert."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Dieses Gerät unterstützt die ausschließliche Nutzung von 5 GHz nicht. Es greift aber immer auf das 5-GHz-Band zurück, wenn dieses verfügbar ist."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-el/strings.xml b/packages/SettingsProvider/res/values-el/strings.xml
index 924fab5..c47fea2 100644
--- a/packages/SettingsProvider/res/values-el/strings.xml
+++ b/packages/SettingsProvider/res/values-el/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Αποθηκευτικός χώρος ρυθμίσεων"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Αλλαγές στις ρυθμίσεις σημείου πρόσβασης Wi-Fi"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Το εύρος σημείου πρόσβασης Wi-Fi άλλαξε."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Αυτή η συσκευή δεν υποστηρίζει την προτίμησή σας για αποκλειστική χρήση του εύρους 5 GHz. Αντ\' αυτού, αυτή η συσκευή θα χρησιμοποιεί το εύρος 5 GHz όταν είναι διαθέσιμο."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-en-rAU/strings.xml b/packages/SettingsProvider/res/values-en-rAU/strings.xml
index 05cd54e..fac51d83 100644
--- a/packages/SettingsProvider/res/values-en-rAU/strings.xml
+++ b/packages/SettingsProvider/res/values-en-rAU/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Settings Storage"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Changes to your hotspot settings"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Your hotspot band has changed."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"This device doesn’t support your preference for 5 GHz only. Instead, this device will use the 5 GHz band when available."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-en-rCA/strings.xml b/packages/SettingsProvider/res/values-en-rCA/strings.xml
index 05cd54e..fac51d83 100644
--- a/packages/SettingsProvider/res/values-en-rCA/strings.xml
+++ b/packages/SettingsProvider/res/values-en-rCA/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Settings Storage"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Changes to your hotspot settings"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Your hotspot band has changed."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"This device doesn’t support your preference for 5 GHz only. Instead, this device will use the 5 GHz band when available."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-en-rGB/strings.xml b/packages/SettingsProvider/res/values-en-rGB/strings.xml
index 05cd54e..fac51d83 100644
--- a/packages/SettingsProvider/res/values-en-rGB/strings.xml
+++ b/packages/SettingsProvider/res/values-en-rGB/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Settings Storage"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Changes to your hotspot settings"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Your hotspot band has changed."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"This device doesn’t support your preference for 5 GHz only. Instead, this device will use the 5 GHz band when available."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-en-rIN/strings.xml b/packages/SettingsProvider/res/values-en-rIN/strings.xml
index 05cd54e..fac51d83 100644
--- a/packages/SettingsProvider/res/values-en-rIN/strings.xml
+++ b/packages/SettingsProvider/res/values-en-rIN/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Settings Storage"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Changes to your hotspot settings"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Your hotspot band has changed."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"This device doesn’t support your preference for 5 GHz only. Instead, this device will use the 5 GHz band when available."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-es-rUS/strings.xml b/packages/SettingsProvider/res/values-es-rUS/strings.xml
index d5e6da9..af90257 100644
--- a/packages/SettingsProvider/res/values-es-rUS/strings.xml
+++ b/packages/SettingsProvider/res/values-es-rUS/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Almacenamiento de configuración"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Cambios en la configuración de tu hotspot"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Cambió la banda de tu hotspot."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Si bien este dispositivo no admite la opción para conectarse exclusivamente a bandas de 5 GHz, las usará cuando estén disponibles."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-es/strings.xml b/packages/SettingsProvider/res/values-es/strings.xml
index d5e6da9..ff4ee38 100644
--- a/packages/SettingsProvider/res/values-es/strings.xml
+++ b/packages/SettingsProvider/res/values-es/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Almacenamiento de configuración"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Cambios en los ajustes del punto de acceso"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"La banda de tu punto de acceso ha cambiado."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Este dispositivo no admite la opción de conectarse únicamente a bandas de 5 GHz, pero las usará cuando estén disponibles."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-et/strings.xml b/packages/SettingsProvider/res/values-et/strings.xml
index a3e4db6..a0ec593 100644
--- a/packages/SettingsProvider/res/values-et/strings.xml
+++ b/packages/SettingsProvider/res/values-et/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Seadete talletusruum"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Muudatused teie kuumkoha seadetes"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Teie kuumkoha sagedusriba on muutunud."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"See seade ei toeta teie eelistatud ainult 5 GHz riba. Seade kasutab 5 GHz riba ainult siis, kui see on saadaval."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-eu/strings.xml b/packages/SettingsProvider/res/values-eu/strings.xml
index 8d410de1..220b486 100644
--- a/packages/SettingsProvider/res/values-eu/strings.xml
+++ b/packages/SettingsProvider/res/values-eu/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Ezarpenen biltegia"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Aldaketak egin dira sare publikoaren ezarpenetan"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Aldatu da sare publikoaren banda."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Gailuak ez du onartzen 5 GHz-ko banda soilik erabiltzeko hobespena. Horren ordez, erabilgarri dagoen bakoitzean erabiliko da 5 GHz-ko banda."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-fa/strings.xml b/packages/SettingsProvider/res/values-fa/strings.xml
index ed9d168..6819d2f 100644
--- a/packages/SettingsProvider/res/values-fa/strings.xml
+++ b/packages/SettingsProvider/res/values-fa/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"تنظیم محل ذخیره"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"تغییرات در تنظیمات نقطه اتصال"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"نوار نقطه اتصال شما تغییر کرد."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"این دستگاه از اولویت فقط ۵ گیگاهرتز شما پشتیبانی نمیکند. هرزمان نوار ۵ گیگاهرتزی دردسترس باشد، این دستگاه از آن استفاده خواهد کرد."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-fi/strings.xml b/packages/SettingsProvider/res/values-fi/strings.xml
index 9ff2c41..9ad01eb 100644
--- a/packages/SettingsProvider/res/values-fi/strings.xml
+++ b/packages/SettingsProvider/res/values-fi/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Asetuksien tallennus"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Hotspot-asetustesi muutokset"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Hotspot-taajuutesi on muuttunut."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Tämä laite ei tue asetustasi (vain 5 GHz). Sen sijaan laite käyttää 5 GHz:n taajuutta sen ollessa käytettävissä."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-fr-rCA/strings.xml b/packages/SettingsProvider/res/values-fr-rCA/strings.xml
index fdfdb1d..62951bd 100644
--- a/packages/SettingsProvider/res/values-fr-rCA/strings.xml
+++ b/packages/SettingsProvider/res/values-fr-rCA/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Stockage des paramètres"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Modifications apportées à vos paramètres de point d\'accès"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"La bande de votre point d\'accès a changé."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Cet appareil ne prend pas en charge votre préférence pour la bande de 5 GHz seulement. Au lieu de cela, cet appareil utilisera la bande de 5 GHz lorsqu\'elle sera disponible."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-fr/strings.xml b/packages/SettingsProvider/res/values-fr/strings.xml
index fdfdb1d..56bc65b 100644
--- a/packages/SettingsProvider/res/values-fr/strings.xml
+++ b/packages/SettingsProvider/res/values-fr/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Stockage des paramètres"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Modifications apportées à vos paramètres de point d\'accès"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"La bande utilisée par votre point d\'accès a été modifiée."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Cet appareil n\'est pas conçu pour utiliser exclusivement la bande 5 GHz, mais il l\'utilisera chaque fois que disponible."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-gl/strings.xml b/packages/SettingsProvider/res/values-gl/strings.xml
index 7b1599e..771fade 100644
--- a/packages/SettingsProvider/res/values-gl/strings.xml
+++ b/packages/SettingsProvider/res/values-gl/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Almacenamento da configuración"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Cambios na configuración da zona wifi"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Modificouse a banda da zona wifi."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Este dispositivo non admite a opción de conectarse só a bandas de 5 GHz, pero usaraas se están dispoñibles."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-gu/strings.xml b/packages/SettingsProvider/res/values-gu/strings.xml
index 00246f9..a561924 100644
--- a/packages/SettingsProvider/res/values-gu/strings.xml
+++ b/packages/SettingsProvider/res/values-gu/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"સેટિંગ્સ સંગ્રહ"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"તમારા હૉટસ્પૉટ સેટિંગને બદલે છે"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"તમારું હૉટસ્પૉટ બૅન્ડ બદલાઈ ગયું છે."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"આ ડિવાઇસ તમારી ફક્ત 5GHz માટેની પસંદગીને સપોર્ટ કરતું નથી. તેના બદલે, જ્યારે 5GHz બૅન્ડ ઉપલબ્ધ હશે ત્યારે આ ડિવાઇસ તેનો ઉપયોગ કરશે."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-hi/strings.xml b/packages/SettingsProvider/res/values-hi/strings.xml
index 35ed78f..199a546 100644
--- a/packages/SettingsProvider/res/values-hi/strings.xml
+++ b/packages/SettingsProvider/res/values-hi/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"सेटिंग मेमोरी"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"आपकी हॉटस्पॉट की सेटिंग में किए गए बदलाव"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"आपका हॉटस्पॉट का बैंड बदल दिया गया है."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"इस डिवाइस पर आप \'सिर्फ़ 5 गीगाहर्ट्ज़\' वाला विकल्प नहीं चुन सकते. इसके बजाय, 5 गीगाहर्ट्ज़ बैंड उपलब्ध होने पर यह डिवाइस उसका इस्तेमाल करेगा."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-hr/strings.xml b/packages/SettingsProvider/res/values-hr/strings.xml
index 070d061..9129a04 100644
--- a/packages/SettingsProvider/res/values-hr/strings.xml
+++ b/packages/SettingsProvider/res/values-hr/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Postavke pohrane"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Promjene postavki vaše žarišne točke"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Promijenila se frekvencija vaše žarišne točke."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Ovaj uređaj ne podržava vašu postavku za upotrebu samo 5 GHz. Upotrebljavat će frekvenciju od 5 GHz kada je dostupna."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-hu/strings.xml b/packages/SettingsProvider/res/values-hu/strings.xml
index 97124ae..a1ed494 100644
--- a/packages/SettingsProvider/res/values-hu/strings.xml
+++ b/packages/SettingsProvider/res/values-hu/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Beállítástároló"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"A hotspot beállításainak módosítása"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"A hotspot sávja megváltozott."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Ez az eszköz nem támogatja a csak 5 GHz-es sávra vonatkozó beállítást. Az eszköz akkor használ 5 GHz-es sávot, ha a sáv rendelkezésre áll."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-hy/strings.xml b/packages/SettingsProvider/res/values-hy/strings.xml
index d494012..6d716f8 100644
--- a/packages/SettingsProvider/res/values-hy/strings.xml
+++ b/packages/SettingsProvider/res/values-hy/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Կարգավորումների պահուստ"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Փոփոխություններ թեժ կետի կարգավորումներում"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Ձեր թեժ կետի հաճախականությունը փոխվել է։"</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Սարքը չի կարող աշխատել միայն 5 ԳՀց հաճախականությամբ։ Այդ հաճախականությունը կօգտագործվի հնարավորության դեպքում։"</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-in/strings.xml b/packages/SettingsProvider/res/values-in/strings.xml
index 4ec8f84..8b1b1f4 100644
--- a/packages/SettingsProvider/res/values-in/strings.xml
+++ b/packages/SettingsProvider/res/values-in/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Setelan Penyimpanan"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Perubahan pada setelan hotspot Anda"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Band hotspot Anda telah berubah."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Perangkat ini tidak mendukung preferensi Anda, yaitu hanya 5GHz. Sebagai gantinya, perangkat ini akan menggunakan band 5GHz jika tersedia."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-is/strings.xml b/packages/SettingsProvider/res/values-is/strings.xml
index d75abae..150c084 100644
--- a/packages/SettingsProvider/res/values-is/strings.xml
+++ b/packages/SettingsProvider/res/values-is/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Stillingageymsla"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Breytingar á stillingum heits reits"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Tíðnisvið heita reitsins hefur breyst."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Þetta tæki styður ekki val þitt fyrir aðeins 5 GHz. Í staðinn mun þetta tæki nota 5 GHz tíðnisvið þegar það er í boði."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-it/strings.xml b/packages/SettingsProvider/res/values-it/strings.xml
index a1e3901..6715c3c 100644
--- a/packages/SettingsProvider/res/values-it/strings.xml
+++ b/packages/SettingsProvider/res/values-it/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Memoria impostazioni"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Modifiche alle tue impostazioni dell\'hotspot"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"La banda dell\'hotspot è cambiata."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Questo dispositivo non supporta la tua preferenza esclusiva per 5 GHz. Utilizzerà la banda a 5 GHz solo quando è disponibile."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-iw/strings.xml b/packages/SettingsProvider/res/values-iw/strings.xml
index c14f776..dd44329 100644
--- a/packages/SettingsProvider/res/values-iw/strings.xml
+++ b/packages/SettingsProvider/res/values-iw/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"אחסון הגדרות"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"שינויים להגדרות של הנקודה לשיתוף אינטרנט"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"התדר של הנקודה לשיתוף אינטרנט השתנה."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"מכשיר זה לא תומך בהעדפות שלך ל-5GHz בלבד. במקום זאת, מכשיר זה ישתמש בתדר 5GHz כשיהיה זמין."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-ja/strings.xml b/packages/SettingsProvider/res/values-ja/strings.xml
index b11ec3b..7bbcd46 100644
--- a/packages/SettingsProvider/res/values-ja/strings.xml
+++ b/packages/SettingsProvider/res/values-ja/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"ストレージの設定"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"アクセス ポイントの設定の変更"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"アクセス ポイントの帯域幅が変更されました。"</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"このデバイスは 5 GHz のみという設定に対応していません。ただし、5 GHz 周波数帯が利用できるときには利用します。"</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-ka/strings.xml b/packages/SettingsProvider/res/values-ka/strings.xml
index d08e71e..86db4f3 100644
--- a/packages/SettingsProvider/res/values-ka/strings.xml
+++ b/packages/SettingsProvider/res/values-ka/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"პარამეტრების საცავი"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"თქვენი უსადენო ქსელის პარამეტრების ცვლილება"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"თქვენი უსადენო ქსელის დიაპაზონი შეიცვალა."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"ამ მოწყობილობას არ შეუძლია მხოლოდ 5 გჰც სიხშირეზე მუშაობა. აღნიშნული სიხშირის გამოყენება მოხდება მაშინ, როცა ეს შესაძლებელია."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-kk/strings.xml b/packages/SettingsProvider/res/values-kk/strings.xml
index c07264c..a093d08 100644
--- a/packages/SettingsProvider/res/values-kk/strings.xml
+++ b/packages/SettingsProvider/res/values-kk/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Параметрлер жады"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Хотспот параметрлеріне өзгерістер енгізілді"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Хотспот жолағы өзгертілді."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Бұл құрылғы тек 5 ГГц жиілікте жұмыс істей алмайды. Бұл жиілік мүмкін болған жағдайда ғана қолданылады."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-km/strings.xml b/packages/SettingsProvider/res/values-km/strings.xml
index c880ead..f0a2712 100644
--- a/packages/SettingsProvider/res/values-km/strings.xml
+++ b/packages/SettingsProvider/res/values-km/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"កំណត់ការផ្ទុក"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"ប្ដូរទៅការកំណត់ហតស្ប៉តរបស់អ្នក"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"កម្រិតបញ្ជូនហតស្ប៉តរបស់អ្នកបានផ្លាស់ប្ដូរ។"</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"ឧបករណ៍នេះមិនស្គាល់ចំណូលចិត្តរបស់អ្នកសម្រាប់តែ 5GHz ប៉ុណ្ណោះ។ ផ្ទុយមកវិញ ឧបករណ៍នេះនឹងប្រើកម្រិតបញ្ជូន 5GHz នៅពេលដែលអាចប្រើបាន។"</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-kn/strings.xml b/packages/SettingsProvider/res/values-kn/strings.xml
index d823323..f2c1d5e 100644
--- a/packages/SettingsProvider/res/values-kn/strings.xml
+++ b/packages/SettingsProvider/res/values-kn/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"ಸೆಟ್ಟಿಂಗ್ಗಳ ಸಂಗ್ರಹಣೆ"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"ನಿಮ್ಮ ಹಾಟ್ಸ್ಪಾಟ್ ಸೆಟ್ಟಿಂಗ್ಗಳಲ್ಲಿನ ಬದಲಾವಣೆಗಳು"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"ನಿಮ್ಮ ಹಾಟ್ಸ್ಪಾಟ್ ಬ್ಯಾಂಡ್ ಬದಲಾಗಿದೆ."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"ಈ ಸಾಧನವು 5GHz ಗೆ ಮಾತ್ರ ನಿಮ್ಮ ಆದ್ಯತೆಯನ್ನು ಬೆಂಬಲಿಸುವುದಿಲ್ಲ. ಬದಲಿಗೆ, ಈ ಸಾಧನವು 5GHz ಬ್ಯಾಂಡ್ ಅನ್ನು ಲಭ್ಯವಿರುವಾಗ ಬಳಸುತ್ತದೆ."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-ko/strings.xml b/packages/SettingsProvider/res/values-ko/strings.xml
index ab8fb2b..841832d 100644
--- a/packages/SettingsProvider/res/values-ko/strings.xml
+++ b/packages/SettingsProvider/res/values-ko/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"설정 저장소"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"핫스팟 설정 변경"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"핫스팟 대역이 변경되었습니다."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"이 기기에서는 5GHz 전용 환경설정이 지원되지 않습니다. 대신 가능할 때만 기기에서 5GHz 대역이 사용됩니다."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-ky/strings.xml b/packages/SettingsProvider/res/values-ky/strings.xml
index 566c481..014c66c 100644
--- a/packages/SettingsProvider/res/values-ky/strings.xml
+++ b/packages/SettingsProvider/res/values-ky/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Жөндөөлөрдү сактоо"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Байланыш түйүнүңүздүн жөндөөлөрү өзгөрүлдү"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Байланыш түйүнүңүздүн жыштыгы өзгөрдү."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Бул түзмөк 5ГГцти гана колдонуу жөндөөсүн колдоого албайт. Анын ордуна, бул түзмөк 5ГГц жыштыгын ал жеткиликтүү болгондо колдонот."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-lo/strings.xml b/packages/SettingsProvider/res/values-lo/strings.xml
index 1aa5fe9..9d60ba1 100644
--- a/packages/SettingsProvider/res/values-lo/strings.xml
+++ b/packages/SettingsProvider/res/values-lo/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"ບ່ອນເກັບຂໍ້ມູນການຕັ້ງຄ່າ"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"ການປ່ຽນແປງການຕັ້ງຄ່າຮັອດສະປອດຂອງທ່ານ"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"ຄື້ນຄວາມຖີ່ຮັອດສະປອດຂອງທ່ານປ່ຽນແປງແລ້ວ."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"ອຸປະກອນນີ້ບໍ່ຮອງຮັບການຕັ້ງຄ່າຂອງທ່ານສຳລັບ 5GHz ເທົ່ານັ້ນ. ແຕ່ວ່າອຸປະກອນນີ້ຈະໃຊ້ຄື້ນຄວາມຖີ່ 5GHz ເມື່ອສາມາດໃຊ້ໄດ້."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-lt/strings.xml b/packages/SettingsProvider/res/values-lt/strings.xml
index 47cd6b4..775d3b9 100644
--- a/packages/SettingsProvider/res/values-lt/strings.xml
+++ b/packages/SettingsProvider/res/values-lt/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Nustatymų saugykla"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Viešosios interneto prieigos taško nustatymų pakeitimai"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Viešosios prieigos taško dažnio juosta pasikeitė."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Šiame įrenginyje nepalaikoma tik 5 GHz nuostata. Vietoj to šiame įrenginyje bus naudojama 5 GHz dažnio juosta, kai bus pasiekiama."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-lv/strings.xml b/packages/SettingsProvider/res/values-lv/strings.xml
index d221d46..f7f3117 100644
--- a/packages/SettingsProvider/res/values-lv/strings.xml
+++ b/packages/SettingsProvider/res/values-lv/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Iestatījumu krātuve"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Izmaiņas tīklāja iestatījumos"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Ir mainīts tīklāja joslas platums."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Šajā ierīcē netiek atbalstīta jūsu preference par tikai 5 GHz joslu. 5 GHz josla ierīcē tiks izmantota, kad tā būs pieejama."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-mk/strings.xml b/packages/SettingsProvider/res/values-mk/strings.xml
index dc74c4a..a245e5f 100644
--- a/packages/SettingsProvider/res/values-mk/strings.xml
+++ b/packages/SettingsProvider/res/values-mk/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Поставки за меморија"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Промени на поставките за точка на пристап"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Опсегот за точка на пристап е променет."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Уредов не ги поддржува вашите поставки за само 5 GHz. Наместо тоа, ќе го користи опсегот од 5 GHz кога е достапен."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-ml/strings.xml b/packages/SettingsProvider/res/values-ml/strings.xml
index a11e236..b63f20e 100644
--- a/packages/SettingsProvider/res/values-ml/strings.xml
+++ b/packages/SettingsProvider/res/values-ml/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"സംഭരണ ക്രമീകരണം"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"നിങ്ങളുടെ ഹോട്ട്സ്പോട്ട് ക്രമീകരണത്തിൽ വരുത്തിയ മാറ്റങ്ങൾ"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"നിങ്ങളുടെ ഹോട്ട്സ്പോട്ട് ബാൻഡ് മാറിയിരിക്കുന്നു."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"നിങ്ങളുടെ മുൻഗണനയനുസരിച്ചുള്ള, 5GHz മാത്രം എന്നത് ഈ ഉപകരണം പിന്തുണയ്ക്കുന്നില്ല. പകരം, 5GHz ബാൻഡ് ലഭ്യമാകുമ്പോൾ അത് ഉപയോഗിക്കും."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-mn/strings.xml b/packages/SettingsProvider/res/values-mn/strings.xml
index f6437c75..c839177 100644
--- a/packages/SettingsProvider/res/values-mn/strings.xml
+++ b/packages/SettingsProvider/res/values-mn/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Тохиргооны Сан"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Таны сүлжээний цэгийн тохиргооны өөрчлөлт"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Таны сүлжээний цэгийн хязгаарыг өөрчилсөн."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Энэ төхөөрөмж нь зөвхөн 5Гц гэсэн таны сонголтыг дэмждэггүй. Оронд нь энэ төхөөрөмж 5Гц-н хязгаарыг боломжтой үед нь ашиглах болно."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-mr/strings.xml b/packages/SettingsProvider/res/values-mr/strings.xml
index 7888488..0c7041e 100644
--- a/packages/SettingsProvider/res/values-mr/strings.xml
+++ b/packages/SettingsProvider/res/values-mr/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"सेटिंग्ज संचयन"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"तुमच्या हॉटस्पॉट सेटिंग्जमधील बदल"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"तुमचा हॉटस्पॉट बँड बदलला गेला आहे."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"हे डिव्हाइस फक्त ५GHz च्या तुमच्या प्राधान्याला सपोर्ट करत नाही. त्याऐवजी, उपलब्ध असेल तेव्हा हे डिव्हाइस ५GHz बँड वापरेल."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-ms/strings.xml b/packages/SettingsProvider/res/values-ms/strings.xml
index bcde71c..a1574df 100644
--- a/packages/SettingsProvider/res/values-ms/strings.xml
+++ b/packages/SettingsProvider/res/values-ms/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Storan Tetapan"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Perubahan kepada tetapan tempat liputan anda"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Jalur tempat liputan anda telah berubah."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Peranti ini tidak menyokong pilihan anda untuk 5GHz sahaja. Sebaliknya, peranti ini akan menggunakan jalur 5GHz apabila tersedia."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-my/strings.xml b/packages/SettingsProvider/res/values-my/strings.xml
index b2e670e..48d4dba 100644
--- a/packages/SettingsProvider/res/values-my/strings.xml
+++ b/packages/SettingsProvider/res/values-my/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"သိုလှောင်မှုဆက်တင်များ"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"သင်၏ဟော့စပေါ့ ဆက်တင်များ ပြောင်းလဲမှု"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"သင်၏ ဟော့စပေါ့လိုင်း ပြောင်းသွားပါပြီ။"</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"ဤစက်ပစ္စည်းသည် သင်၏ 5GHz သီးသန့်ရွေးချယ်မှုအတွက် ပံ့ပိုးမထားပါ။ ၎င်းအစား ဤစက်ပစ္စည်းသည် ရနိုင်သည့်အခါ 5GHz လိုင်းကို သုံးသွားပါမည်။"</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-nb/strings.xml b/packages/SettingsProvider/res/values-nb/strings.xml
index 5c60ad7..e0cbd7e 100644
--- a/packages/SettingsProvider/res/values-nb/strings.xml
+++ b/packages/SettingsProvider/res/values-nb/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Lagring av innstillinger"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Endres til innstillingene dine for Wi-Fi-soner"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Båndet ditt for Wi-Fi-sone er endret."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Denne enheten støtter ikke innstillingen din for bare 5 GHz. I stedet bruker enheten 5 GHz-båndet når det er tilgjengelig."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-ne/strings.xml b/packages/SettingsProvider/res/values-ne/strings.xml
index 8c4f8c8..2fd9b00 100644
--- a/packages/SettingsProvider/res/values-ne/strings.xml
+++ b/packages/SettingsProvider/res/values-ne/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"सेटिङहरू भण्डारण"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"तपाईंका हटस्पट सेटिङहरूमा गरिएका परिवर्तनहरू"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"तपाईंको हटस्पट ब्यान्ड परिवर्तन भएको छ।"</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"यो यन्त्रले तपाईंको 5GHz मात्रको प्राथमिकतालाई समर्थन गर्दैन। बरु, उपलब्ध भएको खण्डमा यो यन्त्रले 5GHz ब्यान्ड प्रयोग गर्ने छ।"</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-nl/strings.xml b/packages/SettingsProvider/res/values-nl/strings.xml
index 7ad4588..0b843ae 100644
--- a/packages/SettingsProvider/res/values-nl/strings.xml
+++ b/packages/SettingsProvider/res/values-nl/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Opslagruimte voor instellingen"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Wijzigingen in je hotspot-instellingen"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Je hotspot-band is gewijzigd."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Dit apparaat biedt geen ondersteuning voor je voorkeur voor alleen 5 GHz. In plaats daarvan gebruikt dit apparaat de 5-GHz-band wanneer deze beschikbaar is."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-or/strings.xml b/packages/SettingsProvider/res/values-or/strings.xml
index 1837219..53f6104 100644
--- a/packages/SettingsProvider/res/values-or/strings.xml
+++ b/packages/SettingsProvider/res/values-or/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"ସେଟିଙ୍ଗ ଷ୍ଟୋରେଜ୍"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"ଆପଣଙ୍କର ହଟ୍ସ୍ପଟ୍ ସେଟିଂସ୍କୁ ବଦଳାଇଥାଏ"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"ଆପଣଙ୍କର ହଟ୍ସ୍ପଟ୍ ପରିବର୍ତ୍ତନ କରାଯାଇଛି।"</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"କେବଳ 5GHz ପାଇଁ, ଏହି ଡିଭାଇସ୍ ଆପଣଙ୍କର ପସନ୍ଦକୁ ସମର୍ଥନ କରେ ନାହିଁ। ଏହା ପରିବର୍ତ୍ତେ, ଉପଲବ୍ଧ ହେଲେ ଏହି ଡିଭାଇସ୍ 5GHz ବ୍ୟାଣ୍ଡ ବ୍ୟବହାର କରିବ।"</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-pa/strings.xml b/packages/SettingsProvider/res/values-pa/strings.xml
index 2961435..9a41e36 100644
--- a/packages/SettingsProvider/res/values-pa/strings.xml
+++ b/packages/SettingsProvider/res/values-pa/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"ਸੈਟਿੰਗਾਂ ਸਟੋਰੇਜ"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"ਤੁਹਾਡੀਆਂ ਹੌਟਸਪੌਟ ਸੈਟਿੰਗਾਂ ਵਿੱਚ ਬਦਲਾਅ"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"ਤੁਹਾਡਾ ਹੌਟਸਪੌਟ ਬੈਂਡ ਬਦਲ ਗਿਆ ਹੈ।"</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"ਇਹ ਡੀਵਾਈਸ ਸਿਰਫ਼ 5GHz ਦੀ ਤੁਹਾਡੀ ਤਰਜੀਹ ਦਾ ਸਮਰਥਨ ਨਹੀਂ ਕਰਦਾ ਹੈ। ਇਸਦੀ ਬਜਾਏ, ਇਹ ਡੀਵਾਈਸ ਉਪਲਬਧ ਹੋਣ \'ਤੇ 5GHz ਬੈਂਡ ਵਰਤੇਗਾ।"</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-pl/strings.xml b/packages/SettingsProvider/res/values-pl/strings.xml
index 9963aee..7fd2b13 100644
--- a/packages/SettingsProvider/res/values-pl/strings.xml
+++ b/packages/SettingsProvider/res/values-pl/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Pamięć ustawień"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Zmieniono ustawienia hotspotu"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Zmieniono pasmo hotspotu."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"To urządzenie nie może korzystać tylko z częstotliwości 5 GHz. Będzie korzystać z tego pasma, jeśli będzie ono dostępne."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-pt-rBR/strings.xml b/packages/SettingsProvider/res/values-pt-rBR/strings.xml
index e25e82e..18db8f6 100644
--- a/packages/SettingsProvider/res/values-pt-rBR/strings.xml
+++ b/packages/SettingsProvider/res/values-pt-rBR/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Armazenamento de configurações"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Mudanças nas suas configurações de ponto de acesso"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Sua banda de ponto de acesso foi modificada."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Este dispositivo não é compatível com sua preferência apenas por 5 GHz. Em vez disso, o dispositivo usará a banda de 5 GHz quando ela estiver disponível."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-pt-rPT/strings.xml b/packages/SettingsProvider/res/values-pt-rPT/strings.xml
index 3b95a31..be88cce 100644
--- a/packages/SettingsProvider/res/values-pt-rPT/strings.xml
+++ b/packages/SettingsProvider/res/values-pt-rPT/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Armazenamento de definições"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Alterações às definições de zona Wi-Fi"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"A banda da sua zona Wi-Fi foi alterada."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Este dispositivo não suporta a sua preferência apenas para 5 GHz. Em alternativa, este dispositivo vai utilizar a banda de 5 GHz quando estiver disponível."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-pt/strings.xml b/packages/SettingsProvider/res/values-pt/strings.xml
index e25e82e..18db8f6 100644
--- a/packages/SettingsProvider/res/values-pt/strings.xml
+++ b/packages/SettingsProvider/res/values-pt/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Armazenamento de configurações"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Mudanças nas suas configurações de ponto de acesso"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Sua banda de ponto de acesso foi modificada."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Este dispositivo não é compatível com sua preferência apenas por 5 GHz. Em vez disso, o dispositivo usará a banda de 5 GHz quando ela estiver disponível."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-ro/strings.xml b/packages/SettingsProvider/res/values-ro/strings.xml
index 5a5ac6d..3a234e1 100644
--- a/packages/SettingsProvider/res/values-ro/strings.xml
+++ b/packages/SettingsProvider/res/values-ro/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Stocare setări"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Modificări aduse setărilor pentru hotspot"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"S-a schimbat banda de frecvență a hotspotului."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Dispozitivul nu acceptă doar preferința pentru 5 GHz. Dispozitivul va folosi banda de 5 GHz când este disponibilă."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-ru/strings.xml b/packages/SettingsProvider/res/values-ru/strings.xml
index 15ca313..184afdd 100644
--- a/packages/SettingsProvider/res/values-ru/strings.xml
+++ b/packages/SettingsProvider/res/values-ru/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Хранилище настроек"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Изменения в настройках точки доступа"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Частота точки доступа изменена."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Устройство не может работать только на частоте 5 ГГц. Эта частота будет использоваться, когда это возможно."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-si/strings.xml b/packages/SettingsProvider/res/values-si/strings.xml
index feff43c..69e04f1 100644
--- a/packages/SettingsProvider/res/values-si/strings.xml
+++ b/packages/SettingsProvider/res/values-si/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"සැකසීම් ගබඩාව"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"ඔබගේ හොට්ස්පොට් සැකසීම්වලට වෙනස් කිරීම්"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"ඔබගේ හොට්ස්පොට් කලාපය වෙනස් වී ඇත."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"මෙම උපාංගය 5GHz සඳහා ඔබේ මනාපවලට සහාය නොදක්වයි. ඒ වෙනුවට, මෙම උපාංගය ලබා ගත හැකි විට 5GHz කලාපය භාවිතා කරනු ඇත."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-sk/strings.xml b/packages/SettingsProvider/res/values-sk/strings.xml
index 1207a94..a53178d 100644
--- a/packages/SettingsProvider/res/values-sk/strings.xml
+++ b/packages/SettingsProvider/res/values-sk/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Ukladací priestor nastavení"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Zmeny nastavení hotspotu"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Pásmo vášho hotspotu sa zmenilo."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Toto zariadenie nepodporuje vašu predvoľbu používať iba 5 GHz. Namiesto toho bude pásmo 5 GHz používať vtedy, keď bude k dispozícii."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-sl/strings.xml b/packages/SettingsProvider/res/values-sl/strings.xml
index 28a9937..ea697fe 100644
--- a/packages/SettingsProvider/res/values-sl/strings.xml
+++ b/packages/SettingsProvider/res/values-sl/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Shramba nastavitev"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Spremembe nastavitev dostopne točke"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Pas dostopne točke je spremenjen."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Ta naprava ne podpira prednostne nastavitve samo za 5-GHz pas. Namesto tega bo ta naprava uporabljala 5-GHz pas, ko bo na voljo."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-sq/strings.xml b/packages/SettingsProvider/res/values-sq/strings.xml
index 977fe02..a111576 100644
--- a/packages/SettingsProvider/res/values-sq/strings.xml
+++ b/packages/SettingsProvider/res/values-sq/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Hapësira ruajtëse e \"Cilësimeve\""</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Ndryshimet në cilësimet e zonës së qasjes për internet"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Brezi yt i zonës së qasjes për internet ka ndryshuar."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Kjo pajisje nuk e mbështet preferencën për vetëm 5 GHz. Përkundrazi, pajisja do të përdorë brezin 5 GHz nëse ka."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-sr/strings.xml b/packages/SettingsProvider/res/values-sr/strings.xml
index 74b9dde..d473102 100644
--- a/packages/SettingsProvider/res/values-sr/strings.xml
+++ b/packages/SettingsProvider/res/values-sr/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Подешавања складишта"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Промене подешавања за хотспот"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Опсег хотспота је промењен."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Овај уређај не подржава подешавање само за 5 GHz. Уређај ће користити опсег од 5 GHz када буде доступан."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-sv/strings.xml b/packages/SettingsProvider/res/values-sv/strings.xml
index 1444626..fea3e5e 100644
--- a/packages/SettingsProvider/res/values-sv/strings.xml
+++ b/packages/SettingsProvider/res/values-sv/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Lagring av inställningar"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Ändringar i inställningarna för surfzon"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Frekvensbandet för surfzonen har ändrats."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Den här enheten har inte stöd för inställningen för att endast använda 5 GHz. I stället används 5 GHz när det är möjligt."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-sw/strings.xml b/packages/SettingsProvider/res/values-sw/strings.xml
index c244d88..4d05817 100644
--- a/packages/SettingsProvider/res/values-sw/strings.xml
+++ b/packages/SettingsProvider/res/values-sw/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Hifadhi ya Mipangilio"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Mabadiliko kwenye mipangilio ya mtandaopepe"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Bendi ya mtandaopepe wako imebadilika."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Kifaa hiki hakitumii mapendeleo yako ya GHz 5 pekee. Badala yake, kifaa hiki kitatumia bendi ya GHz 5 itakapopatikana."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-ta/strings.xml b/packages/SettingsProvider/res/values-ta/strings.xml
index b26c875..f518a78 100644
--- a/packages/SettingsProvider/res/values-ta/strings.xml
+++ b/packages/SettingsProvider/res/values-ta/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"அமைப்புகளின் சேமிப்பிடம்"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"உங்கள் ஹாட்ஸ்பாட் அமைப்புகளில் செய்யப்பட்டுள்ள மாற்றங்கள்"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"உங்கள் ஹாட்ஸ்பாட்டின் அலைவரிசை வரம்பு மாறிவிட்டது."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"இந்தச் சாதனத்தில், ’5GHz மட்டும்’ எனும் முன்னுரிமைத் தேர்வு ஆதரிக்கப்படவில்லை. எனினும் 5GHz அலைவரிசை வரம்பிற்குள் இருக்கும்போது சாதனம் அதைப் பயன்படுத்திக்கொள்ளும்."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-te/strings.xml b/packages/SettingsProvider/res/values-te/strings.xml
index 2a4971a..6c59223 100644
--- a/packages/SettingsProvider/res/values-te/strings.xml
+++ b/packages/SettingsProvider/res/values-te/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"సెట్టింగ్ల నిల్వ"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"మీ హాట్స్పాట్ సెట్టింగ్లకు మార్పులు"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"మీ హాట్స్పాట్ బ్యాండ్ మార్చబడింది."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"ఈ పరికరం 5GHz కోసం మాత్రమే మీ ప్రాధాన్యతకు మద్దతు ఇవ్వదు. బదులుగా, ఈ పరికరం అందుబాటులో ఉన్నప్పుడు 5GHz బ్యాండ్ను ఉపయోగిస్తుంది."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-th/strings.xml b/packages/SettingsProvider/res/values-th/strings.xml
index db47654..4bf148f 100644
--- a/packages/SettingsProvider/res/values-th/strings.xml
+++ b/packages/SettingsProvider/res/values-th/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"ที่เก็บข้อมูลการตั้งค่า"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"มีการเปลี่ยนแปลงการตั้งค่าฮอตสปอต"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"ย่านความถี่ฮอตสปอตมีการเปลี่ยนแปลง"</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"อุปกรณ์นี้ไม่รองรับค่ากำหนดของคุณเฉพาะสำหรับ 5 GHz เท่านั้น และจะใช้ย่านความถี่ 5 GHz แทน เมื่อใช้ได้"</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-tl/strings.xml b/packages/SettingsProvider/res/values-tl/strings.xml
index 71c6266..2a36d58 100644
--- a/packages/SettingsProvider/res/values-tl/strings.xml
+++ b/packages/SettingsProvider/res/values-tl/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Storage ng Mga Setting"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Mga pagbabago sa mga setting ng iyong hotspot"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Nagbago ang band ng iyong hotspot."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Hindi sinusuportahan ng device na ito ang kagustuhan mong gumamit lang ng 5GHz. Sa halip, gagamitin ng device na ito ang 5GHz na band kapag available."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-tr/strings.xml b/packages/SettingsProvider/res/values-tr/strings.xml
index 4737a1e..add1fdb 100644
--- a/packages/SettingsProvider/res/values-tr/strings.xml
+++ b/packages/SettingsProvider/res/values-tr/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Ayarlar Deposu"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Hotspot ayarlarınız değişti"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Hotspot bandınız değişti."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Bu cihaz yalnızca 5 GHz bandının kullanılmasına yönelik tercihinizi desteklemiyor. Bunun yerine, bu cihaz 5 GHz bandını mevcut olduğunda kullanacak."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-uk/strings.xml b/packages/SettingsProvider/res/values-uk/strings.xml
index 2c77c6a61..cd678bc 100644
--- a/packages/SettingsProvider/res/values-uk/strings.xml
+++ b/packages/SettingsProvider/res/values-uk/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Сховище налаштувань"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Зміни в налаштуваннях точки доступу"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Діапазон частот точки доступу змінено."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"На цьому пристрої не підтримується налаштування \"Лише 5 ГГц\". Натомість буде використано діапазон частот 5 ГГц (якщо доступно)."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-ur/strings.xml b/packages/SettingsProvider/res/values-ur/strings.xml
index 31694e0..2241ce9 100644
--- a/packages/SettingsProvider/res/values-ur/strings.xml
+++ b/packages/SettingsProvider/res/values-ur/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"ترتیبات کا اسٹوریج"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"اپنے ہاٹ اسپاٹ کی ترتیبات میں تبدیلیاں"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"آپ کا ہاٹ اسپات بینڈ تبدیل ہو گیا ہے۔"</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"یہ آلہ صرف 5GHz کے لیے آپ کی ترجیح کو سپورٹ نہیں کرے گا۔ بلکہ 5GHz بینڈ کے دستیاب ہونے پر اس کا استعمال کرے گا۔"</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-uz/strings.xml b/packages/SettingsProvider/res/values-uz/strings.xml
index 86a980e..a266bf0 100644
--- a/packages/SettingsProvider/res/values-uz/strings.xml
+++ b/packages/SettingsProvider/res/values-uz/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Sozlamalar xotirasi"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Hotspot sozlamalari o‘zgartirildi"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Hotspot chastotasi oʻzgartirildi."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Qurilma faqat 5 GGs chastotada ishlay olmaydi. Bu chastotadan imkoniyatga qarab foydalaniladi."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-vi/strings.xml b/packages/SettingsProvider/res/values-vi/strings.xml
index 6476927..74f93b2 100644
--- a/packages/SettingsProvider/res/values-vi/strings.xml
+++ b/packages/SettingsProvider/res/values-vi/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Lưu trữ bộ nhớ"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Những thay đổi trong mục cài đặt điểm phát sóng của bạn"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Bằng tần của điểm phát sóng đã thay đổi."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Thiết bị này không hỗ trợ tùy chọn chỉ sử dụng băng tần 5 GHz. Thay vào đó, thiết bị này sẽ sử dụng băng tần 5 GHz khi có thể."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-zh-rCN/strings.xml b/packages/SettingsProvider/res/values-zh-rCN/strings.xml
index 1395912..95b15e0 100644
--- a/packages/SettingsProvider/res/values-zh-rCN/strings.xml
+++ b/packages/SettingsProvider/res/values-zh-rCN/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"设置存储"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"您的热点设置已变更"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"您的热点频段已变更。"</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"此设备不支持您的偏好设置(仅限 5GHz),而且会在 5GHz 频段可用时使用该频段。"</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-zh-rHK/strings.xml b/packages/SettingsProvider/res/values-zh-rHK/strings.xml
index 2845264..41ebe27 100644
--- a/packages/SettingsProvider/res/values-zh-rHK/strings.xml
+++ b/packages/SettingsProvider/res/values-zh-rHK/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"設定儲存空間"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"您的熱點設定變更"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"您的熱點頻段已變更。"</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"此裝置不支援只限 5 GHz 的偏好設定,但會在 5 GHz 頻段可用時採用。"</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-zh-rTW/strings.xml b/packages/SettingsProvider/res/values-zh-rTW/strings.xml
index 2845264..d0a30f5 100644
--- a/packages/SettingsProvider/res/values-zh-rTW/strings.xml
+++ b/packages/SettingsProvider/res/values-zh-rTW/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"設定儲存空間"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"無線基地台設定變更"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"你的無線基地台頻帶已變更。"</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"這部裝置不支援你的偏好設定 (僅限 5GHz),而是會在 5GHz 可用時使用該頻帶。"</string>
</resources>
diff --git a/packages/SettingsProvider/res/values-zu/strings.xml b/packages/SettingsProvider/res/values-zu/strings.xml
index 8c1d9e0..0440b3b 100644
--- a/packages/SettingsProvider/res/values-zu/strings.xml
+++ b/packages/SettingsProvider/res/values-zu/strings.xml
@@ -20,10 +20,7 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_label" msgid="4567566098528588863">"Izilungiselelo zesitoreji"</string>
- <!-- no translation found for wifi_softap_config_change (5338670993556993667) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_summary (7600005249167787750) -->
- <skip />
- <!-- no translation found for wifi_softap_config_change_detailed (2504664754843959730) -->
- <skip />
+ <string name="wifi_softap_config_change" msgid="5338670993556993667">"Ushintsho kuzilungiselelo zakho ze-hotspot"</string>
+ <string name="wifi_softap_config_change_summary" msgid="7600005249167787750">"Ibhendi yakho ye-hotspot ishintshile."</string>
+ <string name="wifi_softap_config_change_detailed" msgid="2504664754843959730">"Le divayisi ayisekeli okuncamelayo kwe-5GHz kuphela. Kunalokho, le divayisi izosebenzisa ibhendi ye-5GHz uma itholakala."</string>
</resources>
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index 21b3ba3..c9e1944 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -224,7 +224,7 @@
<bool name="def_charging_sounds_enabled">true</bool>
<!-- Default for Settings.Secure.NOTIFICATION_BUBBLES -->
- <bool name="def_notification_bubbles">false</bool>
+ <bool name="def_notification_bubbles">true</bool>
<!-- Default for Settings.Secure.AWARE_ENABLED -->
<bool name="def_aware_enabled">false</bool>
diff --git a/packages/SettingsProvider/src/android/provider/settings/backup/GlobalSettings.java b/packages/SettingsProvider/src/android/provider/settings/backup/GlobalSettings.java
index 1f68742..987e82e 100644
--- a/packages/SettingsProvider/src/android/provider/settings/backup/GlobalSettings.java
+++ b/packages/SettingsProvider/src/android/provider/settings/backup/GlobalSettings.java
@@ -72,5 +72,6 @@
Settings.Global.NOTIFICATION_BUBBLES,
Settings.Global.CUSTOM_BUGREPORT_HANDLER_APP,
Settings.Global.CUSTOM_BUGREPORT_HANDLER_USER,
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED
};
}
diff --git a/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java b/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java
index 3b929b9..76e7ab4 100644
--- a/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java
+++ b/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java
@@ -155,6 +155,7 @@
Settings.Secure.GLOBAL_ACTIONS_PANEL_ENABLED,
Settings.Secure.AWARE_LOCK_ENABLED,
Settings.Secure.AWARE_TAP_PAUSE_GESTURE_COUNT,
- Settings.Secure.AWARE_TAP_PAUSE_TOUCH_COUNT
+ Settings.Secure.AWARE_TAP_PAUSE_TOUCH_COUNT,
+ Settings.Secure.PEOPLE_STRIP,
};
}
diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/GlobalSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/GlobalSettingsValidators.java
index 3d278db..72923a3 100644
--- a/packages/SettingsProvider/src/android/provider/settings/validators/GlobalSettingsValidators.java
+++ b/packages/SettingsProvider/src/android/provider/settings/validators/GlobalSettingsValidators.java
@@ -151,5 +151,6 @@
VALIDATORS.put(Global.NOTIFICATION_BUBBLES, BOOLEAN_VALIDATOR);
VALIDATORS.put(Global.CUSTOM_BUGREPORT_HANDLER_APP, ANY_STRING_VALIDATOR);
VALIDATORS.put(Global.CUSTOM_BUGREPORT_HANDLER_USER, ANY_INTEGER_VALIDATOR);
+ VALIDATORS.put(Global.DEVELOPMENT_SETTINGS_ENABLED, BOOLEAN_VALIDATOR);
}
}
diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java
index 090af98..ae07598 100644
--- a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java
+++ b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java
@@ -234,5 +234,6 @@
VALIDATORS.put(Secure.AWARE_LOCK_ENABLED, BOOLEAN_VALIDATOR);
VALIDATORS.put(Secure.DISPLAY_DENSITY_FORCED, NON_NEGATIVE_INTEGER_VALIDATOR);
VALIDATORS.put(Secure.TAP_GESTURE, BOOLEAN_VALIDATOR);
+ VALIDATORS.put(Secure.PEOPLE_STRIP, BOOLEAN_VALIDATOR);
}
}
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 2027345..375a650 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -951,8 +951,7 @@
(1 << AudioManager.STREAM_NOTIFICATION) |
(1 << AudioManager.STREAM_SYSTEM) |
(1 << AudioManager.STREAM_SYSTEM_ENFORCED);
- if (!mContext.getResources().getBoolean(
- com.android.internal.R.bool.config_voice_capable)) {
+ if (!getTelephonyManager().isVoiceCapable()) {
ringerModeAffectedStreams |= (1 << AudioManager.STREAM_MUSIC);
}
db.execSQL("DELETE FROM system WHERE name='"
@@ -2548,7 +2547,7 @@
StringBuilder val = new StringBuilder();
List<Integer> defaultNetworks = TelephonyProperties.default_network();
int phoneCount = 1;
- TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
+ TelephonyManager telephonyManager = getTelephonyManager();
if (telephonyManager != null) {
phoneCount = telephonyManager.getSupportedModemCount();
}
@@ -2663,4 +2662,8 @@
private String getDefaultDeviceName() {
return mContext.getResources().getString(R.string.def_device_name_simple, Build.MODEL);
}
+
+ private TelephonyManager getTelephonyManager() {
+ return (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ }
}
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
index 443288c..c19a340 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
@@ -28,7 +28,7 @@
import android.net.NetworkPolicy;
import android.net.NetworkPolicyManager;
import android.net.Uri;
-import android.net.wifi.WifiConfiguration;
+import android.net.wifi.SoftApConfiguration;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.ParcelFileDescriptor;
@@ -875,32 +875,23 @@
}
private byte[] getSoftAPConfiguration() {
- try {
- return mWifiManager.getWifiApConfiguration().getBytesForBackup();
- } catch (IOException ioe) {
- Log.e(TAG, "Failed to marshal SoftAPConfiguration" + ioe.getMessage());
- return new byte[0];
- }
+ return mWifiManager.retrieveSoftApBackupData();
}
private void restoreSoftApConfiguration(byte[] data) {
- try {
- WifiConfiguration config = WifiConfiguration
- .getWifiConfigFromBackup(new DataInputStream(new ByteArrayInputStream(data)));
- if (DEBUG) Log.d(TAG, "Successfully unMarshaled WifiConfiguration ");
- int originalApBand = config.apBand;
- mWifiManager.setWifiApConfiguration(config);
+ SoftApConfiguration config = mWifiManager.restoreSoftApBackupData(data);
+ if (config != null) {
+ int originalApBand = config.getBand();
+ if (DEBUG) Log.d(TAG, "Successfully unMarshaled SoftApConfiguration ");
// Depending on device hardware, we may need to notify the user of a setting change for
// the apBand preference
boolean dualMode = mWifiManager.isDualModeSupported();
- int storedApBand = mWifiManager.getWifiApConfiguration().apBand;
+ int storedApBand = mWifiManager.getSoftApConfiguration().getBand();
if (dualMode && storedApBand != originalApBand) {
Log.d(TAG, "restored ap configuration requires a conversion, notify the user");
WifiSoftApBandChangedNotifier.notifyUserOfApBandConversion(this);
}
- } catch (IOException | BackupUtils.BadVersionException e) {
- Log.e(TAG, "Failed to unMarshal SoftAPConfiguration " + e.getMessage());
}
}
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
index 0a2dd38..80077c8 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
@@ -691,6 +691,9 @@
dumpRepeatedSetting(s, p,
Settings.Global.ERROR_LOGCAT_PREFIX,
GlobalSettingsProto.ERROR_LOGCAT_LINES);
+ dumpRepeatedSetting(s, p,
+ Settings.Global.MAX_ERROR_BYTES_PREFIX,
+ GlobalSettingsProto.MAX_ERROR_BYTES);
final long euiccToken = p.start(GlobalSettingsProto.EUICC);
dumpSetting(s, p,
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 93a1407..4309c80 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -3264,7 +3264,7 @@
}
private final class UpgradeController {
- private static final int SETTINGS_VERSION = 184;
+ private static final int SETTINGS_VERSION = 185;
private final int mUserId;
@@ -4446,20 +4446,15 @@
}
if (currentVersion == 182) {
- // Remove secure bubble settings.
+ // Remove secure bubble settings; it's in global now.
getSecureSettingsLocked(userId).deleteSettingLocked("notification_bubbles");
- // Add global bubble settings.
- getGlobalSettingsLocked().insertSettingLocked(Global.NOTIFICATION_BUBBLES,
- getContext().getResources().getBoolean(
- R.bool.def_notification_bubbles) ? "1" : "0", null /* tag */,
- true /* makeDefault */, SettingsState.SYSTEM_PACKAGE_NAME);
-
+ // Removed. Updated NOTIFICATION_BUBBLES to be true by default, see 184.
currentVersion = 183;
}
if (currentVersion == 183) {
- // Version 184: Set default values for WIRELESS_CHARGING_STARTED_SOUND
+ // Version 183: Set default values for WIRELESS_CHARGING_STARTED_SOUND
// and CHARGING_STARTED_SOUND
final SettingsState globalSettings = getGlobalSettingsLocked();
@@ -4500,6 +4495,18 @@
currentVersion = 184;
}
+ if (currentVersion == 184) {
+ // Version 184: Reset the default for Global Settings: NOTIFICATION_BUBBLES
+ // This is originally set in version 182, however, the default value changed
+ // so this step is to ensure the value is updated to the correct default.
+ getGlobalSettingsLocked().insertSettingLocked(Global.NOTIFICATION_BUBBLES,
+ getContext().getResources().getBoolean(
+ R.bool.def_notification_bubbles) ? "1" : "0", null /* tag */,
+ true /* makeDefault */, SettingsState.SYSTEM_PACKAGE_NAME);
+
+ currentVersion = 185;
+ }
+
// vXXX: Add new settings above this point.
if (currentVersion != newVersion) {
diff --git a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
index c23a494..5d0db01 100644
--- a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
+++ b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
@@ -223,7 +223,6 @@
Settings.Global.DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES,
Settings.Global.DEVELOPMENT_FORCE_RTL,
Settings.Global.DEVELOPMENT_ENABLE_SIZECOMPAT_FREEFORM,
- Settings.Global.DEVELOPMENT_SETTINGS_ENABLED,
Settings.Global.DEVICE_DEMO_MODE,
Settings.Global.DEVICE_IDLE_CONSTANTS,
Settings.Global.BATTERY_SAVER_ADAPTIVE_CONSTANTS,
@@ -324,6 +323,7 @@
Settings.Global.LOW_POWER_MODE_SUGGESTION_PARAMS,
Settings.Global.LTE_SERVICE_FORCED,
Settings.Global.LID_BEHAVIOR,
+ Settings.Global.MAX_ERROR_BYTES_PREFIX,
Settings.Global.MAX_NOTIFICATION_ENQUEUE_RATE,
Settings.Global.MAX_SOUND_TRIGGER_DETECTION_SERVICE_OPS_PER_DAY,
Settings.Global.MDC_INITIAL_MAX_RETRY,
@@ -734,7 +734,8 @@
Settings.Secure.DOZE_WAKE_LOCK_SCREEN_GESTURE,
Settings.Secure.DOZE_WAKE_DISPLAY_GESTURE,
Settings.Secure.FACE_UNLOCK_RE_ENROLL,
- Settings.Secure.TAP_GESTURE);
+ Settings.Secure.TAP_GESTURE,
+ Settings.Secure.WINDOW_MAGNIFICATION);
@Test
public void systemSettingsBackedUpOrBlacklisted() {
diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp
index 2a5bdc7..404e791 100644
--- a/packages/SystemUI/Android.bp
+++ b/packages/SystemUI/Android.bp
@@ -127,7 +127,7 @@
"SystemUI-proto",
"metrics-helper-lib",
"androidx.test.rules", "hamcrest-library",
- "mockito-target-inline-minus-junit4",
+ "mockito-target-extended-minus-junit4",
"testables",
"truth-prebuilt",
"dagger2-2.19",
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 3514704..a8318d6 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -28,11 +28,6 @@
android:glEsVersion="0x00020000"
android:required="true" />
- <!-- SysUI must be the one to define this permission; its name is
- referenced by the core OS. -->
- <permission android:name="android.permission.systemui.IDENTITY"
- android:protectionLevel="signature" />
-
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- Used to read wallpaper -->
diff --git a/packages/SystemUI/plugin_core/Android.bp b/packages/SystemUI/plugin_core/Android.bp
index 42d6762..581fef7 100644
--- a/packages/SystemUI/plugin_core/Android.bp
+++ b/packages/SystemUI/plugin_core/Android.bp
@@ -16,4 +16,8 @@
sdk_version: "current",
name: "PluginCoreLib",
srcs: ["src/**/*.java"],
+
+ // Enforce that the library is built against java 8 so that there are
+ // no compatibility issues with launcher
+ java_version: "1.8",
}
diff --git a/packages/SystemUI/res/drawable/ic_control_magnification_grey.xml b/packages/SystemUI/res/drawable/ic_control_magnification_grey.xml
new file mode 100644
index 0000000..80ce8c1
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_control_magnification_grey.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2019 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.
+-->
+
+<vector android:height="96dp" android:viewportHeight="24"
+ android:viewportWidth="24" android:width="96dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#757575" android:pathData="M15.54,5.54L13.77,7.3 12,5.54 10.23,7.3 8.46,5.54 12,2zM18.46,15.54l-1.76,-1.77L18.46,12l-1.76,-1.77 1.76,-1.77L22,12zM8.46,18.46l1.77,-1.76L12,18.46l1.77,-1.76 1.77,1.76L12,22zM5.54,8.46l1.76,1.77L5.54,12l1.76,1.77 -1.76,1.77L2,12z"/>
+ <path android:fillColor="#757575" android:pathData="M12,12m-3,0a3,3 0,1 1,6 0a3,3 0,1 1,-6 0"/>
+</vector>
diff --git a/packages/SystemUI/res/layout/magnifier_controllers.xml b/packages/SystemUI/res/layout/magnifier_controllers.xml
new file mode 100644
index 0000000..0203cd4
--- /dev/null
+++ b/packages/SystemUI/res/layout/magnifier_controllers.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 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.
+ -->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="@dimen/magnification_controls_size"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentEnd="true"
+ android:layout_height="@dimen/magnification_controls_size"
+ android:gravity="center">
+
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:focusable="true"
+ android:id="@+id/controller"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/ic_control_magnification_grey" />
+
+ <View
+ android:id="@+id/left_control"
+ android:layout_width="@dimen/magnifier_left_right_controls_width"
+ android:layout_height="@dimen/magnifier_left_right_controls_height"
+ android:layout_alignLeft="@+id/controller"
+ android:layout_centerVertical="true" />
+
+ <View
+ android:id="@+id/up_control"
+ android:layout_width="@dimen/magnifier_up_down_controls_width"
+ android:layout_height="@dimen/magnifier_up_down_controls_height"
+ android:layout_alignTop="@+id/controller"
+ android:layout_centerHorizontal="true" />
+
+ <View
+ android:id="@+id/right_control"
+ android:layout_width="@dimen/magnifier_left_right_controls_width"
+ android:layout_height="@dimen/magnifier_left_right_controls_height"
+ android:layout_alignRight="@+id/controller"
+ android:layout_centerVertical="true" />
+
+ <View
+ android:id="@+id/down_control"
+ android:layout_width="@dimen/magnifier_up_down_controls_width"
+ android:layout_height="@dimen/magnifier_up_down_controls_height"
+ android:layout_alignBottom="@+id/controller"
+ android:layout_centerHorizontal="true" />
+ </RelativeLayout>
+
+</FrameLayout>
diff --git a/packages/SystemUI/res/layout/window_magnifier_view.xml b/packages/SystemUI/res/layout/window_magnifier_view.xml
new file mode 100644
index 0000000..f818612
--- /dev/null
+++ b/packages/SystemUI/res/layout/window_magnifier_view.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 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.
+ -->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <SurfaceView
+ android:layout_marginStart="@dimen/magnification_border_size"
+ android:layout_marginTop="@dimen/magnification_border_size"
+ android:id="@+id/surface_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <View
+ android:id="@+id/left_handle"
+ android:layout_width="@dimen/magnification_border_size"
+ android:layout_height="match_parent"
+ android:layout_above="@+id/drag_handle"
+ android:background="@color/magnification_border_color" />
+
+ <View
+ android:id="@+id/top_handle"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/magnification_border_size"
+ android:background="@color/magnification_border_color" />
+
+ <View
+ android:id="@+id/right_handle"
+ android:layout_width="@dimen/magnification_border_size"
+ android:layout_height="match_parent"
+ android:layout_above="@+id/drag_handle"
+ android:layout_alignParentEnd="true"
+ android:background="@color/magnification_border_color" />
+
+ <View
+ android:id="@+id/bottom_handle"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/magnification_border_size"
+ android:layout_above="@+id/drag_handle"
+ android:background="@color/magnification_border_color" />
+
+ <View
+ android:id="@+id/drag_handle"
+ android:layout_width="@dimen/magnification_drag_view_width"
+ android:layout_height="@dimen/magnification_drag_view_height"
+ android:layout_alignParentBottom="true"
+ android:layout_centerHorizontal="true"
+ android:background="@color/magnification_border_color" />
+
+ </RelativeLayout>
+</FrameLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index 92c7477..c142465 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -211,4 +211,5 @@
<color name="GM2_green_500">#FF34A853</color>
<color name="GM2_blue_500">#FF4285F4</color>
+ <color name="magnification_border_color">#FF9900</color>
</resources>
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index e896c16..640f31b 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -295,6 +295,7 @@
<item>com.android.systemui.SizeCompatModeActivityController</item>
<item>com.android.systemui.statusbar.notification.InstantAppNotifier</item>
<item>com.android.systemui.theme.ThemeOverlayController</item>
+ <item>com.android.systemui.accessibility.WindowMagnification</item>
</string-array>
<!-- SystemUI vender service, used in config_systemUIServiceComponents. -->
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index c948116..da0323a 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -1139,4 +1139,16 @@
<dimen name="qs_media_width">350dp</dimen>
<dimen name="qs_media_padding">8dp</dimen>
<dimen name="qs_media_corner_radius">10dp</dimen>
+
+ <dimen name="magnification_border_size">5dp</dimen>
+ <dimen name="magnification_frame_move_short">5dp</dimen>
+ <dimen name="magnification_frame_move_long">25dp</dimen>
+ <dimen name="magnification_drag_view_width">100dp</dimen>
+ <dimen name="magnification_drag_view_height">35dp</dimen>
+ <dimen name="magnification_controls_size">90dp</dimen>
+ <dimen name="magnifier_left_right_controls_width">35dp</dimen>
+ <dimen name="magnifier_left_right_controls_height">45dp</dimen>
+ <dimen name="magnifier_up_down_controls_width">45dp</dimen>
+ <dimen name="magnifier_up_down_controls_height">40dp</dimen>
+
</resources>
diff --git a/packages/SystemUI/res/values/integers.xml b/packages/SystemUI/res/values/integers.xml
index deae7e2..c1cf7b4 100644
--- a/packages/SystemUI/res/values/integers.xml
+++ b/packages/SystemUI/res/values/integers.xml
@@ -32,4 +32,6 @@
<!-- Ratio of "right" end of status bar that will swipe to QS. -->
<integer name="qs_split_fraction">2</integer>
+ <integer name="magnification_default_scale">2</integer>
+
</resources>
\ No newline at end of file
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 1053750..bc808b3 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -2492,4 +2492,12 @@
<!-- Title of the overlay warning the user to interact with the device or it will go to sleep. [CHAR LIMIT=25] -->
<string name="inattentive_sleep_warning_title">Standby</string>
+
+ <!-- Window Magnification strings -->
+ <!-- Title for Magnification Overlay Window [CHAR LIMIT=NONE] -->
+ <string name="magnification_overlay_title">Magnification Overlay Window</string>
+ <!-- Title for Magnification Window [CHAR LIMIT=NONE] -->
+ <string name="magnification_window_title">Magnification Window</string>
+ <!-- Title for Magnification Controls Window [CHAR LIMIT=NONE] -->
+ <string name="magnification_controls_title">Magnification Window Controls</string>
</resources>
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java
index 70f8e15..deaafca 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java
@@ -28,6 +28,7 @@
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import android.annotation.NonNull;
+import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RecentTaskInfo;
import android.app.ActivityManager.RunningTaskInfo;
@@ -161,6 +162,23 @@
}
/**
+ * Removes the outdated snapshot of home task.
+ */
+ public void invalidateHomeTaskSnapshot(final Activity homeActivity) {
+ mBackgroundExecutor.submit(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ActivityTaskManager.getService().invalidateHomeTaskSnapshot(
+ homeActivity.getActivityToken());
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to invalidate home snapshot", e);
+ }
+ }
+ });
+ }
+
+ /**
* @return the activity label, badging if necessary.
*/
public String getBadgedActivityLabel(ActivityInfo info, int userId) {
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java
index 22d1675c..9f13718 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/WindowManagerWrapper.java
@@ -27,6 +27,7 @@
import android.os.Handler;
import android.os.RemoteException;
import android.util.Log;
+import android.view.SurfaceControl;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
@@ -215,4 +216,23 @@
public void removePinnedStackListener(PinnedStackListener listener) {
mPinnedStackListenerForwarder.removeListener(listener);
}
+
+ /**
+ * Mirrors a specified display. The SurfaceControl returned is the root of the mirrored
+ * hierarchy.
+ *
+ * @param displayId The id of the display to mirror
+ * @return The SurfaceControl for the root of the mirrored hierarchy.
+ */
+ public SurfaceControl mirrorDisplay(final int displayId) {
+ try {
+ SurfaceControl outSurfaceControl = new SurfaceControl();
+ WindowManagerGlobal.getWindowManagerService().mirrorDisplay(displayId,
+ outSurfaceControl);
+ return outSurfaceControl;
+ } catch (RemoteException e) {
+ Log.e(TAG, "Unable to reach window manager", e);
+ }
+ return null;
+ }
}
diff --git a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
index d66a53c..caf5ee0 100644
--- a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
+++ b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
@@ -163,8 +163,7 @@
public CarrierTextController(Context context, CharSequence separator, boolean showAirplaneMode,
boolean showMissingSim) {
mContext = context;
- mIsEmergencyCallCapable = context.getResources().getBoolean(
- com.android.internal.R.bool.config_voice_capable);
+ mIsEmergencyCallCapable = getTelephonyManager().isVoiceCapable();
mShowAirplaneMode = showAirplaneMode;
mShowMissingSim = showMissingSim;
diff --git a/packages/SystemUI/src/com/android/keyguard/EmergencyButton.java b/packages/SystemUI/src/com/android/keyguard/EmergencyButton.java
index 867014b6..c2cedad 100644
--- a/packages/SystemUI/src/com/android/keyguard/EmergencyButton.java
+++ b/packages/SystemUI/src/com/android/keyguard/EmergencyButton.java
@@ -28,7 +28,9 @@
import android.os.SystemClock;
import android.os.UserHandle;
import android.telecom.TelecomManager;
+import android.telephony.TelephonyManager;
import android.util.AttributeSet;
+import android.util.Log;
import android.util.Slog;
import android.view.MotionEvent;
import android.view.View;
@@ -86,13 +88,16 @@
public EmergencyButton(Context context, AttributeSet attrs) {
super(context, attrs);
- mIsVoiceCapable = context.getResources().getBoolean(
- com.android.internal.R.bool.config_voice_capable);
+ mIsVoiceCapable = getTelephonyManager().isVoiceCapable();
mEnableEmergencyCallWhileSimLocked = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_enable_emergency_call_while_sim_locked);
mEmergencyAffordanceManager = new EmergencyAffordanceManager(context);
}
+ private TelephonyManager getTelephonyManager() {
+ return (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ }
+
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
@@ -110,11 +115,7 @@
super.onFinishInflate();
mLockPatternUtils = new LockPatternUtils(mContext);
mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
- setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- takeEmergencyCallAction();
- }
- });
+ setOnClickListener(v -> takeEmergencyCallAction());
setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
@@ -164,9 +165,9 @@
*/
public void takeEmergencyCallAction() {
MetricsLogger.action(mContext, MetricsEvent.ACTION_EMERGENCY_CALL);
- // TODO: implement a shorter timeout once new PowerManager API is ready.
- // should be the equivalent to the old userActivity(EMERGENCY_CALL_TIMEOUT)
- mPowerManager.userActivity(SystemClock.uptimeMillis(), true);
+ if (mPowerManager != null) {
+ mPowerManager.userActivity(SystemClock.uptimeMillis(), true);
+ }
try {
ActivityTaskManager.getService().stopSystemLockTaskMode();
} catch (RemoteException e) {
@@ -178,10 +179,19 @@
mEmergencyButtonCallback.onEmergencyButtonClickedWhenInCall();
}
} else {
- Dependency.get(KeyguardUpdateMonitor.class).reportEmergencyCallAction(
- true /* bypassHandler */);
+ KeyguardUpdateMonitor updateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
+ if (updateMonitor != null) {
+ updateMonitor.reportEmergencyCallAction(true /* bypassHandler */);
+ } else {
+ Log.w(LOG_TAG, "KeyguardUpdateMonitor was null, launching intent anyway.");
+ }
+ TelecomManager telecomManager = getTelecommManager();
+ if (telecomManager == null) {
+ Log.wtf(LOG_TAG, "TelecomManager was null, cannot launch emergency dialer");
+ return;
+ }
Intent emergencyDialIntent =
- getTelecommManager().createLaunchEmergencyDialerIntent(null /* number*/)
+ telecomManager.createLaunchEmergencyDialerIntent(null /* number*/)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
| Intent.FLAG_ACTIVITY_CLEAR_TOP)
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
index 9380eb4..4e7956d 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
@@ -290,6 +290,7 @@
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+ getWindow().setFitWindowInsetsTypes(0 /* types */);
getWindow().setNavigationBarContrastEnforced(false);
getWindow().setNavigationBarColor(Color.TRANSPARENT);
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/ClockInfo.java b/packages/SystemUI/src/com/android/keyguard/clock/ClockInfo.java
index 812f215..0210e08 100644
--- a/packages/SystemUI/src/com/android/keyguard/clock/ClockInfo.java
+++ b/packages/SystemUI/src/com/android/keyguard/clock/ClockInfo.java
@@ -25,12 +25,12 @@
final class ClockInfo {
private final String mName;
- private final String mTitle;
+ private final Supplier<String> mTitle;
private final String mId;
private final Supplier<Bitmap> mThumbnail;
private final Supplier<Bitmap> mPreview;
- private ClockInfo(String name, String title, String id,
+ private ClockInfo(String name, Supplier<String> title, String id,
Supplier<Bitmap> thumbnail, Supplier<Bitmap> preview) {
mName = name;
mTitle = title;
@@ -50,7 +50,7 @@
* Gets the name (title) of the clock face to be shown in the picker app.
*/
String getTitle() {
- return mTitle;
+ return mTitle.get();
}
/**
@@ -80,7 +80,7 @@
static class Builder {
private String mName;
- private String mTitle;
+ private Supplier<String> mTitle;
private String mId;
private Supplier<Bitmap> mThumbnail;
private Supplier<Bitmap> mPreview;
@@ -94,7 +94,7 @@
return this;
}
- public Builder setTitle(String title) {
+ public Builder setTitle(Supplier<String> title) {
mTitle = title;
return this;
}
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java b/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java
index dfabe69..9cd4aec 100644
--- a/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java
+++ b/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java
@@ -244,11 +244,12 @@
mPreviewClocks.reloadCurrentClock();
mListeners.forEach((listener, clocks) -> {
clocks.reloadCurrentClock();
- ClockPlugin clock = clocks.getCurrentClock();
- if (clock instanceof DefaultClockController) {
- listener.onClockChanged(null);
+ final ClockPlugin clock = clocks.getCurrentClock();
+ if (Looper.myLooper() == Looper.getMainLooper()) {
+ listener.onClockChanged(clock instanceof DefaultClockController ? null : clock);
} else {
- listener.onClockChanged(clock);
+ mMainHandler.post(() -> listener.onClockChanged(
+ clock instanceof DefaultClockController ? null : clock));
}
});
}
@@ -323,7 +324,7 @@
mClocks.put(plugin.getClass().getName(), plugin);
mClockInfo.add(ClockInfo.builder()
.setName(plugin.getName())
- .setTitle(plugin.getTitle())
+ .setTitle(plugin::getTitle)
.setId(id)
.setThumbnail(plugin::getThumbnail)
.setPreview(() -> plugin.getPreview(mWidth, mHeight))
diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java
index 6821265..dd38a33 100644
--- a/packages/SystemUI/src/com/android/systemui/Dependency.java
+++ b/packages/SystemUI/src/com/android/systemui/Dependency.java
@@ -124,6 +124,7 @@
import com.android.systemui.util.leak.LeakReporter;
import com.android.systemui.util.sensors.AsyncSensorManager;
import com.android.systemui.wm.DisplayWindowController;
+import com.android.systemui.wm.SystemWindows;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -323,6 +324,7 @@
@Inject Lazy<Recents> mRecents;
@Inject Lazy<StatusBar> mStatusBar;
@Inject Lazy<DisplayWindowController> mDisplayWindowController;
+ @Inject Lazy<SystemWindows> mSystemWindows;
@Inject
public Dependency() {
@@ -513,6 +515,7 @@
mProviders.put(Recents.class, mRecents::get);
mProviders.put(StatusBar.class, mStatusBar::get);
mProviders.put(DisplayWindowController.class, mDisplayWindowController::get);
+ mProviders.put(SystemWindows.class, mSystemWindows::get);
// TODO(b/118592525): to support multi-display , we start to add something which is
// per-display, while others may be global. I think it's time to add
diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
index ab7eec5..9ce277e 100644
--- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
+++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
@@ -495,6 +495,7 @@
lp.gravity = Gravity.TOP | Gravity.LEFT;
}
lp.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
+ lp.setFitWindowInsetsTypes(0 /* types */);
if (isLandscape(mRotation)) {
lp.width = WRAP_CONTENT;
lp.height = MATCH_PARENT;
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnification.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnification.java
new file mode 100644
index 0000000..6178ff2
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnification.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2019 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 com.android.systemui.accessibility;
+
+import android.content.Context;
+import android.database.ContentObserver;
+import android.os.Handler;
+import android.provider.Settings;
+
+import com.android.systemui.SystemUI;
+import com.android.systemui.dagger.qualifiers.MainHandler;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+/**
+ * Class to handle changes to setting window_magnification value.
+ */
+@Singleton
+public class WindowMagnification extends SystemUI {
+ private WindowMagnificationController mWindowMagnificationController;
+ private final Handler mHandler;
+
+ @Inject
+ public WindowMagnification(Context context, @MainHandler Handler mainHandler) {
+ super(context);
+ mHandler = mainHandler;
+ }
+
+ @Override
+ public void start() {
+ mContext.getContentResolver().registerContentObserver(
+ Settings.Secure.getUriFor(Settings.Secure.WINDOW_MAGNIFICATION),
+ true, new ContentObserver(mHandler) {
+ @Override
+ public void onChange(boolean selfChange) {
+ updateWindowMagnification();
+ }
+ });
+ }
+
+ private void updateWindowMagnification() {
+ try {
+ boolean enable = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.WINDOW_MAGNIFICATION) != 0;
+ if (enable) {
+ enableMagnification();
+ } else {
+ disableMagnification();
+ }
+ } catch (Settings.SettingNotFoundException e) {
+ disableMagnification();
+ }
+ }
+
+ private void enableMagnification() {
+ if (mWindowMagnificationController == null) {
+ mWindowMagnificationController = new WindowMagnificationController(mContext, mHandler);
+ }
+ mWindowMagnificationController.createWindowMagnification();
+ }
+
+ private void disableMagnification() {
+ if (mWindowMagnificationController != null) {
+ mWindowMagnificationController.deleteWindowMagnification();
+ }
+ mWindowMagnificationController = null;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java
new file mode 100644
index 0000000..e3694ac
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java
@@ -0,0 +1,424 @@
+/*
+ * Copyright (C) 2019 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 com.android.systemui.accessibility;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.PixelFormat;
+import android.graphics.Point;
+import android.graphics.PointF;
+import android.graphics.Rect;
+import android.os.Binder;
+import android.os.Handler;
+import android.view.Display;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.Surface;
+import android.view.SurfaceControl;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+import android.view.View;
+import android.view.ViewTreeObserver;
+import android.view.WindowManager;
+
+import com.android.systemui.R;
+import com.android.systemui.shared.system.WindowManagerWrapper;
+
+/**
+ * Class to handle adding and removing a window magnification.
+ */
+public class WindowMagnificationController implements View.OnClickListener,
+ View.OnLongClickListener, View.OnTouchListener, SurfaceHolder.Callback {
+ private final int mBorderSize;
+ private final int mMoveFrameAmountShort;
+ private final int mMoveFrameAmountLong;
+
+ private final Context mContext;
+ private final Point mDisplaySize = new Point();
+ private final int mDisplayId;
+ private final Handler mHandler;
+ private final Rect mMagnificationFrame = new Rect();
+ private final SurfaceControl.Transaction mTransaction = new SurfaceControl.Transaction();
+
+ private final WindowManager mWm;
+
+ private float mScale;
+
+ private final Rect mTmpRect = new Rect();
+
+ // The root of the mirrored content
+ private SurfaceControl mMirrorSurface;
+
+ private boolean mIsPressedDown;
+
+ private View mLeftControl;
+ private View mUpControl;
+ private View mRightControl;
+ private View mBottomControl;
+
+ private View mDragView;
+ private View mLeftDrag;
+ private View mTopDrag;
+ private View mRightDrag;
+ private View mBottomDrag;
+
+ private final PointF mLastDrag = new PointF();
+ private final Point mMoveWindowOffset = new Point();
+
+ private View mMirrorView;
+ private SurfaceView mMirrorSurfaceView;
+ private View mControlsView;
+ private View mOverlayView;
+
+ private MoveMirrorRunnable mMoveMirrorRunnable = new MoveMirrorRunnable();
+
+ WindowMagnificationController(Context context, Handler handler) {
+ mContext = context;
+ mHandler = handler;
+ Display display = mContext.getDisplay();
+ display.getSize(mDisplaySize);
+ mDisplayId = mContext.getDisplayId();
+
+ mWm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+
+ Resources r = context.getResources();
+ mBorderSize = (int) r.getDimension(R.dimen.magnification_border_size);
+ mMoveFrameAmountShort = (int) r.getDimension(R.dimen.magnification_frame_move_short);
+ mMoveFrameAmountLong = (int) r.getDimension(R.dimen.magnification_frame_move_long);
+
+ mScale = r.getInteger(R.integer.magnification_default_scale);
+ }
+
+ /**
+ * Creates a magnification window if it doesn't already exist.
+ */
+ void createWindowMagnification() {
+ if (mMirrorView != null) {
+ return;
+ }
+ createOverlayWindow();
+ }
+
+ private void createOverlayWindow() {
+ WindowManager.LayoutParams params = new WindowManager.LayoutParams(
+ WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT,
+ WindowManager.LayoutParams.TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY,
+ WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
+ | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
+ PixelFormat.TRANSPARENT);
+ params.gravity = Gravity.TOP | Gravity.LEFT;
+ params.token = new Binder();
+ params.setTitle(mContext.getString(R.string.magnification_overlay_title));
+
+ mOverlayView = new View(mContext);
+ mOverlayView.getViewTreeObserver().addOnWindowAttachListener(
+ new ViewTreeObserver.OnWindowAttachListener() {
+ @Override
+ public void onWindowAttached() {
+ mOverlayView.getViewTreeObserver().removeOnWindowAttachListener(this);
+ createMirrorWindow();
+ createControls();
+ }
+
+ @Override
+ public void onWindowDetached() {
+
+ }
+ });
+
+ mOverlayView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
+
+ mWm.addView(mOverlayView, params);
+ }
+
+ /**
+ * Deletes the magnification window.
+ */
+ void deleteWindowMagnification() {
+ if (mMirrorSurface != null) {
+ mTransaction.remove(mMirrorSurface).apply();
+ mMirrorSurface = null;
+ }
+
+ if (mOverlayView != null) {
+ mWm.removeView(mOverlayView);
+ mOverlayView = null;
+ }
+
+ if (mMirrorView != null) {
+ mWm.removeView(mMirrorView);
+ mMirrorView = null;
+ }
+
+ if (mControlsView != null) {
+ mWm.removeView(mControlsView);
+ mControlsView = null;
+ }
+ }
+
+ private void createMirrorWindow() {
+ setInitialStartBounds();
+
+ // The window should be the size the mirrored surface will be but also add room for the
+ // border and the drag handle.
+ int dragViewHeight = (int) mContext.getResources().getDimension(
+ R.dimen.magnification_drag_view_height);
+ int windowWidth = mMagnificationFrame.width() + 2 * mBorderSize;
+ int windowHeight = mMagnificationFrame.height() + dragViewHeight + 2 * mBorderSize;
+
+ WindowManager.LayoutParams params = new WindowManager.LayoutParams(
+ windowWidth, windowHeight,
+ WindowManager.LayoutParams.TYPE_APPLICATION_PANEL,
+ WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
+ | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
+ PixelFormat.TRANSPARENT);
+ params.gravity = Gravity.TOP | Gravity.LEFT;
+ params.token = mOverlayView.getWindowToken();
+ params.x = mMagnificationFrame.left;
+ params.y = mMagnificationFrame.top;
+ params.setTitle(mContext.getString(R.string.magnification_window_title));
+
+ mMirrorView = LayoutInflater.from(mContext).inflate(R.layout.window_magnifier_view, null);
+ mMirrorSurfaceView = mMirrorView.findViewById(R.id.surface_view);
+ // This places the SurfaceView's SurfaceControl above the ViewRootImpl's SurfaceControl to
+ // ensure the mirrored area can get touch instead of going to the window
+ mMirrorSurfaceView.setZOrderOnTop(true);
+
+ mMirrorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
+ mWm.addView(mMirrorView, params);
+
+ SurfaceHolder holder = mMirrorSurfaceView.getHolder();
+ holder.addCallback(this);
+ holder.setFormat(PixelFormat.RGBA_8888);
+
+ addDragTouchListeners();
+ }
+
+ private void createControls() {
+ int controlsSize = (int) mContext.getResources().getDimension(
+ R.dimen.magnification_controls_size);
+
+ WindowManager.LayoutParams lp = new WindowManager.LayoutParams(controlsSize, controlsSize,
+ WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL,
+ WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
+ | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
+ PixelFormat.RGBA_8888);
+ lp.gravity = Gravity.BOTTOM | Gravity.RIGHT;
+ lp.token = mOverlayView.getWindowToken();
+ lp.setTitle(mContext.getString(R.string.magnification_controls_title));
+
+ mControlsView = LayoutInflater.from(mContext).inflate(R.layout.magnifier_controllers, null);
+ mWm.addView(mControlsView, lp);
+
+ mLeftControl = mControlsView.findViewById(R.id.left_control);
+ mUpControl = mControlsView.findViewById(R.id.up_control);
+ mRightControl = mControlsView.findViewById(R.id.right_control);
+ mBottomControl = mControlsView.findViewById(R.id.down_control);
+
+ mLeftControl.setOnClickListener(this);
+ mUpControl.setOnClickListener(this);
+ mRightControl.setOnClickListener(this);
+ mBottomControl.setOnClickListener(this);
+
+ mLeftControl.setOnLongClickListener(this);
+ mUpControl.setOnLongClickListener(this);
+ mRightControl.setOnLongClickListener(this);
+ mBottomControl.setOnLongClickListener(this);
+
+ mLeftControl.setOnTouchListener(this);
+ mUpControl.setOnTouchListener(this);
+ mRightControl.setOnTouchListener(this);
+ mBottomControl.setOnTouchListener(this);
+ }
+
+ private void setInitialStartBounds() {
+ // Sets the initial frame area for the mirror and places it in the center of the display.
+ int initSize = Math.min(mDisplaySize.x, mDisplaySize.y) / 2;
+ int initX = mDisplaySize.x / 2 - initSize / 2;
+ int initY = mDisplaySize.y / 2 - initSize / 2;
+ mMagnificationFrame.set(initX, initY, initX + initSize, initY + initSize);
+ }
+
+ /**
+ * This is called once the surfaceView is created so the mirrored content can be placed as a
+ * child of the surfaceView.
+ */
+ private void createMirror() {
+ mMirrorSurface = WindowManagerWrapper.getInstance().mirrorDisplay(mDisplayId);
+ if (!mMirrorSurface.isValid()) {
+ return;
+ }
+ mTransaction.show(mMirrorSurface)
+ .reparent(mMirrorSurface, mMirrorSurfaceView.getSurfaceControl());
+
+ modifyWindowMagnification(mTransaction);
+ mTransaction.apply();
+ }
+
+ private void addDragTouchListeners() {
+ mDragView = mMirrorView.findViewById(R.id.drag_handle);
+ mLeftDrag = mMirrorView.findViewById(R.id.left_handle);
+ mTopDrag = mMirrorView.findViewById(R.id.top_handle);
+ mRightDrag = mMirrorView.findViewById(R.id.right_handle);
+ mBottomDrag = mMirrorView.findViewById(R.id.bottom_handle);
+
+ mDragView.setOnTouchListener(this);
+ mLeftDrag.setOnTouchListener(this);
+ mTopDrag.setOnTouchListener(this);
+ mRightDrag.setOnTouchListener(this);
+ mBottomDrag.setOnTouchListener(this);
+ }
+
+ /**
+ * Modifies the placement of the mirrored content.
+ */
+ private void modifyWindowMagnification(SurfaceControl.Transaction t) {
+ Rect sourceBounds = getSourceBounds(mMagnificationFrame, mScale);
+ // The final destination for the magnification surface should be at 0,0 since the
+ // ViewRootImpl's position will change
+ mTmpRect.set(0, 0, mMagnificationFrame.width(), mMagnificationFrame.height());
+
+ WindowManager.LayoutParams params =
+ (WindowManager.LayoutParams) mMirrorView.getLayoutParams();
+ params.x = mMagnificationFrame.left;
+ params.y = mMagnificationFrame.top;
+ mWm.updateViewLayout(mMirrorView, params);
+
+ t.setGeometry(mMirrorSurface, sourceBounds, mTmpRect, Surface.ROTATION_0);
+ }
+
+ @Override
+ public void onClick(View v) {
+ setMoveOffset(v, mMoveFrameAmountShort);
+ moveMirrorFromControls();
+ }
+
+ @Override
+ public boolean onLongClick(View v) {
+ mIsPressedDown = true;
+ setMoveOffset(v, mMoveFrameAmountLong);
+ mHandler.post(mMoveMirrorRunnable);
+ return true;
+ }
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if (v == mLeftControl || v == mUpControl || v == mRightControl || v == mBottomControl) {
+ return handleControlTouchEvent(event);
+ } else if (v == mDragView || v == mLeftDrag || v == mTopDrag || v == mRightDrag
+ || v == mBottomDrag) {
+ return handleDragTouchEvent(event);
+ }
+ return false;
+ }
+
+ private boolean handleControlTouchEvent(MotionEvent event) {
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_UP:
+ case MotionEvent.ACTION_CANCEL:
+ mIsPressedDown = false;
+ break;
+ }
+ return false;
+ }
+
+ private boolean handleDragTouchEvent(MotionEvent event) {
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ mLastDrag.set(event.getRawX(), event.getRawY());
+ return true;
+ case MotionEvent.ACTION_MOVE:
+ int xDiff = (int) (event.getRawX() - mLastDrag.x);
+ int yDiff = (int) (event.getRawY() - mLastDrag.y);
+ mMagnificationFrame.offset(xDiff, yDiff);
+ mLastDrag.set(event.getRawX(), event.getRawY());
+ modifyWindowMagnification(mTransaction);
+ mTransaction.apply();
+ return true;
+ }
+ return false;
+ }
+
+ private void setMoveOffset(View v, int moveFrameAmount) {
+ mMoveWindowOffset.set(0, 0);
+
+ if (v == mLeftControl) {
+ mMoveWindowOffset.x = -moveFrameAmount;
+ } else if (v == mUpControl) {
+ mMoveWindowOffset.y = -moveFrameAmount;
+ } else if (v == mRightControl) {
+ mMoveWindowOffset.x = moveFrameAmount;
+ } else if (v == mBottomControl) {
+ mMoveWindowOffset.y = moveFrameAmount;
+ }
+ }
+
+ private void moveMirrorFromControls() {
+ mMagnificationFrame.offset(mMoveWindowOffset.x, mMoveWindowOffset.y);
+
+ modifyWindowMagnification(mTransaction);
+ mTransaction.apply();
+ }
+
+ /**
+ * Calculates the desired source bounds. This will be the area under from the center of the
+ * displayFrame, factoring in scale.
+ */
+ private Rect getSourceBounds(Rect displayFrame, float scale) {
+ int halfWidth = displayFrame.width() / 2;
+ int halfHeight = displayFrame.height() / 2;
+ int left = displayFrame.left + (halfWidth - (int) (halfWidth / scale));
+ int right = displayFrame.right - (halfWidth - (int) (halfWidth / scale));
+ int top = displayFrame.top + (halfHeight - (int) (halfHeight / scale));
+ int bottom = displayFrame.bottom - (halfHeight - (int) (halfHeight / scale));
+ return new Rect(left, top, right, bottom);
+ }
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ createMirror();
+ }
+
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ }
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ }
+
+ class MoveMirrorRunnable implements Runnable {
+ @Override
+ public void run() {
+ if (mIsPressedDown) {
+ moveMirrorFromControls();
+ mHandler.postDelayed(mMoveMirrorRunnable, 100);
+ }
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistDisclosure.java b/packages/SystemUI/src/com/android/systemui/assist/AssistDisclosure.java
index 79d4f8d..659629b 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistDisclosure.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistDisclosure.java
@@ -70,6 +70,7 @@
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED,
PixelFormat.TRANSLUCENT);
lp.setTitle("AssistDisclosure");
+ lp.setFitWindowInsetsTypes(0 /* types */);
mWm.addView(mView, lp);
mViewAdded = true;
diff --git a/packages/SystemUI/src/com/android/systemui/assist/ui/DefaultUiController.java b/packages/SystemUI/src/com/android/systemui/assist/ui/DefaultUiController.java
index 4cb1708..eb615a0 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/ui/DefaultUiController.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/ui/DefaultUiController.java
@@ -85,6 +85,7 @@
PixelFormat.TRANSLUCENT);
mLayoutParams.privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
mLayoutParams.gravity = Gravity.BOTTOM;
+ mLayoutParams.setFitWindowInsetsTypes(0 /* types */);
mLayoutParams.setTitle("Assist");
mInvocationLightsView = (InvocationLightsView)
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java
index 3948416..36c89fd 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java
@@ -35,6 +35,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.WindowInsets.Type;
import android.view.WindowManager;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
@@ -590,6 +591,7 @@
lp.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS;
lp.setTitle("BiometricPrompt");
lp.token = windowToken;
+ lp.setFitWindowInsetsTypes(lp.getFitWindowInsetsTypes() & ~Type.statusBars());
return lp;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java
index 6b0d3c8..e0ca1ac 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java
@@ -18,6 +18,7 @@
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT;
+import static android.hardware.biometrics.BiometricManager.Authenticators;
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
@@ -29,7 +30,6 @@
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
-import android.hardware.biometrics.Authenticator;
import android.hardware.biometrics.BiometricConstants;
import android.hardware.biometrics.BiometricPrompt;
import android.hardware.biometrics.IBiometricServiceReceiverInternal;
@@ -341,6 +341,10 @@
if (DEBUG) Log.d(TAG, "hideAuthenticationDialog");
mCurrentDialog.dismissFromSystemServer();
+
+ // BiometricService will have already sent the callback to the client in this case.
+ // This avoids a round trip to SystemUI. So, just dismiss the dialog and we're done.
+ mCurrentDialog = null;
}
private void showDialog(SomeArgs args, boolean skipAnimation, Bundle savedState) {
@@ -416,7 +420,7 @@
// TODO: Clean this up
Bundle bundle = (Bundle) mCurrentDialogArgs.arg1;
bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED,
- Authenticator.TYPE_CREDENTIAL);
+ Authenticators.DEVICE_CREDENTIAL);
}
showDialog(mCurrentDialogArgs, true /* skipAnimation */, savedState);
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/OWNERS b/packages/SystemUI/src/com/android/systemui/biometrics/OWNERS
new file mode 100644
index 0000000..8765c9a
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/OWNERS
@@ -0,0 +1,7 @@
+set noparent
+
+kchyn@google.com
+jaggies@google.com
+curtislb@google.com
+ilyamaty@google.com
+joshmccloskey@google.com
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/Utils.java b/packages/SystemUI/src/com/android/systemui/biometrics/Utils.java
index d6f830d..7d237c4 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/Utils.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/Utils.java
@@ -16,23 +16,21 @@
package com.android.systemui.biometrics;
+import static android.hardware.biometrics.BiometricManager.Authenticators;
import static android.view.accessibility.AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE;
import android.annotation.IntDef;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
-import android.hardware.biometrics.Authenticator;
import android.hardware.biometrics.BiometricPrompt;
import android.os.Bundle;
import android.os.UserManager;
import android.util.DisplayMetrics;
-import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import com.android.internal.widget.LockPatternUtils;
-import com.android.systemui.R;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -71,12 +69,12 @@
static boolean isDeviceCredentialAllowed(Bundle biometricPromptBundle) {
final int authenticators = getAuthenticators(biometricPromptBundle);
- return (authenticators & Authenticator.TYPE_CREDENTIAL) != 0;
+ return (authenticators & Authenticators.DEVICE_CREDENTIAL) != 0;
}
static boolean isBiometricAllowed(Bundle biometricPromptBundle) {
final int authenticators = getAuthenticators(biometricPromptBundle);
- return (authenticators & Authenticator.TYPE_BIOMETRIC) != 0;
+ return (authenticators & Authenticators.BIOMETRIC_WEAK) != 0;
}
static int getAuthenticators(Bundle biometricPromptBundle) {
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index db5ff3f..c82bc30 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -103,7 +103,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.function.Consumer;
import javax.inject.Inject;
@@ -735,7 +734,7 @@
@SuppressWarnings("FieldCanBeLocal")
private final NotificationEntryListener mEntryListener = new NotificationEntryListener() {
@Override
- public void onPendingEntryAdded(NotificationEntry entry) {
+ public void onNotificationAdded(NotificationEntry entry) {
boolean previouslyUserCreated = mUserCreatedBubbles.contains(entry.getKey());
boolean userBlocked = mUserBlockedBubbles.contains(entry.getKey());
boolean wasAdjusted = BubbleExperimentConfig.adjustForExperiments(
@@ -1119,36 +1118,33 @@
}
private void sendScreenshotToBubble(Bubble bubble) {
- // delay allows the bubble menu to disappear before the screenshot
- // done here because we already have a Handler to delay with.
- // TODO: Hide bubble + menu UI from screenshots entirely instead of just delaying.
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- mScreenshotHelper.takeScreenshot(
- android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN,
- true /* hasStatus */,
- true /* hasNav */,
- mHandler,
- new Consumer<Uri>() {
- @Override
- public void accept(Uri uri) {
- if (uri != null) {
- NotificationEntry entry = bubble.getEntry();
- Pair<RemoteInput, Notification.Action> pair = entry.getSbn()
- .getNotification().findRemoteInputActionPair(false);
- RemoteInput remoteInput = pair.first;
- Notification.Action action = pair.second;
- Intent dataIntent = prepareRemoteInputFromData("image/png", uri,
- remoteInput, entry);
- sendRemoteInput(dataIntent, entry, action.actionIntent);
- mBubbleData.setSelectedBubble(bubble);
- mBubbleData.setExpanded(true);
- }
+ mScreenshotHelper.takeScreenshot(
+ android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN,
+ true /* hasStatus */,
+ true /* hasNav */,
+ mHandler,
+ new Consumer<Uri>() {
+ @Override
+ public void accept(Uri uri) {
+ if (uri != null) {
+ NotificationEntry entry = bubble.getEntry();
+ Pair<RemoteInput, Notification.Action> pair = entry.getSbn()
+ .getNotification().findRemoteInputActionPair(false);
+ if (pair != null) {
+ RemoteInput remoteInput = pair.first;
+ Notification.Action action = pair.second;
+ Intent dataIntent = prepareRemoteInputFromData("image/png", uri,
+ remoteInput, entry);
+ sendRemoteInput(dataIntent, entry, action.actionIntent);
+ mBubbleData.setSelectedBubble(bubble);
+ mBubbleData.setExpanded(true);
+ } else {
+ Log.w(TAG, "No RemoteInput found for notification: "
+ + entry.getSbn().getKey());
}
- });
- }
- }, 200);
+ }
+ }
+ });
}
private final BubbleScreenshotListener mBubbleScreenshotListener =
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java
index 21471ec..4c1cf49 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExperimentConfig.java
@@ -32,6 +32,9 @@
import android.content.Intent;
import android.content.pm.LauncherApps;
import android.content.pm.ShortcutInfo;
+import android.graphics.Color;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.os.Parcelable;
@@ -39,8 +42,11 @@
import android.provider.Settings;
import android.util.Log;
+import com.android.internal.graphics.ColorUtils;
import com.android.internal.util.ArrayUtils;
+import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import com.android.systemui.statusbar.notification.people.PeopleHubNotificationListenerKt;
import java.util.ArrayList;
import java.util.Arrays;
@@ -227,15 +233,29 @@
List<Person> personList = getPeopleFromNotification(entry);
if (personList.size() > 0) {
final Person person = personList.get(0);
-
if (person != null) {
icon = person.getIcon();
+ if (icon == null) {
+ // Lets try and grab the icon constructed by the layout
+ Drawable d = PeopleHubNotificationListenerKt.extractAvatarFromRow(entry);
+ if (d instanceof BitmapDrawable) {
+ icon = Icon.createWithBitmap(((BitmapDrawable) d).getBitmap());
+ }
+ }
}
}
if (icon == null) {
- icon = notification.getLargeIcon() != null
- ? notification.getLargeIcon()
- : notification.getSmallIcon();
+ boolean shouldTint = notification.getLargeIcon() == null;
+ icon = shouldTint
+ ? notification.getSmallIcon()
+ : notification.getLargeIcon();
+ if (shouldTint) {
+ int notifColor = entry.getSbn().getNotification().color;
+ notifColor = ColorUtils.setAlphaComponent(notifColor, 255);
+ notifColor = ContrastColorUtil.findContrastColor(notifColor, Color.WHITE,
+ true /* findFg */, 3f);
+ icon.setTint(notifColor);
+ }
}
if (intent != null) {
return new Notification.BubbleMetadata.Builder()
@@ -285,7 +305,7 @@
}
static boolean isShortcutIntent(PendingIntent intent) {
- return intent.equals(sDummyShortcutIntent);
+ return intent != null && intent.equals(sDummyShortcutIntent);
}
static List<Person> getPeopleFromNotification(NotificationEntry entry) {
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleMenuView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleMenuView.java
index e8eb72e..bf83065 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleMenuView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleMenuView.java
@@ -31,6 +31,9 @@
private FrameLayout mMenu;
private boolean mShowing = false;
+ /** Delay before taking a screenshot once the button is tapped to allow the menu time to hide.*/
+ public static final long SCREENSHOT_DELAY = 200;
+
public BubbleMenuView(Context context, AttributeSet attrs) {
super(context, attrs);
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
index 29a4bb1..245b232 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
@@ -1731,17 +1731,18 @@
*/
public void showBubbleMenu() {
PointF currentPos = mStackAnimationController.getStackPosition();
- float yPos = currentPos.y;
- float xPos = currentPos.x;
- if (mStackAnimationController.isStackOnLeftSide()) {
- xPos += mBubbleSize;
- } else {
- //TODO: Use the width of the menu instead of this fixed offset. Offset used for now
- // because menu width isn't correct the first time the menu is shown.
- xPos -= mBubbleMenuOffset;
- }
+ mBubbleMenuView.setVisibility(View.INVISIBLE);
+ post(() -> {
+ float yPos = currentPos.y;
+ float xPos = currentPos.x;
+ if (mStackAnimationController.isStackOnLeftSide()) {
+ xPos += mBubbleSize;
+ } else {
+ xPos -= mBubbleMenuView.getMenuView().getWidth();
+ }
- mBubbleMenuView.show(xPos, yPos);
+ mBubbleMenuView.show(xPos, yPos);
+ });
}
/**
@@ -1762,6 +1763,12 @@
* Take a screenshot and send it to the specified bubble.
*/
public void sendScreenshotToBubble(Bubble bubble) {
- mBubbleScreenshotListener.onBubbleScreenshot(bubble);
+ hideBubbleMenu();
+ // delay allows the bubble menu to disappear before the screenshot
+ // done here because we already have a Handler to delay with.
+ // TODO: Hide bubble + menu UI from screenshots entirely instead of just delaying.
+ postDelayed(() -> {
+ mBubbleScreenshotListener.onBubbleScreenshot(bubble);
+ }, BubbleMenuView.SCREENSHOT_DELAY);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java
index b1d205c..995b35f 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleTouchHandler.java
@@ -64,6 +64,7 @@
private boolean mMovedEnough;
private int mTouchSlopSquared;
private VelocityTracker mVelocityTracker;
+ private Runnable mShowBubbleMenuRunnable;
/** View that was initially touched, when we received the first ACTION_DOWN event. */
private View mTouchedView;
@@ -133,6 +134,11 @@
if (isStack) {
mViewPositionOnTouchDown.set(mStack.getStackPosition());
mStack.onDragStart();
+ if (!mStack.isShowingBubbleMenu() && !mStack.isExpanded()) {
+ mShowBubbleMenuRunnable = mStack::showBubbleMenu;
+ mStack.postDelayed(mShowBubbleMenuRunnable,
+ ViewConfiguration.getLongPressTimeout());
+ }
} else if (isFlyout) {
mStack.onFlyoutDragStart();
} else {
@@ -156,6 +162,7 @@
}
if (mMovedEnough) {
+ mStack.removeCallbacks(mShowBubbleMenuRunnable);
if (isStack) {
mStack.onDragged(viewX, viewY);
} else if (isFlyout) {
@@ -163,13 +170,6 @@
} else {
mStack.onBubbleDragged(mTouchedView, viewX, viewY);
}
- } else {
- float touchTime = event.getEventTime() - event.getDownTime();
- if (touchTime > ViewConfiguration.getLongPressTimeout() && !mStack.isExpanded()
- && BubbleExperimentConfig.allowBubbleScreenshotMenu(mContext)) {
- mStack.showBubbleMenu();
- return true;
- }
}
final boolean currentlyInDismissTarget = mStack.isInDismissTarget(event);
@@ -196,6 +196,8 @@
if (mStack.isShowingBubbleMenu()) {
resetForNextGesture();
return true;
+ } else {
+ mStack.removeCallbacks(mShowBubbleMenuRunnable);
}
trackMovement(event);
mVelocityTracker.computeCurrentVelocity(/* maxVelocity */ 1000);
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/DependencyProvider.java b/packages/SystemUI/src/com/android/systemui/dagger/DependencyProvider.java
index 606605a..6ea3f4e 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/DependencyProvider.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/DependencyProvider.java
@@ -20,6 +20,7 @@
import android.app.INotificationManager;
import android.content.Context;
+import android.content.pm.IPackageManager;
import android.hardware.display.AmbientDisplayConfiguration;
import android.hardware.display.NightDisplayListener;
import android.os.Handler;
@@ -150,6 +151,13 @@
/** */
@Singleton
@Provides
+ public IPackageManager provideIPackageManager() {
+ return IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
+ }
+
+ /** */
+ @Singleton
+ @Provides
public LayoutInflater providerLayoutInflater(Context context) {
return LayoutInflater.from(context);
}
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java
index 3cf14d6..99dd5e2 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java
@@ -21,6 +21,7 @@
import com.android.systemui.SizeCompatModeActivityController;
import com.android.systemui.SliceBroadcastRelayHandler;
import com.android.systemui.SystemUI;
+import com.android.systemui.accessibility.WindowMagnification;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.globalactions.GlobalActionsComponent;
import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -156,4 +157,10 @@
@IntoMap
@ClassKey(VolumeUI.class)
public abstract SystemUI bindVolumeUI(VolumeUI sysui);
+
+ /** Inject into WindowMagnification. */
+ @Binds
+ @IntoMap
+ @ClassKey(WindowMagnification.class)
+ public abstract SystemUI bindWindowMagnification(WindowMagnification sysui);
}
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeEvent.java b/packages/SystemUI/src/com/android/systemui/doze/DozeEvent.java
index ea1def0..d2fe394 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeEvent.java
@@ -28,10 +28,12 @@
* and triaging purposes.
*/
public class DozeEvent extends RichEvent {
- public static final int TOTAL_EVENT_TYPES = 19;
-
- public DozeEvent(int logLevel, int type, String reason) {
- super(logLevel, type, reason);
+ /**
+ * Initializes a doze event
+ */
+ public DozeEvent init(@EventType int type, String reason) {
+ super.init(DEBUG, type, reason);
+ return this;
}
/**
@@ -89,21 +91,6 @@
}
}
- /**
- * Builds a DozeEvent.
- */
- public static class DozeEventBuilder extends RichEvent.Builder<DozeEventBuilder> {
- @Override
- public DozeEventBuilder getBuilder() {
- return this;
- }
-
- @Override
- public RichEvent build() {
- return new DozeEvent(mLogLevel, mType, mReason);
- }
- }
-
@IntDef({PICKUP_WAKEUP, PULSE_START, PULSE_FINISH, NOTIFICATION_PULSE, DOZING, FLING,
EMERGENCY_CALL, KEYGUARD_BOUNCER_CHANGED, SCREEN_ON, SCREEN_OFF, MISSED_TICK,
TIME_TICK_SCHEDULED, KEYGUARD_VISIBILITY_CHANGE, DOZE_STATE_CHANGED, WAKE_DISPLAY,
@@ -132,6 +119,7 @@
public static final int PULSE_DROPPED = 16;
public static final int PULSE_DISABLED_BY_PROX = 17;
public static final int SENSOR_TRIGGERED = 18;
+ public static final int TOTAL_EVENT_TYPES = 19;
public static final int TOTAL_REASONS = 10;
@IntDef({PULSE_REASON_NONE, PULSE_REASON_INTENT, PULSE_REASON_NOTIFICATION,
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
index 2e4466d..fe50421 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
@@ -35,9 +35,11 @@
* dependency DumpController DozeLog
*/
@Singleton
-public class DozeLog extends SysuiLog {
+public class DozeLog extends SysuiLog<DozeEvent> {
private static final String TAG = "DozeLog";
+ private DozeEvent mRecycledEvent;
+
private boolean mPulsing;
private long mSince;
private SummaryStats mPickupPulseNearVibrationStats;
@@ -73,8 +75,8 @@
* Appends pickup wakeup event to the logs
*/
public void tracePickupWakeUp(boolean withinVibrationThreshold) {
- if (log(DozeEvent.PICKUP_WAKEUP,
- "withinVibrationThreshold=" + withinVibrationThreshold)) {
+ log(DozeEvent.PICKUP_WAKEUP, "withinVibrationThreshold=" + withinVibrationThreshold);
+ if (mEnabled) {
(withinVibrationThreshold ? mPickupPulseNearVibrationStats
: mPickupPulseNotNearVibrationStats).append();
}
@@ -85,27 +87,24 @@
* @param reason why the pulse started
*/
public void tracePulseStart(@DozeEvent.Reason int reason) {
- if (log(DozeEvent.PULSE_START, DozeEvent.reasonToString(reason))) {
- mPulsing = true;
- }
+ log(DozeEvent.PULSE_START, DozeEvent.reasonToString(reason));
+ if (mEnabled) mPulsing = true;
}
/**
* Appends pulse finished event to the logs
*/
public void tracePulseFinish() {
- if (log(DozeEvent.PULSE_FINISH)) {
- mPulsing = false;
- }
+ log(DozeEvent.PULSE_FINISH);
+ if (mEnabled) mPulsing = false;
}
/**
* Appends pulse event to the logs
*/
public void traceNotificationPulse() {
- if (log(DozeEvent.NOTIFICATION_PULSE)) {
- mNotificationPulseStats.append();
- }
+ log(DozeEvent.NOTIFICATION_PULSE);
+ if (mEnabled) mNotificationPulseStats.append();
}
/**
@@ -113,9 +112,8 @@
* @param dozing true if dozing, else false
*/
public void traceDozing(boolean dozing) {
- if (log(DozeEvent.DOZING, "dozing=" + dozing)) {
- mPulsing = false;
- }
+ log(DozeEvent.DOZING, "dozing=" + dozing);
+ if (mEnabled) mPulsing = false;
}
/**
@@ -133,9 +131,8 @@
* Appends emergency call event to the logs
*/
public void traceEmergencyCall() {
- if (log(DozeEvent.EMERGENCY_CALL)) {
- mEmergencyCallStats.append();
- }
+ log(DozeEvent.EMERGENCY_CALL);
+ if (mEnabled) mEmergencyCallStats.append();
}
/**
@@ -150,7 +147,8 @@
* Appends screen-on event to the logs
*/
public void traceScreenOn() {
- if (log(DozeEvent.SCREEN_ON, "pulsing=" + mPulsing)) {
+ log(DozeEvent.SCREEN_ON, "pulsing=" + mPulsing);
+ if (mEnabled) {
(mPulsing ? mScreenOnPulsingStats : mScreenOnNotPulsingStats).append();
mPulsing = false;
}
@@ -188,10 +186,8 @@
* @param showing whether the keyguard is now showing
*/
public void traceKeyguard(boolean showing) {
- if (log(DozeEvent.KEYGUARD_VISIBILITY_CHANGE, "showing=" + showing)
- && !showing) {
- mPulsing = false;
- }
+ log(DozeEvent.KEYGUARD_VISIBILITY_CHANGE, "showing=" + showing);
+ if (mEnabled && !showing) mPulsing = false;
}
/**
@@ -217,12 +213,11 @@
* @param reason why proximity result was triggered
*/
public void traceProximityResult(boolean near, long millis, @DozeEvent.Reason int reason) {
- if (log(DozeEvent.PROXIMITY_RESULT,
+ log(DozeEvent.PROXIMITY_RESULT,
" reason=" + DozeEvent.reasonToString(reason)
- + " near=" + near
- + " millis=" + millis)) {
- mProxStats[reason][near ? 0 : 1].append();
- }
+ + " near=" + near
+ + " millis=" + millis);
+ if (mEnabled) mProxStats[reason][near ? 0 : 1].append();
}
/**
@@ -250,15 +245,16 @@
}
}
- private boolean log(@DozeEvent.EventType int eventType) {
- return log(eventType, "");
+ private void log(@DozeEvent.EventType int eventType) {
+ log(eventType, "");
}
- private boolean log(@DozeEvent.EventType int eventType, String msg) {
- return super.log(new DozeEvent.DozeEventBuilder()
- .setType(eventType)
- .setReason(msg)
- .build());
+ private void log(@DozeEvent.EventType int eventType, String msg) {
+ if (mRecycledEvent != null) {
+ mRecycledEvent = log(mRecycledEvent.init(eventType, msg));
+ } else {
+ mRecycledEvent = log(new DozeEvent().init(eventType, msg));
+ }
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeWallpaperState.java b/packages/SystemUI/src/com/android/systemui/doze/DozeWallpaperState.java
index 7f1b356..7aeb785 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeWallpaperState.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeWallpaperState.java
@@ -16,6 +16,7 @@
package com.android.systemui.doze;
+import android.annotation.Nullable;
import android.app.IWallpaperManager;
import android.os.RemoteException;
import android.util.Log;
@@ -34,6 +35,7 @@
private static final String TAG = "DozeWallpaperState";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+ @Nullable
private final IWallpaperManager mWallpaperManagerService;
private final DozeParameters mDozeParameters;
private final BiometricUnlockController mBiometricUnlockController;
@@ -79,16 +81,18 @@
if (isAmbientMode != mIsAmbientMode) {
mIsAmbientMode = isAmbientMode;
- try {
- long duration = animated ? StackStateAnimator.ANIMATION_DURATION_WAKEUP : 0L;
- if (DEBUG) {
- Log.i(TAG, "AOD wallpaper state changed to: " + mIsAmbientMode
+ if (mWallpaperManagerService != null) {
+ try {
+ long duration = animated ? StackStateAnimator.ANIMATION_DURATION_WAKEUP : 0L;
+ if (DEBUG) {
+ Log.i(TAG, "AOD wallpaper state changed to: " + mIsAmbientMode
+ ", animationDuration: " + duration);
+ }
+ mWallpaperManagerService.setInAmbientMode(mIsAmbientMode, duration);
+ } catch (RemoteException e) {
+ // Cannot notify wallpaper manager service, but it's fine, let's just skip it.
+ Log.w(TAG, "Cannot notify state to WallpaperManagerService: " + mIsAmbientMode);
}
- mWallpaperManagerService.setInAmbientMode(mIsAmbientMode, duration);
- } catch (RemoteException e) {
- // Cannot notify wallpaper manager service, but it's fine, let's just skip it.
- Log.w(TAG, "Cannot notify state to WallpaperManagerService: " + mIsAmbientMode);
}
}
}
@@ -97,5 +101,6 @@
public void dump(PrintWriter pw) {
pw.println("DozeWallpaperState:");
pw.println(" isAmbientMode: " + mIsAmbientMode);
+ pw.println(" hasWallpaperService: " + (mWallpaperManagerService != null));
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
index 63a7771..ef853e6 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
@@ -1562,6 +1562,7 @@
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
| WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY);
+ window.setFitWindowInsetsTypes(0 /* types */);
setTitle(R.string.global_actions);
mPanelController = plugin;
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsImpl.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsImpl.java
index 53053fc..d385123 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsImpl.java
@@ -120,6 +120,7 @@
window.getAttributes().height = ViewGroup.LayoutParams.MATCH_PARENT;
window.getAttributes().layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY);
+ window.setFitWindowInsetsTypes(0 /* types */);
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
window.addFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
diff --git a/packages/SystemUI/src/com/android/systemui/log/Event.java b/packages/SystemUI/src/com/android/systemui/log/Event.java
index 92862a2..7bc1abf 100644
--- a/packages/SystemUI/src/com/android/systemui/log/Event.java
+++ b/packages/SystemUI/src/com/android/systemui/log/Event.java
@@ -37,20 +37,28 @@
public static final int INFO = 4;
public static final int WARN = 5;
public static final int ERROR = 6;
+ public static final @Level int DEFAULT_LOG_LEVEL = DEBUG;
private long mTimestamp;
- private @Level int mLogLevel = DEBUG;
- protected String mMessage;
+ private @Level int mLogLevel = DEFAULT_LOG_LEVEL;
+ private String mMessage = "";
- public Event(String message) {
- mTimestamp = System.currentTimeMillis();
- mMessage = message;
+ /**
+ * initialize an event with a message
+ */
+ public Event init(String message) {
+ init(DEFAULT_LOG_LEVEL, message);
+ return this;
}
- public Event(@Level int logLevel, String message) {
+ /**
+ * initialize an event with a logLevel and message
+ */
+ public Event init(@Level int logLevel, String message) {
mTimestamp = System.currentTimeMillis();
mLogLevel = logLevel;
mMessage = message;
+ return this;
}
public String getMessage() {
@@ -64,4 +72,13 @@
public @Level int getLogLevel() {
return mLogLevel;
}
+
+ /**
+ * Recycle this event
+ */
+ void recycle() {
+ mTimestamp = -1;
+ mLogLevel = DEFAULT_LOG_LEVEL;
+ mMessage = "";
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/log/RichEvent.java b/packages/SystemUI/src/com/android/systemui/log/RichEvent.java
index acf761ed..470f2b0 100644
--- a/packages/SystemUI/src/com/android/systemui/log/RichEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/log/RichEvent.java
@@ -23,23 +23,21 @@
* Events are stored in {@link SysuiLog} and can be printed in a dumpsys.
*/
public abstract class RichEvent extends Event {
- private final int mType;
- private final String mReason;
+ private int mType;
/**
- * Create a rich event that includes an event type that matches with an index in the array
+ * Initializes a rich event that includes an event type that matches with an index in the array
* getEventLabels().
*/
- public RichEvent(@Event.Level int logLevel, int type, String reason) {
- super(logLevel, null);
+ public RichEvent init(@Event.Level int logLevel, int type, String reason) {
final int numEvents = getEventLabels().length;
if (type < 0 || type >= numEvents) {
throw new IllegalArgumentException("Unsupported event type. Events only supported"
+ " from 0 to " + (numEvents - 1) + ", but given type=" + type);
}
mType = type;
- mReason = reason;
- mMessage = getEventLabels()[mType] + " " + mReason;
+ super.init(logLevel, getEventLabels()[mType] + " " + reason);
+ return this;
}
/**
@@ -49,25 +47,43 @@
*/
public abstract String[] getEventLabels();
- public int getType() {
- return mType;
+ @Override
+ public void recycle() {
+ super.recycle();
+ mType = -1;
}
- public String getReason() {
- return mReason;
+ public int getType() {
+ return mType;
}
/**
* Builder to build a RichEvent.
* @param <B> Log specific builder that is extending this builder
+ * @param <E> Type of event we'll be building
*/
- public abstract static class Builder<B extends Builder<B>> {
+ public abstract static class Builder<B extends Builder<B, E>, E extends RichEvent> {
public static final int UNINITIALIZED = -1;
+ public final SysuiLog mLog;
private B mBuilder = getBuilder();
- protected int mType = UNINITIALIZED;
+ protected int mType;
protected String mReason;
- protected @Level int mLogLevel = VERBOSE;
+ protected @Level int mLogLevel;
+
+ public Builder(SysuiLog sysuiLog) {
+ mLog = sysuiLog;
+ reset();
+ }
+
+ /**
+ * Reset this builder's parameters so it can be reused to build another RichEvent.
+ */
+ public void reset() {
+ mType = UNINITIALIZED;
+ mReason = null;
+ mLogLevel = VERBOSE;
+ }
/**
* Get the log-specific builder.
@@ -75,9 +91,9 @@
public abstract B getBuilder();
/**
- * Build the log-specific event.
+ * Build the log-specific event given an event to populate.
*/
- public abstract RichEvent build();
+ public abstract E build(E e);
/**
* Optional - set the log level. Defaults to DEBUG.
diff --git a/packages/SystemUI/src/com/android/systemui/log/SysuiLog.java b/packages/SystemUI/src/com/android/systemui/log/SysuiLog.java
index 0f71d22..4e15668 100644
--- a/packages/SystemUI/src/com/android/systemui/log/SysuiLog.java
+++ b/packages/SystemUI/src/com/android/systemui/log/SysuiLog.java
@@ -20,6 +20,7 @@
import android.os.SystemProperties;
import android.util.Log;
+import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.DumpController;
import com.android.systemui.Dumpable;
@@ -39,23 +40,26 @@
* To manually view the logs via adb:
* adb shell dumpsys activity service com.android.systemui/.SystemUIService \
* dependency DumpController <SysuiLogId>
+ *
+ * Logs can be disabled by setting the following SystemProperty and then restarting the device:
+ * adb shell setprop persist.sysui.log.enabled.<id> true/false && adb reboot
+ *
+ * @param <E> Type of event we'll be logging
*/
-public class SysuiLog implements Dumpable {
+public class SysuiLog<E extends Event> implements Dumpable {
public static final SimpleDateFormat DATE_FORMAT =
new SimpleDateFormat("MM-dd HH:mm:ss", Locale.US);
- private final Object mDataLock = new Object();
+ protected final Object mDataLock = new Object();
private final String mId;
private final int mMaxLogs;
protected boolean mEnabled;
protected boolean mLogToLogcatEnabled;
- @VisibleForTesting protected ArrayDeque<Event> mTimeline;
+ @VisibleForTesting protected ArrayDeque<E> mTimeline;
/**
* Creates a SysuiLog
- * To enable or disable logs, set the system property and then restart the device:
- * adb shell setprop sysui.log.enabled.<id> true/false && adb reboot
* @param dumpController where to register this logger's dumpsys
* @param id user-readable tag for this logger
* @param maxDebugLogs maximum number of logs to retain when {@link sDebuggable} is true
@@ -79,23 +83,20 @@
dumpController.registerDumpable(mId, this);
}
- public SysuiLog(DumpController dumpController, String id) {
- this(dumpController, id, DEFAULT_MAX_DEBUG_LOGS, DEFAULT_MAX_LOGS);
- }
-
/**
* Logs an event to the timeline which can be printed by the dumpsys.
* May also log to logcat if enabled.
- * @return true if event was logged, else false
+ * @return the last event that was discarded from the Timeline (can be recycled)
*/
- public boolean log(Event event) {
+ public E log(E event) {
if (!mEnabled) {
- return false;
+ return null;
}
+ E recycledEvent = null;
synchronized (mDataLock) {
if (mTimeline.size() >= mMaxLogs) {
- mTimeline.removeFirst();
+ recycledEvent = mTimeline.removeFirst();
}
mTimeline.add(event);
@@ -121,13 +122,18 @@
break;
}
}
- return true;
+
+ if (recycledEvent != null) {
+ recycledEvent.recycle();
+ }
+
+ return recycledEvent;
}
/**
* @return user-readable string of the given event with timestamp
*/
- public String eventToTimestampedString(Event event) {
+ private String eventToTimestampedString(Event event) {
StringBuilder sb = new StringBuilder();
sb.append(SysuiLog.DATE_FORMAT.format(event.getTimestamp()));
sb.append(" ");
@@ -142,9 +148,7 @@
return event.getMessage();
}
- /**
- * only call on this method if you have the mDataLock
- */
+ @GuardedBy("mDataLock")
private void dumpTimelineLocked(PrintWriter pw) {
pw.println("\tTimeline:");
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipDismissViewController.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipDismissViewController.java
index 3f15966..750cc60 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipDismissViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipDismissViewController.java
@@ -109,6 +109,7 @@
lp.setTitle("pip-dismiss-overlay");
lp.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS;
lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
+ lp.setFitWindowInsetsTypes(0 /* types */);
mWindowManager.addView(mDismissView, lp);
}
mDismissView.animate().cancel();
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
index feb10a2..db52e7d 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
@@ -177,7 +177,7 @@
record.tile.removeCallback(record.callback);
}
mTileLayout = mMediaTileLayout;
- setTiles(mHost.getTiles());
+ if (mHost != null) setTiles(mHost.getTiles());
mTileLayout.setListening(mListening);
return true;
} else if (!mMediaPlayer.hasMediaSession()
@@ -190,7 +190,7 @@
record.tile.removeCallback(record.callback);
}
mTileLayout = mRegularTileLayout;
- setTiles(mHost.getTiles());
+ if (mHost != null) setTiles(mHost.getTiles());
mTileLayout.setListening(mListening);
return true;
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java
index e0f26cd..1d37911 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java
@@ -413,6 +413,7 @@
handleSetListening(false);
}
mCallbacks.clear();
+ mHandler.removeCallbacksAndMessages(null);
}
protected void checkIfRestrictionEnforcedByAdminOnly(State state, String userRestriction) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java
index d819b8e..1d649ee 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java
@@ -138,6 +138,7 @@
lp.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS;
lp.setTitle("ScreenPinningConfirmation");
lp.gravity = Gravity.FILL;
+ lp.setFitWindowInsetsTypes(0 /* types */);
return lp;
}
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
index 5041354..00220ce 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
@@ -258,6 +258,7 @@
PixelFormat.TRANSLUCENT);
mWindowLayoutParams.setTitle("ScreenshotAnimation");
mWindowLayoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
+ mWindowLayoutParams.setFitWindowInsetsTypes(0 /* types */);
mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
mNotificationManager =
(NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
diff --git a/packages/SystemUI/src/com/android/systemui/settings/CurrentUserTracker.java b/packages/SystemUI/src/com/android/systemui/settings/CurrentUserTracker.java
index 9f79785..077d260 100644
--- a/packages/SystemUI/src/com/android/systemui/settings/CurrentUserTracker.java
+++ b/packages/SystemUI/src/com/android/systemui/settings/CurrentUserTracker.java
@@ -21,6 +21,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.os.UserHandle;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.broadcast.BroadcastDispatcher;
@@ -97,7 +98,7 @@
if (!mReceiverRegistered) {
mCurrentUserId = ActivityManager.getCurrentUser();
IntentFilter filter = new IntentFilter(Intent.ACTION_USER_SWITCHED);
- mBroadcastDispatcher.registerReceiver(this, filter);
+ mBroadcastDispatcher.registerReceiver(this, filter, null, UserHandle.ALL);
mReceiverRegistered = true;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
index bb34a87..f2b4ad8 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
@@ -23,6 +23,7 @@
import static android.view.PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW;
import static android.view.WindowManager.DOCKED_LEFT;
import static android.view.WindowManager.DOCKED_RIGHT;
+import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -40,12 +41,14 @@
import android.view.Choreographer;
import android.view.Display;
import android.view.DisplayInfo;
+import android.view.InsetsState;
import android.view.MotionEvent;
import android.view.PointerIcon;
import android.view.VelocityTracker;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewConfiguration;
+import android.view.ViewRootImpl;
import android.view.ViewTreeObserver.InternalInsetsInfo;
import android.view.ViewTreeObserver.OnComputeInternalInsetsListener;
import android.view.WindowInsets;
@@ -321,6 +324,16 @@
@Override
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
+ if (isAttachedToWindow()
+ && ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL) {
+ // Our window doesn't cover entire display, so we use the display frame to re-calculate
+ // the insets.
+ final InsetsState state = getWindowInsetsController().getState();
+ insets = state.calculateInsets(state.getDisplayFrame(), insets.isRound(),
+ insets.shouldAlwaysConsumeSystemBars(), insets.getDisplayCutout(),
+ null /* legacyContentInsets */, null /* legacyStableInsets */,
+ SOFT_INPUT_ADJUST_NOTHING, null /* typeSideMap */);
+ }
if (mStableInsets.left != insets.getStableInsetLeft()
|| mStableInsets.top != insets.getStableInsetTop()
|| mStableInsets.right != insets.getStableInsetRight()
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java
index 9dcfb6a..9a64b30 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java
@@ -38,6 +38,7 @@
import com.android.systemui.statusbar.phone.NotificationListenerWithPlugins;
import java.util.ArrayList;
+import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -89,11 +90,22 @@
}
final RankingMap currentRanking = getCurrentRanking();
mMainHandler.post(() -> {
+ // There's currently a race condition between the calls to getActiveNotifications() and
+ // getCurrentRanking(). It's possible for the ranking that we store here to not contain
+ // entries for every notification in getActiveNotifications(). To prevent downstream
+ // crashes, we temporarily fill in these missing rankings with stubs.
+ // See b/146011844 for long-term fix
+ final List<Ranking> newRankings = new ArrayList<>();
+ for (StatusBarNotification sbn : notifications) {
+ newRankings.add(getRankingOrTemporaryStandIn(currentRanking, sbn.getKey()));
+ }
+ final RankingMap completeMap = new RankingMap(newRankings.toArray(new Ranking[0]));
+
for (StatusBarNotification sbn : notifications) {
if (mDownstreamListener != null) {
- mDownstreamListener.onNotificationPosted(sbn, currentRanking);
+ mDownstreamListener.onNotificationPosted(sbn, completeMap);
}
- mEntryManager.addNotification(sbn, currentRanking);
+ mEntryManager.addNotification(sbn, completeMap);
}
});
NotificationManager noMan = mContext.getSystemService(NotificationManager.class);
@@ -192,6 +204,35 @@
}
}
+ private static Ranking getRankingOrTemporaryStandIn(RankingMap rankingMap, String key) {
+ Ranking ranking = new Ranking();
+ if (!rankingMap.getRanking(key, ranking)) {
+ ranking.populate(
+ key,
+ 0,
+ false,
+ 0,
+ 0,
+ 0,
+ null,
+ null,
+ null,
+ new ArrayList<>(),
+ new ArrayList<>(),
+ false,
+ 0,
+ false,
+ 0,
+ false,
+ new ArrayList<>(),
+ new ArrayList<>(),
+ false,
+ false
+ );
+ }
+ return ranking;
+ }
+
public interface NotificationSettingsListener {
default void onStatusBarIconsBehaviorChanged(boolean hideSilentStatusIcons) { }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationUpdateHandler.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationUpdateHandler.java
deleted file mode 100644
index 1ac8198..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationUpdateHandler.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2017 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 com.android.systemui.statusbar;
-
-import android.service.notification.NotificationListenerService;
-import android.service.notification.StatusBarNotification;
-
-/**
- * Interface for accepting notification updates from {@link NotificationListener}.
- */
-public interface NotificationUpdateHandler {
- /**
- * Add a new notification and update the current notification ranking map.
- *
- * @param notification Notification to add
- * @param ranking RankingMap to update with
- */
- void addNotification(StatusBarNotification notification,
- NotificationListenerService.RankingMap ranking);
-
- /**
- * Remove a notification and update the current notification ranking map.
- *
- * @param key Key identifying the notification to remove
- * @param ranking RankingMap to update with
- * @param reason why the notification is being removed, e.g.
- * {@link NotificationListenerService#REASON_CANCEL}.
- */
- void removeNotification(String key, NotificationListenerService.RankingMap ranking, int reason);
-
- /**
- * Update a given notification and the current notification ranking map.
- *
- * @param notification Updated notification
- * @param ranking RankingMap to update with
- */
- void updateNotification(StatusBarNotification notification,
- NotificationListenerService.RankingMap ranking);
-
- /**
- * Update with a new notification ranking map.
- *
- * @param ranking RankingMap to update with
- */
- void updateNotificationRanking(NotificationListenerService.RankingMap ranking);
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
index 7a58097..dbefc7b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
@@ -37,7 +37,6 @@
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationRemoveInterceptor;
import com.android.systemui.statusbar.NotificationUiAdjustment;
-import com.android.systemui.statusbar.NotificationUpdateHandler;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationRankingManager;
import com.android.systemui.statusbar.notification.collection.NotificationRowBinder;
@@ -94,7 +93,6 @@
public class NotificationEntryManager implements
Dumpable,
NotificationContentInflater.InflationCallback,
- NotificationUpdateHandler,
VisualStabilityManager.Callback {
private static final String TAG = "NotificationEntryMgr";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -267,14 +265,13 @@
NotificationEntry entry = mPendingNotifications.get(key);
entry.abortTask();
mPendingNotifications.remove(key);
- mNotifLog.log(NotifEvent.INFLATION_ABORTED, entry.getSbn(), null,
- "PendingNotification aborted. " + reason);
+ mNotifLog.log(NotifEvent.INFLATION_ABORTED, entry, "PendingNotification aborted"
+ + " reason=" + reason);
}
NotificationEntry addedEntry = getActiveNotificationUnfiltered(key);
if (addedEntry != null) {
addedEntry.abortTask();
- mNotifLog.log(NotifEvent.INFLATION_ABORTED, addedEntry.getSbn(),
- null, reason);
+ mNotifLog.log(NotifEvent.INFLATION_ABORTED, addedEntry.getKey() + " " + reason);
}
}
@@ -347,7 +344,6 @@
}
- @Override
public void removeNotification(String key, RankingMap ranking,
int reason) {
removeNotificationInternal(key, ranking, obtainVisibility(key), false /* forceRemove */,
@@ -501,13 +497,12 @@
abortExistingInflation(key, "addNotification");
mPendingNotifications.put(key, entry);
- mNotifLog.log(NotifEvent.NOTIF_ADDED, entry.getSbn());
+ mNotifLog.log(NotifEvent.NOTIF_ADDED, entry);
for (NotificationEntryListener listener : mNotificationEntryListeners) {
listener.onPendingEntryAdded(entry);
}
}
- @Override
public void addNotification(StatusBarNotification notification, RankingMap ranking) {
try {
addNotificationInternal(notification, ranking);
@@ -536,7 +531,7 @@
entry.setSbn(notification);
mGroupManager.onEntryUpdated(entry, oldSbn);
- mNotifLog.log(NotifEvent.NOTIF_UPDATED, entry.getSbn(), entry.getRanking());
+ mNotifLog.log(NotifEvent.NOTIF_UPDATED, entry);
for (NotificationEntryListener listener : mNotificationEntryListeners) {
listener.onPreEntryUpdated(entry);
}
@@ -557,7 +552,6 @@
}
}
- @Override
public void updateNotification(StatusBarNotification notification, RankingMap ranking) {
try {
updateNotificationInternal(notification, ranking);
@@ -577,7 +571,6 @@
}
}
- @Override
public void updateNotificationRanking(RankingMap rankingMap) {
List<NotificationEntry> entries = new ArrayList<>();
entries.addAll(getVisibleNotifications());
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/GroupEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/GroupEntry.java
index 9ae3882..ec1efa5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/GroupEntry.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/GroupEntry.java
@@ -24,6 +24,7 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.Objects;
/**
* Represents a set of grouped notifications. The final notification list is usually a mix of
@@ -57,15 +58,22 @@
@VisibleForTesting
public void setSummary(@Nullable NotificationEntry summary) {
- mSummary = summary;
+ if (!Objects.equals(mSummary, summary)) {
+ mSummary = summary;
+ onGroupingUpdated();
+ }
}
void clearChildren() {
- mChildren.clear();
+ if (mChildren.size() != 0) {
+ mChildren.clear();
+ onGroupingUpdated();
+ }
}
void addChild(NotificationEntry child) {
mChildren.add(child);
+ onGroupingUpdated();
}
void sortChildren(Comparator<? super NotificationEntry> c) {
@@ -77,4 +85,5 @@
}
public static final GroupEntry ROOT_ENTRY = new GroupEntry("<root>");
+
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListEntry.java
index 6ce7fd9..052473a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListEntry.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListEntry.java
@@ -19,6 +19,14 @@
import android.annotation.Nullable;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.systemui.Dependency;
+import com.android.systemui.statusbar.notification.collection.provider.DerivedMember;
+import com.android.systemui.statusbar.notification.collection.provider.IsHighPriorityProvider;
+import com.android.systemui.statusbar.phone.NotificationGroupManager;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
/**
* Abstract superclass for top-level entries, i.e. things that can appear in the final notification
@@ -26,14 +34,23 @@
*/
public abstract class ListEntry {
private final String mKey;
+ private final IsHighPriorityProvider mIsHighPriorityProvider = new IsHighPriorityProvider();
+ private final List<DerivedMember> mDerivedMemberList = Arrays.asList(mIsHighPriorityProvider);
@Nullable private GroupEntry mParent;
@Nullable private GroupEntry mPreviousParent;
private int mSection;
int mFirstAddedIteration = -1;
+ // TODO: (b/145659174) remove groupManager when moving to NewNotifPipeline. Logic
+ // replaced in GroupEntry and NotifListBuilderImpl
+ private final NotificationGroupManager mGroupManager;
+
ListEntry(String key) {
mKey = key;
+
+ // TODO: (b/145659174) remove
+ mGroupManager = Dependency.get(NotificationGroupManager.class);
}
public String getKey() {
@@ -53,7 +70,11 @@
@VisibleForTesting
public void setParent(@Nullable GroupEntry parent) {
- mParent = parent;
+ if (!Objects.equals(mParent, parent)) {
+ invalidateParent();
+ mParent = parent;
+ onGroupingUpdated();
+ }
}
@Nullable public GroupEntry getPreviousParent() {
@@ -72,4 +93,58 @@
void setSection(int section) {
mSection = section;
}
+
+ /**
+ * Resets the cached values of DerivedMembers.
+ */
+ void invalidateDerivedMembers() {
+ for (int i = 0; i < mDerivedMemberList.size(); i++) {
+ mDerivedMemberList.get(i).invalidate();
+ }
+ }
+
+ /**
+ * Whether this notification is shown to the user as a high priority notification: visible on
+ * the lock screen/status bar and in the top section in the shade.
+ */
+ public boolean isHighPriority() {
+ return mIsHighPriorityProvider.get(this);
+ }
+
+ private void invalidateParent() {
+ // invalidate our parent (GroupEntry) since DerivedMembers may be dependent on children
+ if (getParent() != null) {
+ getParent().invalidateDerivedMembers();
+ }
+
+ // TODO: (b/145659174) remove
+ final NotificationEntry notifEntry = getRepresentativeEntry();
+ if (notifEntry != null && mGroupManager.isGroupChild(notifEntry.getSbn())) {
+ NotificationEntry summary = mGroupManager.getLogicalGroupSummary(notifEntry.getSbn());
+ if (summary != null) {
+ summary.invalidateDerivedMembers();
+ }
+ }
+ }
+
+ void onGroupingUpdated() {
+ for (int i = 0; i < mDerivedMemberList.size(); i++) {
+ mDerivedMemberList.get(i).onGroupingUpdated();
+ }
+ invalidateParent();
+ }
+
+ void onSbnUpdated() {
+ for (int i = 0; i < mDerivedMemberList.size(); i++) {
+ mDerivedMemberList.get(i).onSbnUpdated();
+ }
+ invalidateParent();
+ }
+
+ void onRankingUpdated() {
+ for (int i = 0; i < mDerivedMemberList.size(); i++) {
+ mDerivedMemberList.get(i).onRankingUpdated();
+ }
+ invalidateParent();
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImpl.java
index 21a4b4f..a1cfb54 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImpl.java
@@ -29,7 +29,6 @@
import android.annotation.MainThread;
import android.annotation.Nullable;
import android.util.ArrayMap;
-import android.util.Log;
import com.android.systemui.statusbar.notification.collection.listbuilder.NotifListBuilder;
import com.android.systemui.statusbar.notification.collection.listbuilder.OnBeforeRenderListListener;
@@ -40,6 +39,8 @@
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.SectionsProvider;
+import com.android.systemui.statusbar.notification.logging.NotifEvent;
+import com.android.systemui.statusbar.notification.logging.NotifLog;
import com.android.systemui.util.Assert;
import com.android.systemui.util.time.SystemClock;
@@ -59,8 +60,8 @@
@MainThread
@Singleton
public class NotifListBuilderImpl implements NotifListBuilder {
-
private final SystemClock mSystemClock;
+ private final NotifLog mNotifLog;
private final List<ListEntry> mNotifList = new ArrayList<>();
@@ -86,9 +87,10 @@
private final List<ListEntry> mReadOnlyNotifList = Collections.unmodifiableList(mNotifList);
@Inject
- public NotifListBuilderImpl(SystemClock systemClock) {
+ public NotifListBuilderImpl(SystemClock systemClock, NotifLog notifLog) {
Assert.isMainThread();
mSystemClock = systemClock;
+ mNotifLog = notifLog;
}
/**
@@ -193,7 +195,8 @@
Assert.isMainThread();
mPipelineState.requireIsBefore(STATE_BUILD_STARTED);
- Log.i(TAG, "Build request received from NotifCollection");
+ mNotifLog.log(NotifEvent.ON_BUILD_LIST, "Request received from "
+ + "NotifCollection");
mAllEntries = entries;
buildList();
}
@@ -202,8 +205,7 @@
private void onFilterInvalidated(NotifFilter filter) {
Assert.isMainThread();
- // TODO: Convert these log statements (here and elsewhere) into timeline logging
- Log.i(TAG, String.format(
+ mNotifLog.log(NotifEvent.FILTER_INVALIDATED, String.format(
"Filter \"%s\" invalidated; pipeline state is %d",
filter.getName(),
mPipelineState.getState()));
@@ -214,7 +216,7 @@
private void onPromoterInvalidated(NotifPromoter filter) {
Assert.isMainThread();
- Log.i(TAG, String.format(
+ mNotifLog.log(NotifEvent.PROMOTER_INVALIDATED, String.format(
"NotifPromoter \"%s\" invalidated; pipeline state is %d",
filter.getName(),
mPipelineState.getState()));
@@ -225,7 +227,7 @@
private void onSectionsProviderInvalidated(SectionsProvider provider) {
Assert.isMainThread();
- Log.i(TAG, String.format(
+ mNotifLog.log(NotifEvent.SECTIONS_PROVIDER_INVALIDATED, String.format(
"Sections provider \"%s\" invalidated; pipeline state is %d",
provider.getName(),
mPipelineState.getState()));
@@ -236,7 +238,7 @@
private void onNotifComparatorInvalidated(NotifComparator comparator) {
Assert.isMainThread();
- Log.i(TAG, String.format(
+ mNotifLog.log(NotifEvent.COMPARATOR_INVALIDATED, String.format(
"Comparator \"%s\" invalidated; pipeline state is %d",
comparator.getName(),
mPipelineState.getState()));
@@ -254,7 +256,7 @@
* if we detect that behavior, we should crash instantly.
*/
private void buildList() {
- Log.i(TAG, "Starting notif list build #" + mIterationCount + "...");
+ mNotifLog.log(NotifEvent.START_BUILD_LIST, "Run #" + mIterationCount + "...");
mPipelineState.requireIsBefore(STATE_BUILD_STARTED);
mPipelineState.setState(STATE_BUILD_STARTED);
@@ -288,15 +290,16 @@
freeEmptyGroups();
// Step 5: Dispatch the new list, first to any listeners and then to the view layer
- Log.i(TAG, "List finalized, is:\n" + dumpList(mNotifList));
- Log.i(TAG, "Dispatching final list to listeners...");
+ mNotifLog.log(NotifEvent.DISPATCH_FINAL_LIST, "List finalized, is:\n"
+ + dumpList(mNotifList));
dispatchOnBeforeRenderList(mReadOnlyNotifList);
if (mOnRenderListListener != null) {
mOnRenderListListener.onRenderList(mReadOnlyNotifList);
}
// Step 6: We're done!
- Log.i(TAG, "Notif list build #" + mIterationCount + " completed");
+ mNotifLog.log(NotifEvent.LIST_BUILD_COMPLETE,
+ "Notif list build #" + mIterationCount + " completed");
mPipelineState.setState(STATE_IDLE);
mIterationCount++;
}
@@ -354,7 +357,7 @@
if (existingSummary == null) {
group.setSummary(entry);
} else {
- Log.w(TAG, String.format(
+ mNotifLog.log(NotifEvent.WARN, String.format(
"Duplicate summary for group '%s': '%s' vs. '%s'",
group.getKey(),
existingSummary.getKey(),
@@ -377,7 +380,8 @@
final String topLevelKey = entry.getKey();
if (mGroups.containsKey(topLevelKey)) {
- Log.wtf(TAG, "Duplicate non-group top-level key: " + topLevelKey);
+ mNotifLog.log(NotifEvent.WARN,
+ "Duplicate non-group top-level key: " + topLevelKey);
} else {
entry.setParent(ROOT_ENTRY);
out.add(entry);
@@ -539,7 +543,7 @@
private void logParentingChanges() {
for (NotificationEntry entry : mAllEntries) {
if (entry.getParent() != entry.getPreviousParent()) {
- Log.i(TAG, String.format(
+ mNotifLog.log(NotifEvent.PARENT_CHANGED, String.format(
"%s: parent changed from %s to %s",
entry.getKey(),
entry.getPreviousParent() == null
@@ -550,7 +554,7 @@
}
for (GroupEntry group : mGroups.values()) {
if (group.getParent() != group.getPreviousParent()) {
- Log.i(TAG, String.format(
+ mNotifLog.log(NotifEvent.PARENT_CHANGED, String.format(
"%s: parent changed from %s to %s",
group.getKey(),
group.getPreviousParent() == null
@@ -607,17 +611,17 @@
if (filter != entry.mExcludingFilter) {
if (entry.mExcludingFilter == null) {
- Log.i(TAG, String.format(
+ mNotifLog.log(NotifEvent.FILTER_CHANGED, String.format(
"%s: filtered out by '%s'",
entry.getKey(),
filter.getName()));
} else if (filter == null) {
- Log.i(TAG, String.format(
+ mNotifLog.log(NotifEvent.FILTER_CHANGED, String.format(
"%s: no longer filtered out (previous filter was '%s')",
entry.getKey(),
entry.mExcludingFilter.getName()));
} else {
- Log.i(TAG, String.format(
+ mNotifLog.log(NotifEvent.FILTER_CHANGED, String.format(
"%s: filter changed: '%s' -> '%s'",
entry.getKey(),
entry.mExcludingFilter,
@@ -648,23 +652,22 @@
if (promoter != entry.mNotifPromoter) {
if (entry.mNotifPromoter == null) {
- Log.i(TAG, String.format(
+ mNotifLog.log(NotifEvent.PROMOTER_CHANGED, String.format(
"%s: Entry promoted to top level by '%s'",
entry.getKey(),
promoter.getName()));
} else if (promoter == null) {
- Log.i(TAG, String.format(
+ mNotifLog.log(NotifEvent.PROMOTER_CHANGED, String.format(
"%s: Entry is no longer promoted to top level (previous promoter was '%s')",
entry.getKey(),
entry.mNotifPromoter.getName()));
} else {
- Log.i(TAG, String.format(
+ mNotifLog.log(NotifEvent.PROMOTER_CHANGED, String.format(
"%s: Top-level promoter changed: '%s' -> '%s'",
entry.getKey(),
entry.mNotifPromoter,
promoter));
}
-
entry.mNotifPromoter = promoter;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
index 232fb6d..de16ef5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
@@ -21,7 +21,6 @@
import static android.app.Notification.CATEGORY_EVENT;
import static android.app.Notification.CATEGORY_MESSAGE;
import static android.app.Notification.CATEGORY_REMINDER;
-import static android.app.Notification.EXTRA_MESSAGES;
import static android.app.Notification.FLAG_BUBBLE;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_BADGE;
@@ -42,7 +41,6 @@
import android.content.Context;
import android.graphics.drawable.Icon;
import android.os.Bundle;
-import android.os.Parcelable;
import android.os.SystemClock;
import android.service.notification.NotificationListenerService.Ranking;
import android.service.notification.SnoozeCriterion;
@@ -92,7 +90,6 @@
private StatusBarNotification mSbn;
private Ranking mRanking;
-
/*
* Bookkeeping members
*/
@@ -120,7 +117,6 @@
public int targetSdk;
private long lastFullScreenIntentLaunchTime = NOT_LAUNCHED_YET;
public CharSequence remoteInputText;
- private final List<Person> mAssociatedPeople = new ArrayList<>();
private Notification.BubbleMetadata mBubbleMetadata;
/**
@@ -157,12 +153,6 @@
*/
private boolean hasSentReply;
- /**
- * Whether this notification is shown to the user as a high priority notification: visible on
- * the lock screen/status bar and in the top section in the shade.
- */
- private boolean mHighPriority;
-
private boolean mSensitive = true;
private Runnable mOnSensitiveChangedListener;
private boolean mAutoHeadsUp;
@@ -212,9 +202,11 @@
+ " doesn't match existing key " + mKey);
}
- mSbn = sbn;
- mBubbleMetadata = mSbn.getNotification().getBubbleMetadata();
- updatePeopleList();
+ if (!Objects.equals(mSbn, sbn)) {
+ mSbn = sbn;
+ mBubbleMetadata = mSbn.getNotification().getBubbleMetadata();
+ onSbnUpdated();
+ }
}
/**
@@ -239,10 +231,12 @@
+ " doesn't match existing key " + mKey);
}
- mRanking = ranking;
+ if (!Objects.equals(mRanking, ranking)) {
+ mRanking = ranking;
+ onRankingUpdated();
+ }
}
-
/*
* Convenience getters for SBN and Ranking members
*/
@@ -304,49 +298,10 @@
return interruption;
}
- public boolean isHighPriority() {
- return mHighPriority;
- }
-
- public void setIsHighPriority(boolean highPriority) {
- this.mHighPriority = highPriority;
- }
-
public boolean isBubble() {
return (mSbn.getNotification().flags & FLAG_BUBBLE) != 0;
}
- private void updatePeopleList() {
- mAssociatedPeople.clear();
-
- Bundle extras = mSbn.getNotification().extras;
- if (extras == null) {
- return;
- }
-
- List<Person> p = extras.getParcelableArrayList(Notification.EXTRA_PEOPLE_LIST);
-
- if (p != null) {
- mAssociatedPeople.addAll(p);
- }
-
- if (Notification.MessagingStyle.class.equals(
- mSbn.getNotification().getNotificationStyle())) {
- final Parcelable[] messages = extras.getParcelableArray(EXTRA_MESSAGES);
- if (!ArrayUtils.isEmpty(messages)) {
- for (Notification.MessagingStyle.Message message :
- Notification.MessagingStyle.Message
- .getMessagesFromBundleArray(messages)) {
- mAssociatedPeople.add(message.getSenderPerson());
- }
- }
- }
- }
-
- boolean hasAssociatedPeople() {
- return mAssociatedPeople.size() > 0;
- }
-
/**
* Returns the data needed for a bubble for this notification, if it exists.
*/
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRankingManager.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRankingManager.kt
index 48a4882..7010943 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRankingManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationRankingManager.kt
@@ -16,14 +16,11 @@
package com.android.systemui.statusbar.notification.collection
-import android.app.NotificationManager.IMPORTANCE_DEFAULT
import android.app.NotificationManager.IMPORTANCE_HIGH
-import android.app.NotificationManager.IMPORTANCE_LOW
import android.app.NotificationManager.IMPORTANCE_MIN
import android.service.notification.NotificationListenerService.Ranking
import android.service.notification.NotificationListenerService.RankingMap
import android.service.notification.StatusBarNotification
-import com.android.internal.annotations.VisibleForTesting
import com.android.systemui.statusbar.NotificationMediaManager
import com.android.systemui.statusbar.notification.NotificationFilter
import com.android.systemui.statusbar.notification.NotificationSectionsFeatureManager
@@ -105,44 +102,6 @@
return entry.key == mediaManager.mediaNotificationKey && importance > IMPORTANCE_MIN
}
- @VisibleForTesting
- protected fun isHighPriority(entry: NotificationEntry): Boolean {
- if (entry.importance >= IMPORTANCE_DEFAULT ||
- hasHighPriorityCharacteristics(entry)) {
- return true
- }
-
- if (groupManager.isSummaryOfGroup(entry.sbn)) {
- val logicalChildren = groupManager.getLogicalChildren(entry.sbn)
- for (child in logicalChildren) {
- if (isHighPriority(child)) {
- return true
- }
- }
- }
-
- return false
- }
-
- private fun hasHighPriorityCharacteristics(entry: NotificationEntry): Boolean {
- val c = entry.channel
- val n = entry.sbn.notification
-
- if ((n.isForegroundService && entry.ranking.importance >= IMPORTANCE_LOW) ||
- n.hasMediaSession() ||
- entry.isPeopleNotification()) {
- // Users who have long pressed and demoted to silent should not see the notification
- // in the top section
- if (c != null && c.hasUserSetImportance()) {
- return false
- }
-
- return true
- }
-
- return false
- }
-
fun updateRanking(
newRankingMap: RankingMap?,
entries: Collection<NotificationEntry>,
@@ -219,7 +178,10 @@
// TODO: notify group manager here?
groupManager.onEntryUpdated(entry, oldSbn)
}
- entry.setIsHighPriority(isHighPriority(entry))
+
+ // TODO: (b/145659174) remove after moving to new NotifPipeline
+ // (should be able to remove all groupManager code post-migration)
+ entry.invalidateDerivedMembers()
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/DeviceProvisionedCoordinator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/DeviceProvisionedCoordinator.java
index 511aafc..b68cb0d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/DeviceProvisionedCoordinator.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/DeviceProvisionedCoordinator.java
@@ -17,7 +17,6 @@
package com.android.systemui.statusbar.notification.collection.coordinator;
import android.Manifest;
-import android.app.AppGlobals;
import android.app.Notification;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
@@ -43,10 +42,13 @@
private static final String TAG = "DeviceProvisionedCoordinator";
private final DeviceProvisionedController mDeviceProvisionedController;
+ private final IPackageManager mIPackageManager;
@Inject
- public DeviceProvisionedCoordinator(DeviceProvisionedController deviceProvisionedController) {
+ public DeviceProvisionedCoordinator(DeviceProvisionedController deviceProvisionedController,
+ IPackageManager packageManager) {
mDeviceProvisionedController = deviceProvisionedController;
+ mIPackageManager = packageManager;
}
@Override
@@ -56,7 +58,7 @@
notifListBuilder.addFilter(mNotifFilter);
}
- protected final NotifFilter mNotifFilter = new NotifFilter(TAG) {
+ private final NotifFilter mNotifFilter = new NotifFilter(TAG) {
@Override
public boolean shouldFilterOut(NotificationEntry entry, long now) {
return !mDeviceProvisionedController.isDeviceProvisioned()
@@ -70,17 +72,16 @@
* marking them as relevant for setup are allowed to show when device is unprovisioned
*/
private boolean showNotificationEvenIfUnprovisioned(StatusBarNotification sbn) {
- final boolean hasPermission = checkUidPermission(AppGlobals.getPackageManager(),
+ final boolean hasPermission = checkUidPermission(
Manifest.permission.NOTIFICATION_DURING_SETUP,
sbn.getUid()) == PackageManager.PERMISSION_GRANTED;
return hasPermission
&& sbn.getNotification().extras.getBoolean(Notification.EXTRA_ALLOW_DURING_SETUP);
}
- private static int checkUidPermission(IPackageManager packageManager, String permission,
- int uid) {
+ private int checkUidPermission(String permission, int uid) {
try {
- return packageManager.checkUidPermission(permission, uid);
+ return mIPackageManager.checkUidPermission(permission, uid);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/ForegroundCoordinator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/ForegroundCoordinator.java
index 4803cf4..378599b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/ForegroundCoordinator.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/ForegroundCoordinator.java
@@ -24,7 +24,6 @@
import com.android.systemui.ForegroundServiceController;
import com.android.systemui.appops.AppOpsController;
-import com.android.systemui.dagger.qualifiers.BgHandler;
import com.android.systemui.dagger.qualifiers.MainHandler;
import com.android.systemui.statusbar.notification.collection.NotifCollection;
import com.android.systemui.statusbar.notification.collection.NotifCollectionListener;
@@ -52,12 +51,11 @@
*/
@Singleton
public class ForegroundCoordinator implements Coordinator {
- private static final String TAG = "ForegroundNotificationCoordinator";
+ private static final String TAG = "ForegroundCoordinator";
private final ForegroundServiceController mForegroundServiceController;
private final AppOpsController mAppOpsController;
private final Handler mMainHandler;
- private final Handler mBgHandler;
private NotifCollection mNotifCollection;
@@ -65,12 +63,10 @@
public ForegroundCoordinator(
ForegroundServiceController foregroundServiceController,
AppOpsController appOpsController,
- @MainHandler Handler mainHandler,
- @BgHandler Handler bgHandler) {
+ @MainHandler Handler mainHandler) {
mForegroundServiceController = foregroundServiceController;
mAppOpsController = appOpsController;
mMainHandler = mainHandler;
- mBgHandler = bgHandler;
}
@Override
@@ -93,7 +89,7 @@
/**
* Filters out notifications that represent foreground services that are no longer running.
*/
- protected final NotifFilter mNotifFilter = new NotifFilter(TAG) {
+ private final NotifFilter mNotifFilter = new NotifFilter(TAG) {
@Override
public boolean shouldFilterOut(NotificationEntry entry, long now) {
StatusBarNotification sbn = entry.getSbn();
@@ -120,7 +116,8 @@
* Extends the lifetime of foreground notification services such that they show for at least
* five seconds
*/
- private final NotifLifetimeExtender mForegroundLifetimeExtender = new NotifLifetimeExtender() {
+ private final NotifLifetimeExtender mForegroundLifetimeExtender =
+ new NotifLifetimeExtender() {
private static final int MIN_FGS_TIME_MS = 5000;
private OnEndLifetimeExtensionCallback mEndCallback;
private Map<String, Runnable> mEndRunnables = new HashMap<>();
@@ -154,8 +151,8 @@
}
};
mEndRunnables.put(entry.getKey(), runnable);
- mBgHandler.postDelayed(runnable, MIN_FGS_TIME_MS
- - (currTime - entry.getSbn().getPostTime()));
+ mMainHandler.postDelayed(runnable,
+ MIN_FGS_TIME_MS - (currTime - entry.getSbn().getPostTime()));
}
}
@@ -166,7 +163,7 @@
public void cancelLifetimeExtension(NotificationEntry entry) {
if (mEndRunnables.containsKey(entry.getKey())) {
Runnable endRunnable = mEndRunnables.remove(entry.getKey());
- mBgHandler.removeCallbacks(endRunnable);
+ mMainHandler.removeCallbacks(endRunnable);
}
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/KeyguardCoordinator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/KeyguardCoordinator.java
index 6daf3fc..232246e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/KeyguardCoordinator.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/KeyguardCoordinator.java
@@ -37,6 +37,8 @@
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.notification.NotificationUtils;
+import com.android.systemui.statusbar.notification.collection.GroupEntry;
+import com.android.systemui.statusbar.notification.collection.ListEntry;
import com.android.systemui.statusbar.notification.collection.NotifCollection;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.listbuilder.NotifListBuilder;
@@ -51,7 +53,7 @@
*/
@Singleton
public class KeyguardCoordinator implements Coordinator {
- private static final String TAG = "KeyguardNotificationCoordinator";
+ private static final String TAG = "KeyguardCoordinator";
private final Context mContext;
private final Handler mMainHandler;
@@ -86,7 +88,7 @@
notifListBuilder.addFilter(mNotifFilter);
}
- protected final NotifFilter mNotifFilter = new NotifFilter(TAG) {
+ private final NotifFilter mNotifFilter = new NotifFilter(TAG) {
@Override
public boolean shouldFilterOut(NotificationEntry entry, long now) {
final StatusBarNotification sbn = entry.getSbn();
@@ -133,8 +135,8 @@
// to be shown on the lockscreen
// TODO: grouping hasn't happened yet (b/145134683)
if (entry.getParent() != null) {
- final NotificationEntry summary = entry.getParent().getRepresentativeEntry();
- if (priorityExceedsLockscreenShowingThreshold(summary)) {
+ final GroupEntry parent = entry.getParent();
+ if (priorityExceedsLockscreenShowingThreshold(parent)) {
return false;
}
}
@@ -144,7 +146,7 @@
}
};
- private boolean priorityExceedsLockscreenShowingThreshold(NotificationEntry entry) {
+ private boolean priorityExceedsLockscreenShowingThreshold(ListEntry entry) {
if (entry == null) {
return false;
}
@@ -154,7 +156,7 @@
// correctly updated before reaching this point (b/145134683)
return entry.isHighPriority();
} else {
- return !entry.getRanking().isAmbient();
+ return !entry.getRepresentativeEntry().getRanking().isAmbient();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinator.java
index c390f96..24e7a79 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinator.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinator.java
@@ -26,7 +26,10 @@
import javax.inject.Singleton;
/**
- * Filters out NotificationEntries based on its Ranking.
+ * Filters out NotificationEntries based on its Ranking and dozing state.
+ * We check the NotificationEntry's Ranking for:
+ * - whether the notification's app is suspended or hiding its notifications
+ * - whether DND settings are hiding notifications from ambient display or the notification list
*/
@Singleton
public class RankingCoordinator implements Coordinator {
@@ -51,7 +54,7 @@
* NotifListBuilder invalidates the notification list each time the ranking is updated,
* so we don't need to explicitly invalidate this filter on ranking update.
*/
- protected final NotifFilter mNotifFilter = new NotifFilter(TAG) {
+ private final NotifFilter mNotifFilter = new NotifFilter(TAG) {
@Override
public boolean shouldFilterOut(NotificationEntry entry, long now) {
// App suspended from Ranking
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/DerivedMember.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/DerivedMember.java
new file mode 100644
index 0000000..815e6f7
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/DerivedMember.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2019 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 com.android.systemui.statusbar.notification.collection.provider;
+/**
+ * Caches a computed value until invalidate() is called
+ * @param <Parent> Object used to computeValue
+ * @param <Value> type of value to cache until invalidate is called
+ */
+public abstract class DerivedMember<Parent, Value> {
+ private Value mValue;
+ protected abstract Value computeValue(Parent parent);
+
+ /**
+ * Gets the last cached value, else recomputes the value.
+ */
+ public Value get(Parent parent) {
+ if (mValue == null) {
+ mValue = computeValue(parent);
+ }
+ return mValue;
+ }
+
+ /**
+ * Resets the cached value.
+ * Next time "get" is called, the value is recomputed.
+ */
+ public void invalidate() {
+ mValue = null;
+ }
+
+ /**
+ * Called when a NotificationEntry's status bar notification has updated.
+ * Derived members can invalidate here.
+ */
+ public void onSbnUpdated() {}
+
+ /**
+ * Called when a NotificationEntry's Ranking has updated.
+ * Derived members can invalidate here.
+ */
+ public void onRankingUpdated() {}
+
+ /**
+ * Called when a ListEntry's grouping information (parent or children) has changed.
+ * Derived members can invalidate here.
+ */
+ public void onGroupingUpdated() {}
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/IsHighPriorityProvider.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/IsHighPriorityProvider.java
new file mode 100644
index 0000000..76e256b
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/provider/IsHighPriorityProvider.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2019 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 com.android.systemui.statusbar.notification.collection.provider;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.Person;
+
+import com.android.systemui.Dependency;
+import com.android.systemui.statusbar.notification.collection.GroupEntry;
+import com.android.systemui.statusbar.notification.collection.ListEntry;
+import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import com.android.systemui.statusbar.phone.NotificationGroupManager;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Whether the ListEntry is shown to the user as a high priority notification: visible on
+ * the lock screen/status bar and in the top section in the shade.
+ *
+ * A NotificationEntry is considered high priority if it:
+ * - has importance greater than or equal to IMPORTANCE_DEFAULT
+ * OR
+ * - their importance has NOT been set to a low priority option by the user AND the notification
+ * fulfills one of the following:
+ * - has a person associated with it
+ * - has a media session associated with it
+ * - has messaging style
+ *
+ * A GroupEntry is considered high priority if its representativeEntry (summary) or children are
+ * high priority
+ */
+public class IsHighPriorityProvider extends DerivedMember<ListEntry, Boolean> {
+ // TODO: (b/145659174) remove groupManager when moving to NewNotifPipeline. Logic
+ // replaced in GroupEntry and NotifListBuilderImpl
+ private final NotificationGroupManager mGroupManager;
+
+
+ public IsHighPriorityProvider() {
+ // TODO: (b/145659174) remove
+ mGroupManager = Dependency.get(NotificationGroupManager.class);
+ }
+
+ @Override
+ protected Boolean computeValue(ListEntry entry) {
+ if (entry == null) {
+ return false;
+ }
+
+ return isHighPriority(entry);
+ }
+
+ private boolean isHighPriority(ListEntry listEntry) {
+ // requires groups have been set (AFTER PipelineState.STATE_TRANSFORMING)
+ final NotificationEntry notifEntry = listEntry.getRepresentativeEntry();
+ return notifEntry.getRanking().getImportance() >= NotificationManager.IMPORTANCE_DEFAULT
+ || hasHighPriorityCharacteristics(notifEntry)
+ || hasHighPriorityChild(listEntry);
+
+ }
+
+ private boolean hasHighPriorityChild(ListEntry entry) {
+ // TODO: (b/145659174) remove
+ if (entry instanceof NotificationEntry) {
+ NotificationEntry notifEntry = (NotificationEntry) entry;
+ if (mGroupManager.isSummaryOfGroup(notifEntry.getSbn())) {
+ List<NotificationEntry> logicalChildren =
+ mGroupManager.getLogicalChildren(notifEntry.getSbn());
+ for (NotificationEntry child : logicalChildren) {
+ if (child.isHighPriority()) {
+ return true;
+ }
+ }
+ }
+ }
+
+ if (entry instanceof GroupEntry) {
+ for (NotificationEntry child : ((GroupEntry) entry).getChildren()) {
+ if (child.isHighPriority()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean hasHighPriorityCharacteristics(NotificationEntry entry) {
+ return !hasUserSetImportance(entry)
+ && (isImportantOngoing(entry)
+ || entry.getSbn().getNotification().hasMediaSession()
+ || hasPerson(entry)
+ || isMessagingStyle(entry));
+ }
+
+ private boolean isImportantOngoing(NotificationEntry entry) {
+ return entry.getSbn().getNotification().isForegroundService()
+ && entry.getRanking().getImportance() >= NotificationManager.IMPORTANCE_LOW;
+ }
+
+ private boolean isMessagingStyle(NotificationEntry entry) {
+ return Notification.MessagingStyle.class.equals(
+ entry.getSbn().getNotification().getNotificationStyle());
+ }
+
+ private boolean hasPerson(NotificationEntry entry) {
+ // TODO: cache favorite and recent contacts to check contact affinity
+ Notification notification = entry.getSbn().getNotification();
+ ArrayList<Person> people = notification.extras != null
+ ? notification.extras.getParcelableArrayList(Notification.EXTRA_PEOPLE_LIST)
+ : new ArrayList<>();
+ return people != null && !people.isEmpty();
+ }
+
+ private boolean hasUserSetImportance(NotificationEntry entry) {
+ return entry.getRanking().getChannel() != null
+ && entry.getRanking().getChannel().hasUserSetImportance();
+ }
+
+ @Override
+ public void onSbnUpdated() {
+ invalidate();
+ }
+
+ @Override
+ public void onRankingUpdated() {
+ invalidate();
+ }
+
+ @Override
+ public void onGroupingUpdated() {
+ invalidate();
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifEvent.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifEvent.java
index 8ebbca2..3b06220 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifEvent.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifEvent.java
@@ -17,10 +17,12 @@
package com.android.systemui.statusbar.notification.logging;
import android.annotation.IntDef;
-import android.service.notification.NotificationListenerService.Ranking;
+import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import com.android.systemui.log.RichEvent;
+import com.android.systemui.statusbar.notification.NotificationEntryManager;
+import com.android.systemui.statusbar.notification.collection.listbuilder.NotifListBuilder;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -31,103 +33,71 @@
* here to mitigate memory usage.
*/
public class NotifEvent extends RichEvent {
- public static final int TOTAL_EVENT_TYPES = 11;
-
/**
- * Creates a NotifEvent with an event type that matches with an index in the array
- * getSupportedEvents() and {@link EventType}.
- *
- * The status bar notification and ranking objects are stored as shallow copies of the current
- * state of the event when this event occurred.
+ * Initializes a rich event that includes an event type that matches with an index in the array
+ * getEventLabels().
*/
- public NotifEvent(int logLevel, int type, String reason, StatusBarNotification sbn,
- Ranking ranking) {
- super(logLevel, type, reason);
- mMessage += getExtraInfo(sbn, ranking);
- }
-
- private String getExtraInfo(StatusBarNotification sbn, Ranking ranking) {
- StringBuilder extraInfo = new StringBuilder();
-
+ public NotifEvent init(@EventType int type, StatusBarNotification sbn,
+ NotificationListenerService.Ranking ranking, String reason) {
+ StringBuilder extraInfo = new StringBuilder(reason);
if (sbn != null) {
- extraInfo.append(" Sbn=");
- extraInfo.append(sbn);
+ extraInfo.append(" " + sbn.getKey());
}
if (ranking != null) {
extraInfo.append(" Ranking=");
- extraInfo.append(ranking);
+ extraInfo.append(ranking.getRank());
}
-
- return extraInfo.toString();
+ super.init(INFO, type, extraInfo.toString());
+ return this;
}
/**
- * Event labels for NotifEvents
- * Index corresponds to the {@link EventType}
+ * Event labels for ListBuilderEvents
+ * Index corresponds to an # in {@link EventType}
*/
@Override
public String[] getEventLabels() {
- final String[] events = new String[]{
- "NotifAdded",
- "NotifRemoved",
- "NotifUpdated",
- "Filter",
- "Sort",
- "FilterAndSort",
- "NotifVisibilityChanged",
- "LifetimeExtended",
- "RemoveIntercepted",
- "InflationAborted",
- "Inflated"
- };
-
- if (events.length != TOTAL_EVENT_TYPES) {
- throw new IllegalStateException("NotifEvents events.length should match "
- + TOTAL_EVENT_TYPES
- + " events.length=" + events.length
- + " TOTAL_EVENT_LENGTH=" + TOTAL_EVENT_TYPES);
- }
- return events;
+ assert (TOTAL_EVENT_LABELS == (TOTAL_NEM_EVENT_TYPES + TOTAL_LIST_BUILDER_EVENT_TYPES));
+ return EVENT_LABELS;
}
/**
- * Builds a NotifEvent.
+ * @return if this event occurred in {@link NotifListBuilder}
*/
- public static class NotifEventBuilder extends RichEvent.Builder<NotifEventBuilder> {
- private StatusBarNotification mSbn;
- private Ranking mRanking;
-
- @Override
- public NotifEventBuilder getBuilder() {
- return this;
- }
-
- /**
- * Stores the status bar notification object. A shallow copy is stored in the NotifEvent's
- * constructor.
- */
- public NotifEventBuilder setSbn(StatusBarNotification sbn) {
- mSbn = sbn;
- return this;
- }
-
- /**
- * Stores the ranking object. A shallow copy is stored in the NotifEvent's
- * constructor.
- */
- public NotifEventBuilder setRanking(Ranking ranking) {
- mRanking = ranking;
- return this;
- }
-
- @Override
- public RichEvent build() {
- return new NotifEvent(mLogLevel, mType, mReason, mSbn, mRanking);
- }
+ static boolean isListBuilderEvent(@EventType int type) {
+ return isBetweenInclusive(type, 0, TOTAL_LIST_BUILDER_EVENT_TYPES);
}
- @IntDef({NOTIF_ADDED,
+ /**
+ * @return if this event occurred in {@link NotificationEntryManager}
+ */
+ static boolean isNemEvent(@EventType int type) {
+ return isBetweenInclusive(type, TOTAL_LIST_BUILDER_EVENT_TYPES,
+ TOTAL_LIST_BUILDER_EVENT_TYPES + TOTAL_NEM_EVENT_TYPES);
+ }
+
+ private static boolean isBetweenInclusive(int x, int a, int b) {
+ return x >= a && x <= b;
+ }
+
+ @IntDef({
+ // NotifListBuilder events:
+ WARN,
+ ON_BUILD_LIST,
+ START_BUILD_LIST,
+ DISPATCH_FINAL_LIST,
+ LIST_BUILD_COMPLETE,
+ FILTER_INVALIDATED,
+ PROMOTER_INVALIDATED,
+ SECTIONS_PROVIDER_INVALIDATED,
+ COMPARATOR_INVALIDATED,
+ PARENT_CHANGED,
+ FILTER_CHANGED,
+ PROMOTER_CHANGED,
+
+ // NotificationEntryManager events:
+ NOTIF_ADDED,
NOTIF_REMOVED,
NOTIF_UPDATED,
FILTER,
@@ -139,22 +109,72 @@
INFLATION_ABORTED,
INFLATED
})
-
- /**
- * Types of NotifEvents
- */
@Retention(RetentionPolicy.SOURCE)
public @interface EventType {}
- public static final int NOTIF_ADDED = 0;
- public static final int NOTIF_REMOVED = 1;
- public static final int NOTIF_UPDATED = 2;
- public static final int FILTER = 3;
- public static final int SORT = 4;
- public static final int FILTER_AND_SORT = 5;
- public static final int NOTIF_VISIBILITY_CHANGED = 6;
- public static final int LIFETIME_EXTENDED = 7;
+
+ private static final String[] EVENT_LABELS =
+ new String[]{
+ // NotifListBuilder labels:
+ "Warning",
+ "OnBuildList",
+ "StartBuildList",
+ "DispatchFinalList",
+ "ListBuildComplete",
+ "FilterInvalidated",
+ "PromoterInvalidated",
+ "SectionsProviderInvalidated",
+ "ComparatorInvalidated",
+ "ParentChanged",
+ "FilterChanged",
+ "PromoterChanged",
+
+ // NEM event labels:
+ "NotifAdded",
+ "NotifRemoved",
+ "NotifUpdated",
+ "Filter",
+ "Sort",
+ "FilterAndSort",
+ "NotifVisibilityChanged",
+ "LifetimeExtended",
+ "RemoveIntercepted",
+ "InflationAborted",
+ "Inflated"
+ };
+
+ private static final int TOTAL_EVENT_LABELS = EVENT_LABELS.length;
+
+ /**
+ * Events related to {@link NotifListBuilder}
+ */
+ public static final int WARN = 0;
+ public static final int ON_BUILD_LIST = 1;
+ public static final int START_BUILD_LIST = 2;
+ public static final int DISPATCH_FINAL_LIST = 3;
+ public static final int LIST_BUILD_COMPLETE = 4;
+ public static final int FILTER_INVALIDATED = 5;
+ public static final int PROMOTER_INVALIDATED = 6;
+ public static final int SECTIONS_PROVIDER_INVALIDATED = 7;
+ public static final int COMPARATOR_INVALIDATED = 8;
+ public static final int PARENT_CHANGED = 9;
+ public static final int FILTER_CHANGED = 10;
+ public static final int PROMOTER_CHANGED = 11;
+ private static final int TOTAL_LIST_BUILDER_EVENT_TYPES = 12;
+
+ /**
+ * Events related to {@link NotificationEntryManager}
+ */
+ public static final int NOTIF_ADDED = TOTAL_LIST_BUILDER_EVENT_TYPES + 0;
+ public static final int NOTIF_REMOVED = TOTAL_LIST_BUILDER_EVENT_TYPES + 1;
+ public static final int NOTIF_UPDATED = TOTAL_LIST_BUILDER_EVENT_TYPES + 2;
+ public static final int FILTER = TOTAL_LIST_BUILDER_EVENT_TYPES + 3;
+ public static final int SORT = TOTAL_LIST_BUILDER_EVENT_TYPES + 4;
+ public static final int FILTER_AND_SORT = TOTAL_LIST_BUILDER_EVENT_TYPES + 5;
+ public static final int NOTIF_VISIBILITY_CHANGED = TOTAL_LIST_BUILDER_EVENT_TYPES + 6;
+ public static final int LIFETIME_EXTENDED = TOTAL_LIST_BUILDER_EVENT_TYPES + 7;
// unable to remove notif - removal intercepted by {@link NotificationRemoveInterceptor}
- public static final int REMOVE_INTERCEPTED = 8;
- public static final int INFLATION_ABORTED = 9;
- public static final int INFLATED = 10;
+ public static final int REMOVE_INTERCEPTED = TOTAL_LIST_BUILDER_EVENT_TYPES + 8;
+ public static final int INFLATION_ABORTED = TOTAL_LIST_BUILDER_EVENT_TYPES + 9;
+ public static final int INFLATED = TOTAL_LIST_BUILDER_EVENT_TYPES + 10;
+ private static final int TOTAL_NEM_EVENT_TYPES = 11;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifLog.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifLog.java
index 1292831..299d628 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifLog.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/logging/NotifLog.java
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.notification.logging;
+import android.os.SystemProperties;
import android.service.notification.NotificationListenerService.Ranking;
import android.service.notification.StatusBarNotification;
@@ -33,93 +34,82 @@
* dependency DumpController NotifLog
*/
@Singleton
-public class NotifLog extends SysuiLog {
+public class NotifLog extends SysuiLog<NotifEvent> {
private static final String TAG = "NotifLog";
+ private static final boolean SHOW_NEM_LOGS =
+ SystemProperties.getBoolean("persist.sysui.log.notif.nem", true);
+ private static final boolean SHOW_LIST_BUILDER_LOGS =
+ SystemProperties.getBoolean("persist.sysui.log.notif.listbuilder", true);
+
private static final int MAX_DOZE_DEBUG_LOGS = 400;
private static final int MAX_DOZE_LOGS = 50;
+ private NotifEvent mRecycledEvent;
+
@Inject
public NotifLog(DumpController dumpController) {
super(dumpController, TAG, MAX_DOZE_DEBUG_LOGS, MAX_DOZE_LOGS);
}
/**
- * Logs a {@link NotifEvent} with a notification, ranking and message
+ * Logs a {@link NotifEvent} with a notification, ranking and message.
+ * Uses the last recycled event if available.
* @return true if successfully logged, else false
*/
- public boolean log(@NotifEvent.EventType int eventType, StatusBarNotification sbn,
- Ranking ranking, String msg) {
- return log(new NotifEvent.NotifEventBuilder()
- .setType(eventType)
- .setSbn(sbn)
- .setRanking(ranking)
- .setReason(msg)
- .build());
+ public void log(@NotifEvent.EventType int eventType,
+ StatusBarNotification sbn, Ranking ranking, String msg) {
+ if (!mEnabled
+ || (NotifEvent.isListBuilderEvent(eventType) && !SHOW_LIST_BUILDER_LOGS)
+ || (NotifEvent.isNemEvent(eventType) && !SHOW_NEM_LOGS)) {
+ return;
+ }
+
+ if (mRecycledEvent != null) {
+ mRecycledEvent = log(mRecycledEvent.init(eventType, sbn, ranking, msg));
+ } else {
+ mRecycledEvent = log(new NotifEvent().init(eventType, sbn, ranking, msg));
+ }
}
/**
- * Logs a {@link NotifEvent}
- * @return true if successfully logged, else false
+ * Logs a {@link NotifEvent} with no extra information aside from the event type
*/
- public boolean log(@NotifEvent.EventType int eventType) {
- return log(eventType, null, null, null);
+ public void log(@NotifEvent.EventType int eventType) {
+ log(eventType, null, null, "");
}
/**
* Logs a {@link NotifEvent} with a message
- * @return true if successfully logged, else false
*/
- public boolean log(@NotifEvent.EventType int eventType, String msg) {
- return log(eventType, null, null, msg);
+ public void log(@NotifEvent.EventType int eventType, String msg) {
+ log(eventType, null, null, msg);
}
/**
- * Logs a {@link NotifEvent} with a notification
- * @return true if successfully logged, else false
+ * Logs a {@link NotifEvent} with a entry
*/
- public boolean log(@NotifEvent.EventType int eventType, StatusBarNotification sbn) {
- return log(eventType, sbn, null, "");
+ public void log(@NotifEvent.EventType int eventType, NotificationEntry entry) {
+ log(eventType, entry.getSbn(), entry.getRanking(), "");
}
/**
- * Logs a {@link NotifEvent} with a notification
- * @return true if successfully logged, else false
+ * Logs a {@link NotifEvent} with a NotificationEntry and message
*/
- public boolean log(@NotifEvent.EventType int eventType, StatusBarNotification sbn, String msg) {
- return log(eventType, sbn, null, msg);
+ public void log(@NotifEvent.EventType int eventType, NotificationEntry entry, String msg) {
+ log(eventType, entry.getSbn(), entry.getRanking(), msg);
}
/**
- * Logs a {@link NotifEvent} with a ranking
- * @return true if successfully logged, else false
+ * Logs a {@link NotifEvent} with a notification and message
*/
- public boolean log(@NotifEvent.EventType int eventType, Ranking ranking) {
- return log(eventType, null, ranking, "");
+ public void log(@NotifEvent.EventType int eventType, StatusBarNotification sbn, String msg) {
+ log(eventType, sbn, null, msg);
}
/**
- * Logs a {@link NotifEvent} with a notification and ranking
- * @return true if successfully logged, else false
+ * Logs a {@link NotifEvent} with a ranking and message
*/
- public boolean log(@NotifEvent.EventType int eventType, StatusBarNotification sbn,
- Ranking ranking) {
- return log(eventType, sbn, ranking, "");
- }
-
- /**
- * Logs a {@link NotifEvent} with a notification entry
- * @return true if successfully logged, else false
- */
- public boolean log(@NotifEvent.EventType int eventType, NotificationEntry entry) {
- return log(eventType, entry.getSbn(), entry.getRanking(), "");
- }
-
- /**
- * Logs a {@link NotifEvent} with a notification entry
- * @return true if successfully logged, else false
- */
- public boolean log(@NotifEvent.EventType int eventType, NotificationEntry entry,
- String msg) {
- return log(eventType, entry.getSbn(), entry.getRanking(), msg);
+ public void log(@NotifEvent.EventType int eventType, Ranking ranking, String msg) {
+ log(eventType, null, ranking, msg);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubModule.kt
index 4f03003..efcef71 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubModule.kt
@@ -31,6 +31,11 @@
abstract fun peopleHubDataSource(impl: PeopleHubDataSourceImpl): DataSource<PeopleHubModel>
@Binds
+ abstract fun peopleHubSettingChangeDataSource(
+ impl: PeopleHubSettingChangeDataSourceImpl
+ ): DataSource<Boolean>
+
+ @Binds
abstract fun peopleHubViewModelFactoryDataSource(
impl: PeopleHubViewModelFactoryDataSourceImpl
): DataSource<PeopleHubViewModelFactory>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubNotificationListener.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubNotificationListener.kt
index 987b52db..784673e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubNotificationListener.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubNotificationListener.kt
@@ -249,7 +249,7 @@
}
}
-private fun extractAvatarFromRow(entry: NotificationEntry): Drawable? =
+fun extractAvatarFromRow(entry: NotificationEntry): Drawable? =
entry.row
?.childrenWithId(R.id.expanded)
?.mapNotNull { it as? ViewGroup }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubViewController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubViewController.kt
index 5c35408..e9d6a0f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubViewController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubViewController.kt
@@ -16,7 +16,14 @@
package com.android.systemui.statusbar.notification.people
+import android.content.Context
+import android.database.ContentObserver
+import android.net.Uri
+import android.os.Handler
+import android.os.UserHandle
+import android.provider.Settings
import android.view.View
+import com.android.systemui.dagger.qualifiers.MainHandler
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager
import javax.inject.Inject
@@ -90,29 +97,58 @@
@Singleton
class PeopleHubViewModelFactoryDataSourceImpl @Inject constructor(
private val activityStarter: ActivityStarter,
- private val dataSource: DataSource<@JvmSuppressWildcards PeopleHubModel>
+ private val dataSource: DataSource<@JvmSuppressWildcards PeopleHubModel>,
+ private val settingChangeSource: DataSource<@JvmSuppressWildcards Boolean>
) : DataSource<PeopleHubViewModelFactory> {
- override fun registerListener(listener: DataListener<PeopleHubViewModelFactory>) =
- dataSource.registerListener(PeopleHubModelListenerImpl(activityStarter, listener))
+ override fun registerListener(listener: DataListener<PeopleHubViewModelFactory>): Subscription {
+ var stripEnabled = false
+ var model: PeopleHubModel? = null
+
+ fun updateListener() {
+ // don't invoke listener until we've received our first model
+ model?.let { model ->
+ val factory =
+ if (stripEnabled) PeopleHubViewModelFactoryImpl(model, activityStarter)
+ else EmptyViewModelFactory
+ listener.onDataChanged(factory)
+ }
+ }
+
+ val settingSub = settingChangeSource.registerListener(object : DataListener<Boolean> {
+ override fun onDataChanged(data: Boolean) {
+ stripEnabled = data
+ updateListener()
+ }
+ })
+ val dataSub = dataSource.registerListener(object : DataListener<PeopleHubModel> {
+ override fun onDataChanged(data: PeopleHubModel) {
+ model = data
+ updateListener()
+ }
+ })
+ return object : Subscription {
+ override fun unsubscribe() {
+ settingSub.unsubscribe()
+ dataSub.unsubscribe()
+ }
+ }
+ }
}
-private class PeopleHubModelListenerImpl(
- private val activityStarter: ActivityStarter,
- private val dataListener: DataListener<PeopleHubViewModelFactory>
-) : DataListener<PeopleHubModel> {
-
- override fun onDataChanged(data: PeopleHubModel) =
- dataListener.onDataChanged(PeopleHubViewModelFactoryImpl(data, activityStarter))
+private object EmptyViewModelFactory : PeopleHubViewModelFactory {
+ override fun createWithAssociatedClickView(view: View): PeopleHubViewModel {
+ return PeopleHubViewModel(emptySequence(), false)
+ }
}
private class PeopleHubViewModelFactoryImpl(
- private val data: PeopleHubModel,
+ private val model: PeopleHubModel,
private val activityStarter: ActivityStarter
) : PeopleHubViewModelFactory {
override fun createWithAssociatedClickView(view: View): PeopleHubViewModel {
- val personViewModels = data.people.asSequence().map { personModel ->
+ val personViewModels = model.people.asSequence().map { personModel ->
val onClick = {
activityStarter.startPendingIntentDismissingKeyguard(
personModel.clickIntent,
@@ -122,7 +158,42 @@
}
PersonViewModel(personModel.name, personModel.avatar, onClick)
}
- return PeopleHubViewModel(personViewModels, data.people.isNotEmpty())
+ return PeopleHubViewModel(personViewModels, model.people.isNotEmpty())
+ }
+}
+
+@Singleton
+class PeopleHubSettingChangeDataSourceImpl @Inject constructor(
+ @MainHandler private val handler: Handler,
+ context: Context
+) : DataSource<Boolean> {
+
+ private val settingUri = Settings.Secure.getUriFor(Settings.Secure.PEOPLE_STRIP)
+ private val contentResolver = context.contentResolver
+
+ override fun registerListener(listener: DataListener<Boolean>): Subscription {
+ // Immediately report current value of setting
+ updateListener(listener)
+ val observer = object : ContentObserver(handler) {
+ override fun onChange(selfChange: Boolean, uri: Uri?, userId: Int) {
+ super.onChange(selfChange, uri, userId)
+ updateListener(listener)
+ }
+ }
+ contentResolver.registerContentObserver(settingUri, false, observer, UserHandle.USER_ALL)
+ return object : Subscription {
+ override fun unsubscribe() = contentResolver.unregisterContentObserver(observer)
+ }
+ }
+
+ private fun updateListener(listener: DataListener<Boolean>) {
+ val setting = Settings.Secure.getIntForUser(
+ contentResolver,
+ Settings.Secure.PEOPLE_STRIP,
+ 0,
+ UserHandle.USER_CURRENT
+ )
+ listener.onDataChanged(setting != 0)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogController.kt
index 782aad1..315ea0a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogController.kt
@@ -34,6 +34,7 @@
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import android.view.Window
+import android.view.WindowInsets.Type
import android.view.WindowManager
import android.widget.TextView
import com.android.internal.annotations.VisibleForTesting
@@ -287,6 +288,7 @@
setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
addFlags(wmFlags)
setType(WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL)
+ setFitWindowInsetsTypes(getFitWindowInsetsTypes() and Type.statusBars().inv())
setWindowAnimations(com.android.internal.R.style.Animation_InputMethod)
attributes = attributes.apply {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java
index 8e9a051e..2761689 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java
@@ -249,10 +249,8 @@
}
}
- if (adjustPeopleHubVisibilityAndPosition(lastPersonIndex)) {
- // make room for peopleHub
- firstGentleNotifIndex++;
- }
+ // make room for peopleHub
+ firstGentleNotifIndex += adjustPeopleHubVisibilityAndPosition(lastPersonIndex);
adjustGentleHeaderVisibilityAndPosition(firstGentleNotifIndex);
@@ -296,7 +294,7 @@
}
}
- private boolean adjustPeopleHubVisibilityAndPosition(int lastPersonIndex) {
+ private int adjustPeopleHubVisibilityAndPosition(int lastPersonIndex) {
final boolean showPeopleHeader = mPeopleHubVisible
&& mNumberOfSections > 2
&& mStatusBarStateController.getState() != StatusBarState.KEYGUARD;
@@ -307,6 +305,7 @@
if (!showPeopleHeader) {
if (currentlyVisible) {
mParent.removeView(mPeopleHubView);
+ return -1;
}
} else {
mPeopleHubView.unDismiss();
@@ -317,7 +316,7 @@
mPeopleHubView.setTransientContainer(null);
}
mParent.addView(mPeopleHubView, targetIndex);
- return true;
+ return 1;
} else if (currentHubIndex != targetIndex) {
if (currentHubIndex < targetIndex) {
targetIndex--;
@@ -325,7 +324,7 @@
mParent.changeViewPosition(mPeopleHubView, targetIndex);
}
}
- return false;
+ return 0;
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java
index 8ee964f..f25f910 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/EdgeBackGestureHandler.java
@@ -300,6 +300,7 @@
layoutParams.setTitle(TAG + mContext.getDisplayId());
layoutParams.accessibilityTitle = mContext.getString(R.string.nav_bar_edge_panel);
layoutParams.windowAnimations = 0;
+ layoutParams.setFitWindowInsetsTypes(0 /* types */);
return layoutParams;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/FloatingRotationButton.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/FloatingRotationButton.java
index a784984..783e7ad 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/FloatingRotationButton.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/FloatingRotationButton.java
@@ -84,6 +84,7 @@
PixelFormat.TRANSLUCENT);
lp.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS;
lp.setTitle("FloatingRotationButton");
+ lp.setFitWindowInsetsTypes(0 /*types */);
switch (mWindowManager.getDefaultDisplay().getRotation()) {
case Surface.ROTATION_0:
lp.gravity = Gravity.BOTTOM | Gravity.LEFT;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
index 1454e25..4c5bbce 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -360,7 +360,8 @@
return false;
}
- if (mState == ScrimState.AOD && mDozeParameters.getAlwaysOn()) {
+ if (mState == ScrimState.AOD
+ && (mDozeParameters.getAlwaysOn() || mDockManager.isDocked())) {
return true;
}
@@ -560,7 +561,7 @@
}
protected void scheduleUpdate() {
- if (mUpdatePending) return;
+ if (mUpdatePending || mScrimBehind == null) return;
// Make sure that a frame gets scheduled.
mScrimBehind.invalidate();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java
index 2ecceba..f94b2ee 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowController.java
@@ -204,6 +204,7 @@
PixelFormat.TRANSLUCENT);
mLp.token = new Binder();
mLp.gravity = Gravity.TOP;
+ mLp.setFitWindowInsetsTypes(0 /* types */);
mLp.softInputMode = LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
mLp.setTitle("StatusBar");
mLp.packageName = mContext.getPackageName();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java
index 44be6bc..28b6c38 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java
@@ -23,6 +23,8 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.os.UserHandle;
+import android.view.Window;
+import android.view.WindowInsets.Type;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
@@ -102,16 +104,22 @@
public static void setWindowOnTop(Dialog dialog) {
if (Dependency.get(KeyguardStateController.class).isShowing()) {
- dialog.getWindow().setType(LayoutParams.TYPE_STATUS_BAR_PANEL);
+ final Window window = dialog.getWindow();
+ window.setType(LayoutParams.TYPE_STATUS_BAR_PANEL);
+ window.setFitWindowInsetsTypes(
+ window.getFitWindowInsetsTypes() & ~Type.statusBars());
} else {
dialog.getWindow().setType(LayoutParams.TYPE_STATUS_BAR_SUB_PANEL);
}
}
public static AlertDialog applyFlags(AlertDialog dialog) {
- dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL);
- dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
+ final Window window = dialog.getWindow();
+ window.setType(WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL);
+ window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
+ window.setFitWindowInsetsTypes(
+ window.getFitWindowInsetsTypes() & ~Type.statusBars());
return dialog;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
index b0cd90c..a6108a4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
@@ -91,7 +91,8 @@
@VisibleForTesting
boolean mIsShowingIconGracefully = false;
// Some specific carriers have 5GE network which is special LTE CA network.
- private static final int NETWORK_TYPE_LTE_CA_5GE = TelephonyManager.MAX_NETWORK_TYPE + 1;
+ private static final int NETWORK_TYPE_LTE_CA_5GE =
+ TelephonyManager.getAllNetworkTypes().length + 1;
// TODO: Reduce number of vars passed in, if we have the NetworkController, probably don't
// need listener lists anymore.
diff --git a/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimator.kt b/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimator.kt
new file mode 100644
index 0000000..62ae7b9
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimator.kt
@@ -0,0 +1,717 @@
+/*
+ * Copyright (C) 2019 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 com.android.systemui.util.animation
+
+import android.os.Looper
+import android.util.ArrayMap
+import android.util.Log
+import android.view.View
+import androidx.dynamicanimation.animation.DynamicAnimation
+import androidx.dynamicanimation.animation.FlingAnimation
+import androidx.dynamicanimation.animation.FloatPropertyCompat
+import androidx.dynamicanimation.animation.SpringAnimation
+import androidx.dynamicanimation.animation.SpringForce
+import com.android.systemui.util.animation.PhysicsAnimator.Companion.getInstance
+import java.util.WeakHashMap
+
+/**
+ * Extension function for all objects which will return a PhysicsAnimator instance for that object.
+ */
+val <T : View> T.physicsAnimator: PhysicsAnimator<T> get() { return getInstance(this) }
+
+private const val TAG = "PhysicsAnimator"
+
+typealias EndAction = () -> Unit
+
+/** A map of Property -> AnimationUpdate, which is provided to update listeners on each frame. */
+typealias UpdateMap<T> =
+ ArrayMap<FloatPropertyCompat<in T>, PhysicsAnimator.AnimationUpdate>
+
+/**
+ * Map of the animators associated with a given object. This ensures that only one animator
+ * per object exists.
+ */
+internal val animators = WeakHashMap<Any, PhysicsAnimator<*>>()
+
+/**
+ * Default spring configuration to use for animations where stiffness and/or damping ratio
+ * were not provided.
+ */
+private val defaultSpring = PhysicsAnimator.SpringConfig(
+ SpringForce.STIFFNESS_MEDIUM,
+ SpringForce.DAMPING_RATIO_MEDIUM_BOUNCY)
+
+/** Default fling configuration to use for animations where friction was not provided. */
+private val defaultFling = PhysicsAnimator.FlingConfig(
+ friction = 1f, min = -Float.MAX_VALUE, max = Float.MAX_VALUE)
+
+/** Whether to log helpful debug information about animations. */
+private var verboseLogging = false
+
+/**
+ * Animator that uses physics-based animations to animate properties on views and objects. Physics
+ * animations use real-world physical concepts, such as momentum and mass, to realistically simulate
+ * motion. PhysicsAnimator is heavily inspired by [android.view.ViewPropertyAnimator], and
+ * also uses the builder pattern to configure and start animations.
+ *
+ * The physics animations are backed by [DynamicAnimation].
+ *
+ * @param T The type of the object being animated.
+ */
+class PhysicsAnimator<T> private constructor (val target: T) {
+
+ /** Data class for representing animation frame updates. */
+ data class AnimationUpdate(val value: Float, val velocity: Float)
+
+ /** [DynamicAnimation] instances for the given properties. */
+ private val springAnimations = ArrayMap<FloatPropertyCompat<in T>, SpringAnimation>()
+ private val flingAnimations = ArrayMap<FloatPropertyCompat<in T>, FlingAnimation>()
+
+ /**
+ * Spring and fling configurations for the properties to be animated on the target. We'll
+ * configure and start the DynamicAnimations for these properties according to the provided
+ * configurations.
+ */
+ private val springConfigs = ArrayMap<FloatPropertyCompat<in T>, SpringConfig>()
+ private val flingConfigs = ArrayMap<FloatPropertyCompat<in T>, FlingConfig>()
+
+ /**
+ * Animation listeners for the animation. These will be notified when each property animation
+ * updates or ends.
+ */
+ private val updateListeners = ArrayList<UpdateListener<T>>()
+ private val endListeners = ArrayList<EndListener<T>>()
+
+ /** End actions to run when all animations have completed. */
+ private val endActions = ArrayList<EndAction>()
+
+ /**
+ * Internal listeners that respond to DynamicAnimations updating and ending, and dispatch to
+ * the listeners provided via [addUpdateListener] and [addEndListener]. This allows us to add
+ * just one permanent update and end listener to the DynamicAnimations.
+ */
+ internal var internalListeners = ArrayList<InternalListener>()
+
+ /**
+ * Action to run when [start] is called. This can be changed by
+ * [PhysicsAnimatorTestUtils.prepareForTest] to enable animators to run under test and provide
+ * helpful test utilities.
+ */
+ internal var startAction: () -> Unit = ::startInternal
+
+ /**
+ * Springs a property to the given value, using the provided configuration settings.
+ *
+ * Springs are used when you know the exact value to which you want to animate. They can be
+ * configured with a start velocity (typically used when the spring is initiated by a touch
+ * event), but this velocity will be realistically attenuated as forces are applied to move the
+ * property towards the end value.
+ *
+ * If you find yourself repeating the same stiffness and damping ratios many times, consider
+ * storing a single [SpringConfig] instance and passing that in instead of individual values.
+ *
+ * @param property The property to spring to the given value. The property must be an instance
+ * of FloatPropertyCompat<? super T>. For example, if this is a
+ * PhysicsAnimator<FrameLayout>, you can use a FloatPropertyCompat<FrameLayout>, as
+ * well as a FloatPropertyCompat<ViewGroup>, and so on.
+ * @param toPosition The value to spring the given property to.
+ * @param startVelocity The initial velocity to use for the animation.
+ * @param stiffness The stiffness to use for the spring. Higher stiffness values result in
+ * faster animations, while lower stiffness means a slower animation. Reasonable values for
+ * low, medium, and high stiffness can be found as constants in [SpringForce].
+ * @param dampingRatio The damping ratio (bounciness) to use for the spring. Higher values
+ * result in a less 'springy' animation, while lower values allow the animation to bounce
+ * back and forth for a longer time after reaching the final position. Reasonable values for
+ * low, medium, and high damping can be found in [SpringForce].
+ */
+ fun spring(
+ property: FloatPropertyCompat<in T>,
+ toPosition: Float,
+ startVelocity: Float = 0f,
+ stiffness: Float = defaultSpring.stiffness,
+ dampingRatio: Float = defaultSpring.dampingRatio
+ ): PhysicsAnimator<T> {
+ if (verboseLogging) {
+ Log.d(TAG, "Springing ${getReadablePropertyName(property)} to $toPosition.")
+ }
+
+ springConfigs[property] =
+ SpringConfig(stiffness, dampingRatio, startVelocity, toPosition)
+ return this
+ }
+
+ /**
+ * Springs a property to a given value using the provided start velocity and configuration
+ * options.
+ *
+ * @see spring
+ */
+ fun spring(
+ property: FloatPropertyCompat<in T>,
+ toPosition: Float,
+ startVelocity: Float,
+ config: SpringConfig = defaultSpring
+ ): PhysicsAnimator<T> {
+ return spring(
+ property, toPosition, startVelocity, config.stiffness, config.dampingRatio)
+ }
+
+ /**
+ * Springs a property to a given value using the provided configuration options, and a start
+ * velocity of 0f.
+ *
+ * @see spring
+ */
+ fun spring(
+ property: FloatPropertyCompat<in T>,
+ toPosition: Float,
+ config: SpringConfig = defaultSpring
+ ): PhysicsAnimator<T> {
+ return spring(property, toPosition, 0f, config)
+ }
+
+ /**
+ * Flings a property using the given start velocity, using a [FlingAnimation] configured using
+ * the provided configuration settings.
+ *
+ * Flings are used when you have a start velocity, and want the property value to realistically
+ * decrease as friction is applied until the velocity reaches zero. Flings do not have a
+ * deterministic end value. If you are attempting to animate to a specific end value, use
+ * [spring].
+ *
+ * If you find yourself repeating the same friction/min/max values, consider storing a single
+ * [FlingConfig] and passing that in instead.
+ *
+ * @param property The property to fling using the given start velocity.
+ * @param startVelocity The start velocity (in pixels per second) with which to start the fling.
+ * @param friction Friction value applied to slow down the animation over time. Higher values
+ * will more quickly slow the animation. Typical friction values range from 1f to 10f.
+ * @param min The minimum value allowed for the animation. If this value is reached, the
+ * animation will end abruptly.
+ * @param max The maximum value allowed for the animation. If this value is reached, the
+ * animation will end abruptly.
+ */
+ fun fling(
+ property: FloatPropertyCompat<in T>,
+ startVelocity: Float,
+ friction: Float = defaultFling.friction,
+ min: Float = defaultFling.min,
+ max: Float = defaultFling.max
+ ): PhysicsAnimator<T> {
+ if (verboseLogging) {
+ Log.d(TAG, "Flinging ${getReadablePropertyName(property)} " +
+ "with velocity $startVelocity.")
+ }
+
+ flingConfigs[property] = FlingConfig(friction, min, max, startVelocity)
+ return this
+ }
+
+ /**
+ * Flings a property using the given start velocity, using a [FlingAnimation] configured using
+ * the provided configuration settings.
+ *
+ * @see fling
+ */
+ fun fling(
+ property: FloatPropertyCompat<in T>,
+ startVelocity: Float,
+ config: FlingConfig = defaultFling
+ ): PhysicsAnimator<T> {
+ return fling(property, startVelocity, config.friction, config.min, config.max)
+ }
+
+ /**
+ * Adds a listener that will be called whenever any property on the animated object is updated.
+ * This will be called on every animation frame, with the current value of the animated object
+ * and the new property values.
+ */
+ fun addUpdateListener(listener: UpdateListener<T>): PhysicsAnimator<T> {
+ updateListeners.add(listener)
+ return this
+ }
+
+ /**
+ * Adds a listener that will be called whenever a property's animation ends. This is useful if
+ * you care about a specific property ending, or want to use the end value/end velocity from a
+ * particular property's animation. If you just want to run an action when all property
+ * animations have ended, use [withEndActions].
+ */
+ fun addEndListener(listener: EndListener<T>): PhysicsAnimator<T> {
+ endListeners.add(listener)
+ return this
+ }
+
+ /**
+ * Adds end actions that will be run sequentially when animations for every property involved in
+ * this specific animation have ended (unless they were explicitly canceled). For example, if
+ * you call:
+ *
+ * animator
+ * .spring(TRANSLATION_X, ...)
+ * .spring(TRANSLATION_Y, ...)
+ * .withEndAction(action)
+ * .start()
+ *
+ * 'action' will be run when both TRANSLATION_X and TRANSLATION_Y end.
+ *
+ * Other properties may still be animating, if those animations were not started in the same
+ * call. For example:
+ *
+ * animator
+ * .spring(ALPHA, ...)
+ * .start()
+ *
+ * animator
+ * .spring(TRANSLATION_X, ...)
+ * .spring(TRANSLATION_Y, ...)
+ * .withEndAction(action)
+ * .start()
+ *
+ * 'action' will still be run as soon as TRANSLATION_X and TRANSLATION_Y end, even if ALPHA is
+ * still animating.
+ *
+ * If you want to run actions as soon as a subset of property animations have ended, you want
+ * access to the animation's end value/velocity, or you want to run these actions even if the
+ * animation is explicitly canceled, use [addEndListener]. End listeners have an allEnded param,
+ * which indicates that all relevant animations have ended.
+ */
+ fun withEndActions(vararg endActions: EndAction): PhysicsAnimator<T> {
+ this.endActions.addAll(endActions)
+ return this
+ }
+
+ /** Starts the animations! */
+ fun start() {
+ startAction()
+ }
+
+ /**
+ * Starts the animations for real! This is typically called immediately by [start] unless this
+ * animator is under test.
+ */
+ internal fun startInternal() {
+ if (!Looper.getMainLooper().isCurrentThread) {
+ Log.e(TAG, "Animations can only be started on the main thread. If you are seeing " +
+ "this message in a test, call PhysicsAnimatorTestUtils#prepareForTest in " +
+ "your test setup.")
+ }
+
+ // Add an internal listener that will dispatch animation events to the provided listeners.
+ internalListeners.add(InternalListener(
+ getAnimatedProperties(),
+ ArrayList(updateListeners),
+ ArrayList(endListeners),
+ ArrayList(endActions)))
+
+ for ((property, config) in flingConfigs) {
+ val currentValue = property.getValue(target)
+
+ // If the fling is already out of bounds, don't start it.
+ if (currentValue <= config.min || currentValue >= config.max) {
+ continue
+ }
+
+ val flingAnim = getFlingAnimation(property)
+ config.applyToAnimation(flingAnim)
+ flingAnim.start()
+ }
+
+ for ((property, config) in springConfigs) {
+ val springAnim = getSpringAnimation(property)
+ config.applyToAnimation(springAnim)
+ springAnim.start()
+ }
+
+ clearAnimator()
+ }
+
+ /** Clear the animator's builder variables. */
+ private fun clearAnimator() {
+ springConfigs.clear()
+ flingConfigs.clear()
+
+ updateListeners.clear()
+ endListeners.clear()
+ endActions.clear()
+ }
+
+ /** Retrieves a spring animation for the given property, building one if needed. */
+ private fun getSpringAnimation(property: FloatPropertyCompat<in T>): SpringAnimation {
+ return springAnimations.getOrPut(
+ property,
+ { configureDynamicAnimation(SpringAnimation(target, property), property)
+ as SpringAnimation })
+ }
+
+ /** Retrieves a fling animation for the given property, building one if needed. */
+ private fun getFlingAnimation(property: FloatPropertyCompat<in T>): FlingAnimation {
+ return flingAnimations.getOrPut(
+ property,
+ { configureDynamicAnimation(FlingAnimation(target, property), property)
+ as FlingAnimation })
+ }
+
+ /**
+ * Adds update and end listeners to the DynamicAnimation which will dispatch to the internal
+ * listeners.
+ */
+ private fun configureDynamicAnimation(
+ anim: DynamicAnimation<*>,
+ property: FloatPropertyCompat<in T>
+ ): DynamicAnimation<*> {
+ anim.addUpdateListener { _, value, velocity ->
+ for (i in 0 until internalListeners.size) {
+ internalListeners[i].onInternalAnimationUpdate(property, value, velocity)
+ }
+ }
+ anim.addEndListener { _, canceled, value, velocity ->
+ internalListeners.removeAll {
+ it.onInternalAnimationEnd(property, canceled, value, velocity) } }
+ return anim
+ }
+
+ /**
+ * Internal listener class that receives updates from DynamicAnimation listeners, and dispatches
+ * them to the appropriate update/end listeners. This class is also aware of which properties
+ * were being animated when the end listeners were passed in, so that we can provide the
+ * appropriate value for allEnded to [EndListener.onAnimationEnd].
+ */
+ internal inner class InternalListener constructor(
+ private var properties: Set<FloatPropertyCompat<in T>>,
+ private var updateListeners: List<UpdateListener<T>>,
+ private var endListeners: List<EndListener<T>>,
+ private var endActions: List<EndAction>
+ ) {
+
+ /** The number of properties whose animations haven't ended. */
+ private var numPropertiesAnimating = properties.size
+
+ /**
+ * Update values that haven't yet been dispatched because not all property animations have
+ * updated yet.
+ */
+ private val undispatchedUpdates =
+ ArrayMap<FloatPropertyCompat<in T>, AnimationUpdate>()
+
+ /** Called when a DynamicAnimation updates. */
+ internal fun onInternalAnimationUpdate(
+ property: FloatPropertyCompat<in T>,
+ value: Float,
+ velocity: Float
+ ) {
+
+ // If this property animation isn't relevant to this listener, ignore it.
+ if (!properties.contains(property)) {
+ return
+ }
+
+ undispatchedUpdates[property] = AnimationUpdate(value, velocity)
+ maybeDispatchUpdates()
+ }
+
+ /**
+ * Called when a DynamicAnimation ends.
+ *
+ * @return True if this listener should be removed from the list of internal listeners, so
+ * it no longer receives updates from DynamicAnimations.
+ */
+ internal fun onInternalAnimationEnd(
+ property: FloatPropertyCompat<in T>,
+ canceled: Boolean,
+ finalValue: Float,
+ finalVelocity: Float
+ ): Boolean {
+
+ // If this property animation isn't relevant to this listener, ignore it.
+ if (!properties.contains(property)) {
+ return false
+ }
+
+ // Dispatch updates if we have one for each property.
+ numPropertiesAnimating--
+ maybeDispatchUpdates()
+
+ // If we didn't have an update for each property, dispatch the update for the ending
+ // property. This guarantees that an update isn't sent for this property *after* we call
+ // onAnimationEnd for that property.
+ if (undispatchedUpdates.contains(property)) {
+ updateListeners.forEach { updateListener ->
+ updateListener.onAnimationUpdateForProperty(
+ target,
+ UpdateMap<T>().also { it[property] = undispatchedUpdates[property] })
+ }
+
+ undispatchedUpdates.remove(property)
+ }
+
+ val allEnded = !arePropertiesAnimating(properties)
+ endListeners.forEach {
+ it.onAnimationEnd(target, property, canceled, finalValue, finalVelocity, allEnded) }
+
+ // If all of the animations that this listener cares about have ended, run the end
+ // actions unless the animation was canceled.
+ if (allEnded && !canceled) {
+ endActions.forEach { it() }
+ }
+
+ return allEnded
+ }
+
+ /**
+ * Dispatch undispatched values if we've received an update from each of the animating
+ * properties.
+ */
+ private fun maybeDispatchUpdates() {
+ if (undispatchedUpdates.size >= numPropertiesAnimating &&
+ undispatchedUpdates.size > 0) {
+ updateListeners.forEach {
+ it.onAnimationUpdateForProperty(target, ArrayMap(undispatchedUpdates))
+ }
+
+ undispatchedUpdates.clear()
+ }
+ }
+ }
+
+ /** Return true if any animations are running on the object. */
+ fun isRunning(): Boolean {
+ return arePropertiesAnimating(springAnimations.keys.union(flingAnimations.keys))
+ }
+
+ /** Returns whether the given property is animating. */
+ fun isPropertyAnimating(property: FloatPropertyCompat<in T>): Boolean {
+ return springAnimations[property]?.isRunning ?: false
+ }
+
+ /** Returns whether any of the given properties are animating. */
+ fun arePropertiesAnimating(properties: Set<FloatPropertyCompat<in T>>): Boolean {
+ return properties.any { isPropertyAnimating(it) }
+ }
+
+ /** Return the set of properties that will begin animating upon calling [start]. */
+ internal fun getAnimatedProperties(): Set<FloatPropertyCompat<in T>> {
+ return springConfigs.keys.union(flingConfigs.keys)
+ }
+
+ /** Cancels all in progress animations on all properties. */
+ fun cancel() {
+ for (dynamicAnim in flingAnimations.values.union(springAnimations.values)) {
+ dynamicAnim.cancel()
+ }
+ }
+
+ /**
+ * Container object for spring animation configuration settings. This allows you to store
+ * default stiffness and damping ratio values in a single configuration object, which you can
+ * pass to [spring].
+ */
+ data class SpringConfig internal constructor(
+ internal var stiffness: Float,
+ internal var dampingRatio: Float,
+ internal var startVel: Float = 0f,
+ internal var finalPosition: Float = -Float.MAX_VALUE
+ ) {
+
+ constructor() :
+ this(defaultSpring.stiffness, defaultSpring.dampingRatio)
+
+ constructor(stiffness: Float, dampingRatio: Float) :
+ this(stiffness = stiffness, dampingRatio = dampingRatio, startVel = 0f)
+
+ /** Apply these configuration settings to the given SpringAnimation. */
+ internal fun applyToAnimation(anim: SpringAnimation) {
+ val springForce = anim.spring ?: SpringForce()
+ anim.spring = springForce.apply {
+ stiffness = this@SpringConfig.stiffness
+ dampingRatio = this@SpringConfig.dampingRatio
+ finalPosition = this@SpringConfig.finalPosition
+ }
+
+ if (startVel != 0f) anim.setStartVelocity(startVel)
+ }
+ }
+
+ /**
+ * Container object for fling animation configuration settings. This allows you to store default
+ * friction values (as well as optional min/max values) in a single configuration object, which
+ * you can pass to [fling] and related methods.
+ */
+ data class FlingConfig internal constructor(
+ internal var friction: Float,
+ internal var min: Float,
+ internal var max: Float,
+ internal var startVel: Float
+ ) {
+
+ constructor() : this(defaultFling.friction)
+
+ constructor(friction: Float) :
+ this(friction, defaultFling.min, defaultFling.max)
+
+ constructor(friction: Float, min: Float, max: Float) :
+ this(friction, min, max, startVel = 0f)
+
+ /** Apply these configuration settings to the given FlingAnimation. */
+ internal fun applyToAnimation(anim: FlingAnimation) {
+ anim.apply {
+ friction = this@FlingConfig.friction
+ setMinValue(min)
+ setMaxValue(max)
+ setStartVelocity(startVel)
+ }
+ }
+ }
+
+ /**
+ * Listener for receiving values from in progress animations. Used with
+ * [PhysicsAnimator.addUpdateListener].
+ *
+ * @param <T> The type of the object being animated.
+ </T> */
+ interface UpdateListener<T> {
+
+ /**
+ * Called on each animation frame with the target object, and a map of FloatPropertyCompat
+ * -> AnimationUpdate, containing the latest value and velocity for that property. When
+ * multiple properties are animating together, the map will typically contain one entry for
+ * each property. However, you should never assume that this is the case - when a property
+ * animation ends earlier than the others, you'll receive an UpdateMap containing only that
+ * property's final update. Subsequently, you'll only receive updates for the properties
+ * that are still animating.
+ *
+ * Always check that the map contains an update for the property you're interested in before
+ * accessing it.
+ *
+ * @param target The animated object itself.
+ * @param values Map of property to AnimationUpdate, which contains that property
+ * animation's latest value and velocity. You should never assume that a particular property
+ * is present in this map.
+ */
+ fun onAnimationUpdateForProperty(
+ target: T,
+ values: UpdateMap<T>
+ )
+ }
+
+ /**
+ * Listener for receiving callbacks when animations end.
+ *
+ * @param <T> The type of the object being animated.
+ </T> */
+ interface EndListener<T> {
+
+ /**
+ * Called with the final animation values as each property animation ends. This can be used
+ * to respond to specific property animations concluding (such as hiding a view when ALPHA
+ * ends, even if the corresponding TRANSLATION animations have not ended).
+ *
+ * If you just want to run an action when all of the property animations have ended, you can
+ * use [PhysicsAnimator.withEndActions].
+ *
+ * @param target The animated object itself.
+ * @param property The property whose animation has just ended.
+ * @param canceled Whether the animation was explicitly canceled before it naturally ended.
+ * @param finalValue The final value of the animated property.
+ * @param finalVelocity The final velocity (in pixels per second) of the ended animation.
+ * This is typically zero, unless this was a fling animation which ended abruptly due to
+ * reaching its configured min/max values.
+ * @param allRelevantPropertyAnimsEnded Whether all properties relevant to this end listener
+ * have ended. Relevant properties are those which were animated alongside the
+ * [addEndListener] call where this animator was passed in. For example:
+ *
+ * animator
+ * .spring(TRANSLATION_X, 100f)
+ * .spring(TRANSLATION_Y, 200f)
+ * .withEndListener(firstEndListener)
+ * .start()
+ *
+ * firstEndListener will be called first for TRANSLATION_X, with allEnded = false,
+ * because TRANSLATION_Y is still running. When TRANSLATION_Y ends, it'll be called with
+ * allEnded = true.
+ *
+ * If a subsequent call to start() is made with other properties, those properties are not
+ * considered relevant and allEnded will still equal true when only TRANSLATION_X and
+ * TRANSLATION_Y end. For example, if immediately after the prior example, while
+ * TRANSLATION_X and TRANSLATION_Y are still animating, we called:
+ *
+ * animator.
+ * .spring(SCALE_X, 2f, stiffness = 10f) // That will take awhile...
+ * .withEndListener(secondEndListener)
+ * .start()
+ *
+ * firstEndListener will still be called with allEnded = true when TRANSLATION_X/Y end, even
+ * though SCALE_X is still animating. Similarly, secondEndListener will be called with
+ * allEnded = true as soon as SCALE_X ends, even if the translation animations are still
+ * running.
+ */
+ fun onAnimationEnd(
+ target: T,
+ property: FloatPropertyCompat<in T>,
+ canceled: Boolean,
+ finalValue: Float,
+ finalVelocity: Float,
+ allRelevantPropertyAnimsEnded: Boolean
+ )
+ }
+
+ companion object {
+
+ /**
+ * Constructor to use to for new physics animator instances in [getInstance]. This is
+ * typically the default constructor, but [PhysicsAnimatorTestUtils] can change it so that
+ * all code using the physics animator is given testable instances instead.
+ */
+ internal var instanceConstructor: (Any) -> PhysicsAnimator<*> = ::PhysicsAnimator
+
+ @JvmStatic
+ fun <T : Any> getInstance(target: T): PhysicsAnimator<T> {
+ if (!animators.containsKey(target)) {
+ animators[target] = instanceConstructor(target)
+ }
+
+ return animators[target] as PhysicsAnimator<T>
+ }
+
+ /**
+ * Set whether all physics animators should log a lot of information about animations.
+ * Useful for debugging!
+ */
+ @JvmStatic
+ fun setVerboseLogging(debug: Boolean) {
+ verboseLogging = debug
+ }
+
+ @JvmStatic
+ fun getReadablePropertyName(property: FloatPropertyCompat<*>): String {
+ return when (property) {
+ DynamicAnimation.TRANSLATION_X -> "translationX"
+ DynamicAnimation.TRANSLATION_Y -> "translationY"
+ DynamicAnimation.TRANSLATION_Z -> "translationZ"
+ DynamicAnimation.SCALE_X -> "scaleX"
+ DynamicAnimation.SCALE_Y -> "scaleY"
+ DynamicAnimation.ROTATION -> "rotation"
+ DynamicAnimation.ROTATION_X -> "rotationX"
+ DynamicAnimation.ROTATION_Y -> "rotationY"
+ DynamicAnimation.SCROLL_X -> "scrollX"
+ DynamicAnimation.SCROLL_Y -> "scrollY"
+ DynamicAnimation.ALPHA -> "alpha"
+ else -> "Custom FloatPropertyCompat instance"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimatorTestUtils.kt b/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimatorTestUtils.kt
new file mode 100644
index 0000000..a1f74eb
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimatorTestUtils.kt
@@ -0,0 +1,457 @@
+/*
+ * Copyright (C) 2019 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 com.android.systemui.util.animation
+
+import android.os.Handler
+import android.os.Looper
+import android.util.ArrayMap
+import androidx.dynamicanimation.animation.FloatPropertyCompat
+import java.util.ArrayDeque
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
+
+typealias UpdateMatcher = (PhysicsAnimator.AnimationUpdate) -> Boolean
+typealias UpdateFramesPerProperty<T> =
+ ArrayMap<FloatPropertyCompat<in T>, ArrayList<PhysicsAnimator.AnimationUpdate>>
+
+/**
+ * Utilities for testing code that uses [PhysicsAnimator].
+ *
+ * Start by calling [prepareForTest] at the beginning of each test - this will modify the behavior
+ * of all PhysicsAnimator instances so that they post animations to the main thread (so they don't
+ * crash). It'll also enable the use of the other static helper methods in this class, which you can
+ * use to do things like block the test until animations complete (so you can test end states), or
+ * verify keyframes.
+ */
+object PhysicsAnimatorTestUtils {
+ var timeoutMs: Long = 2000
+ private var startBlocksUntilAnimationsEnd = false
+ private val animationThreadHandler = Handler(Looper.getMainLooper())
+ private val allAnimatedObjects = HashSet<Any>()
+ private val animatorTestHelpers = HashMap<PhysicsAnimator<*>, AnimatorTestHelper<*>>()
+
+ /**
+ * Modifies the behavior of all [PhysicsAnimator] instances so that they post animations to the
+ * main thread, and report all of their
+ */
+ @JvmStatic
+ fun prepareForTest() {
+ val defaultConstructor = PhysicsAnimator.instanceConstructor
+ PhysicsAnimator.instanceConstructor = fun(target: Any): PhysicsAnimator<*> {
+ val animator = defaultConstructor(target)
+ allAnimatedObjects.add(target)
+ animatorTestHelpers[animator] = AnimatorTestHelper(animator)
+ return animator
+ }
+
+ timeoutMs = 2000
+ startBlocksUntilAnimationsEnd = false
+ allAnimatedObjects.clear()
+ }
+
+ @JvmStatic
+ fun tearDown() {
+ val latch = CountDownLatch(1)
+ animationThreadHandler.post {
+ animatorTestHelpers.keys.forEach { it.cancel() }
+ latch.countDown()
+ }
+
+ latch.await()
+
+ animatorTestHelpers.clear()
+ animators.clear()
+ allAnimatedObjects.clear()
+ }
+
+ /**
+ * Sets the maximum time (in milliseconds) to block the test thread while waiting for animations
+ * before throwing an exception.
+ */
+ @JvmStatic
+ fun setBlockTimeout(timeoutMs: Long) {
+ this.timeoutMs = timeoutMs
+ }
+
+ /**
+ * Sets whether all animations should block the test thread until they end. This is typically
+ * the desired behavior, since you can invoke code that runs an animation and then assert things
+ * about its end state.
+ */
+ @JvmStatic
+ fun setAllAnimationsBlock(block: Boolean) {
+ startBlocksUntilAnimationsEnd = block
+ }
+
+ /**
+ * Blocks the calling thread until animations of the given property on the target object end.
+ */
+ @JvmStatic
+ @Throws(InterruptedException::class)
+ fun <T : Any> blockUntilAnimationsEnd(
+ animator: PhysicsAnimator<T>,
+ vararg properties: FloatPropertyCompat<in T>
+ ) {
+ val animatingProperties = HashSet<FloatPropertyCompat<in T>>()
+ for (property in properties) {
+ if (animator.isPropertyAnimating(property)) {
+ animatingProperties.add(property)
+ }
+ }
+
+ if (animatingProperties.size > 0) {
+ val latch = CountDownLatch(animatingProperties.size)
+ getAnimationTestHelper(animator).addTestEndListener(
+ object : PhysicsAnimator.EndListener<T> {
+ override fun onAnimationEnd(
+ target: T,
+ property: FloatPropertyCompat<in T>,
+ canceled: Boolean,
+ finalValue: Float,
+ finalVelocity: Float,
+ allRelevantPropertyAnimsEnded: Boolean
+ ) {
+ if (animatingProperties.contains(property)) {
+ latch.countDown()
+ }
+ }
+ })
+
+ latch.await(timeoutMs, TimeUnit.MILLISECONDS)
+ }
+ }
+
+ /**
+ * Blocks the calling thread until all animations of the given property (on all target objects)
+ * have ended. Useful when you don't have access to the objects being animated, but still need
+ * to wait for them to end so that other testable side effects occur (such as update/end
+ * listeners).
+ */
+ @JvmStatic
+ @Throws(InterruptedException::class)
+ fun <T : Any> blockUntilAnimationsEnd(
+ properties: FloatPropertyCompat<in T>
+ ) {
+ for (target in allAnimatedObjects) {
+ try {
+ blockUntilAnimationsEnd(
+ PhysicsAnimator.getInstance(target) as PhysicsAnimator<T>, properties)
+ } catch (e: ClassCastException) {
+ // Keep checking the other objects for ones whose types match the provided
+ // properties.
+ }
+ }
+ }
+
+ /**
+ * Blocks the calling thread until the first animation frame in which predicate returns true. If
+ * the given object isn't animating, returns without blocking.
+ */
+ @JvmStatic
+ @Throws(InterruptedException::class)
+ fun <T : Any> blockUntilFirstAnimationFrameWhereTrue(
+ animator: PhysicsAnimator<T>,
+ predicate: (T) -> Boolean
+ ) {
+ if (animator.isRunning()) {
+ val latch = CountDownLatch(1)
+ getAnimationTestHelper(animator).addTestUpdateListener(object : PhysicsAnimator
+ .UpdateListener<T> {
+ override fun onAnimationUpdateForProperty(
+ target: T,
+ values: UpdateMap<T>
+ ) {
+ if (predicate(target)) {
+ latch.countDown()
+ }
+ }
+ })
+
+ latch.await(timeoutMs, TimeUnit.MILLISECONDS)
+ }
+ }
+
+ /**
+ * Verifies that the animator reported animation frame values to update listeners that satisfy
+ * the given matchers, in order. Not all frames need to satisfy a matcher - we'll run through
+ * all animation frames, and check them against the current predicate. If it returns false, we
+ * continue through the frames until it returns true, and then move on to the next matcher.
+ * Verification fails if we run out of frames while unsatisfied matchers remain.
+ *
+ * If verification is successful, all frames to this point are considered 'verified' and will be
+ * cleared. Subsequent calls to this method will start verification at the next animation frame.
+ *
+ * Example: Verify that an animation surpassed x = 50f before going negative.
+ * verifyAnimationUpdateFrames(
+ * animator, TRANSLATION_X,
+ * { u -> u.value > 50f },
+ * { u -> u.value < 0f })
+ *
+ * Example: verify that an animation went backwards at some point while still being on-screen.
+ * verifyAnimationUpdateFrames(
+ * animator, TRANSLATION_X,
+ * { u -> u.velocity < 0f && u.value >= 0f })
+ *
+ * This method is intended to help you test longer, more complicated animations where it's
+ * critical that certain values were reached. Using this method to test short animations can
+ * fail due to the animation having fewer frames than provided matchers. For example, an
+ * animation from x = 1f to x = 5f might only have two frames, at x = 3f and x = 5f. The
+ * following would then fail despite it seeming logically sound:
+ *
+ * verifyAnimationUpdateFrames(
+ * animator, TRANSLATION_X,
+ * { u -> u.value > 1f },
+ * { u -> u.value > 2f },
+ * { u -> u.value > 3f })
+ *
+ * Tests might also fail if your matchers are too granular, such as this example test after an
+ * animation from x = 0f to x = 100f. It's unlikely there was a frame specifically between 2f
+ * and 3f.
+ *
+ * verifyAnimationUpdateFrames(
+ * animator, TRANSLATION_X,
+ * { u -> u.value > 2f && u.value < 3f },
+ * { u -> u.value >= 50f })
+ *
+ * Failures will print a helpful log of all animation frames so you can see what caused the test
+ * to fail.
+ */
+ fun <T : Any> verifyAnimationUpdateFrames(
+ animator: PhysicsAnimator<T>,
+ property: FloatPropertyCompat<in T>,
+ firstUpdateMatcher: UpdateMatcher,
+ vararg additionalUpdateMatchers: UpdateMatcher
+ ) {
+ val updateFrames: UpdateFramesPerProperty<T> = getAnimationUpdateFrames(animator)
+ val matchers = ArrayDeque<UpdateMatcher>(
+ additionalUpdateMatchers.toList())
+ val frameTraceMessage = StringBuilder()
+
+ var curMatcher = firstUpdateMatcher
+
+ // Loop through the updates from the testable animator.
+ for (update in updateFrames[property]
+ ?: error("No frames for given target object and property.")) {
+
+ // Check whether this frame satisfies the current matcher.
+ if (curMatcher(update)) {
+
+ // If that was the last unsatisfied matcher, we're good here. 'Verify' all remaining
+ // frames and return without failing.
+ if (matchers.size == 0) {
+ getAnimationUpdateFrames(animator).remove(property)
+ return
+ }
+
+ frameTraceMessage.append("$update\t(satisfied matcher)\n")
+ curMatcher = matchers.pop() // Get the next matcher and keep going.
+ } else {
+ frameTraceMessage.append("${update}\n")
+ }
+ }
+
+ val readablePropertyName = PhysicsAnimator.getReadablePropertyName(property)
+ getAnimationUpdateFrames(animator).remove(property)
+
+ throw RuntimeException(
+ "Failed to verify animation frames for property $readablePropertyName: " +
+ "Provided ${additionalUpdateMatchers.size + 1} matchers, " +
+ "however ${matchers.size + 1} remained unsatisfied.\n\n" +
+ "All frames:\n$frameTraceMessage")
+ }
+
+ /**
+ * Overload of [verifyAnimationUpdateFrames] that builds matchers for you, from given float
+ * values. For example, to verify that an animations passed from 0f to 50f to 100f back to 50f:
+ *
+ * verifyAnimationUpdateFrames(animator, TRANSLATION_X, 0f, 50f, 100f, 50f)
+ *
+ * This verifies that update frames were received with values of >= 0f, >= 50f, >= 100f, and
+ * <= 50f.
+ *
+ * The same caveats apply: short animations might not have enough frames to satisfy all of the
+ * matchers, and overly specific calls (such as 0f, 1f, 2f, 3f, etc. for an animation from
+ * x = 0f to x = 100f) might fail as the animation only had frames at 0f, 25f, 50f, 75f, and
+ * 100f. As with [verifyAnimationUpdateFrames], failures will print a helpful log of all frames
+ * so you can see what caused the test to fail.
+ */
+ fun <T : Any> verifyAnimationUpdateFrames(
+ animator: PhysicsAnimator<T>,
+ property: FloatPropertyCompat<in T>,
+ startValue: Float,
+ firstTargetValue: Float,
+ vararg additionalTargetValues: Float
+ ) {
+ val matchers = ArrayList<UpdateMatcher>()
+
+ val values = ArrayList<Float>().also {
+ it.add(firstTargetValue)
+ it.addAll(additionalTargetValues.toList())
+ }
+
+ var prevVal = startValue
+ for (value in values) {
+ if (value > prevVal) {
+ matchers.add { update -> update.value >= value }
+ } else {
+ matchers.add { update -> update.value <= value }
+ }
+
+ prevVal = value
+ }
+
+ verifyAnimationUpdateFrames(
+ animator, property, matchers[0], *matchers.drop(0).toTypedArray())
+ }
+
+ /**
+ * Returns all of the values that have ever been reported to update listeners, per property.
+ */
+ fun <T : Any> getAnimationUpdateFrames(animator: PhysicsAnimator<T>):
+ UpdateFramesPerProperty<T> {
+ return animatorTestHelpers[animator]?.getUpdates() as UpdateFramesPerProperty<T>
+ }
+
+ /**
+ * Clears animation frame updates from the given animator so they aren't used the next time its
+ * passed to [verifyAnimationUpdateFrames].
+ */
+ fun <T : Any> clearAnimationUpdateFrames(animator: PhysicsAnimator<T>) {
+ animatorTestHelpers[animator]?.clearUpdates()
+ }
+
+ private fun <T> getAnimationTestHelper(animator: PhysicsAnimator<T>): AnimatorTestHelper<T> {
+ return animatorTestHelpers[animator] as AnimatorTestHelper<T>
+ }
+
+ /**
+ * Helper class for testing an animator. This replaces the animator's start action with
+ * [startForTest] and adds test listeners to enable other test utility behaviors. We build one
+ * these for each Animator and keep them around so we can access the updates.
+ */
+ class AnimatorTestHelper<T> (private val animator: PhysicsAnimator<T>) {
+
+ /** All updates received for each property animation. */
+ private val allUpdates =
+ ArrayMap<FloatPropertyCompat<in T>, ArrayList<PhysicsAnimator.AnimationUpdate>>()
+
+ private val testEndListeners = ArrayList<PhysicsAnimator.EndListener<T>>()
+ private val testUpdateListeners = ArrayList<PhysicsAnimator.UpdateListener<T>>()
+
+ init {
+ animator.startAction = ::startForTest
+ }
+
+ internal fun addTestEndListener(listener: PhysicsAnimator.EndListener<T>) {
+ testEndListeners.add(listener)
+ }
+
+ internal fun addTestUpdateListener(listener: PhysicsAnimator.UpdateListener<T>) {
+ testUpdateListeners.add(listener)
+ }
+
+ internal fun getUpdates(): UpdateFramesPerProperty<T> {
+ return allUpdates
+ }
+
+ internal fun clearUpdates() {
+ allUpdates.clear()
+ }
+
+ private fun startForTest() {
+ // The testable animator needs to block the main thread until super.start() has been
+ // called, since callers expect .start() to be synchronous but we're posting it to a
+ // handler here. We may also continue blocking until all animations end, if
+ // startBlocksUntilAnimationsEnd = true.
+ val unblockLatch = CountDownLatch(if (startBlocksUntilAnimationsEnd) 2 else 1)
+
+ animationThreadHandler.post {
+ val animatedProperties = animator.getAnimatedProperties()
+
+ // Add an update listener that dispatches to any test update listeners added by
+ // tests.
+ animator.addUpdateListener(object : PhysicsAnimator.UpdateListener<T> {
+ override fun onAnimationUpdateForProperty(
+ target: T,
+ values: ArrayMap<FloatPropertyCompat<in T>, PhysicsAnimator.AnimationUpdate>
+ ) {
+ for (listener in testUpdateListeners) {
+ listener.onAnimationUpdateForProperty(target, values)
+ }
+ }
+ })
+
+ // Add an end listener that dispatches to any test end listeners added by tests, and
+ // unblocks the main thread if required.
+ animator.addEndListener(object : PhysicsAnimator.EndListener<T> {
+ override fun onAnimationEnd(
+ target: T,
+ property: FloatPropertyCompat<in T>,
+ canceled: Boolean,
+ finalValue: Float,
+ finalVelocity: Float,
+ allRelevantPropertyAnimsEnded: Boolean
+ ) {
+ for (listener in testEndListeners) {
+ listener.onAnimationEnd(
+ target, property, canceled, finalValue, finalVelocity,
+ allRelevantPropertyAnimsEnded)
+ }
+
+ if (allRelevantPropertyAnimsEnded) {
+ testEndListeners.clear()
+ testUpdateListeners.clear()
+
+ if (startBlocksUntilAnimationsEnd) {
+ unblockLatch.countDown()
+ }
+ }
+ }
+ })
+
+ val updateListeners = ArrayList<PhysicsAnimator.UpdateListener<T>>().also {
+ it.add(object : PhysicsAnimator.UpdateListener<T> {
+ override fun onAnimationUpdateForProperty(
+ target: T,
+ values: ArrayMap<FloatPropertyCompat<in T>,
+ PhysicsAnimator.AnimationUpdate>
+ ) {
+ values.forEach { (property, value) ->
+ allUpdates.getOrPut(property, { ArrayList() }).add(value)
+ }
+ }
+ })
+ }
+
+ /**
+ * Add an internal listener at the head of the list that captures update values
+ * directly from DynamicAnimation. We use this to build a list of all updates so we
+ * can verify that InternalListener dispatches to the real listeners properly.
+ */
+ animator.internalListeners.add(0, animator.InternalListener(
+ animatedProperties,
+ updateListeners,
+ ArrayList(),
+ ArrayList()))
+
+ animator.startInternal()
+ unblockLatch.countDown()
+ }
+
+ unblockLatch.await(timeoutMs, TimeUnit.MILLISECONDS)
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/wm/DisplayLayout.java b/packages/SystemUI/src/com/android/systemui/wm/DisplayLayout.java
new file mode 100644
index 0000000..264a683
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/wm/DisplayLayout.java
@@ -0,0 +1,474 @@
+/*
+ * Copyright (C) 2019 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 com.android.systemui.wm;
+
+import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
+import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
+import static android.content.res.Configuration.UI_MODE_TYPE_CAR;
+import static android.content.res.Configuration.UI_MODE_TYPE_MASK;
+import static android.os.Process.SYSTEM_UID;
+import static android.provider.Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS;
+import static android.view.Display.FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS;
+import static android.view.Surface.ROTATION_0;
+import static android.view.Surface.ROTATION_270;
+import static android.view.Surface.ROTATION_90;
+
+import android.annotation.NonNull;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Rect;
+import android.os.SystemProperties;
+import android.provider.Settings;
+import android.util.Size;
+import android.view.Display;
+import android.view.DisplayCutout;
+import android.view.DisplayInfo;
+import android.view.Gravity;
+import android.view.Surface;
+
+import com.android.internal.R;
+
+import java.util.List;
+
+/**
+ * Contains information about the layout-properties of a display. This refers to internal layout
+ * like insets/cutout/rotation. In general, this can be thought of as the System-UI analog to
+ * DisplayPolicy.
+ */
+public class DisplayLayout {
+ // Navigation bar position values
+ private static final int NAV_BAR_LEFT = 1 << 0;
+ private static final int NAV_BAR_RIGHT = 1 << 1;
+ private static final int NAV_BAR_BOTTOM = 1 << 2;
+
+ private int mUiMode;
+ private int mWidth;
+ private int mHeight;
+ private DisplayCutout mCutout;
+ private int mRotation;
+ private int mDensityDpi;
+ private final Rect mNonDecorInsets = new Rect();
+ private final Rect mStableInsets = new Rect();
+ private boolean mHasNavigationBar = false;
+ private boolean mHasStatusBar = false;
+
+ /**
+ * Create empty layout.
+ */
+ public DisplayLayout() {
+ }
+
+ /**
+ * Construct a custom display layout using a DisplayInfo.
+ * @param info
+ * @param res
+ */
+ public DisplayLayout(DisplayInfo info, Resources res, boolean hasNavigationBar,
+ boolean hasStatusBar) {
+ init(info, res, hasNavigationBar, hasStatusBar);
+ }
+
+ /**
+ * Construct a display layout based on a live display.
+ * @param context Used for resources.
+ */
+ public DisplayLayout(@NonNull Context context, @NonNull Display rawDisplay) {
+ final int displayId = rawDisplay.getDisplayId();
+ DisplayInfo info = new DisplayInfo();
+ rawDisplay.getDisplayInfo(info);
+ init(info, context.getResources(), hasNavigationBar(info, context, displayId),
+ hasStatusBar(displayId));
+ }
+
+ public DisplayLayout(DisplayLayout dl) {
+ set(dl);
+ }
+
+ /** sets this DisplayLayout to a copy of another on. */
+ public void set(DisplayLayout dl) {
+ mUiMode = dl.mUiMode;
+ mWidth = dl.mWidth;
+ mHeight = dl.mHeight;
+ mCutout = dl.mCutout;
+ mRotation = dl.mRotation;
+ mDensityDpi = dl.mDensityDpi;
+ mHasNavigationBar = dl.mHasNavigationBar;
+ mHasStatusBar = dl.mHasStatusBar;
+ mNonDecorInsets.set(dl.mNonDecorInsets);
+ mStableInsets.set(dl.mStableInsets);
+ }
+
+ private void init(DisplayInfo info, Resources res, boolean hasNavigationBar,
+ boolean hasStatusBar) {
+ mUiMode = res.getConfiguration().uiMode;
+ mWidth = info.logicalWidth;
+ mHeight = info.logicalHeight;
+ mRotation = info.rotation;
+ mCutout = info.displayCutout;
+ mDensityDpi = info.logicalDensityDpi;
+ mHasNavigationBar = hasNavigationBar;
+ mHasStatusBar = hasStatusBar;
+ recalcInsets(res);
+ }
+
+ private void recalcInsets(Resources res) {
+ computeNonDecorInsets(res, mRotation, mWidth, mHeight, mCutout, mUiMode, mNonDecorInsets,
+ mHasNavigationBar);
+ mStableInsets.set(mNonDecorInsets);
+ if (mHasStatusBar) {
+ convertNonDecorInsetsToStableInsets(res, mStableInsets, mWidth, mHeight, mHasStatusBar);
+ }
+ }
+
+ /**
+ * Apply a rotation to this layout and its parameters.
+ * @param res
+ * @param targetRotation
+ */
+ public void rotateTo(Resources res, @Surface.Rotation int targetRotation) {
+ final int rotationDelta = (targetRotation - mRotation + 4) % 4;
+ final boolean changeOrient = (rotationDelta % 2) != 0;
+
+ final int origWidth = mWidth;
+ final int origHeight = mHeight;
+
+ mRotation = targetRotation;
+ if (changeOrient) {
+ mWidth = origHeight;
+ mHeight = origWidth;
+ }
+
+ if (mCutout != null && !mCutout.isEmpty()) {
+ mCutout = calculateDisplayCutoutForRotation(mCutout, rotationDelta, origWidth,
+ origHeight);
+ }
+
+ recalcInsets(res);
+ }
+
+ /** Get this layout's non-decor insets. */
+ public Rect nonDecorInsets() {
+ return mNonDecorInsets;
+ }
+
+ /** Get this layout's stable insets. */
+ public Rect stableInsets() {
+ return mStableInsets;
+ }
+
+ /** Get this layout's width. */
+ public int width() {
+ return mWidth;
+ }
+
+ /** Get this layout's height. */
+ public int height() {
+ return mHeight;
+ }
+
+ /** Get this layout's display rotation. */
+ public int rotation() {
+ return mRotation;
+ }
+
+ /** Get this layout's display density. */
+ public int densityDpi() {
+ return mDensityDpi;
+ }
+
+ /** Get whether this layout is landscape. */
+ public boolean isLandscape() {
+ return mWidth > mHeight;
+ }
+
+ /** Gets the orientation of this layout */
+ public int getOrientation() {
+ return (mWidth > mHeight) ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT;
+ }
+
+ /** Gets the calculated stable-bounds for this layout */
+ public void getStableBounds(Rect outBounds) {
+ outBounds.set(0, 0, mWidth, mHeight);
+ outBounds.inset(mStableInsets);
+ }
+
+ /**
+ * Rotates bounds as if parentBounds and bounds are a group. The group is rotated by `delta`
+ * 90-degree counter-clockwise increments. This assumes that parentBounds is at 0,0 and
+ * remains at 0,0 after rotation.
+ *
+ * Only 'bounds' is mutated.
+ */
+ public static void rotateBounds(Rect inOutBounds, Rect parentBounds, int delta) {
+ int rdelta = ((delta % 4) + 4) % 4;
+ int origLeft = inOutBounds.left;
+ switch (rdelta) {
+ case 0:
+ return;
+ case 1:
+ inOutBounds.left = inOutBounds.top;
+ inOutBounds.top = parentBounds.right - inOutBounds.right;
+ inOutBounds.right = inOutBounds.bottom;
+ inOutBounds.bottom = parentBounds.right - origLeft;
+ return;
+ case 2:
+ inOutBounds.left = parentBounds.right - inOutBounds.right;
+ inOutBounds.right = parentBounds.right - origLeft;
+ return;
+ case 3:
+ inOutBounds.left = parentBounds.bottom - inOutBounds.bottom;
+ inOutBounds.bottom = inOutBounds.right;
+ inOutBounds.right = parentBounds.bottom - inOutBounds.top;
+ inOutBounds.top = origLeft;
+ return;
+ }
+ }
+
+ /**
+ * Calculates the stable insets if we already have the non-decor insets.
+ */
+ private static void convertNonDecorInsetsToStableInsets(Resources res, Rect inOutInsets,
+ int displayWidth, int displayHeight, boolean hasStatusBar) {
+ if (!hasStatusBar) {
+ return;
+ }
+ int statusBarHeight = getStatusBarHeight(displayWidth > displayHeight, res);
+ inOutInsets.top = Math.max(inOutInsets.top, statusBarHeight);
+ }
+
+ /**
+ * Calculates the insets for the areas that could never be removed in Honeycomb, i.e. system
+ * bar or button bar.
+ *
+ * @param displayRotation the current display rotation
+ * @param displayWidth the current display width
+ * @param displayHeight the current display height
+ * @param displayCutout the current display cutout
+ * @param outInsets the insets to return
+ */
+ static void computeNonDecorInsets(Resources res, int displayRotation, int displayWidth,
+ int displayHeight, DisplayCutout displayCutout, int uiMode, Rect outInsets,
+ boolean hasNavigationBar) {
+ outInsets.setEmpty();
+
+ // Only navigation bar
+ if (hasNavigationBar) {
+ int position = navigationBarPosition(res, displayWidth, displayHeight, displayRotation);
+ int navBarSize =
+ getNavigationBarSize(res, position, displayWidth > displayHeight, uiMode);
+ if (position == NAV_BAR_BOTTOM) {
+ outInsets.bottom = navBarSize;
+ } else if (position == NAV_BAR_RIGHT) {
+ outInsets.right = navBarSize;
+ } else if (position == NAV_BAR_LEFT) {
+ outInsets.left = navBarSize;
+ }
+ }
+
+ if (displayCutout != null) {
+ outInsets.left += displayCutout.getSafeInsetLeft();
+ outInsets.top += displayCutout.getSafeInsetTop();
+ outInsets.right += displayCutout.getSafeInsetRight();
+ outInsets.bottom += displayCutout.getSafeInsetBottom();
+ }
+ }
+
+ /**
+ * Calculates the stable insets without running a layout.
+ *
+ * @param displayRotation the current display rotation
+ * @param displayWidth the current display width
+ * @param displayHeight the current display height
+ * @param displayCutout the current display cutout
+ * @param outInsets the insets to return
+ */
+ static void computeStableInsets(Resources res, int displayRotation, int displayWidth,
+ int displayHeight, DisplayCutout displayCutout, int uiMode, Rect outInsets,
+ boolean hasNavigationBar, boolean hasStatusBar) {
+ outInsets.setEmpty();
+
+ // Navigation bar and status bar.
+ computeNonDecorInsets(res, displayRotation, displayWidth, displayHeight, displayCutout,
+ uiMode, outInsets, hasNavigationBar);
+ convertNonDecorInsetsToStableInsets(res, outInsets, displayWidth, displayHeight,
+ hasStatusBar);
+ }
+
+ /** Retrieve the statusbar height from resources. */
+ static int getStatusBarHeight(boolean landscape, Resources res) {
+ return landscape ? res.getDimensionPixelSize(
+ com.android.internal.R.dimen.status_bar_height_landscape)
+ : res.getDimensionPixelSize(
+ com.android.internal.R.dimen.status_bar_height_portrait);
+ }
+
+ /** Calculate the DisplayCutout for a particular display size/rotation. */
+ public static DisplayCutout calculateDisplayCutoutForRotation(
+ DisplayCutout cutout, int rotation, int displayWidth, int displayHeight) {
+ if (cutout == null || cutout == DisplayCutout.NO_CUTOUT) {
+ return null;
+ }
+ if (rotation == ROTATION_0) {
+ return computeSafeInsets(
+ cutout, displayWidth, displayHeight);
+ }
+ final boolean rotated = (rotation == ROTATION_90 || rotation == ROTATION_270);
+ Rect[] cutoutRects = computeSafeInsets(cutout, displayWidth, displayHeight)
+ .getBoundingRectsAll();
+ final Rect[] newBounds = new Rect[cutoutRects.length];
+ final Rect displayBounds = new Rect(0, 0, displayWidth, displayHeight);
+ for (int i = 0; i < cutoutRects.length; ++i) {
+ newBounds[i] = new Rect(cutoutRects[i]);
+ rotateBounds(newBounds[i], displayBounds, rotation);
+ }
+ return computeSafeInsets(DisplayCutout.fromBounds(newBounds),
+ rotated ? displayHeight : displayWidth,
+ rotated ? displayWidth : displayHeight);
+ }
+
+ /** Calculate safe insets. */
+ public static DisplayCutout computeSafeInsets(DisplayCutout inner,
+ int displayWidth, int displayHeight) {
+ if (inner == DisplayCutout.NO_CUTOUT || inner.isBoundsEmpty()) {
+ return null;
+ }
+
+ final Size displaySize = new Size(displayWidth, displayHeight);
+ final Rect safeInsets = computeSafeInsets(displaySize, inner);
+ return inner.replaceSafeInsets(safeInsets);
+ }
+
+ private static Rect computeSafeInsets(Size displaySize, DisplayCutout cutout) {
+ if (displaySize.getWidth() < displaySize.getHeight()) {
+ final List<Rect> boundingRects = cutout.replaceSafeInsets(
+ new Rect(0, displaySize.getHeight() / 2, 0, displaySize.getHeight() / 2))
+ .getBoundingRects();
+ int topInset = findInsetForSide(displaySize, boundingRects, Gravity.TOP);
+ int bottomInset = findInsetForSide(displaySize, boundingRects, Gravity.BOTTOM);
+ return new Rect(0, topInset, 0, bottomInset);
+ } else if (displaySize.getWidth() > displaySize.getHeight()) {
+ final List<Rect> boundingRects = cutout.replaceSafeInsets(
+ new Rect(displaySize.getWidth() / 2, 0, displaySize.getWidth() / 2, 0))
+ .getBoundingRects();
+ int leftInset = findInsetForSide(displaySize, boundingRects, Gravity.LEFT);
+ int right = findInsetForSide(displaySize, boundingRects, Gravity.RIGHT);
+ return new Rect(leftInset, 0, right, 0);
+ } else {
+ throw new UnsupportedOperationException("not implemented: display=" + displaySize
+ + " cutout=" + cutout);
+ }
+ }
+
+ private static int findInsetForSide(Size display, List<Rect> boundingRects, int gravity) {
+ int inset = 0;
+ final int size = boundingRects.size();
+ for (int i = 0; i < size; i++) {
+ Rect boundingRect = boundingRects.get(i);
+ switch (gravity) {
+ case Gravity.TOP:
+ if (boundingRect.top == 0) {
+ inset = Math.max(inset, boundingRect.bottom);
+ }
+ break;
+ case Gravity.BOTTOM:
+ if (boundingRect.bottom == display.getHeight()) {
+ inset = Math.max(inset, display.getHeight() - boundingRect.top);
+ }
+ break;
+ case Gravity.LEFT:
+ if (boundingRect.left == 0) {
+ inset = Math.max(inset, boundingRect.right);
+ }
+ break;
+ case Gravity.RIGHT:
+ if (boundingRect.right == display.getWidth()) {
+ inset = Math.max(inset, display.getWidth() - boundingRect.left);
+ }
+ break;
+ default:
+ throw new IllegalArgumentException("unknown gravity: " + gravity);
+ }
+ }
+ return inset;
+ }
+
+ static boolean hasNavigationBar(DisplayInfo info, Context context, int displayId) {
+ if (displayId == Display.DEFAULT_DISPLAY) {
+ // Allow a system property to override this. Used by the emulator.
+ final String navBarOverride = SystemProperties.get("qemu.hw.mainkeys");
+ if ("1".equals(navBarOverride)) {
+ return false;
+ } else if ("0".equals(navBarOverride)) {
+ return true;
+ }
+ return context.getResources().getBoolean(R.bool.config_showNavigationBar);
+ } else {
+ boolean isUntrustedVirtualDisplay = info.type == Display.TYPE_VIRTUAL
+ && info.ownerUid != SYSTEM_UID;
+ final ContentResolver resolver = context.getContentResolver();
+ boolean forceDesktopOnExternal = Settings.Global.getInt(resolver,
+ DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS, 0) != 0;
+
+ return ((info.flags & FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS) != 0
+ || (forceDesktopOnExternal && !isUntrustedVirtualDisplay));
+ // TODO(b/142569966): make sure VR2D and DisplayWindowSettings are moved here somehow.
+ }
+ }
+
+ static boolean hasStatusBar(int displayId) {
+ return displayId == Display.DEFAULT_DISPLAY;
+ }
+
+ /** Retrieve navigation bar position from resources based on rotation and size. */
+ public static int navigationBarPosition(Resources res, int displayWidth, int displayHeight,
+ int rotation) {
+ boolean navBarCanMove = displayWidth != displayHeight && res.getBoolean(
+ com.android.internal.R.bool.config_navBarCanMove);
+ if (navBarCanMove && displayWidth > displayHeight) {
+ if (rotation == Surface.ROTATION_90) {
+ return NAV_BAR_RIGHT;
+ } else {
+ return NAV_BAR_LEFT;
+ }
+ }
+ return NAV_BAR_BOTTOM;
+ }
+
+ /** Retrieve navigation bar size from resources based on side/orientation/ui-mode */
+ public static int getNavigationBarSize(Resources res, int navBarSide, boolean landscape,
+ int uiMode) {
+ final boolean carMode = (uiMode & UI_MODE_TYPE_MASK) == UI_MODE_TYPE_CAR;
+ if (carMode) {
+ if (navBarSide == NAV_BAR_BOTTOM) {
+ return res.getDimensionPixelSize(landscape
+ ? R.dimen.navigation_bar_height_landscape_car_mode
+ : R.dimen.navigation_bar_height_car_mode);
+ } else {
+ return res.getDimensionPixelSize(R.dimen.navigation_bar_width_car_mode);
+ }
+ } else {
+ if (navBarSide == NAV_BAR_BOTTOM) {
+ return res.getDimensionPixelSize(landscape
+ ? R.dimen.navigation_bar_height_landscape
+ : R.dimen.navigation_bar_height);
+ } else {
+ return res.getDimensionPixelSize(R.dimen.navigation_bar_width);
+ }
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/wm/DisplayWindowController.java b/packages/SystemUI/src/com/android/systemui/wm/DisplayWindowController.java
index 19fff79..ae82115 100644
--- a/packages/SystemUI/src/com/android/systemui/wm/DisplayWindowController.java
+++ b/packages/SystemUI/src/com/android/systemui/wm/DisplayWindowController.java
@@ -16,16 +16,20 @@
package com.android.systemui.wm;
+import android.annotation.Nullable;
+import android.content.Context;
import android.content.res.Configuration;
+import android.hardware.display.DisplayManager;
import android.os.Handler;
import android.os.RemoteException;
import android.util.Slog;
import android.util.SparseArray;
+import android.view.Display;
import android.view.IDisplayWindowListener;
import android.view.IDisplayWindowRotationCallback;
import android.view.IDisplayWindowRotationController;
+import android.view.IWindowManager;
import android.view.WindowContainerTransaction;
-import android.view.WindowManagerGlobal;
import com.android.systemui.dagger.qualifiers.MainHandler;
@@ -45,6 +49,8 @@
private static final String TAG = "DisplayWindowController";
private final Handler mHandler;
+ private final Context mContext;
+ private final IWindowManager mWmService;
private final ArrayList<OnDisplayWindowRotationController> mRotationControllers =
new ArrayList<>();
@@ -76,6 +82,14 @@
}
};
+ /**
+ * Get's a display by id from DisplayManager.
+ */
+ public Display getDisplay(int displayId) {
+ final DisplayManager displayManager = mContext.getSystemService(DisplayManager.class);
+ return displayManager.getDisplay(displayId);
+ }
+
private final IDisplayWindowListener mDisplayContainerListener =
new IDisplayWindowListener.Stub() {
@Override
@@ -87,6 +101,10 @@
}
DisplayRecord record = new DisplayRecord();
record.mDisplayId = displayId;
+ Display display = getDisplay(displayId);
+ record.mContext = (displayId == Display.DEFAULT_DISPLAY) ? mContext
+ : mContext.createDisplayContext(display);
+ record.mDisplayLayout = new DisplayLayout(record.mContext, display);
mDisplays.put(displayId, record);
for (int i = 0; i < mDisplayChangedListeners.size(); ++i) {
mDisplayChangedListeners.get(i).onDisplayAdded(displayId);
@@ -105,6 +123,13 @@
+ " display.");
return;
}
+ Display display = getDisplay(displayId);
+ Context perDisplayContext = mContext;
+ if (displayId != Display.DEFAULT_DISPLAY) {
+ perDisplayContext = mContext.createDisplayContext(display);
+ }
+ dr.mContext = perDisplayContext.createConfigurationContext(newConfig);
+ dr.mDisplayLayout = new DisplayLayout(dr.mContext, display);
for (int i = 0; i < mDisplayChangedListeners.size(); ++i) {
mDisplayChangedListeners.get(i).onDisplayConfigurationChanged(
displayId, newConfig);
@@ -127,19 +152,36 @@
};
@Inject
- public DisplayWindowController(@MainHandler Handler mainHandler) {
+ public DisplayWindowController(Context context, @MainHandler Handler mainHandler,
+ IWindowManager wmService) {
mHandler = mainHandler;
+ mContext = context;
+ mWmService = wmService;
try {
- WindowManagerGlobal.getWindowManagerService().registerDisplayWindowListener(
- mDisplayContainerListener);
- WindowManagerGlobal.getWindowManagerService().setDisplayWindowRotationController(
- mDisplayRotationController);
+ mWmService.registerDisplayWindowListener(mDisplayContainerListener);
+ mWmService.setDisplayWindowRotationController(mDisplayRotationController);
} catch (RemoteException e) {
throw new RuntimeException("Unable to register hierarchy listener");
}
}
/**
+ * Gets the DisplayLayout associated with a display.
+ */
+ public @Nullable DisplayLayout getDisplayLayout(int displayId) {
+ final DisplayRecord r = mDisplays.get(displayId);
+ return r != null ? r.mDisplayLayout : null;
+ }
+
+ /**
+ * Gets a display-specific context for a display.
+ */
+ public @Nullable Context getDisplayContext(int displayId) {
+ final DisplayRecord r = mDisplays.get(displayId);
+ return r != null ? r.mContext : null;
+ }
+
+ /**
* Add a display window-container listener. It will get notified whenever a display's
* configuration changes or when displays are added/removed from the WM hierarchy.
*/
@@ -184,6 +226,8 @@
private static class DisplayRecord {
int mDisplayId;
+ Context mContext;
+ DisplayLayout mDisplayLayout;
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/wm/SystemWindows.java b/packages/SystemUI/src/com/android/systemui/wm/SystemWindows.java
new file mode 100644
index 0000000..5ec61c3
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/wm/SystemWindows.java
@@ -0,0 +1,330 @@
+/*
+ * Copyright (C) 2019 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 com.android.systemui.wm;
+
+import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
+
+import android.annotation.NonNull;
+import android.content.Context;
+import android.content.res.Configuration;
+import android.graphics.Point;
+import android.graphics.Rect;
+import android.os.Bundle;
+import android.os.ParcelFileDescriptor;
+import android.os.RemoteException;
+import android.util.MergedConfiguration;
+import android.util.Slog;
+import android.util.SparseArray;
+import android.view.Display;
+import android.view.DisplayCutout;
+import android.view.DragEvent;
+import android.view.IWindow;
+import android.view.IWindowManager;
+import android.view.IWindowSession;
+import android.view.IWindowSessionCallback;
+import android.view.InsetsSourceControl;
+import android.view.InsetsState;
+import android.view.SurfaceControl;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.view.WindowlessViewRoot;
+import android.view.WindowlessWindowManager;
+
+import com.android.internal.os.IResultReceiver;
+
+import java.util.HashMap;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+/**
+ * Represents the "windowing" layer of the System-UI. This layer allows system-ui components to
+ * place and manipulate windows without talking to WindowManager.
+ */
+@Singleton
+public class SystemWindows {
+ private static final String TAG = "SystemWindows";
+
+ private final SparseArray<PerDisplay> mPerDisplay = new SparseArray<>();
+ final HashMap<View, WindowlessViewRoot> mViewRoots = new HashMap<>();
+ Context mContext;
+ IWindowSession mSession;
+ DisplayWindowController mDisplayController;
+ IWindowManager mWmService;
+
+ private final DisplayWindowController.DisplayWindowListener mDisplayListener =
+ new DisplayWindowController.DisplayWindowListener() {
+ @Override
+ public void onDisplayAdded(int displayId) { }
+
+ @Override
+ public void onDisplayConfigurationChanged(int displayId, Configuration newConfig) {
+ PerDisplay pd = mPerDisplay.get(displayId);
+ if (pd == null) {
+ return;
+ }
+ pd.updateConfiguration(newConfig);
+ }
+
+ @Override
+ public void onDisplayRemoved(int displayId) { }
+ };
+
+ @Inject
+ public SystemWindows(Context context, DisplayWindowController displayController,
+ IWindowManager wmService) {
+ mContext = context;
+ mWmService = wmService;
+ mDisplayController = displayController;
+ mDisplayController.addDisplayWindowListener(mDisplayListener);
+ try {
+ mSession = wmService.openSession(
+ new IWindowSessionCallback.Stub() {
+ @Override
+ public void onAnimatorScaleChanged(float scale) {}
+ });
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Unable to create layer", e);
+ }
+ }
+
+ /**
+ * Adds a view to system-ui window management.
+ */
+ public void addView(View view, WindowManager.LayoutParams attrs, int displayId,
+ int windowType) {
+ PerDisplay pd = mPerDisplay.get(displayId);
+ if (pd == null) {
+ pd = new PerDisplay(displayId);
+ mPerDisplay.put(displayId, pd);
+ }
+ pd.addView(view, attrs, windowType);
+ }
+
+ /**
+ * Removes a view from system-ui window management.
+ * @param view
+ */
+ public void removeView(View view) {
+ WindowlessViewRoot root = mViewRoots.remove(view);
+ root.die();
+ }
+
+ /**
+ * Updates the layout params of a view.
+ */
+ public void updateViewLayout(@NonNull View view, ViewGroup.LayoutParams params) {
+ WindowlessViewRoot root = mViewRoots.get(view);
+ if (root == null || !(params instanceof WindowManager.LayoutParams)) {
+ return;
+ }
+ view.setLayoutParams(params);
+ root.relayout((WindowManager.LayoutParams) params);
+ }
+
+ /**
+ * Adds a root for system-ui window management with no views. Only useful for IME.
+ */
+ public void addRoot(int displayId, int windowType) {
+ PerDisplay pd = mPerDisplay.get(displayId);
+ if (pd == null) {
+ pd = new PerDisplay(displayId);
+ mPerDisplay.put(displayId, pd);
+ }
+ pd.addRoot(windowType);
+ }
+
+ /**
+ * Get the IWindow token for a specific root.
+ *
+ * @param windowType A window type from {@link android.view.WindowManager}.
+ */
+ IWindow getWindow(int displayId, int windowType) {
+ PerDisplay pd = mPerDisplay.get(displayId);
+ if (pd == null) {
+ return null;
+ }
+ return pd.getWindow(windowType);
+ }
+
+ private class PerDisplay {
+ final int mDisplayId;
+ private final SparseArray<SysUiWindowManager> mWwms = new SparseArray<>();
+
+ PerDisplay(int displayId) {
+ mDisplayId = displayId;
+ }
+
+ public void addView(View view, WindowManager.LayoutParams attrs, int windowType) {
+ SysUiWindowManager wwm = addRoot(windowType);
+ if (wwm == null) {
+ Slog.e(TAG, "Unable to create systemui root");
+ return;
+ }
+ final Display display = mDisplayController.getDisplay(mDisplayId);
+ WindowlessViewRoot viewRoot = new WindowlessViewRoot(mContext, display, wwm);
+ attrs.flags |= FLAG_HARDWARE_ACCELERATED;
+ viewRoot.addView(view, attrs);
+ mViewRoots.put(view, viewRoot);
+ }
+
+ SysUiWindowManager addRoot(int windowType) {
+ SysUiWindowManager wwm = mWwms.get(windowType);
+ if (wwm != null) {
+ return wwm;
+ }
+ SurfaceControl rootSurface = null;
+ ContainerWindow win = new ContainerWindow();
+ try {
+ rootSurface = mWmService.addShellRoot(mDisplayId, win, windowType);
+ } catch (RemoteException e) {
+ }
+ if (rootSurface == null) {
+ Slog.e(TAG, "Unable to get root surfacecontrol for systemui");
+ return null;
+ }
+ Context displayContext = mDisplayController.getDisplayContext(mDisplayId);
+ wwm = new SysUiWindowManager(mDisplayId, displayContext, rootSurface, win);
+ mWwms.put(windowType, wwm);
+ return wwm;
+ }
+
+ IWindow getWindow(int windowType) {
+ SysUiWindowManager wwm = mWwms.get(windowType);
+ if (wwm == null) {
+ return null;
+ }
+ return wwm.mContainerWindow;
+ }
+
+ void updateConfiguration(Configuration configuration) {
+ for (int i = 0; i < mWwms.size(); ++i) {
+ mWwms.valueAt(i).updateConfiguration(configuration);
+ }
+ }
+ }
+
+ /**
+ * A subclass of WindowlessWindowManager that provides insets to its viewroots.
+ */
+ public class SysUiWindowManager extends WindowlessWindowManager {
+ final int mDisplayId;
+ ContainerWindow mContainerWindow;
+ public SysUiWindowManager(int displayId, Context ctx, SurfaceControl rootSurface,
+ ContainerWindow container) {
+ super(ctx.getResources().getConfiguration(), rootSurface, null /* hostInputToken */);
+ mContainerWindow = container;
+ mDisplayId = displayId;
+ }
+
+ @Override
+ public int relayout(IWindow window, int seq, WindowManager.LayoutParams attrs,
+ int requestedWidth, int requestedHeight, int viewVisibility, int flags,
+ long frameNumber, Rect outFrame, Rect outOverscanInsets, Rect outContentInsets,
+ Rect outVisibleInsets, Rect outStableInsets,
+ DisplayCutout.ParcelableWrapper cutout, MergedConfiguration mergedConfiguration,
+ SurfaceControl outSurfaceControl, InsetsState outInsetsState) {
+ int res = super.relayout(window, seq, attrs, requestedWidth, requestedHeight,
+ viewVisibility, flags, frameNumber, outFrame, outOverscanInsets,
+ outContentInsets, outVisibleInsets, outStableInsets,
+ cutout, mergedConfiguration, outSurfaceControl, outInsetsState);
+ if (res != 0) {
+ return res;
+ }
+ DisplayLayout dl = mDisplayController.getDisplayLayout(mDisplayId);
+ outStableInsets.set(dl.stableInsets());
+ return 0;
+ }
+
+ void updateConfiguration(Configuration configuration) {
+ setConfiguration(configuration);
+ }
+ }
+
+ class ContainerWindow extends IWindow.Stub {
+ ContainerWindow() {}
+
+ @Override
+ public void resized(Rect frame, Rect contentInsets, Rect visibleInsets, Rect stableInsets,
+ boolean reportDraw, MergedConfiguration newMergedConfiguration, Rect backDropFrame,
+ boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId,
+ DisplayCutout.ParcelableWrapper displayCutout) {}
+
+ @Override
+ public void locationInParentDisplayChanged(Point offset) {}
+
+ @Override
+ public void insetsChanged(InsetsState insetsState) {}
+
+ @Override
+ public void insetsControlChanged(InsetsState insetsState,
+ InsetsSourceControl[] activeControls) {}
+
+ @Override
+ public void showInsets(int types, boolean fromIme) {}
+
+ @Override
+ public void hideInsets(int types, boolean fromIme) {}
+
+ @Override
+ public void moved(int newX, int newY) {}
+
+ @Override
+ public void dispatchAppVisibility(boolean visible) {}
+
+ @Override
+ public void dispatchGetNewSurface() {}
+
+ @Override
+ public void windowFocusChanged(boolean hasFocus, boolean inTouchMode) {}
+
+ @Override
+ public void executeCommand(String command, String parameters, ParcelFileDescriptor out) {}
+
+ @Override
+ public void closeSystemDialogs(String reason) {}
+
+ @Override
+ public void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep,
+ boolean sync) {}
+
+ @Override
+ public void dispatchWallpaperCommand(String action, int x, int y,
+ int z, Bundle extras, boolean sync) {}
+
+ /* Drag/drop */
+ @Override
+ public void dispatchDragEvent(DragEvent event) {}
+
+ @Override
+ public void updatePointerIcon(float x, float y) {}
+
+ @Override
+ public void dispatchSystemUiVisibilityChanged(int seq, int globalVisibility,
+ int localValue, int localChanges) {}
+
+ @Override
+ public void dispatchWindowShown() {}
+
+ @Override
+ public void requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId) {}
+
+ @Override
+ public void dispatchPointerCaptureChanged(boolean hasCapture) {}
+ }
+}
diff --git a/packages/SystemUI/tests/Android.mk b/packages/SystemUI/tests/Android.mk
index 81e2c22..e5f56d4 100644
--- a/packages/SystemUI/tests/Android.mk
+++ b/packages/SystemUI/tests/Android.mk
@@ -32,7 +32,8 @@
LOCAL_JNI_SHARED_LIBRARIES := \
libdexmakerjvmtiagent \
- libmultiplejvmtiagentsinterferenceagent
+ libmultiplejvmtiagentsinterferenceagent \
+ libstaticjvmtiagent
LOCAL_JAVA_LIBRARIES := \
android.test.runner \
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/clock/ClockInfoTest.java b/packages/SystemUI/tests/src/com/android/keyguard/clock/ClockInfoTest.java
index d2b2654..4c0890a 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/clock/ClockInfoTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/clock/ClockInfoTest.java
@@ -57,7 +57,7 @@
@Test
public void testGetTitle() {
final String title = "title";
- ClockInfo info = ClockInfo.builder().setTitle(title).build();
+ ClockInfo info = ClockInfo.builder().setTitle(() -> title).build();
assertThat(info.getTitle()).isEqualTo(title);
}
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/clock/ClockOptionsProviderTest.java b/packages/SystemUI/tests/src/com/android/keyguard/clock/ClockOptionsProviderTest.java
index 0cd6f9a..d2832fb9 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/clock/ClockOptionsProviderTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/clock/ClockOptionsProviderTest.java
@@ -117,12 +117,12 @@
public void testQuery_listOptions() {
mClocks.add(ClockInfo.builder()
.setName("name_a")
- .setTitle("title_a")
+ .setTitle(() -> "title_a")
.setId("id_a")
.build());
mClocks.add(ClockInfo.builder()
.setName("name_b")
- .setTitle("title_b")
+ .setTitle(() -> "title_b")
.setId("id_b")
.build());
Cursor cursor = mProvider.query(mListOptionsUri, null, null, null);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthBiometricViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthBiometricViewTest.java
index df67637..25cc9a3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthBiometricViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthBiometricViewTest.java
@@ -16,6 +16,8 @@
package com.android.systemui.biometrics;
+import static android.hardware.biometrics.BiometricManager.Authenticators;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -24,7 +26,6 @@
import static org.mockito.Mockito.verify;
import android.content.Context;
-import android.hardware.biometrics.Authenticator;
import android.hardware.biometrics.BiometricPrompt;
import android.os.Bundle;
import android.test.suitebuilder.annotation.SmallTest;
@@ -292,9 +293,9 @@
private Bundle buildBiometricPromptBundle(boolean allowDeviceCredential) {
Bundle bundle = new Bundle();
bundle.putCharSequence(BiometricPrompt.KEY_TITLE, "Title");
- int authenticators = Authenticator.TYPE_BIOMETRIC;
+ int authenticators = Authenticators.BIOMETRIC_WEAK;
if (allowDeviceCredential) {
- authenticators |= Authenticator.TYPE_CREDENTIAL;
+ authenticators |= Authenticators.DEVICE_CREDENTIAL;
} else {
bundle.putCharSequence(BiometricPrompt.KEY_NEGATIVE_TEXT, "Negative");
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.java
index 6e438e8..162b16e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.java
@@ -16,6 +16,8 @@
package com.android.systemui.biometrics;
+import static android.hardware.biometrics.BiometricManager.Authenticators;
+
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -26,7 +28,6 @@
import static org.mockito.Mockito.verify;
import android.content.Context;
-import android.hardware.biometrics.Authenticator;
import android.hardware.biometrics.BiometricAuthenticator;
import android.hardware.biometrics.BiometricPrompt;
import android.os.Bundle;
@@ -64,7 +65,7 @@
@Test
public void testActionAuthenticated_sendsDismissedAuthenticated() {
- initializeContainer(Authenticator.TYPE_BIOMETRIC);
+ initializeContainer(Authenticators.BIOMETRIC_WEAK);
mAuthContainer.mBiometricCallback.onAction(
AuthBiometricView.Callback.ACTION_AUTHENTICATED);
@@ -73,7 +74,7 @@
@Test
public void testActionUserCanceled_sendsDismissedUserCanceled() {
- initializeContainer(Authenticator.TYPE_BIOMETRIC);
+ initializeContainer(Authenticators.BIOMETRIC_WEAK);
mAuthContainer.mBiometricCallback.onAction(
AuthBiometricView.Callback.ACTION_USER_CANCELED);
@@ -82,7 +83,7 @@
@Test
public void testActionButtonNegative_sendsDismissedButtonNegative() {
- initializeContainer(Authenticator.TYPE_BIOMETRIC);
+ initializeContainer(Authenticators.BIOMETRIC_WEAK);
mAuthContainer.mBiometricCallback.onAction(
AuthBiometricView.Callback.ACTION_BUTTON_NEGATIVE);
@@ -91,7 +92,7 @@
@Test
public void testActionTryAgain_sendsTryAgain() {
- initializeContainer(Authenticator.TYPE_BIOMETRIC);
+ initializeContainer(Authenticators.BIOMETRIC_WEAK);
mAuthContainer.mBiometricCallback.onAction(
AuthBiometricView.Callback.ACTION_BUTTON_TRY_AGAIN);
@@ -100,7 +101,7 @@
@Test
public void testActionError_sendsDismissedError() {
- initializeContainer(Authenticator.TYPE_BIOMETRIC);
+ initializeContainer(Authenticators.BIOMETRIC_WEAK);
mAuthContainer.mBiometricCallback.onAction(
AuthBiometricView.Callback.ACTION_ERROR);
@@ -110,7 +111,7 @@
@Test
public void testActionUseDeviceCredential_sendsOnDeviceCredentialPressed() {
initializeContainer(
- Authenticator.TYPE_BIOMETRIC | Authenticator.TYPE_CREDENTIAL);
+ Authenticators.BIOMETRIC_WEAK | Authenticators.DEVICE_CREDENTIAL);
mAuthContainer.mBiometricCallback.onAction(
AuthBiometricView.Callback.ACTION_USE_DEVICE_CREDENTIAL);
@@ -125,7 +126,7 @@
@Test
public void testAnimateToCredentialUI_invokesStartTransitionToCredentialUI() {
initializeContainer(
- Authenticator.TYPE_BIOMETRIC | Authenticator.TYPE_CREDENTIAL);
+ Authenticators.BIOMETRIC_WEAK | Authenticators.DEVICE_CREDENTIAL);
mAuthContainer.mBiometricView = mock(AuthBiometricView.class);
mAuthContainer.animateToCredentialUI();
@@ -134,7 +135,7 @@
@Test
public void testShowBiometricUI() {
- initializeContainer(Authenticator.TYPE_BIOMETRIC);
+ initializeContainer(Authenticators.BIOMETRIC_WEAK);
assertNotEquals(null, mAuthContainer.mBiometricView);
@@ -146,7 +147,7 @@
@Test
public void testShowCredentialUI_doesNotInflateBiometricUI() {
- initializeContainer(Authenticator.TYPE_CREDENTIAL);
+ initializeContainer(Authenticators.DEVICE_CREDENTIAL);
mAuthContainer.onAttachedToWindowInternal();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java
index f6375fc..c0e92e0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java
@@ -16,6 +16,8 @@
package com.android.systemui.biometrics;
+import static android.hardware.biometrics.BiometricManager.Authenticators;
+
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
import static junit.framework.TestCase.assertNotNull;
@@ -38,7 +40,6 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
-import android.hardware.biometrics.Authenticator;
import android.hardware.biometrics.BiometricAuthenticator;
import android.hardware.biometrics.BiometricConstants;
import android.hardware.biometrics.BiometricPrompt;
@@ -109,28 +110,28 @@
@Test
public void testSendsReasonUserCanceled_whenDismissedByUserCancel() throws Exception {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
mAuthController.onDismissed(AuthDialogCallback.DISMISSED_USER_CANCELED);
verify(mReceiver).onDialogDismissed(BiometricPrompt.DISMISSED_REASON_USER_CANCEL);
}
@Test
public void testSendsReasonNegative_whenDismissedByButtonNegative() throws Exception {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
mAuthController.onDismissed(AuthDialogCallback.DISMISSED_BUTTON_NEGATIVE);
verify(mReceiver).onDialogDismissed(BiometricPrompt.DISMISSED_REASON_NEGATIVE);
}
@Test
public void testSendsReasonConfirmed_whenDismissedByButtonPositive() throws Exception {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
mAuthController.onDismissed(AuthDialogCallback.DISMISSED_BUTTON_POSITIVE);
verify(mReceiver).onDialogDismissed(BiometricPrompt.DISMISSED_REASON_BIOMETRIC_CONFIRMED);
}
@Test
public void testSendsReasonConfirmNotRequired_whenDismissedByAuthenticated() throws Exception {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
mAuthController.onDismissed(AuthDialogCallback.DISMISSED_BIOMETRIC_AUTHENTICATED);
verify(mReceiver).onDialogDismissed(
BiometricPrompt.DISMISSED_REASON_BIOMETRIC_CONFIRM_NOT_REQUIRED);
@@ -138,14 +139,14 @@
@Test
public void testSendsReasonError_whenDismissedByError() throws Exception {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
mAuthController.onDismissed(AuthDialogCallback.DISMISSED_ERROR);
verify(mReceiver).onDialogDismissed(BiometricPrompt.DISMISSED_REASON_ERROR);
}
@Test
public void testSendsReasonServerRequested_whenDismissedByServer() throws Exception {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
mAuthController.onDismissed(AuthDialogCallback.DISMISSED_BY_SYSTEM_SERVER);
verify(mReceiver).onDialogDismissed(BiometricPrompt.DISMISSED_REASON_SERVER_REQUESTED);
}
@@ -153,7 +154,7 @@
@Test
public void testSendsReasonCredentialConfirmed_whenDeviceCredentialAuthenticated()
throws Exception {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
mAuthController.onDismissed(AuthDialogCallback.DISMISSED_CREDENTIAL_AUTHENTICATED);
verify(mReceiver).onDialogDismissed(BiometricPrompt.DISMISSED_REASON_CREDENTIAL_CONFIRMED);
}
@@ -163,20 +164,20 @@
@Test
public void testShowInvoked_whenSystemRequested()
throws Exception {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
verify(mDialog1).show(any(), any());
}
@Test
public void testOnAuthenticationSucceededInvoked_whenSystemRequested() {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
mAuthController.onBiometricAuthenticated();
verify(mDialog1).onAuthenticationSucceeded();
}
@Test
public void testOnAuthenticationFailedInvoked_whenBiometricRejected() {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
mAuthController.onBiometricError(BiometricAuthenticator.TYPE_NONE,
BiometricConstants.BIOMETRIC_PAUSED_REJECTED,
0 /* vendorCode */);
@@ -189,7 +190,7 @@
@Test
public void testOnAuthenticationFailedInvoked_whenBiometricTimedOut() {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
final int error = BiometricConstants.BIOMETRIC_ERROR_TIMEOUT;
final int vendorCode = 0;
mAuthController.onBiometricError(BiometricAuthenticator.TYPE_FACE, error, vendorCode);
@@ -202,7 +203,7 @@
@Test
public void testOnHelpInvoked_whenSystemRequested() {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
final String helpMessage = "help";
mAuthController.onBiometricHelp(helpMessage);
@@ -214,7 +215,7 @@
@Test
public void testOnErrorInvoked_whenSystemRequested() throws Exception {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
final int error = 1;
final int vendorCode = 0;
mAuthController.onBiometricError(BiometricAuthenticator.TYPE_FACE, error, vendorCode);
@@ -227,7 +228,7 @@
@Test
public void testErrorLockout_whenCredentialAllowed_AnimatesToCredentialUI() {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
final int error = BiometricConstants.BIOMETRIC_ERROR_LOCKOUT;
final int vendorCode = 0;
@@ -240,7 +241,7 @@
@Test
public void testErrorLockoutPermanent_whenCredentialAllowed_AnimatesToCredentialUI() {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
final int error = BiometricConstants.BIOMETRIC_ERROR_LOCKOUT_PERMANENT;
final int vendorCode = 0;
@@ -253,7 +254,7 @@
@Test
public void testErrorLockout_whenCredentialNotAllowed_sendsOnError() {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
final int error = BiometricConstants.BIOMETRIC_ERROR_LOCKOUT;
final int vendorCode = 0;
@@ -266,7 +267,7 @@
@Test
public void testErrorLockoutPermanent_whenCredentialNotAllowed_sendsOnError() {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
final int error = BiometricConstants.BIOMETRIC_ERROR_LOCKOUT_PERMANENT;
final int vendorCode = 0;
@@ -278,30 +279,24 @@
}
@Test
- public void testDismissWithoutCallbackInvoked_whenSystemRequested() {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
- mAuthController.hideAuthenticationDialog();
- verify(mDialog1).dismissFromSystemServer();
- }
-
- @Test
- public void testClientNotified_whenDismissedBySystemServer() {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ public void testHideAuthenticationDialog_invokesDismissFromSystemServer() {
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
mAuthController.hideAuthenticationDialog();
verify(mDialog1).dismissFromSystemServer();
- assertNotNull(mAuthController.mCurrentDialog);
- assertNotNull(mAuthController.mReceiver);
+ // In this case, BiometricService sends the error to the client immediately, without
+ // doing a round trip to SystemUI.
+ assertNull(mAuthController.mCurrentDialog);
}
// Corner case tests
@Test
public void testShowNewDialog_beforeOldDialogDismissed_SkipsAnimations() {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
verify(mDialog1).show(any(), any());
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
// First dialog should be dismissed without animation
verify(mDialog1).dismissWithoutCallback(eq(false) /* animate */);
@@ -312,7 +307,7 @@
@Test
public void testConfigurationPersists_whenOnConfigurationChanged() {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
verify(mDialog1).show(any(), any());
// Return that the UI is in "showing" state
@@ -342,7 +337,7 @@
@Test
public void testConfigurationPersists_whenBiometricFallbackToCredential() {
- showDialog(Authenticator.TYPE_CREDENTIAL | Authenticator.TYPE_BIOMETRIC,
+ showDialog(Authenticators.DEVICE_CREDENTIAL | Authenticators.BIOMETRIC_WEAK,
BiometricPrompt.TYPE_FACE);
verify(mDialog1).show(any(), any());
@@ -361,14 +356,14 @@
// Check that the new dialog was initialized to the credential UI.
ArgumentCaptor<Bundle> captor = ArgumentCaptor.forClass(Bundle.class);
verify(mDialog2).show(any(), captor.capture());
- assertEquals(Authenticator.TYPE_CREDENTIAL,
+ assertEquals(Authenticators.DEVICE_CREDENTIAL,
mAuthController.mLastBiometricPromptBundle
.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED));
}
@Test
public void testClientNotified_whenTaskStackChangesDuringAuthentication() throws Exception {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
List<ActivityManager.RunningTaskInfo> tasks = new ArrayList<>();
ActivityManager.RunningTaskInfo taskInfo = mock(ActivityManager.RunningTaskInfo.class);
@@ -388,21 +383,21 @@
@Test
public void testDoesNotCrash_whenTryAgainPressedAfterDismissal() {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
mAuthController.onDismissed(AuthDialogCallback.DISMISSED_USER_CANCELED);
mAuthController.onTryAgainPressed();
}
@Test
public void testDoesNotCrash_whenDeviceCredentialPressedAfterDismissal() {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
mAuthController.onDismissed(AuthDialogCallback.DISMISSED_USER_CANCELED);
mAuthController.onDeviceCredentialPressed();
}
@Test
public void testActionCloseSystemDialogs_dismissesDialogIfShowing() throws Exception {
- showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
+ showDialog(Authenticators.BIOMETRIC_WEAK, BiometricPrompt.TYPE_FACE);
Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
mAuthController.mBroadcastReceiver.onReceive(mContext, intent);
waitForIdleSync();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
index 2ccecec..2bf855a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
@@ -261,7 +261,7 @@
@Test
public void testRemoveBubble_withDismissedNotif() {
- mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mEntryListener.onNotificationAdded(mRow.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
assertTrue(mBubbleController.hasBubbles());
@@ -304,7 +304,7 @@
assertFalse(mBubbleController.isStackExpanded());
// Mark it as a bubble and add it explicitly
- mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mEntryListener.onNotificationAdded(mRow.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
// We should have bubbles & their notifs should not be suppressed
@@ -334,8 +334,8 @@
@Test
public void testCollapseAfterChangingExpandedBubble() {
// Mark it as a bubble and add it explicitly
- mEntryListener.onPendingEntryAdded(mRow.getEntry());
- mEntryListener.onPendingEntryAdded(mRow2.getEntry());
+ mEntryListener.onNotificationAdded(mRow.getEntry());
+ mEntryListener.onNotificationAdded(mRow2.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
mBubbleController.updateBubble(mRow2.getEntry());
@@ -377,7 +377,7 @@
@Test
public void testExpansionRemovesShowInShadeAndDot() {
// Mark it as a bubble and add it explicitly
- mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mEntryListener.onNotificationAdded(mRow.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
// We should have bubbles & their notifs should not be suppressed
@@ -403,7 +403,7 @@
@Test
public void testUpdateWhileExpanded_DoesntChangeShowInShadeAndDot() {
// Mark it as a bubble and add it explicitly
- mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mEntryListener.onNotificationAdded(mRow.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
// We should have bubbles & their notifs should not be suppressed
@@ -439,8 +439,8 @@
@Test
public void testRemoveLastExpandedCollapses() {
// Mark it as a bubble and add it explicitly
- mEntryListener.onPendingEntryAdded(mRow.getEntry());
- mEntryListener.onPendingEntryAdded(mRow2.getEntry());
+ mEntryListener.onNotificationAdded(mRow.getEntry());
+ mEntryListener.onNotificationAdded(mRow2.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
mBubbleController.updateBubble(mRow2.getEntry());
verify(mBubbleStateChangeListener).onHasBubblesChanged(true);
@@ -483,7 +483,7 @@
Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE, false /* enableFlag */);
// Add the auto expand bubble
- mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mEntryListener.onNotificationAdded(mRow.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
// Expansion shouldn't change
@@ -501,7 +501,7 @@
Notification.BubbleMetadata.FLAG_AUTO_EXPAND_BUBBLE, true /* enableFlag */);
// Add the auto expand bubble
- mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mEntryListener.onNotificationAdded(mRow.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
// Expansion should change
@@ -519,7 +519,7 @@
Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION, true /* enableFlag */);
// Add the suppress notif bubble
- mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mEntryListener.onNotificationAdded(mRow.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
// Notif should be suppressed because we were foreground
@@ -564,7 +564,7 @@
public void testExpandStackAndSelectBubble_removedFirst() {
final String key = mRow.getEntry().getKey();
- mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mEntryListener.onNotificationAdded(mRow.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
// Simulate notification cancellation.
@@ -576,7 +576,7 @@
@Test
public void testMarkNewNotificationAsShowInShade() {
- mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mEntryListener.onNotificationAdded(mRow.getEntry());
assertFalse(mBubbleController.isBubbleNotificationSuppressedFromShade(
mRow.getEntry().getKey()));
@@ -586,7 +586,7 @@
@Test
public void testAddNotif_notBubble() {
- mEntryListener.onPendingEntryAdded(mNonBubbleNotifRow.getEntry());
+ mEntryListener.onNotificationAdded(mNonBubbleNotifRow.getEntry());
mEntryListener.onPreEntryUpdated(mNonBubbleNotifRow.getEntry());
verify(mBubbleStateChangeListener, never()).onHasBubblesChanged(anyBoolean());
@@ -631,7 +631,7 @@
@Test
public void testRemoveBubble_succeeds_appCancel() {
- mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mEntryListener.onNotificationAdded(mRow.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
assertTrue(mBubbleController.hasBubbles());
@@ -646,7 +646,7 @@
@Test
public void removeBubble_fails_clearAll() {
- mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mEntryListener.onNotificationAdded(mRow.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
assertTrue(mBubbleController.hasBubbles());
@@ -669,7 +669,7 @@
@Test
public void removeBubble_fails_userDismissNotif() {
- mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mEntryListener.onNotificationAdded(mRow.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
assertTrue(mBubbleController.hasBubbles());
@@ -692,7 +692,7 @@
@Test
public void removeBubble_succeeds_userDismissBubble_userDimissNotif() {
- mEntryListener.onPendingEntryAdded(mRow.getEntry());
+ mEntryListener.onNotificationAdded(mRow.getEntry());
mBubbleController.updateBubble(mRow.getEntry());
assertTrue(mBubbleController.hasBubbles());
diff --git a/packages/SystemUI/tests/src/com/android/systemui/log/RichEventTest.java b/packages/SystemUI/tests/src/com/android/systemui/log/RichEventTest.java
index 2f90641..4a90bb9 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/log/RichEventTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/log/RichEventTest.java
@@ -57,7 +57,7 @@
class TestableRichEvent extends RichEvent {
TestableRichEvent(int logLevel, int type, String reason) {
- super(logLevel, type, reason);
+ init(logLevel, type, reason);
}
@Override
diff --git a/packages/SystemUI/tests/src/com/android/systemui/log/SysuiLogTest.java b/packages/SystemUI/tests/src/com/android/systemui/log/SysuiLogTest.java
index 1e8ebea..e7b317e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/log/SysuiLogTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/log/SysuiLogTest.java
@@ -35,11 +35,12 @@
@RunWith(AndroidTestingRunner.class)
public class SysuiLogTest extends SysuiTestCase {
private static final String TEST_ID = "TestLogger";
+ private static final String TEST_MSG = "msg";
private static final int MAX_LOGS = 5;
@Mock
private DumpController mDumpController;
- private SysuiLog mSysuiLog;
+ private SysuiLog<Event> mSysuiLog;
@Before
public void setup() {
@@ -48,35 +49,63 @@
@Test
public void testLogDisabled_noLogsWritten() {
- mSysuiLog = new SysuiLog(mDumpController, TEST_ID, MAX_LOGS, false, false);
- assertEquals(mSysuiLog.mTimeline, null);
+ mSysuiLog = new TestSysuiLog(mDumpController, TEST_ID, MAX_LOGS, false);
+ assertEquals(null, mSysuiLog.mTimeline);
- mSysuiLog.log(new Event("msg"));
- assertEquals(mSysuiLog.mTimeline, null);
+ mSysuiLog.log(createEvent(TEST_MSG));
+ assertEquals(null, mSysuiLog.mTimeline);
}
@Test
public void testLogEnabled_logWritten() {
- mSysuiLog = new SysuiLog(mDumpController, TEST_ID, MAX_LOGS, true, false);
- assertEquals(mSysuiLog.mTimeline.size(), 0);
+ mSysuiLog = new TestSysuiLog(mDumpController, TEST_ID, MAX_LOGS, true);
+ assertEquals(0, mSysuiLog.mTimeline.size());
- mSysuiLog.log(new Event("msg"));
- assertEquals(mSysuiLog.mTimeline.size(), 1);
+ mSysuiLog.log(createEvent(TEST_MSG));
+ assertEquals(1, mSysuiLog.mTimeline.size());
}
@Test
public void testMaxLogs() {
- mSysuiLog = new SysuiLog(mDumpController, TEST_ID, MAX_LOGS, true, false);
+ mSysuiLog = new TestSysuiLog(mDumpController, TEST_ID, MAX_LOGS, true);
assertEquals(mSysuiLog.mTimeline.size(), 0);
- final String msg = "msg";
for (int i = 0; i < MAX_LOGS + 1; i++) {
- mSysuiLog.log(new Event(msg + i));
+ mSysuiLog.log(createEvent(TEST_MSG + i));
}
- assertEquals(mSysuiLog.mTimeline.size(), MAX_LOGS);
+ assertEquals(MAX_LOGS, mSysuiLog.mTimeline.size());
- // check the first message (msg0) is deleted:
- assertEquals(mSysuiLog.mTimeline.getFirst().getMessage(), msg + "1");
+ // check the first message (msg0) was replaced with msg1:
+ assertEquals(TEST_MSG + "1", mSysuiLog.mTimeline.getFirst().getMessage());
+ }
+
+ @Test
+ public void testRecycleLogs() {
+ // GIVEN a SysuiLog with one log
+ mSysuiLog = new TestSysuiLog(mDumpController, TEST_ID, MAX_LOGS, true);
+ Event e = createEvent(TEST_MSG); // msg
+ mSysuiLog.log(e); // Logs: [msg]
+
+ Event recycledEvent = null;
+ // WHEN we add MAX_LOGS after the first log
+ for (int i = 0; i < MAX_LOGS; i++) {
+ recycledEvent = mSysuiLog.log(createEvent(TEST_MSG + i));
+ }
+ // Logs: [msg1, msg2, msg3, msg4]
+
+ // THEN we see the recycledEvent is e
+ assertEquals(e, recycledEvent);
+ }
+
+ private Event createEvent(String msg) {
+ return new Event().init(msg);
+ }
+
+ public class TestSysuiLog extends SysuiLog<Event> {
+ protected TestSysuiLog(DumpController dumpController, String id, int maxLogs,
+ boolean enabled) {
+ super(dumpController, id, maxLogs, enabled, false);
+ }
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java
index 192d8f8..49b47c5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java
@@ -188,6 +188,16 @@
verify(mTile).handleSetListening(eq(false));
}
+ @Test
+ public void testHandleDestroyClearsHandlerQueue() {
+ when(mTile.getStaleTimeout()).thenReturn(0L);
+ mTile.handleRefreshState(null); // this will add a delayed H.STALE message
+ mTile.handleDestroy();
+
+ mTestableLooper.processAllMessages();
+ verify(mTile, never()).handleStale();
+ }
+
private class TileLogMatcher implements ArgumentMatcher<LogMaker> {
private final int mCategory;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java
index ba7b2e2..cef210c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationLockscreenUserManagerTest.java
@@ -26,12 +26,14 @@
import static junit.framework.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.ActivityManager;
import android.app.KeyguardManager;
+import android.app.Notification;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -198,11 +200,13 @@
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 0);
+ final Notification notification = mock(Notification.class);
+ when(notification.isForegroundService()).thenReturn(true);
NotificationEntry entry = new NotificationEntryBuilder()
.setImportance(IMPORTANCE_LOW)
+ .setNotification(notification)
.build();
entry.setBucket(BUCKET_SILENT);
- entry.setIsHighPriority(true);
assertFalse(mLockscreenUserManager.shouldShowOnKeyguard(entry));
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java
index d003b99..5310dd8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java
@@ -76,6 +76,7 @@
mSmartActions = copyList(ranking.getSmartActions());
mSmartReplies = copyList(ranking.getSmartReplies());
mCanBubble = ranking.canBubble();
+ mIsVisuallyInterruptive = ranking.visuallyInterruptive();
}
public Ranking build() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/GroupEntryTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/GroupEntryTest.java
new file mode 100644
index 0000000..721bbdc
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/GroupEntryTest.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2019 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 com.android.systemui.statusbar.notification.collection;
+
+import static android.app.NotificationManager.IMPORTANCE_HIGH;
+import static android.app.NotificationManager.IMPORTANCE_MIN;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import android.testing.AndroidTestingRunner;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.systemui.SysuiTestCase;
+import com.android.systemui.statusbar.NotificationEntryBuilder;
+import com.android.systemui.statusbar.RankingBuilder;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@SmallTest
+@RunWith(AndroidTestingRunner.class)
+public class GroupEntryTest extends SysuiTestCase {
+ @Test
+ public void testIsHighPriority_addChild() {
+ // GIVEN a GroupEntry with a lowPrioritySummary and no children
+ final GroupEntry parentEntry = new GroupEntry("test_group_key");
+ final NotificationEntry lowPrioritySummary = createNotifEntry(false);
+ setSummary(parentEntry, lowPrioritySummary);
+ assertFalse(parentEntry.isHighPriority());
+
+ // WHEN we add a high priority child and invalidate derived members
+ addChild(parentEntry, createNotifEntry(true));
+ parentEntry.invalidateDerivedMembers();
+
+ // THEN the GroupEntry's priority is updated to high even though the summary is still low
+ // priority
+ assertTrue(parentEntry.isHighPriority());
+ assertFalse(lowPrioritySummary.isHighPriority());
+ }
+
+ @Test
+ public void testIsHighPriority_clearChildren() {
+ // GIVEN a GroupEntry with a lowPrioritySummary and high priority children
+ final GroupEntry parentEntry = new GroupEntry("test_group_key");
+ setSummary(parentEntry, createNotifEntry(false));
+ addChild(parentEntry, createNotifEntry(true));
+ addChild(parentEntry, createNotifEntry(true));
+ addChild(parentEntry, createNotifEntry(true));
+ assertTrue(parentEntry.isHighPriority());
+
+ // WHEN we clear the children and invalidate derived members
+ parentEntry.clearChildren();
+ parentEntry.invalidateDerivedMembers();
+
+ // THEN the parentEntry isn't high priority anymore
+ assertFalse(parentEntry.isHighPriority());
+ }
+
+ @Test
+ public void testIsHighPriority_summaryUpdated() {
+ // GIVEN a GroupEntry with a lowPrioritySummary and no children
+ final GroupEntry parentEntry = new GroupEntry("test_group_key");
+ final NotificationEntry lowPrioritySummary = createNotifEntry(false);
+ setSummary(parentEntry, lowPrioritySummary);
+ assertFalse(parentEntry.isHighPriority());
+
+ // WHEN the summary changes to high priority and invalidates its derived members
+ lowPrioritySummary.setRanking(
+ new RankingBuilder()
+ .setKey(lowPrioritySummary.getKey())
+ .setImportance(IMPORTANCE_HIGH)
+ .build());
+ lowPrioritySummary.invalidateDerivedMembers();
+ assertTrue(lowPrioritySummary.isHighPriority());
+
+ // THEN the GroupEntry's priority is updated to high
+ assertTrue(parentEntry.isHighPriority());
+ }
+
+ @Test
+ public void testIsHighPriority_checkChildrenToCalculatePriority() {
+ // GIVEN:
+ // GroupEntry = parentEntry, summary = lowPrioritySummary
+ // NotificationEntry = lowPriorityChild
+ // NotificationEntry = highPriorityChild
+ final GroupEntry parentEntry = new GroupEntry("test_group_key");
+ setSummary(parentEntry, createNotifEntry(false));
+ addChild(parentEntry, createNotifEntry(false));
+ addChild(parentEntry, createNotifEntry(true));
+
+ // THEN the GroupEntry parentEntry is high priority since it has a high priority child
+ assertTrue(parentEntry.isHighPriority());
+ }
+
+ @Test
+ public void testIsHighPriority_childEntryRankingUpdated() {
+ // GIVEN:
+ // GroupEntry = parentEntry, summary = lowPrioritySummary
+ // NotificationEntry = lowPriorityChild
+ final GroupEntry parentEntry = new GroupEntry("test_group_key");
+ final NotificationEntry lowPriorityChild = createNotifEntry(false);
+ setSummary(parentEntry, createNotifEntry(false));
+ addChild(parentEntry, lowPriorityChild);
+
+ // WHEN the child entry ranking changes to high priority and invalidates its derived members
+ lowPriorityChild.setRanking(
+ new RankingBuilder()
+ .setKey(lowPriorityChild.getKey())
+ .setImportance(IMPORTANCE_HIGH)
+ .build());
+ lowPriorityChild.invalidateDerivedMembers();
+
+ // THEN the parent entry's high priority value is updated - but not the parent's summary
+ assertTrue(parentEntry.isHighPriority());
+ assertFalse(parentEntry.getSummary().isHighPriority());
+ }
+
+ private NotificationEntry createNotifEntry(boolean highPriority) {
+ return new NotificationEntryBuilder()
+ .setImportance(highPriority ? IMPORTANCE_HIGH : IMPORTANCE_MIN)
+ .build();
+ }
+
+ private void setSummary(GroupEntry parent, NotificationEntry summary) {
+ parent.setSummary(summary);
+ summary.setParent(parent);
+ }
+
+ private void addChild(GroupEntry parent, NotificationEntry child) {
+ parent.addChild(child);
+ child.setParent(parent);
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImplTest.java
index ffaea15..bbabb11 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifListBuilderImplTest.java
@@ -47,6 +47,7 @@
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.SectionsProvider;
+import com.android.systemui.statusbar.notification.logging.NotifLog;
import com.android.systemui.util.Assert;
import com.android.systemui.util.time.FakeSystemClock;
@@ -76,6 +77,7 @@
private NotifListBuilderImpl mListBuilder;
private FakeSystemClock mSystemClock = new FakeSystemClock();
+ @Mock private NotifLog mNotifLog;
@Mock private NotifCollection mNotifCollection;
@Spy private OnBeforeTransformGroupsListener mOnBeforeTransformGroupsListener;
@Spy private OnBeforeSortListener mOnBeforeSortListener;
@@ -97,7 +99,7 @@
MockitoAnnotations.initMocks(this);
Assert.sMainLooper = TestableLooper.get(this).getLooper();
- mListBuilder = new NotifListBuilderImpl(mSystemClock);
+ mListBuilder = new NotifListBuilderImpl(mSystemClock, mNotifLog);
mListBuilder.setOnRenderListListener(mOnRenderListListener);
mListBuilder.attach(mNotifCollection);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryTest.java
index 536aeb4..17d556d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationEntryTest.java
@@ -21,6 +21,8 @@
import static android.app.Notification.CATEGORY_EVENT;
import static android.app.Notification.CATEGORY_MESSAGE;
import static android.app.Notification.CATEGORY_REMINDER;
+import static android.app.NotificationManager.IMPORTANCE_HIGH;
+import static android.app.NotificationManager.IMPORTANCE_MIN;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT;
import static com.android.systemui.statusbar.NotificationEntryHelper.modifyRanking;
@@ -91,6 +93,44 @@
}
@Test
+ public void testIsHighPriority_notificationUpdates() {
+ // GIVEN a notification with high importance
+ final NotificationEntry entryHigh = new NotificationEntryBuilder()
+ .setImportance(IMPORTANCE_HIGH)
+ .build();
+
+ // WHEN we get the value for the high priority entry, we're caching the high priority value
+ assertTrue(entryHigh.isHighPriority());
+
+ // WHEN we change the ranking and derived members (high priority) are invalidated
+ entryHigh.setRanking(
+ new RankingBuilder()
+ .setKey(entryHigh.getKey())
+ .setImportance(IMPORTANCE_MIN)
+ .build());
+ entryHigh.invalidateDerivedMembers();
+
+ // THEN the priority is recalculated and is now low
+ assertFalse(entryHigh.isHighPriority());
+
+ // WHEN the sbn is updated to have messaging style (high priority characteristic)
+ // AND the entry invalidates its derived members
+ final Notification notification =
+ new Notification.Builder(mContext, "test")
+ .setStyle(new Notification.MessagingStyle(""))
+ .build();
+ final StatusBarNotification sbn = entryHigh.getSbn();
+ entryHigh.setSbn(new StatusBarNotification(
+ sbn.getPackageName(), sbn.getPackageName(),
+ sbn.getId(), sbn.getTag(), sbn.getUid(), sbn.getInitialPid(),
+ notification, sbn.getUser(), sbn.getOverrideGroupKey(), 0));
+ entryHigh.invalidateDerivedMembers();
+
+ // THEN the priority is recalculated and is now high
+ assertTrue(entryHigh.isHighPriority());
+ }
+
+ @Test
public void testIsExemptFromDndVisualSuppression_foreground() {
mEntry.getSbn().getNotification().flags = Notification.FLAG_FOREGROUND_SERVICE;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationRankingManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationRankingManagerTest.kt
index cda1538e..1764bef 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationRankingManagerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotificationRankingManagerTest.kt
@@ -17,17 +17,12 @@
package com.android.systemui.statusbar.notification.collection
import android.app.Notification
-import android.app.NotificationChannel
import android.app.NotificationManager.IMPORTANCE_DEFAULT
+import android.app.NotificationManager.IMPORTANCE_HIGH
import android.app.NotificationManager.IMPORTANCE_LOW
import android.service.notification.NotificationListenerService.RankingMap
-import android.service.notification.StatusBarNotification
import android.testing.AndroidTestingRunner
-
-import org.junit.runner.RunWith
-
import androidx.test.filters.SmallTest
-
import com.android.systemui.SysuiTestCase
import com.android.systemui.statusbar.NotificationEntryBuilder
import com.android.systemui.statusbar.NotificationEntryHelper.modifyRanking
@@ -42,12 +37,9 @@
import com.android.systemui.statusbar.policy.HeadsUpManager
import dagger.Lazy
import junit.framework.Assert.assertEquals
-import junit.framework.Assert.assertFalse
-import junit.framework.Assert.assertTrue
-
import org.junit.Before
import org.junit.Test
-import org.mockito.Mockito.`when`
+import org.junit.runner.RunWith
import org.mockito.Mockito.mock
@SmallTest
@@ -76,106 +68,34 @@
}
@Test
- fun testPeopleNotification_isHighPriority() {
- val notification = Notification.Builder(mContext, "test")
- .build()
-
- val sbn = StatusBarNotification("pkg", "pkg", 0, "tag", 0, 0,
- notification, mContext.user, "", 0)
-
- `when`(personNotificationIdentifier.isPeopleNotification(sbn)).thenReturn(true)
-
- val e = NotificationEntryBuilder()
- .setNotification(notification)
- .setSbn(sbn)
- .build()
-
- assertTrue(rankingManager.isHighPriority2(e))
- }
-
- @Test
- fun lowForegroundHighPriority() {
- val notification = mock(Notification::class.java)
- `when`(notification.isForegroundService).thenReturn(true)
-
- val sbn = StatusBarNotification("pkg", "pkg", 0, "tag", 0, 0,
- notification, mContext.user, "", 0)
-
- val e = NotificationEntryBuilder()
- .setNotification(notification)
- .setSbn(sbn)
- .build()
-
- modifyRanking(e)
- .setImportance(IMPORTANCE_LOW)
- .build()
-
- assertTrue(rankingManager.isHighPriority2(e))
- }
-
- @Test
- fun userChangeTrumpsHighPriorityCharacteristics() {
- val notification = Notification.Builder(mContext, "test")
- .setStyle(Notification.MessagingStyle(""))
- .setFlag(Notification.FLAG_FOREGROUND_SERVICE, true)
- .build()
-
- val sbn = StatusBarNotification("pkg", "pkg", 0, "tag", 0, 0,
- notification, mContext.user, "", 0)
-
- `when`(personNotificationIdentifier.isPeopleNotification(sbn)).thenReturn(true)
-
- val channel = NotificationChannel("a", "a", IMPORTANCE_LOW)
- channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE)
-
- val e = NotificationEntryBuilder()
- .setSbn(sbn)
- .setChannel(channel)
- .build()
-
- assertFalse(rankingManager.isHighPriority2(e))
- }
-
- @Test
fun testSort_highPriorityTrumpsNMSRank() {
// NMS rank says A and then B. But A is not high priority and B is, so B should sort in
// front
- val aN = Notification.Builder(mContext, "test")
- .setStyle(Notification.MessagingStyle(""))
- .build()
val a = NotificationEntryBuilder()
+ .setImportance(IMPORTANCE_LOW) // low priority
+ .setRank(1) // NMS says rank first
.setPkg("pkg")
.setOpPkg("pkg")
.setTag("tag")
- .setNotification(aN)
+ .setNotification(
+ Notification.Builder(mContext, "test")
+ .build())
.setUser(mContext.getUser())
.setOverrideGroupKey("")
.build()
- a.setIsHighPriority(false)
-
- modifyRanking(a)
- .setImportance(IMPORTANCE_LOW)
- .setRank(1)
- .build()
-
- val bN = Notification.Builder(mContext, "test")
- .setStyle(Notification.MessagingStyle(""))
- .build()
val b = NotificationEntryBuilder()
+ .setImportance(IMPORTANCE_HIGH) // high priority
+ .setRank(2) // NMS says rank second
.setPkg("pkg2")
.setOpPkg("pkg2")
.setTag("tag")
- .setNotification(bN)
+ .setNotification(
+ Notification.Builder(mContext, "test")
+ .build())
.setUser(mContext.getUser())
.setOverrideGroupKey("")
.build()
- b.setIsHighPriority(true)
-
- modifyRanking(b)
- .setImportance(IMPORTANCE_LOW)
- .setRank(2)
- .build()
assertEquals(
listOf(b, a),
@@ -189,6 +109,8 @@
.setStyle(Notification.MessagingStyle(""))
.build()
val a = NotificationEntryBuilder()
+ .setRank(1)
+ .setImportance(IMPORTANCE_HIGH)
.setPkg("pkg")
.setOpPkg("pkg")
.setTag("tag")
@@ -196,17 +118,13 @@
.setUser(mContext.getUser())
.setOverrideGroupKey("")
.build()
- a.setIsHighPriority(false)
-
- modifyRanking(a)
- .setImportance(IMPORTANCE_LOW)
- .setRank(1)
- .build()
val bN = Notification.Builder(mContext, "test")
.setStyle(Notification.MessagingStyle(""))
.build()
val b = NotificationEntryBuilder()
+ .setRank(2)
+ .setImportance(IMPORTANCE_HIGH)
.setPkg("pkg2")
.setOpPkg("pkg2")
.setTag("tag")
@@ -214,12 +132,6 @@
.setUser(mContext.getUser())
.setOverrideGroupKey("")
.build()
- b.setIsHighPriority(false)
-
- modifyRanking(b)
- .setImportance(IMPORTANCE_LOW)
- .setRank(2)
- .build()
assertEquals(
listOf(a, b),
@@ -239,7 +151,7 @@
.setOverrideGroupKey("")
.build()
- modifyRanking(e).setImportance(IMPORTANCE_DEFAULT) .build()
+ modifyRanking(e).setImportance(IMPORTANCE_DEFAULT).build()
rankingManager.updateRanking(RankingMap(arrayOf(e.ranking)), listOf(e), "test")
assertEquals(e.bucket, BUCKET_ALERTING)
@@ -281,11 +193,6 @@
sectionsFeatureManager,
peopleNotificationIdentifier
) {
-
- fun isHighPriority2(e: NotificationEntry): Boolean {
- return isHighPriority(e)
- }
-
fun applyTestRankingMap(r: RankingMap) {
rankingMap = r
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/DeviceProvisionedCoordinatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/DeviceProvisionedCoordinatorTest.java
new file mode 100644
index 0000000..a9413c7
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/DeviceProvisionedCoordinatorTest.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2019 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 com.android.systemui.statusbar.notification.collection.coordinator;
+
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.Manifest;
+import android.app.ActivityManagerInternal;
+import android.app.Notification;
+import android.content.pm.IPackageManager;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.os.RemoteException;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import com.android.systemui.SysuiTestCase;
+import com.android.systemui.statusbar.NotificationEntryBuilder;
+import com.android.systemui.statusbar.RankingBuilder;
+import com.android.systemui.statusbar.notification.collection.NotifListBuilderImpl;
+import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
+import com.android.systemui.statusbar.policy.DeviceProvisionedController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoSession;
+
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class DeviceProvisionedCoordinatorTest extends SysuiTestCase {
+ private static final int NOTIF_UID = 0;
+
+ private static final String SHOW_WHEN_UNPROVISIONED_FLAG =
+ Notification.EXTRA_ALLOW_DURING_SETUP;
+ private static final String SETUP_NOTIF_PERMISSION =
+ Manifest.permission.NOTIFICATION_DURING_SETUP;
+
+ private MockitoSession mMockitoSession;
+
+ @Mock private ActivityManagerInternal mActivityMangerInternal;
+ @Mock private IPackageManager mIPackageManager;
+ @Mock private DeviceProvisionedController mDeviceProvisionedController;
+ @Mock private NotifListBuilderImpl mNotifListBuilder;
+ private Notification mNotification;
+ private NotificationEntry mEntry;
+ private DeviceProvisionedCoordinator mDeviceProvisionedCoordinator;
+ private NotifFilter mDeviceProvisionedFilter;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mDeviceProvisionedCoordinator = new DeviceProvisionedCoordinator(
+ mDeviceProvisionedController, mIPackageManager);
+
+ mNotification = new Notification();
+ mEntry = new NotificationEntryBuilder()
+ .setNotification(mNotification)
+ .setUid(NOTIF_UID)
+ .build();
+
+ ArgumentCaptor<NotifFilter> filterCaptor = ArgumentCaptor.forClass(NotifFilter.class);
+ mDeviceProvisionedCoordinator.attach(null, mNotifListBuilder);
+ verify(mNotifListBuilder, times(1)).addFilter(filterCaptor.capture());
+ mDeviceProvisionedFilter = filterCaptor.getValue();
+ }
+
+ @Test
+ public void deviceProvisioned() {
+ // GIVEN device is provisioned
+ when(mDeviceProvisionedController.isDeviceProvisioned()).thenReturn(true);
+
+ // THEN don't filter out the notification
+ assertFalse(mDeviceProvisionedFilter.shouldFilterOut(mEntry, 0));
+ }
+
+ @Test
+ public void deviceUnprovisioned() {
+ // GIVEN device is unprovisioned
+ when(mDeviceProvisionedController.isDeviceProvisioned()).thenReturn(false);
+
+ // THEN filter out the notification
+ assertTrue(mDeviceProvisionedFilter.shouldFilterOut(mEntry, 0));
+ }
+
+ @Test
+ public void deviceUnprovisionedCanBypass() throws RemoteException {
+ // GIVEN device is unprovisioned
+ when(mDeviceProvisionedController.isDeviceProvisioned()).thenReturn(false);
+
+ // GIVEN notification has a flag to allow the notification during setup
+ Bundle extras = new Bundle();
+ extras.putBoolean(SHOW_WHEN_UNPROVISIONED_FLAG, true);
+ mNotification.extras = extras;
+
+ // GIVEN notification has the permission to display during setup
+ when(mIPackageManager.checkUidPermission(SETUP_NOTIF_PERMISSION, NOTIF_UID))
+ .thenReturn(PackageManager.PERMISSION_GRANTED);
+
+ // THEN don't filter out the notification
+ assertFalse(mDeviceProvisionedFilter.shouldFilterOut(mEntry, 0));
+ }
+
+ @Test
+ public void deviceUnprovisionedTryBypassWithoutPermission() throws RemoteException {
+ // GIVEN device is unprovisioned
+ when(mDeviceProvisionedController.isDeviceProvisioned()).thenReturn(false);
+
+ // GIVEN notification has a flag to allow the notification during setup
+ Bundle extras = new Bundle();
+ extras.putBoolean(SHOW_WHEN_UNPROVISIONED_FLAG, true);
+ mNotification.extras = extras;
+
+ // GIVEN notification does NOT have permission to display during setup
+ when(mIPackageManager.checkUidPermission(SETUP_NOTIF_PERMISSION, NOTIF_UID))
+ .thenReturn(PackageManager.PERMISSION_DENIED);
+
+ // THEN filter out the notification
+ assertTrue(mDeviceProvisionedFilter.shouldFilterOut(mEntry, 0));
+ }
+
+ private RankingBuilder getRankingForUnfilteredNotif() {
+ return new RankingBuilder()
+ .setKey(mEntry.getKey())
+ .setSuppressedVisualEffects(0)
+ .setSuspended(false);
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/ForegroundCoordinatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/ForegroundCoordinatorTest.java
new file mode 100644
index 0000000..ffaa335
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/ForegroundCoordinatorTest.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2019 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 com.android.systemui.statusbar.notification.collection.coordinator;
+
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.Notification;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.UserHandle;
+import android.service.notification.NotificationListenerService;
+import android.service.notification.StatusBarNotification;
+import android.testing.AndroidTestingRunner;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.systemui.ForegroundServiceController;
+import com.android.systemui.SysuiTestCase;
+import com.android.systemui.appops.AppOpsController;
+import com.android.systemui.statusbar.NotificationEntryBuilder;
+import com.android.systemui.statusbar.notification.collection.NotifCollection;
+import com.android.systemui.statusbar.notification.collection.NotifLifetimeExtender;
+import com.android.systemui.statusbar.notification.collection.NotifListBuilderImpl;
+import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+@SmallTest
+@RunWith(AndroidTestingRunner.class)
+public class ForegroundCoordinatorTest extends SysuiTestCase {
+ private static final String TEST_PKG = "test_pkg";
+ private static final int NOTIF_USER_ID = 0;
+
+ @Mock private Handler mMainHandler;
+ @Mock private ForegroundServiceController mForegroundServiceController;
+ @Mock private AppOpsController mAppOpsController;
+ @Mock private NotifListBuilderImpl mNotifListBuilder;
+ @Mock private NotifCollection mNotifCollection;
+
+ private NotificationEntry mEntry;
+ private Notification mNotification;
+ private ForegroundCoordinator mForegroundCoordinator;
+ private NotifFilter mForegroundFilter;
+ private NotifLifetimeExtender mForegroundNotifLifetimeExtender;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mForegroundCoordinator = new ForegroundCoordinator(
+ mForegroundServiceController, mAppOpsController, mMainHandler);
+
+ mNotification = new Notification();
+ mEntry = new NotificationEntryBuilder()
+ .setUser(new UserHandle(NOTIF_USER_ID))
+ .setNotification(mNotification)
+ .build();
+
+ ArgumentCaptor<NotifFilter> filterCaptor = ArgumentCaptor.forClass(NotifFilter.class);
+ ArgumentCaptor<NotifLifetimeExtender> lifetimeExtenderCaptor =
+ ArgumentCaptor.forClass(NotifLifetimeExtender.class);
+
+ mForegroundCoordinator.attach(mNotifCollection, mNotifListBuilder);
+ verify(mNotifListBuilder, times(1)).addFilter(filterCaptor.capture());
+ verify(mNotifCollection, times(1)).addNotificationLifetimeExtender(
+ lifetimeExtenderCaptor.capture());
+
+ mForegroundFilter = filterCaptor.getValue();
+ mForegroundNotifLifetimeExtender = lifetimeExtenderCaptor.getValue();
+ }
+
+ @Test
+ public void filterTest_disclosureUnnecessary() {
+ StatusBarNotification sbn = mEntry.getSbn();
+
+ // GIVEN the notification is a disclosure notification
+ when(mForegroundServiceController.isDisclosureNotification(sbn)).thenReturn(true);
+
+ // GIVEN the disclosure isn't needed for this user
+ when(mForegroundServiceController.isDisclosureNeededForUser(sbn.getUserId()))
+ .thenReturn(false);
+
+ // THEN filter out the notification
+ assertTrue(mForegroundFilter.shouldFilterOut(mEntry, 0));
+ }
+
+ @Test
+ public void filterTest_systemAlertNotificationUnnecessary() {
+ StatusBarNotification sbn = mEntry.getSbn();
+
+ // GIVEN the notification is a system alert notification + not a disclosure notification
+ when(mForegroundServiceController.isSystemAlertNotification(sbn)).thenReturn(true);
+ when(mForegroundServiceController.isDisclosureNotification(sbn)).thenReturn(false);
+
+ // GIVEN the alert notification isn't needed for this user
+ final Bundle extras = new Bundle();
+ extras.putStringArray(Notification.EXTRA_FOREGROUND_APPS,
+ new String[]{TEST_PKG});
+ mNotification.extras = extras;
+ when(mForegroundServiceController.isSystemAlertWarningNeeded(sbn.getUserId(), TEST_PKG))
+ .thenReturn(false);
+
+ // THEN filter out the notification
+ assertTrue(mForegroundFilter.shouldFilterOut(mEntry, 0));
+ }
+
+ @Test
+ public void filterTest_doNotFilter() {
+ StatusBarNotification sbn = mEntry.getSbn();
+
+ // GIVEN the notification isn't a system alert notification nor a disclosure notification
+ when(mForegroundServiceController.isSystemAlertNotification(sbn)).thenReturn(false);
+ when(mForegroundServiceController.isDisclosureNotification(sbn)).thenReturn(false);
+
+ // THEN don't filter out the notification
+ assertFalse(mForegroundFilter.shouldFilterOut(mEntry, 0));
+ }
+
+ @Test
+ public void extendLifetimeText_notForeground() {
+ // GIVEN the notification doesn't represent a foreground service
+ mNotification.flags = 0;
+
+ // THEN don't extend the lifetime
+ assertFalse(mForegroundNotifLifetimeExtender
+ .shouldExtendLifetime(mEntry, NotificationListenerService.REASON_CLICK));
+ }
+
+ @Test
+ public void extendLifetimeText_foregroundNotifRecentlyPosted() {
+ // GIVEN the notification represents a foreground service that was just posted
+ mNotification.flags |= Notification.FLAG_FOREGROUND_SERVICE;
+ mEntry = new NotificationEntryBuilder()
+ .setUser(new UserHandle(NOTIF_USER_ID))
+ .setSbn(new StatusBarNotification(TEST_PKG, TEST_PKG, NOTIF_USER_ID, "",
+ NOTIF_USER_ID, NOTIF_USER_ID, mNotification,
+ new UserHandle(NOTIF_USER_ID), "", System.currentTimeMillis()))
+ .setNotification(mNotification)
+ .build();
+
+ // THEN extend the lifetime
+ assertTrue(mForegroundNotifLifetimeExtender
+ .shouldExtendLifetime(mEntry, NotificationListenerService.REASON_CLICK));
+ }
+
+ @Test
+ public void extendLifetimeText_foregroundNotifOld() {
+ // GIVEN the notification represents a foreground service that was posted 10 seconds ago
+ mNotification.flags |= Notification.FLAG_FOREGROUND_SERVICE;
+ mEntry = new NotificationEntryBuilder()
+ .setUser(new UserHandle(NOTIF_USER_ID))
+ .setSbn(new StatusBarNotification(TEST_PKG, TEST_PKG, NOTIF_USER_ID, "",
+ NOTIF_USER_ID, NOTIF_USER_ID, mNotification,
+ new UserHandle(NOTIF_USER_ID), "",
+ System.currentTimeMillis() - 10000))
+ .setNotification(mNotification)
+ .build();
+
+ // THEN don't extend the lifetime because the extended time exceeds
+ // ForegroundCoordinator.MIN_FGS_TIME_MS
+ assertFalse(mForegroundNotifLifetimeExtender
+ .shouldExtendLifetime(mEntry, NotificationListenerService.REASON_CLICK));
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/KeyguardCoordinatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/KeyguardCoordinatorTest.java
index 87b3783d..527370e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/KeyguardCoordinatorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/KeyguardCoordinatorTest.java
@@ -24,6 +24,8 @@
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.os.Handler;
@@ -40,12 +42,15 @@
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.RankingBuilder;
import com.android.systemui.statusbar.notification.collection.GroupEntry;
+import com.android.systemui.statusbar.notification.collection.NotifListBuilderImpl;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -61,14 +66,16 @@
@Mock private BroadcastDispatcher mBroadcastDispatcher;
@Mock private StatusBarStateController mStatusBarStateController;
@Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
+ @Mock private NotifListBuilderImpl mNotifListBuilder;
private NotificationEntry mEntry;
- private KeyguardCoordinator mKeyguardNotificationCoordinator;
+ private KeyguardCoordinator mKeyguardCoordinator;
+ private NotifFilter mKeyguardFilter;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
- mKeyguardNotificationCoordinator = new KeyguardCoordinator(
+ mKeyguardCoordinator = new KeyguardCoordinator(
mContext, mMainHandler, mKeyguardStateController, mLockscreenUserManager,
mBroadcastDispatcher, mStatusBarStateController,
mKeyguardUpdateMonitor);
@@ -76,6 +83,11 @@
mEntry = new NotificationEntryBuilder()
.setUser(new UserHandle(NOTIF_USER_ID))
.build();
+
+ ArgumentCaptor<NotifFilter> filterCaptor = ArgumentCaptor.forClass(NotifFilter.class);
+ mKeyguardCoordinator.attach(null, mNotifListBuilder);
+ verify(mNotifListBuilder, times(1)).addFilter(filterCaptor.capture());
+ mKeyguardFilter = filterCaptor.getValue();
}
@Test
@@ -84,7 +96,7 @@
setupUnfilteredState();
// THEN don't filter out the entry
- assertFalse(mKeyguardNotificationCoordinator.mNotifFilter.shouldFilterOut(mEntry, 0));
+ assertFalse(mKeyguardFilter.shouldFilterOut(mEntry, 0));
}
@Test
@@ -94,7 +106,7 @@
when(mLockscreenUserManager.isCurrentProfile(NOTIF_USER_ID)).thenReturn(false);
// THEN filter out the entry
- assertTrue(mKeyguardNotificationCoordinator.mNotifFilter.shouldFilterOut(mEntry, 0));
+ assertTrue(mKeyguardFilter.shouldFilterOut(mEntry, 0));
}
@Test
@@ -104,7 +116,7 @@
when(mKeyguardStateController.isShowing()).thenReturn(false);
// THEN don't filter out the entry
- assertFalse(mKeyguardNotificationCoordinator.mNotifFilter.shouldFilterOut(mEntry, 0));
+ assertFalse(mKeyguardFilter.shouldFilterOut(mEntry, 0));
}
@Test
@@ -116,7 +128,7 @@
when(mLockscreenUserManager.shouldShowLockscreenNotifications()).thenReturn(false);
// THEN filter out the entry
- assertTrue(mKeyguardNotificationCoordinator.mNotifFilter.shouldFilterOut(mEntry, 0));
+ assertTrue(mKeyguardFilter.shouldFilterOut(mEntry, 0));
}
@Test
@@ -128,7 +140,7 @@
when(mKeyguardUpdateMonitor.isUserInLockdown(NOTIF_USER_ID)).thenReturn(true);
// THEN filter out the entry
- assertTrue(mKeyguardNotificationCoordinator.mNotifFilter.shouldFilterOut(mEntry, 0));
+ assertTrue(mKeyguardFilter.shouldFilterOut(mEntry, 0));
}
@Test
@@ -143,7 +155,7 @@
.thenReturn(false);
// THEN filter out the entry
- assertTrue(mKeyguardNotificationCoordinator.mNotifFilter.shouldFilterOut(mEntry, 0));
+ assertTrue(mKeyguardFilter.shouldFilterOut(mEntry, 0));
}
@Test
@@ -159,7 +171,7 @@
.setVisibilityOverride(VISIBILITY_SECRET).build());
// THEN filter out the entry
- assertTrue(mKeyguardNotificationCoordinator.mNotifFilter.shouldFilterOut(mEntry, 0));
+ assertTrue(mKeyguardFilter.shouldFilterOut(mEntry, 0));
}
@Test
@@ -174,7 +186,7 @@
.build());
// THEN filter out the entry
- assertTrue(mKeyguardNotificationCoordinator.mNotifFilter.shouldFilterOut(mEntry, 0));
+ assertTrue(mKeyguardFilter.shouldFilterOut(mEntry, 0));
}
@Test
@@ -199,7 +211,7 @@
mEntry.setParent(group);
// THEN don't filter out the entry
- assertFalse(mKeyguardNotificationCoordinator.mNotifFilter.shouldFilterOut(mEntry, 0));
+ assertFalse(mKeyguardFilter.shouldFilterOut(mEntry, 0));
}
/**
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinatorTest.java
new file mode 100644
index 0000000..182e866
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinatorTest.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2019 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 com.android.systemui.statusbar.notification.collection.coordinator;
+
+import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT;
+import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST;
+
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.testing.AndroidTestingRunner;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.systemui.SysuiTestCase;
+import com.android.systemui.plugins.statusbar.StatusBarStateController;
+import com.android.systemui.statusbar.NotificationEntryBuilder;
+import com.android.systemui.statusbar.RankingBuilder;
+import com.android.systemui.statusbar.notification.collection.NotifListBuilderImpl;
+import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+@SmallTest
+@RunWith(AndroidTestingRunner.class)
+public class RankingCoordinatorTest extends SysuiTestCase {
+
+ @Mock private StatusBarStateController mStatusBarStateController;
+ @Mock private NotifListBuilderImpl mNotifListBuilder;
+ private NotificationEntry mEntry;
+ private RankingCoordinator mRankingCoordinator;
+ private NotifFilter mRankingFilter;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ mRankingCoordinator = new RankingCoordinator(mStatusBarStateController);
+ mEntry = new NotificationEntryBuilder().build();
+
+ ArgumentCaptor<NotifFilter> filterCaptor = ArgumentCaptor.forClass(NotifFilter.class);
+ mRankingCoordinator.attach(null, mNotifListBuilder);
+ verify(mNotifListBuilder, times(1)).addFilter(filterCaptor.capture());
+ mRankingFilter = filterCaptor.getValue();
+ }
+
+ @Test
+ public void testUnfilteredState() {
+ // GIVEN no suppressed visual effects + app not suspended
+ mEntry.setRanking(getRankingForUnfilteredNotif().build());
+
+ // THEN don't filter out the notification
+ assertFalse(mRankingFilter.shouldFilterOut(mEntry, 0));
+ }
+
+ @Test
+ public void filterSuspended() {
+ // GIVEN the notification's app is suspended
+ mEntry.setRanking(getRankingForUnfilteredNotif()
+ .setSuspended(true)
+ .build());
+
+ // THEN filter out the notification
+ assertTrue(mRankingFilter.shouldFilterOut(mEntry, 0));
+ }
+
+ @Test
+ public void filterDozingSuppressAmbient() {
+ // GIVEN should suppress ambient
+ mEntry.setRanking(getRankingForUnfilteredNotif()
+ .setSuppressedVisualEffects(SUPPRESSED_EFFECT_AMBIENT)
+ .build());
+
+ // WHEN it's dozing (on ambient display)
+ when(mStatusBarStateController.isDozing()).thenReturn(true);
+
+ // THEN filter out the notification
+ assertTrue(mRankingFilter.shouldFilterOut(mEntry, 0));
+
+ // WHEN it's not dozing (showing the notification list)
+ when(mStatusBarStateController.isDozing()).thenReturn(false);
+
+ // THEN don't filter out the notification
+ assertFalse(mRankingFilter.shouldFilterOut(mEntry, 0));
+ }
+
+ @Test
+ public void filterDozingSuppressNotificationList() {
+ // GIVEN should suppress from the notification list
+ mEntry.setRanking(getRankingForUnfilteredNotif()
+ .setSuppressedVisualEffects(SUPPRESSED_EFFECT_NOTIFICATION_LIST)
+ .build());
+
+ // WHEN it's dozing (on ambient display)
+ when(mStatusBarStateController.isDozing()).thenReturn(true);
+
+ // THEN don't filter out the notification
+ assertFalse(mRankingFilter.shouldFilterOut(mEntry, 0));
+
+ // WHEN it's not dozing (showing the notification list)
+ when(mStatusBarStateController.isDozing()).thenReturn(false);
+
+ // THEN filter out the notification
+ assertTrue(mRankingFilter.shouldFilterOut(mEntry, 0));
+ }
+
+ private RankingBuilder getRankingForUnfilteredNotif() {
+ return new RankingBuilder()
+ .setKey(mEntry.getKey())
+ .setSuppressedVisualEffects(0)
+ .setSuspended(false);
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/provider/IsHighPriorityProviderTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/provider/IsHighPriorityProviderTest.java
new file mode 100644
index 0000000..11488a0
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/provider/IsHighPriorityProviderTest.java
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) 2019 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 com.android.systemui.statusbar.notification.collection.provider;
+
+import static android.app.NotificationManager.IMPORTANCE_HIGH;
+import static android.app.NotificationManager.IMPORTANCE_LOW;
+import static android.app.NotificationManager.IMPORTANCE_MIN;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.Person;
+import android.testing.AndroidTestingRunner;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.systemui.SysuiTestCase;
+import com.android.systemui.statusbar.NotificationEntryBuilder;
+import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@SmallTest
+@RunWith(AndroidTestingRunner.class)
+public class IsHighPriorityProviderTest extends SysuiTestCase {
+ private IsHighPriorityProvider mIsHighPriorityProvider;
+
+ @Before
+ public void setup() {
+ mIsHighPriorityProvider = new IsHighPriorityProvider();
+ }
+
+ @Test
+ public void testCache() {
+ // GIVEN a notification with high importance
+ final NotificationEntry entryHigh = new NotificationEntryBuilder()
+ .setImportance(IMPORTANCE_HIGH)
+ .build();
+
+ // GIVEN notification with min importance
+ final NotificationEntry entryMin = new NotificationEntryBuilder()
+ .setImportance(IMPORTANCE_MIN)
+ .build();
+
+ // WHEN we get the value for the high priority entry
+ assertTrue(mIsHighPriorityProvider.get(entryHigh));
+
+ // THEN the value is cached, so even when passed an entryMin, we still get high priority
+ assertTrue(mIsHighPriorityProvider.get(entryMin));
+
+ // UNTIL the provider is invalidated
+ mIsHighPriorityProvider.invalidate();
+
+ // THEN the priority is recalculated
+ assertFalse(mIsHighPriorityProvider.get(entryMin));
+ }
+
+ @Test
+ public void highImportance() {
+ // GIVEN notification has high importance
+ final NotificationEntry entry = new NotificationEntryBuilder()
+ .setImportance(IMPORTANCE_HIGH)
+ .build();
+
+ // THEN it has high priority
+ assertTrue(mIsHighPriorityProvider.get(entry));
+ }
+
+ @Test
+ public void peopleNotification() {
+ // GIVEN notification is low importance but has a person associated with it
+ final Notification notification = new Notification.Builder(mContext, "test")
+ .addPerson(
+ new Person.Builder()
+ .setName("name")
+ .setKey("abc")
+ .setUri("uri")
+ .setBot(true)
+ .build())
+ .build();
+
+ final NotificationEntry entry = new NotificationEntryBuilder()
+ .setNotification(notification)
+ .setImportance(IMPORTANCE_LOW)
+ .build();
+
+ // THEN it has high priority
+ assertTrue(mIsHighPriorityProvider.get(entry));
+ }
+
+ @Test
+ public void messagingStyle() {
+ // GIVEN notification is low importance but has messaging style
+ final Notification notification = new Notification.Builder(mContext, "test")
+ .setStyle(new Notification.MessagingStyle(""))
+ .build();
+
+ final NotificationEntry entry = new NotificationEntryBuilder()
+ .setNotification(notification)
+ .build();
+
+ // THEN it has high priority
+ assertTrue(mIsHighPriorityProvider.get(entry));
+ }
+
+ @Test
+ public void lowImportanceForeground() {
+ // GIVEN notification is low importance and is associated with a foreground service
+ final Notification notification = mock(Notification.class);
+ when(notification.isForegroundService()).thenReturn(true);
+
+ final NotificationEntry entry = new NotificationEntryBuilder()
+ .setNotification(notification)
+ .setImportance(IMPORTANCE_LOW)
+ .build();
+
+ // THEN it has high priority
+ assertTrue(mIsHighPriorityProvider.get(entry));
+ }
+
+ @Test
+ public void minImportanceForeground() {
+ // GIVEN notification is low importance and is associated with a foreground service
+ final Notification notification = mock(Notification.class);
+ when(notification.isForegroundService()).thenReturn(true);
+
+ final NotificationEntry entry = new NotificationEntryBuilder()
+ .setNotification(notification)
+ .setImportance(IMPORTANCE_MIN)
+ .build();
+
+ // THEN it does NOT have high priority
+ assertFalse(mIsHighPriorityProvider.get(entry));
+ }
+
+ @Test
+ public void userChangeTrumpsHighPriorityCharacteristics() {
+ // GIVEN notification has high priority characteristics but the user changed the importance
+ // to less than IMPORTANCE_DEFAULT (ie: IMPORTANCE_LOW or IMPORTANCE_MIN)
+ final Notification notification = new Notification.Builder(mContext, "test")
+ .addPerson(
+ new Person.Builder()
+ .setName("name")
+ .setKey("abc")
+ .setUri("uri")
+ .setBot(true)
+ .build())
+ .setStyle(new Notification.MessagingStyle(""))
+ .setFlag(Notification.FLAG_FOREGROUND_SERVICE, true)
+ .build();
+
+ final NotificationChannel channel = new NotificationChannel("a", "a",
+ IMPORTANCE_LOW);
+ channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
+
+ final NotificationEntry entry = new NotificationEntryBuilder()
+ .setNotification(notification)
+ .setChannel(channel)
+ .build();
+
+ // THEN it does NOT have high priority
+ assertFalse(mIsHighPriorityProvider.get(entry));
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/people/PeopleHubViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/people/PeopleHubViewControllerTest.kt
index f5d6f22..0764d0c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/people/PeopleHubViewControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/people/PeopleHubViewControllerTest.kt
@@ -89,8 +89,17 @@
return mockSubscription
}
}
+ val fakeSettingDataSource = object : DataSource<Boolean> {
+ override fun registerListener(listener: DataListener<Boolean>): Subscription {
+ listener.onDataChanged(true)
+ return mockSubscription
+ }
+ }
val factoryDataSource = PeopleHubViewModelFactoryDataSourceImpl(
- mockActivityStarter, fakeModelDataSource)
+ mockActivityStarter,
+ fakeModelDataSource,
+ fakeSettingDataSource
+ )
val fakeListener = FakeDataListener<PeopleHubViewModelFactory>()
val mockClickView = mock(View::class.java)
@@ -112,6 +121,41 @@
same(mockClickView)
)
}
+
+ @Test
+ fun testViewModelDataSource_notVisibleIfSettingDisabled() {
+ val fakeClickIntent = PendingIntent.getActivity(context, 0, Intent("action"), 0)
+ val fakePerson = fakePersonModel("id", "name", fakeClickIntent)
+ val fakeModel = PeopleHubModel(listOf(fakePerson))
+ val mockSubscription = mock(Subscription::class.java)
+ val fakeModelDataSource = object : DataSource<PeopleHubModel> {
+ override fun registerListener(listener: DataListener<PeopleHubModel>): Subscription {
+ listener.onDataChanged(fakeModel)
+ return mockSubscription
+ }
+ }
+ val fakeSettingDataSource = object : DataSource<Boolean> {
+ override fun registerListener(listener: DataListener<Boolean>): Subscription {
+ listener.onDataChanged(false)
+ return mockSubscription
+ }
+ }
+ val factoryDataSource = PeopleHubViewModelFactoryDataSourceImpl(
+ mockActivityStarter,
+ fakeModelDataSource,
+ fakeSettingDataSource
+ )
+ val fakeListener = FakeDataListener<PeopleHubViewModelFactory>()
+ val mockClickView = mock(View::class.java)
+
+ factoryDataSource.registerListener(fakeListener)
+
+ val viewModel = (fakeListener.lastSeen as Maybe.Just).value
+ .createWithAssociatedClickView(mockClickView)
+ assertThat(viewModel.isVisible).isFalse()
+ val people = viewModel.people.toList()
+ assertThat(people.size).isEqualTo(0)
+ }
}
/** Works around Mockito matchers returning `null` and breaking non-nullable Kotlin code. */
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
index 43d39a2..ccc9496 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
@@ -20,6 +20,7 @@
import static android.app.AppOpsManager.OP_RECORD_AUDIO;
import static android.app.AppOpsManager.OP_SYSTEM_ALERT_WINDOW;
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static android.service.notification.NotificationListenerService.Ranking.USER_SENTIMENT_NEGATIVE;
import static com.android.systemui.statusbar.NotificationEntryHelper.modifyRanking;
@@ -383,15 +384,14 @@
NotificationInfo notificationInfoView = mock(NotificationInfo.class);
ExpandableNotificationRow row = spy(mHelper.createRow());
row.setBlockingHelperShowing(true);
- modifyRanking(row.getEntry())
+ final NotificationEntry entry = row.getEntry();
+ modifyRanking(entry)
.setUserSentiment(USER_SENTIMENT_NEGATIVE)
- .setImportance(IMPORTANCE_DEFAULT)
+ .setImportance(IMPORTANCE_HIGH)
.build();
- row.getEntry().setIsHighPriority(true);
- when(row.getIsNonblockable()).thenReturn(false);
- StatusBarNotification statusBarNotification = row.getEntry().getSbn();
- NotificationEntry entry = row.getEntry();
+ when(row.getIsNonblockable()).thenReturn(false);
+ StatusBarNotification statusBarNotification = entry.getSbn();
mGutsManager.initializeNotificationInfo(row, notificationInfoView);
verify(notificationInfoView).bindNotification(
@@ -408,7 +408,7 @@
eq(false),
eq(false),
eq(true) /* isForBlockingHelper */,
- eq(IMPORTANCE_DEFAULT),
+ eq(IMPORTANCE_HIGH),
eq(true) /* wasShownHighPriority */);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
index 4d6ff1f..008a349 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
@@ -760,6 +760,17 @@
}
@Test
+ public void testWillHideDockedWallpaper() {
+ mAlwaysOnEnabled = false;
+ when(mDockManager.isDocked()).thenReturn(true);
+ mScrimController.setWallpaperSupportsAmbientMode(true);
+
+ mScrimController.transitionTo(ScrimState.AOD);
+
+ verify(mAlarmManager).setExact(anyInt(), anyLong(), any(), any(), any());
+ }
+
+ @Test
public void testConservesExpansionOpacityAfterTransition() {
mScrimController.transitionTo(ScrimState.UNLOCKED);
mScrimController.setPanelExpansion(0.5f);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/DeviceConfigProxyFake.java b/packages/SystemUI/tests/src/com/android/systemui/util/DeviceConfigProxyFake.java
index 426aba0..260ff2d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/util/DeviceConfigProxyFake.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/util/DeviceConfigProxyFake.java
@@ -69,8 +69,11 @@
}
for (Pair<Executor, OnPropertiesChangedListener> listener : mListeners) {
- listener.first.execute(() -> listener.second.onPropertiesChanged(
- new Properties(namespace, mProperties.get(namespace))));
+ Properties.Builder propBuilder = new Properties.Builder(namespace);
+ for (String key : mProperties.get(namespace).keySet()) {
+ propBuilder.setString(key, mProperties.get(namespace).get(key));
+ }
+ listener.first.execute(() -> listener.second.onPropertiesChanged(propBuilder.build()));
}
return true;
}
@@ -88,10 +91,12 @@
private Properties propsForNamespaceAndName(String namespace, String name) {
if (mProperties.containsKey(namespace) && mProperties.get(namespace).containsKey(name)) {
- return new Properties(namespace, mProperties.get(namespace));
+ return new Properties.Builder(namespace)
+ .setString(name, mProperties.get(namespace).get(name)).build();
}
if (mDefaultProperties.containsKey(namespace)) {
- return new Properties(namespace, mDefaultProperties.get(namespace));
+ return new Properties.Builder(namespace)
+ .setString(name, mDefaultProperties.get(namespace).get(name)).build();
}
return null;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/animation/PhysicsAnimatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/util/animation/PhysicsAnimatorTest.kt
new file mode 100644
index 0000000..a39fbc4
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/util/animation/PhysicsAnimatorTest.kt
@@ -0,0 +1,436 @@
+package com.android.systemui.util.animation
+
+import android.testing.AndroidTestingRunner
+import android.testing.TestableLooper
+import android.util.ArrayMap
+import android.view.View
+import android.view.ViewGroup
+import android.widget.FrameLayout
+import androidx.dynamicanimation.animation.DynamicAnimation
+import androidx.dynamicanimation.animation.FloatPropertyCompat
+import androidx.dynamicanimation.animation.SpringForce
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.util.animation.PhysicsAnimator.EndListener
+import com.android.systemui.util.animation.PhysicsAnimator.UpdateListener
+import com.android.systemui.util.animation.PhysicsAnimatorTestUtils.clearAnimationUpdateFrames
+import com.android.systemui.util.animation.PhysicsAnimatorTestUtils.getAnimationUpdateFrames
+import com.android.systemui.util.animation.PhysicsAnimatorTestUtils.verifyAnimationUpdateFrames
+import org.junit.After
+import org.junit.Assert
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNotEquals
+import org.junit.Assert.assertTrue
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentMatchers.anyFloat
+import org.mockito.Mockito
+import org.mockito.Mockito.mock
+import org.mockito.Mockito.times
+import org.mockito.Mockito.verify
+import org.mockito.Mockito.verifyNoMoreInteractions
+import org.mockito.MockitoAnnotations
+
+@TestableLooper.RunWithLooper
+@RunWith(AndroidTestingRunner::class)
+@SmallTest
+class PhysicsAnimatorTest : SysuiTestCase() {
+ private lateinit var viewGroup: ViewGroup
+ private lateinit var testView: View
+ private lateinit var testView2: View
+
+ private lateinit var animator: PhysicsAnimator<View>
+
+ private val springConfig = PhysicsAnimator.SpringConfig(
+ SpringForce.STIFFNESS_LOW, SpringForce.DAMPING_RATIO_NO_BOUNCY)
+ private val flingConfig = PhysicsAnimator.FlingConfig(2f)
+
+ private lateinit var mockUpdateListener: UpdateListener<View>
+ private lateinit var mockEndListener: EndListener<View>
+ private lateinit var mockEndAction: Runnable
+
+ private fun <T> eq(value: T): T = Mockito.eq(value) ?: value
+
+ @Before
+ fun setup() {
+ MockitoAnnotations.initMocks(this)
+
+ mockUpdateListener = mock(UpdateListener::class.java) as UpdateListener<View>
+ mockEndListener = mock(EndListener::class.java) as EndListener<View>
+ mockEndAction = mock(Runnable::class.java)
+
+ viewGroup = FrameLayout(context)
+ testView = View(context)
+ testView2 = View(context)
+ viewGroup.addView(testView)
+ viewGroup.addView(testView2)
+
+ PhysicsAnimatorTestUtils.prepareForTest()
+
+ // Most of our tests involve checking the end state of animations, so we want calls that
+ // start animations to block the test thread until the animations have ended.
+ PhysicsAnimatorTestUtils.setAllAnimationsBlock(true)
+
+ animator = PhysicsAnimator.getInstance(testView)
+ }
+
+ @After
+ fun tearDown() {
+ PhysicsAnimatorTestUtils.tearDown()
+ }
+
+ @Test
+ fun testOneAnimatorPerView() {
+ assertEquals(animator, PhysicsAnimator.getInstance(testView))
+ assertEquals(PhysicsAnimator.getInstance(testView), PhysicsAnimator.getInstance(testView))
+ assertNotEquals(animator, PhysicsAnimator.getInstance(testView2))
+ }
+
+ @Test
+ fun testSpringOneProperty() {
+ animator
+ .spring(DynamicAnimation.TRANSLATION_X, 50f, springConfig)
+ .start()
+
+ assertEquals(testView.translationX, 50f, 1f)
+ }
+
+ @Test
+ fun testSpringMultipleProperties() {
+ animator
+ .spring(DynamicAnimation.TRANSLATION_X, 10f, springConfig)
+ .spring(DynamicAnimation.TRANSLATION_Y, 50f, springConfig)
+ .spring(DynamicAnimation.SCALE_Y, 1.1f, springConfig)
+ .start()
+
+ assertEquals(10f, testView.translationX, 1f)
+ assertEquals(50f, testView.translationY, 1f)
+ assertEquals(1.1f, testView.scaleY, 0.01f)
+ }
+
+ @Test
+ fun testFling() {
+ val startTime = System.currentTimeMillis()
+
+ animator
+ .fling(DynamicAnimation.TRANSLATION_X, 1000f /* startVelocity */, flingConfig)
+ .fling(DynamicAnimation.TRANSLATION_Y, 500f, flingConfig)
+ .start()
+
+ val elapsedTimeSeconds = (System.currentTimeMillis() - startTime) / 1000f
+
+ // If the fling worked, the view should be somewhere between its starting position and the
+ // and the theoretical no-friction maximum of startVelocity (in pixels per second)
+ // multiplied by elapsedTimeSeconds. We can't calculate an exact expected location for a
+ // fling, so this is close enough.
+ assertTrue(testView.translationX > 0f)
+ assertTrue(testView.translationX < 1000f * elapsedTimeSeconds)
+ assertTrue(testView.translationY > 0f)
+ assertTrue(testView.translationY < 500f * elapsedTimeSeconds)
+ }
+
+ @Test
+ @Throws(InterruptedException::class)
+ fun testEndListenersAndActions() {
+ PhysicsAnimatorTestUtils.setAllAnimationsBlock(false)
+ animator
+ .spring(DynamicAnimation.TRANSLATION_X, 10f, springConfig)
+ .spring(DynamicAnimation.TRANSLATION_Y, 500f, springConfig)
+ .addEndListener(mockEndListener)
+ .withEndActions(mockEndAction::run)
+ .start()
+
+ PhysicsAnimatorTestUtils.blockUntilAnimationsEnd(animator, DynamicAnimation.TRANSLATION_X)
+
+ // Once TRANSLATION_X is done, the view should be at x = 10...
+ assertEquals(10f, testView.translationX, 1f)
+
+ // / ...TRANSLATION_Y should still be running...
+ assertTrue(animator.isPropertyAnimating(DynamicAnimation.TRANSLATION_Y))
+
+ // ...and our end listener should have been called with x = 10, velocity = 0, and allEnded =
+ // false since TRANSLATION_Y is still running.
+ verify(mockEndListener).onAnimationEnd(
+ testView,
+ DynamicAnimation.TRANSLATION_X,
+ canceled = false,
+ finalValue = 10f,
+ finalVelocity = 0f,
+ allRelevantPropertyAnimsEnded = false)
+ verifyNoMoreInteractions(mockEndListener)
+
+ // The end action should not have been run yet.
+ verify(mockEndAction, times(0)).run()
+
+ // Block until TRANSLATION_Y finishes.
+ PhysicsAnimatorTestUtils.blockUntilAnimationsEnd(animator, DynamicAnimation.TRANSLATION_Y)
+
+ // The view should have been moved.
+ assertEquals(10f, testView.translationX, 1f)
+ assertEquals(500f, testView.translationY, 1f)
+
+ // The end listener should have been called, this time with TRANSLATION_Y, y = 50, and
+ // allEnded = true.
+ verify(mockEndListener).onAnimationEnd(
+ testView,
+ DynamicAnimation.TRANSLATION_Y,
+ canceled = false,
+ finalValue = 500f,
+ finalVelocity = 0f,
+ allRelevantPropertyAnimsEnded = true)
+ verifyNoMoreInteractions(mockEndListener)
+
+ // Now that all properties are done animating, the end action should have been called.
+ verify(mockEndAction, times(1)).run()
+ }
+
+ @Test
+ fun testUpdateListeners() {
+ animator
+ .spring(DynamicAnimation.TRANSLATION_X, 100f, springConfig)
+ .spring(DynamicAnimation.TRANSLATION_Y, 50f, springConfig)
+ .addUpdateListener(object : UpdateListener<View> {
+ override fun onAnimationUpdateForProperty(
+ target: View,
+ values: UpdateMap<View>
+ ) {
+ mockUpdateListener.onAnimationUpdateForProperty(target, values)
+ }
+ })
+ .start()
+
+ verifyUpdateListenerCalls(animator, mockUpdateListener)
+ }
+
+ @Test
+ fun testListenersNotCalledOnSubsequentAnimations() {
+ animator
+ .spring(DynamicAnimation.TRANSLATION_X, 10f, springConfig)
+ .addUpdateListener(mockUpdateListener)
+ .addEndListener(mockEndListener)
+ .withEndActions(mockEndAction::run)
+ .start()
+
+ verifyUpdateListenerCalls(animator, mockUpdateListener)
+ verify(mockEndListener, times(1)).onAnimationEnd(
+ eq(testView), eq(DynamicAnimation.TRANSLATION_X), eq(false), anyFloat(), anyFloat(),
+ eq(true))
+ verify(mockEndAction, times(1)).run()
+
+ animator
+ .spring(DynamicAnimation.TRANSLATION_X, 0f, springConfig)
+ .start()
+
+ // We didn't pass any of the listeners/actions to the subsequent animation, so they should
+ // never have been called.
+ verifyNoMoreInteractions(mockUpdateListener)
+ verifyNoMoreInteractions(mockEndListener)
+ verifyNoMoreInteractions(mockEndAction)
+ }
+
+ @Test
+ @Throws(InterruptedException::class)
+ fun testAnimationsUpdatedWhileInMotion() {
+ PhysicsAnimatorTestUtils.setAllAnimationsBlock(false)
+
+ // Spring towards x = 100f.
+ animator
+ .spring(
+ DynamicAnimation.TRANSLATION_X,
+ 100f,
+ springConfig)
+ .start()
+
+ // Block until it reaches x = 50f.
+ PhysicsAnimatorTestUtils.blockUntilFirstAnimationFrameWhereTrue(
+ animator) { view -> view.translationX > 50f }
+
+ // Translation X value at the time of reversing the animation to spring to x = 0f.
+ val reversalTranslationX = testView.translationX
+
+ // Spring back towards 0f.
+ animator
+ .spring(
+ DynamicAnimation.TRANSLATION_X,
+ 0f,
+ // Lower the stiffness to ensure the update listener receives at least one
+ // update frame where the view has continued to move to the right.
+ springConfig.apply { stiffness = SpringForce.STIFFNESS_LOW })
+ .start()
+
+ // Wait for TRANSLATION_X.
+ PhysicsAnimatorTestUtils.blockUntilAnimationsEnd(animator, DynamicAnimation.TRANSLATION_X)
+
+ // Verify that the animation continued past the X value at the time of reversal, before
+ // springing back. This ensures the change in direction was not abrupt.
+ verifyAnimationUpdateFrames(
+ animator, DynamicAnimation.TRANSLATION_X,
+ { u -> u.value > reversalTranslationX },
+ { u -> u.value < reversalTranslationX })
+
+ // Verify that the view is where it should be.
+ assertEquals(0f, testView.translationX, 1f)
+ }
+
+ @Test
+ @Throws(InterruptedException::class)
+ fun testAnimationsUpdatedWhileInMotion_originalListenersStillCalled() {
+ PhysicsAnimatorTestUtils.setAllAnimationsBlock(false)
+
+ // Spring TRANSLATION_X to 100f, with an update and end listener provided.
+ animator
+ .spring(DynamicAnimation.TRANSLATION_X, 100f, springConfig)
+ .addUpdateListener(mockUpdateListener)
+ .addEndListener(mockEndListener)
+ .start()
+
+ // Wait until the animation is halfway there.
+ PhysicsAnimatorTestUtils.blockUntilFirstAnimationFrameWhereTrue(
+ animator) { view -> view.translationX > 50f }
+
+ // The end listener shouldn't have been called since the animation hasn't ended.
+ verifyNoMoreInteractions(mockEndListener)
+
+ // Make sure we called the update listener with appropriate values.
+ verifyAnimationUpdateFrames(animator, DynamicAnimation.TRANSLATION_X,
+ { u -> u.value > 0f },
+ { u -> u.value >= 50f })
+
+ // Mock a second end listener.
+ val secondEndListener = mock(EndListener::class.java) as EndListener<View>
+ val secondUpdateListener = mock(UpdateListener::class.java) as UpdateListener<View>
+
+ // Start a new animation that springs both TRANSLATION_X and TRANSLATION_Y, and provide it
+ // the second end listener. This new end listener should be called for the end of
+ // TRANSLATION_X and TRANSLATION_Y, with allEnded = true when both have ended.
+ animator
+ .spring(DynamicAnimation.TRANSLATION_X, 200f, springConfig)
+ .spring(DynamicAnimation.TRANSLATION_Y, 4000f, springConfig)
+ .addUpdateListener(secondUpdateListener)
+ .addEndListener(secondEndListener)
+ .start()
+
+ // Wait for TRANSLATION_X to end.
+ PhysicsAnimatorTestUtils.blockUntilAnimationsEnd(animator, DynamicAnimation.TRANSLATION_X)
+
+ // The update listener provided to the initial animation call (the one that only animated
+ // TRANSLATION_X) should have been called with values on the way to x = 200f. This is
+ // because the second animation call updated the original TRANSLATION_X animation.
+ verifyAnimationUpdateFrames(
+ animator, DynamicAnimation.TRANSLATION_X,
+ { u -> u.value > 100f }, { u -> u.value >= 200f })
+
+ // The original end listener should also have been called, with allEnded = true since it was
+ // provided to an animator that animated only TRANSLATION_X.
+ verify(mockEndListener, times(1))
+ .onAnimationEnd(testView, DynamicAnimation.TRANSLATION_X, false, 200f, 0f, true)
+ verifyNoMoreInteractions(mockEndListener)
+
+ // The second end listener should have been called, but with allEnded = false since it was
+ // provided to an animator that animated both TRANSLATION_X and TRANSLATION_Y.
+ verify(secondEndListener, times(1))
+ .onAnimationEnd(testView, DynamicAnimation.TRANSLATION_X, false, 200f, 0f, false)
+ verifyNoMoreInteractions(secondEndListener)
+
+ PhysicsAnimatorTestUtils.blockUntilAnimationsEnd(animator, DynamicAnimation.TRANSLATION_Y)
+
+ // The original end listener shouldn't receive any callbacks because it was not provided to
+ // an animator that animated TRANSLATION_Y.
+ verifyNoMoreInteractions(mockEndListener)
+
+ verify(secondEndListener, times(1))
+ .onAnimationEnd(testView, DynamicAnimation.TRANSLATION_Y, false, 4000f, 0f, true)
+ verifyNoMoreInteractions(secondEndListener)
+ }
+
+ @Test
+ fun testFlingRespectsMinMax() {
+ animator
+ .fling(DynamicAnimation.TRANSLATION_X,
+ startVelocity = 1000f,
+ friction = 1.1f,
+ max = 10f)
+ .addEndListener(mockEndListener)
+ .start()
+
+ // Ensure that the view stopped at x = 10f, and the end listener was called once with that
+ // value.
+ assertEquals(10f, testView.translationX, 1f)
+ verify(mockEndListener, times(1))
+ .onAnimationEnd(
+ eq(testView), eq(DynamicAnimation.TRANSLATION_X), eq(false), eq(10f),
+ anyFloat(), eq(true))
+
+ animator
+ .fling(
+ DynamicAnimation.TRANSLATION_X,
+ startVelocity = -1000f,
+ friction = 1.1f,
+ min = -5f)
+ .addEndListener(mockEndListener)
+ .start()
+
+ // Ensure that the view stopped at x = -5f, and the end listener was called once with that
+ // value.
+ assertEquals(-5f, testView.translationX, 1f)
+ verify(mockEndListener, times(1))
+ .onAnimationEnd(
+ eq(testView), eq(DynamicAnimation.TRANSLATION_X), eq(false), eq(-5f),
+ anyFloat(), eq(true))
+ }
+
+ @Test
+ fun testExtensionProperty() {
+ testView
+ .physicsAnimator
+ .spring(DynamicAnimation.TRANSLATION_X, 200f)
+ .start()
+
+ assertEquals(200f, testView.translationX, 1f)
+ }
+
+ /**
+ * Verifies that the calls to the mock update listener match the animation update frames
+ * reported by the test internal listener, in order.
+ */
+ private fun <T : Any> verifyUpdateListenerCalls(
+ animator: PhysicsAnimator<T>,
+ mockUpdateListener: UpdateListener<T>
+ ) {
+ val updates = getAnimationUpdateFrames(animator)
+
+ for (invocation in Mockito.mockingDetails(mockUpdateListener).invocations) {
+
+ // Grab the update map of Property -> AnimationUpdate that was passed to the mock update
+ // listener.
+ val updateMap = invocation.arguments[1]
+ as ArrayMap<FloatPropertyCompat<in T>, PhysicsAnimator.AnimationUpdate>
+
+ //
+ for ((property, update) in updateMap) {
+ val updatesForProperty = updates[property]!!
+
+ // This update should be the next one in the list for this property.
+ if (update != updatesForProperty[0]) {
+ Assert.fail("The update listener was called with an unexpected value: $update.")
+ }
+
+ updatesForProperty.remove(update)
+ }
+
+ // Mark this invocation verified.
+ verify(mockUpdateListener).onAnimationUpdateForProperty(animator.target, updateMap)
+ }
+
+ verifyNoMoreInteractions(mockUpdateListener)
+
+ // Since we were removing values as matching invocations were found, there should no longer
+ // be any values remaining. If there are, it means the update listener wasn't notified when
+ // it should have been.
+ assertEquals(0,
+ updates.values.fold(0, { count, propertyUpdates -> count + propertyUpdates.size }))
+
+ clearAnimationUpdateFrames(animator)
+ }
+}
\ No newline at end of file
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wm/DisplayLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/wm/DisplayLayoutTest.java
new file mode 100644
index 0000000..9596a73
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/wm/DisplayLayoutTest.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2019 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 com.android.systemui.wm;
+
+import static android.content.res.Configuration.UI_MODE_TYPE_NORMAL;
+import static android.view.Surface.ROTATION_0;
+import static android.view.Surface.ROTATION_270;
+import static android.view.Surface.ROTATION_90;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.graphics.Insets;
+import android.graphics.Rect;
+import android.view.DisplayCutout;
+import android.view.DisplayInfo;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.internal.R;
+import com.android.systemui.SysuiTestCase;
+
+import org.junit.Test;
+
+@SmallTest
+public class DisplayLayoutTest extends SysuiTestCase {
+
+ @Test
+ public void testInsets() {
+ Resources res = createResources(40, 50, false, 30, 40);
+ // Test empty display, no bars or anything
+ DisplayInfo info = createDisplayInfo(1000, 1500, 0, ROTATION_0);
+ DisplayLayout dl = new DisplayLayout(info, res, false, false);
+ assertEquals(new Rect(0, 0, 0, 0), dl.stableInsets());
+ assertEquals(new Rect(0, 0, 0, 0), dl.nonDecorInsets());
+
+ // Test with bars
+ dl = new DisplayLayout(info, res, true, true);
+ assertEquals(new Rect(0, 40, 0, 50), dl.stableInsets());
+ assertEquals(new Rect(0, 0, 0, 50), dl.nonDecorInsets());
+
+ // Test just cutout
+ info = createDisplayInfo(1000, 1500, 60, ROTATION_0);
+ dl = new DisplayLayout(info, res, false, false);
+ assertEquals(new Rect(0, 60, 0, 0), dl.stableInsets());
+ assertEquals(new Rect(0, 60, 0, 0), dl.nonDecorInsets());
+
+ // Test with bars and cutout
+ dl = new DisplayLayout(info, res, true, true);
+ assertEquals(new Rect(0, 60, 0, 50), dl.stableInsets());
+ assertEquals(new Rect(0, 60, 0, 50), dl.nonDecorInsets());
+ }
+
+ @Test
+ public void testRotate() {
+ // Basic rotate utility
+ Rect testParent = new Rect(0, 0, 1000, 600);
+ Rect testInner = new Rect(40, 20, 120, 80);
+ Rect testResult = new Rect(testInner);
+ DisplayLayout.rotateBounds(testResult, testParent, 1);
+ assertEquals(new Rect(20, 880, 80, 960), testResult);
+ testResult.set(testInner);
+ DisplayLayout.rotateBounds(testResult, testParent, 2);
+ assertEquals(new Rect(880, 20, 960, 80), testResult);
+ testResult.set(testInner);
+ DisplayLayout.rotateBounds(testResult, testParent, 3);
+ assertEquals(new Rect(520, 40, 580, 120), testResult);
+
+ Resources res = createResources(40, 50, false, 30, 40);
+ DisplayInfo info = createDisplayInfo(1000, 1500, 60, ROTATION_0);
+ DisplayLayout dl = new DisplayLayout(info, res, true, true);
+ assertEquals(new Rect(0, 60, 0, 50), dl.stableInsets());
+ assertEquals(new Rect(0, 60, 0, 50), dl.nonDecorInsets());
+
+ // Rotate to 90
+ dl.rotateTo(res, ROTATION_90);
+ assertEquals(new Rect(60, 30, 0, 40), dl.stableInsets());
+ assertEquals(new Rect(60, 0, 0, 40), dl.nonDecorInsets());
+
+ // Rotate with moving navbar
+ res = createResources(40, 50, true, 30, 40);
+ dl = new DisplayLayout(info, res, true, true);
+ dl.rotateTo(res, ROTATION_270);
+ assertEquals(new Rect(40, 30, 60, 0), dl.stableInsets());
+ assertEquals(new Rect(40, 0, 60, 0), dl.nonDecorInsets());
+ }
+
+ private Resources createResources(
+ int navLand, int navPort, boolean navMoves, int statusLand, int statusPort) {
+ Configuration cfg = new Configuration();
+ cfg.uiMode = UI_MODE_TYPE_NORMAL;
+ Resources res = mock(Resources.class);
+ doReturn(navLand).when(res).getDimensionPixelSize(
+ R.dimen.navigation_bar_height_landscape_car_mode);
+ doReturn(navPort).when(res).getDimensionPixelSize(R.dimen.navigation_bar_height_car_mode);
+ doReturn(navLand).when(res).getDimensionPixelSize(R.dimen.navigation_bar_width_car_mode);
+ doReturn(navLand).when(res).getDimensionPixelSize(R.dimen.navigation_bar_height_landscape);
+ doReturn(navPort).when(res).getDimensionPixelSize(R.dimen.navigation_bar_height);
+ doReturn(navLand).when(res).getDimensionPixelSize(R.dimen.navigation_bar_width);
+ doReturn(navMoves).when(res).getBoolean(R.bool.config_navBarCanMove);
+ doReturn(statusLand).when(res).getDimensionPixelSize(R.dimen.status_bar_height_landscape);
+ doReturn(statusPort).when(res).getDimensionPixelSize(R.dimen.status_bar_height_portrait);
+ doReturn(cfg).when(res).getConfiguration();
+ return res;
+ }
+
+ private DisplayInfo createDisplayInfo(int width, int height, int cutoutHeight, int rotation) {
+ DisplayInfo info = new DisplayInfo();
+ info.logicalWidth = width;
+ info.logicalHeight = height;
+ info.rotation = rotation;
+ if (cutoutHeight > 0) {
+ info.displayCutout = new DisplayCutout(
+ Insets.of(0, cutoutHeight, 0, 0) /* safeInsets */, null /* boundLeft */,
+ new Rect(width / 2 - cutoutHeight, 0, width / 2 + cutoutHeight,
+ cutoutHeight) /* boundTop */, null /* boundRight */,
+ null /* boundBottom */);
+ } else {
+ info.displayCutout = DisplayCutout.NO_CUTOUT;
+ }
+ info.logicalDensityDpi = 300;
+ return info;
+ }
+}
diff --git a/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java b/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
index eb0d443..7fb286b 100644
--- a/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
+++ b/packages/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
@@ -17,6 +17,7 @@
import static android.Manifest.permission.NETWORK_STACK;
import static android.net.ConnectivityManager.TETHER_ERROR_NO_ERROR;
+import static android.net.ConnectivityManager.TETHER_ERROR_SERVICE_UNAVAIL;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -175,6 +176,10 @@
*/
@Deprecated
public int tether(@NonNull String iface) {
+ if (mConnector == null) {
+ Slog.wtf(TAG, "Tethering not ready yet");
+ return TETHER_ERROR_SERVICE_UNAVAIL;
+ }
try {
mConnector.tether(iface);
} catch (RemoteException e) {
@@ -191,6 +196,10 @@
*/
@Deprecated
public int untether(@NonNull String iface) {
+ if (mConnector == null) {
+ Slog.wtf(TAG, "Tethering not ready yet");
+ return TETHER_ERROR_SERVICE_UNAVAIL;
+ }
try {
mConnector.untether(iface);
} catch (RemoteException e) {
@@ -210,6 +219,10 @@
*/
@Deprecated
public int setUsbTethering(boolean enable) {
+ if (mConnector == null) {
+ Slog.wtf(TAG, "Tethering not ready yet");
+ return TETHER_ERROR_SERVICE_UNAVAIL;
+ }
try {
mConnector.setUsbTethering(enable);
} catch (RemoteException e) {
@@ -227,6 +240,10 @@
// TODO: improve the usage of ResultReceiver, b/145096122
public void startTethering(int type, @NonNull ResultReceiver receiver,
boolean showProvisioningUi) {
+ if (mConnector == null) {
+ Slog.wtf(TAG, "Tethering not ready yet");
+ return;
+ }
try {
mConnector.startTethering(type, receiver, showProvisioningUi);
} catch (RemoteException e) {
@@ -241,6 +258,10 @@
* {@hide}
*/
public void stopTethering(int type) {
+ if (mConnector == null) {
+ Slog.wtf(TAG, "Tethering not ready yet");
+ return;
+ }
try {
mConnector.stopTethering(type);
} catch (RemoteException e) {
@@ -258,6 +279,10 @@
// TODO: improve the usage of ResultReceiver, b/145096122
public void requestLatestTetheringEntitlementResult(int type, @NonNull ResultReceiver receiver,
boolean showEntitlementUi) {
+ if (mConnector == null) {
+ Slog.wtf(TAG, "Tethering not ready yet");
+ return;
+ }
try {
mConnector.requestLatestTetheringEntitlementResult(type, receiver, showEntitlementUi);
} catch (RemoteException e) {
diff --git a/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java b/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java
index 7c78ef8..743fd6a 100644
--- a/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java
+++ b/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java
@@ -456,7 +456,7 @@
mLog.e("setWifiTethering: failed to get WifiManager!");
return TETHER_ERROR_SERVICE_UNAVAIL;
}
- if ((enable && mgr.startSoftAp(null /* use existing wifi config */))
+ if ((enable && mgr.startTetheredHotspot(null /* use existing softap config */))
|| (!enable && mgr.stopSoftAp())) {
mWifiTetherRequested = enable;
return TETHER_ERROR_NO_ERROR;
diff --git a/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringTest.java b/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringTest.java
index 0273ed3..cdbc541 100644
--- a/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringTest.java
+++ b/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringTest.java
@@ -94,7 +94,7 @@
import android.net.util.InterfaceParams;
import android.net.util.NetworkConstants;
import android.net.util.SharedLog;
-import android.net.wifi.WifiConfiguration;
+import android.net.wifi.SoftApConfiguration;
import android.net.wifi.WifiManager;
import android.net.wifi.p2p.WifiP2pGroup;
import android.net.wifi.p2p.WifiP2pInfo;
@@ -806,12 +806,12 @@
// TODO: Test with and without interfaceStatusChanged().
@Test
public void failingWifiTetheringLegacyApBroadcast() throws Exception {
- when(mWifiManager.startSoftAp(any(WifiConfiguration.class))).thenReturn(true);
+ when(mWifiManager.startTetheredHotspot(any(SoftApConfiguration.class))).thenReturn(true);
// Emulate pressing the WiFi tethering button.
mTethering.startTethering(TETHERING_WIFI, null, false);
mLooper.dispatchAll();
- verify(mWifiManager, times(1)).startSoftAp(null);
+ verify(mWifiManager, times(1)).startTetheredHotspot(null);
verifyNoMoreInteractions(mWifiManager);
verifyNoMoreInteractions(mNMService);
@@ -833,12 +833,12 @@
// TODO: Test with and without interfaceStatusChanged().
@Test
public void workingWifiTetheringEnrichedApBroadcast() throws Exception {
- when(mWifiManager.startSoftAp(any(WifiConfiguration.class))).thenReturn(true);
+ when(mWifiManager.startTetheredHotspot(any(SoftApConfiguration.class))).thenReturn(true);
// Emulate pressing the WiFi tethering button.
mTethering.startTethering(TETHERING_WIFI, null, false);
mLooper.dispatchAll();
- verify(mWifiManager, times(1)).startSoftAp(null);
+ verify(mWifiManager, times(1)).startTetheredHotspot(null);
verifyNoMoreInteractions(mWifiManager);
verifyNoMoreInteractions(mNMService);
@@ -907,13 +907,13 @@
// TODO: Test with and without interfaceStatusChanged().
@Test
public void failureEnablingIpForwarding() throws Exception {
- when(mWifiManager.startSoftAp(any(WifiConfiguration.class))).thenReturn(true);
+ when(mWifiManager.startTetheredHotspot(any(SoftApConfiguration.class))).thenReturn(true);
doThrow(new RemoteException()).when(mNMService).setIpForwardingEnabled(true);
// Emulate pressing the WiFi tethering button.
mTethering.startTethering(TETHERING_WIFI, null, false);
mLooper.dispatchAll();
- verify(mWifiManager, times(1)).startSoftAp(null);
+ verify(mWifiManager, times(1)).startTetheredHotspot(null);
verifyNoMoreInteractions(mWifiManager);
verifyNoMoreInteractions(mNMService);
@@ -1155,7 +1155,7 @@
when(mUpstreamNetworkMonitor.getCurrentPreferredUpstream()).thenReturn(upstreamState);
when(mUpstreamNetworkMonitor.selectPreferredUpstreamType(any()))
.thenReturn(upstreamState);
- when(mWifiManager.startSoftAp(any(WifiConfiguration.class))).thenReturn(true);
+ when(mWifiManager.startTetheredHotspot(any(SoftApConfiguration.class))).thenReturn(true);
mTethering.interfaceStatusChanged(TEST_WLAN_IFNAME, true);
mLooper.dispatchAll();
tetherState = callback.pollTetherStatesChanged();
diff --git a/services/Android.bp b/services/Android.bp
index fd4094f..8376d2b 100644
--- a/services/Android.bp
+++ b/services/Android.bp
@@ -111,7 +111,7 @@
srcs: [":services-sources"],
installable: false,
// TODO: remove the --hide options below
- args: " --show-single-annotation android.annotation.SystemApi" +
+ args: " --show-single-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.INTERNAL,process=android.annotation.SystemApi.Process.SYSTEM_SERVER\\)" +
" --hide-annotation android.annotation.Hide" +
" --hide-package com.google.android.startop.iorap" +
" --hide ReferencesHidden" +
diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/AccessibilityGestureDetector.java b/services/accessibility/java/com/android/server/accessibility/gestures/AccessibilityGestureDetector.java
deleted file mode 100644
index 3dfe59e..0000000
--- a/services/accessibility/java/com/android/server/accessibility/gestures/AccessibilityGestureDetector.java
+++ /dev/null
@@ -1,640 +0,0 @@
-/*
- ** Copyright 2015, 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 com.android.server.accessibility.gestures;
-
-import android.accessibilityservice.AccessibilityGestureEvent;
-import android.accessibilityservice.AccessibilityService;
-import android.content.Context;
-import android.gesture.GesturePoint;
-import android.graphics.PointF;
-import android.util.Slog;
-import android.util.TypedValue;
-import android.view.GestureDetector;
-import android.view.MotionEvent;
-
-import java.util.ArrayList;
-
-/**
- * This class handles gesture detection for the Touch Explorer. It collects
- * touch events and determines when they match a gesture, as well as when they
- * won't match a gesture. These state changes are then surfaced to mListener.
- */
-class AccessibilityGestureDetector extends GestureDetector.SimpleOnGestureListener {
-
- private static final boolean DEBUG = false;
-
- // Tag for logging received events.
- private static final String LOG_TAG = "AccessibilityGestureDetector";
-
- // Constants for sampling motion event points.
- // We sample based on a minimum distance between points, primarily to improve accuracy by
- // reducing noisy minor changes in direction.
- private static final float MIN_INCHES_BETWEEN_SAMPLES = 0.1f;
- private final float mMinPixelsBetweenSamplesX;
- private final float mMinPixelsBetweenSamplesY;
-
- // Constants for separating gesture segments
- private static final float ANGLE_THRESHOLD = 0.0f;
-
- // Constants for line segment directions
- private static final int LEFT = 0;
- private static final int RIGHT = 1;
- private static final int UP = 2;
- private static final int DOWN = 3;
- private static final int[][] DIRECTIONS_TO_GESTURE_ID = {
- {
- AccessibilityService.GESTURE_SWIPE_LEFT,
- AccessibilityService.GESTURE_SWIPE_LEFT_AND_RIGHT,
- AccessibilityService.GESTURE_SWIPE_LEFT_AND_UP,
- AccessibilityService.GESTURE_SWIPE_LEFT_AND_DOWN
- },
- {
- AccessibilityService.GESTURE_SWIPE_RIGHT_AND_LEFT,
- AccessibilityService.GESTURE_SWIPE_RIGHT,
- AccessibilityService.GESTURE_SWIPE_RIGHT_AND_UP,
- AccessibilityService.GESTURE_SWIPE_RIGHT_AND_DOWN
- },
- {
- AccessibilityService.GESTURE_SWIPE_UP_AND_LEFT,
- AccessibilityService.GESTURE_SWIPE_UP_AND_RIGHT,
- AccessibilityService.GESTURE_SWIPE_UP,
- AccessibilityService.GESTURE_SWIPE_UP_AND_DOWN
- },
- {
- AccessibilityService.GESTURE_SWIPE_DOWN_AND_LEFT,
- AccessibilityService.GESTURE_SWIPE_DOWN_AND_RIGHT,
- AccessibilityService.GESTURE_SWIPE_DOWN_AND_UP,
- AccessibilityService.GESTURE_SWIPE_DOWN
- }
- };
-
-
- /**
- * Listener functions are called as a result of onMoveEvent(). The current
- * MotionEvent in the context of these functions is the event passed into
- * onMotionEvent.
- */
- public interface Listener {
- /**
- * Called when the user has performed a double tap and then held down
- * the second tap.
- *
- * @param event The most recent MotionEvent received.
- * @param policyFlags The policy flags of the most recent event.
- */
- void onDoubleTapAndHold(MotionEvent event, int policyFlags);
-
- /**
- * Called when the user lifts their finger on the second tap of a double
- * tap.
- *
- * @param event The most recent MotionEvent received.
- * @param policyFlags The policy flags of the most recent event.
- *
- * @return true if the event is consumed, else false
- */
- boolean onDoubleTap(MotionEvent event, int policyFlags);
-
- /**
- * Called when the system has decided the event stream is a gesture.
- *
- * @return true if the event is consumed, else false
- */
- boolean onGestureStarted();
-
- /**
- * Called when an event stream is recognized as a gesture.
- *
- * @param gestureEvent Information about the gesture.
- *
- * @return true if the event is consumed, else false
- */
- boolean onGestureCompleted(AccessibilityGestureEvent gestureEvent);
-
- /**
- * Called when the system has decided an event stream doesn't match any
- * known gesture.
- *
- * @param event The most recent MotionEvent received.
- * @param policyFlags The policy flags of the most recent event.
- *
- * @return true if the event is consumed, else false
- */
- public boolean onGestureCancelled(MotionEvent event, int policyFlags);
- }
-
- private final Listener mListener;
- private final Context mContext; // Retained for on-demand construction of GestureDetector.
- private final GestureDetector mGestureDetector; // Double-tap detector.
-
- // Indicates that a single tap has occurred.
- private boolean mFirstTapDetected;
-
- // Indicates that the down event of a double tap has occured.
- private boolean mDoubleTapDetected;
-
- // Indicates that motion events are being collected to match a gesture.
- private boolean mRecognizingGesture;
-
- // Indicates that we've collected enough data to be sure it could be a
- // gesture.
- private boolean mGestureStarted;
-
- // Indicates that motion events from the second pointer are being checked
- // for a double tap.
- private boolean mSecondFingerDoubleTap;
-
- // Tracks the most recent time where ACTION_POINTER_DOWN was sent for the
- // second pointer.
- private long mSecondPointerDownTime;
-
- // Policy flags of the previous event.
- private int mPolicyFlags;
-
- // These values track the previous point that was saved to use for gesture
- // detection. They are only updated when the user moves more than the
- // recognition threshold.
- private float mPreviousGestureX;
- private float mPreviousGestureY;
-
- // These values track the previous point that was used to determine if there
- // was a transition into or out of gesture detection. They are updated when
- // the user moves more than the detection threshold.
- private float mBaseX;
- private float mBaseY;
- private long mBaseTime;
-
- // This is the calculated movement threshold used track if the user is still
- // moving their finger.
- private final float mGestureDetectionThreshold;
-
- // Buffer for storing points for gesture detection.
- private final ArrayList<GesturePoint> mStrokeBuffer = new ArrayList<GesturePoint>(100);
-
- // The minimal delta between moves to add a gesture point.
- private static final int TOUCH_TOLERANCE = 3;
-
- // The minimal score for accepting a predicted gesture.
- private static final float MIN_PREDICTION_SCORE = 2.0f;
-
- // Distance a finger must travel before we decide if it is a gesture or not.
- private static final int GESTURE_CONFIRM_MM = 10;
-
- // Time threshold used to determine if an interaction is a gesture or not.
- // If the first movement of 1cm takes longer than this value, we assume it's
- // a slow movement, and therefore not a gesture.
- //
- // This value was determined by measuring the time for the first 1cm
- // movement when gesturing, and touch exploring. Based on user testing,
- // all gestures started with the initial movement taking less than 100ms.
- // When touch exploring, the first movement almost always takes longer than
- // 200ms.
- private static final long CANCEL_ON_PAUSE_THRESHOLD_NOT_STARTED_MS = 150;
-
- // Time threshold used to determine if a gesture should be cancelled. If
- // the finger takes more than this time to move 1cm, the ongoing gesture is
- // cancelled.
- private static final long CANCEL_ON_PAUSE_THRESHOLD_STARTED_MS = 300;
-
- /**
- * Construct the gesture detector for {@link TouchExplorer}.
- *
- * @see #AccessibilityGestureDetector(Context, Listener, GestureDetector)
- */
- AccessibilityGestureDetector(Context context, Listener listener) {
- this(context, listener, null);
- }
-
- /**
- * Construct the gesture detector for {@link TouchExplorer}.
- *
- * @param context A context handle for accessing resources.
- * @param listener A listener to callback with gesture state or information.
- * @param detector The gesture detector to handle touch event. If null the default one created
- * in place, or for testing purpose.
- */
- AccessibilityGestureDetector(Context context, Listener listener, GestureDetector detector) {
- mListener = listener;
- mContext = context;
-
- // Break the circular dependency between constructors and let the class to be testable
- if (detector == null) {
- mGestureDetector = new GestureDetector(context, this);
- } else {
- mGestureDetector = detector;
- }
- mGestureDetector.setOnDoubleTapListener(this);
- mGestureDetectionThreshold = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, 1,
- context.getResources().getDisplayMetrics()) * GESTURE_CONFIRM_MM;
-
- // Calculate minimum gesture velocity
- final float pixelsPerInchX = context.getResources().getDisplayMetrics().xdpi;
- final float pixelsPerInchY = context.getResources().getDisplayMetrics().ydpi;
- mMinPixelsBetweenSamplesX = MIN_INCHES_BETWEEN_SAMPLES * pixelsPerInchX;
- mMinPixelsBetweenSamplesY = MIN_INCHES_BETWEEN_SAMPLES * pixelsPerInchY;
- }
-
- /**
- * Handle a motion event. If an action is completed, the appropriate
- * callback on mListener is called, and the return value of the callback is
- * passed to the caller.
- *
- * @param event The transformed motion event to be handled.
- * @param rawEvent The raw motion event. It's important that this be the raw
- * event, before any transformations have been applied, so that measurements
- * can be made in physical units.
- * @param policyFlags Policy flags for the event.
- *
- * @return true if the event is consumed, else false
- */
- public boolean onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
- // The accessibility gesture detector is interested in the movements in physical space,
- // so it uses the rawEvent to ignore magnification and other transformations.
- final float x = rawEvent.getX();
- final float y = rawEvent.getY();
- final long time = rawEvent.getEventTime();
-
- mPolicyFlags = policyFlags;
- switch (rawEvent.getActionMasked()) {
- case MotionEvent.ACTION_DOWN:
- mDoubleTapDetected = false;
- mSecondFingerDoubleTap = false;
- mRecognizingGesture = true;
- mGestureStarted = false;
- mPreviousGestureX = x;
- mPreviousGestureY = y;
- mStrokeBuffer.clear();
- mStrokeBuffer.add(new GesturePoint(x, y, time));
-
- mBaseX = x;
- mBaseY = y;
- mBaseTime = time;
- break;
-
- case MotionEvent.ACTION_MOVE:
- if (mRecognizingGesture) {
- final float deltaX = mBaseX - x;
- final float deltaY = mBaseY - y;
- final double moveDelta = Math.hypot(deltaX, deltaY);
- if (moveDelta > mGestureDetectionThreshold) {
- // If the pointer has moved more than the threshold,
- // update the stored values.
- mBaseX = x;
- mBaseY = y;
- mBaseTime = time;
-
- // Since the pointer has moved, this is not a double
- // tap.
- mFirstTapDetected = false;
- mDoubleTapDetected = false;
-
- // If this hasn't been confirmed as a gesture yet, send
- // the event.
- if (!mGestureStarted) {
- mGestureStarted = true;
- return mListener.onGestureStarted();
- }
- } else if (!mFirstTapDetected) {
- // The finger may not move if they are double tapping.
- // In that case, we shouldn't cancel the gesture.
- final long timeDelta = time - mBaseTime;
- final long threshold = mGestureStarted ?
- CANCEL_ON_PAUSE_THRESHOLD_STARTED_MS :
- CANCEL_ON_PAUSE_THRESHOLD_NOT_STARTED_MS;
-
- // If the pointer hasn't moved for longer than the
- // timeout, cancel gesture detection.
- if (timeDelta > threshold) {
- cancelGesture();
- return mListener.onGestureCancelled(rawEvent, policyFlags);
- }
- }
-
- final float dX = Math.abs(x - mPreviousGestureX);
- final float dY = Math.abs(y - mPreviousGestureY);
- if (dX >= mMinPixelsBetweenSamplesX || dY >= mMinPixelsBetweenSamplesY) {
- mPreviousGestureX = x;
- mPreviousGestureY = y;
- mStrokeBuffer.add(new GesturePoint(x, y, time));
- }
- }
- break;
-
- case MotionEvent.ACTION_UP:
- if (mDoubleTapDetected) {
- return finishDoubleTap(rawEvent, policyFlags);
- }
- if (mGestureStarted) {
- final float dX = Math.abs(x - mPreviousGestureX);
- final float dY = Math.abs(y - mPreviousGestureY);
- if (dX >= mMinPixelsBetweenSamplesX || dY >= mMinPixelsBetweenSamplesY) {
- mStrokeBuffer.add(new GesturePoint(x, y, time));
- }
- return recognizeGesture(rawEvent, policyFlags);
- }
- break;
-
- case MotionEvent.ACTION_POINTER_DOWN:
- // Once a second finger is used, we're definitely not
- // recognizing a gesture.
- cancelGesture();
-
- if (rawEvent.getPointerCount() == 2) {
- // If this was the second finger, attempt to recognize double
- // taps on it.
- mSecondFingerDoubleTap = true;
- mSecondPointerDownTime = time;
- } else {
- // If there are more than two fingers down, stop watching
- // for a double tap.
- mSecondFingerDoubleTap = false;
- }
- break;
-
- case MotionEvent.ACTION_POINTER_UP:
- // If we're detecting taps on the second finger, see if we
- // should finish the double tap.
- if (mSecondFingerDoubleTap && mDoubleTapDetected) {
- return finishDoubleTap(rawEvent, policyFlags);
- }
- break;
-
- case MotionEvent.ACTION_CANCEL:
- clear();
- break;
- }
-
- // If we're detecting taps on the second finger, map events from the
- // finger to the first finger.
- if (mSecondFingerDoubleTap) {
- MotionEvent newEvent = mapSecondPointerToFirstPointer(rawEvent);
- if (newEvent == null) {
- return false;
- }
- boolean handled = mGestureDetector.onTouchEvent(newEvent);
- newEvent.recycle();
- return handled;
- }
-
- if (!mRecognizingGesture) {
- return false;
- }
-
- // Pass the transformed event on to the standard gesture detector.
- return mGestureDetector.onTouchEvent(event);
- }
-
- public void clear() {
- mFirstTapDetected = false;
- mDoubleTapDetected = false;
- mSecondFingerDoubleTap = false;
- mGestureStarted = false;
- mGestureDetector.onTouchEvent(MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_CANCEL,
- 0.0f, 0.0f, 0));
- cancelGesture();
- }
-
-
- @Override
- public void onLongPress(MotionEvent e) {
- maybeSendLongPress(e, mPolicyFlags);
- }
-
- @Override
- public boolean onSingleTapUp(MotionEvent event) {
- mFirstTapDetected = true;
- return false;
- }
-
- @Override
- public boolean onSingleTapConfirmed(MotionEvent event) {
- clear();
- return false;
- }
-
- @Override
- public boolean onDoubleTap(MotionEvent event) {
- // The processing of the double tap is deferred until the finger is
- // lifted, so that we can detect a long press on the second tap.
- mDoubleTapDetected = true;
- return false;
- }
-
- private void maybeSendLongPress(MotionEvent event, int policyFlags) {
- if (!mDoubleTapDetected) {
- return;
- }
-
- clear();
-
- mListener.onDoubleTapAndHold(event, policyFlags);
- }
-
- private boolean finishDoubleTap(MotionEvent event, int policyFlags) {
- clear();
-
- return mListener.onDoubleTap(event, policyFlags);
- }
-
- private void cancelGesture() {
- mRecognizingGesture = false;
- mGestureStarted = false;
- mStrokeBuffer.clear();
- }
-
- /**
- * Looks at the sequence of motions in mStrokeBuffer, classifies the gesture, then calls
- * Listener callbacks for success or failure.
- *
- * @param event The raw motion event to pass to the listener callbacks.
- * @param policyFlags Policy flags for the event.
- *
- * @return true if the event is consumed, else false
- */
- private boolean recognizeGesture(MotionEvent event, int policyFlags) {
- if (mStrokeBuffer.size() < 2) {
- return mListener.onGestureCancelled(event, policyFlags);
- }
-
- // Look at mStrokeBuffer and extract 2 line segments, delimited by near-perpendicular
- // direction change.
- // Method: for each sampled motion event, check the angle of the most recent motion vector
- // versus the preceding motion vector, and segment the line if the angle is about
- // 90 degrees.
-
- ArrayList<PointF> path = new ArrayList<>();
- PointF lastDelimiter = new PointF(mStrokeBuffer.get(0).x, mStrokeBuffer.get(0).y);
- path.add(lastDelimiter);
-
- float dX = 0; // Sum of unit vectors from last delimiter to each following point
- float dY = 0;
- int count = 0; // Number of points since last delimiter
- float length = 0; // Vector length from delimiter to most recent point
-
- PointF next = new PointF();
- for (int i = 1; i < mStrokeBuffer.size(); ++i) {
- next = new PointF(mStrokeBuffer.get(i).x, mStrokeBuffer.get(i).y);
- if (count > 0) {
- // Average of unit vectors from delimiter to following points
- float currentDX = dX / count;
- float currentDY = dY / count;
-
- // newDelimiter is a possible new delimiter, based on a vector with length from
- // the last delimiter to the previous point, but in the direction of the average
- // unit vector from delimiter to previous points.
- // Using the averaged vector has the effect of "squaring off the curve",
- // creating a sharper angle between the last motion and the preceding motion from
- // the delimiter. In turn, this sharper angle achieves the splitting threshold
- // even in a gentle curve.
- PointF newDelimiter = new PointF(length * currentDX + lastDelimiter.x,
- length * currentDY + lastDelimiter.y);
-
- // Unit vector from newDelimiter to the most recent point
- float nextDX = next.x - newDelimiter.x;
- float nextDY = next.y - newDelimiter.y;
- float nextLength = (float) Math.sqrt(nextDX * nextDX + nextDY * nextDY);
- nextDX = nextDX / nextLength;
- nextDY = nextDY / nextLength;
-
- // Compare the initial motion direction to the most recent motion direction,
- // and segment the line if direction has changed by about 90 degrees.
- float dot = currentDX * nextDX + currentDY * nextDY;
- if (dot < ANGLE_THRESHOLD) {
- path.add(newDelimiter);
- lastDelimiter = newDelimiter;
- dX = 0;
- dY = 0;
- count = 0;
- }
- }
-
- // Vector from last delimiter to most recent point
- float currentDX = next.x - lastDelimiter.x;
- float currentDY = next.y - lastDelimiter.y;
- length = (float) Math.sqrt(currentDX * currentDX + currentDY * currentDY);
-
- // Increment sum of unit vectors from delimiter to each following point
- count = count + 1;
- dX = dX + currentDX / length;
- dY = dY + currentDY / length;
- }
-
- path.add(next);
- Slog.i(LOG_TAG, "path=" + path.toString());
-
- // Classify line segments, and call Listener callbacks.
- return recognizeGesturePath(event, policyFlags, path);
- }
-
- /**
- * Classifies a pair of line segments, by direction.
- * Calls Listener callbacks for success or failure.
- *
- * @param event The raw motion event to pass to the listener's onGestureCanceled method.
- * @param policyFlags Policy flags for the event.
- * @param path A sequence of motion line segments derived from motion points in mStrokeBuffer.
- *
- * @return true if the event is consumed, else false
- */
- private boolean recognizeGesturePath(MotionEvent event, int policyFlags,
- ArrayList<PointF> path) {
-
- final int displayId = event.getDisplayId();
- if (path.size() == 2) {
- PointF start = path.get(0);
- PointF end = path.get(1);
-
- float dX = end.x - start.x;
- float dY = end.y - start.y;
- int direction = toDirection(dX, dY);
- switch (direction) {
- case LEFT:
- return mListener.onGestureCompleted(
- new AccessibilityGestureEvent(AccessibilityService.GESTURE_SWIPE_LEFT,
- displayId));
- case RIGHT:
- return mListener.onGestureCompleted(
- new AccessibilityGestureEvent(AccessibilityService.GESTURE_SWIPE_RIGHT,
- displayId));
- case UP:
- return mListener.onGestureCompleted(
- new AccessibilityGestureEvent(AccessibilityService.GESTURE_SWIPE_UP,
- displayId));
- case DOWN:
- return mListener.onGestureCompleted(
- new AccessibilityGestureEvent(AccessibilityService.GESTURE_SWIPE_DOWN,
- displayId));
- default:
- // Do nothing.
- }
-
- } else if (path.size() == 3) {
- PointF start = path.get(0);
- PointF mid = path.get(1);
- PointF end = path.get(2);
-
- float dX0 = mid.x - start.x;
- float dY0 = mid.y - start.y;
-
- float dX1 = end.x - mid.x;
- float dY1 = end.y - mid.y;
-
- int segmentDirection0 = toDirection(dX0, dY0);
- int segmentDirection1 = toDirection(dX1, dY1);
- int gestureId = DIRECTIONS_TO_GESTURE_ID[segmentDirection0][segmentDirection1];
- return mListener.onGestureCompleted(
- new AccessibilityGestureEvent(gestureId, displayId));
- }
- // else if (path.size() < 2 || 3 < path.size()) then no gesture recognized.
- return mListener.onGestureCancelled(event, policyFlags);
- }
-
- /** Maps a vector to a dominant direction in set {LEFT, RIGHT, UP, DOWN}. */
- private static int toDirection(float dX, float dY) {
- if (Math.abs(dX) > Math.abs(dY)) {
- // Horizontal
- return (dX < 0) ? LEFT : RIGHT;
- } else {
- // Vertical
- return (dY < 0) ? UP : DOWN;
- }
- }
-
- private MotionEvent mapSecondPointerToFirstPointer(MotionEvent event) {
- // Only map basic events when two fingers are down.
- if (event.getPointerCount() != 2 ||
- (event.getActionMasked() != MotionEvent.ACTION_POINTER_DOWN &&
- event.getActionMasked() != MotionEvent.ACTION_POINTER_UP &&
- event.getActionMasked() != MotionEvent.ACTION_MOVE)) {
- return null;
- }
-
- int action = event.getActionMasked();
-
- if (action == MotionEvent.ACTION_POINTER_DOWN) {
- action = MotionEvent.ACTION_DOWN;
- } else if (action == MotionEvent.ACTION_POINTER_UP) {
- action = MotionEvent.ACTION_UP;
- }
-
- // Map the information from the second pointer to the first.
- return MotionEvent.obtain(mSecondPointerDownTime, event.getEventTime(), action,
- event.getX(1), event.getY(1), event.getPressure(1), event.getSize(1),
- event.getMetaState(), event.getXPrecision(), event.getYPrecision(),
- event.getDeviceId(), event.getEdgeFlags());
- }
-}
diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/GestureManifold.java b/services/accessibility/java/com/android/server/accessibility/gestures/GestureManifold.java
new file mode 100644
index 0000000..9b7adc8
--- /dev/null
+++ b/services/accessibility/java/com/android/server/accessibility/gestures/GestureManifold.java
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2019 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 com.android.server.accessibility.gestures;
+
+import static android.accessibilityservice.AccessibilityService.GESTURE_DOUBLE_TAP;
+import static android.accessibilityservice.AccessibilityService.GESTURE_DOUBLE_TAP_AND_HOLD;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_DOWN;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_DOWN_AND_LEFT;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_DOWN_AND_RIGHT;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_DOWN_AND_UP;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_LEFT;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_LEFT_AND_DOWN;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_LEFT_AND_RIGHT;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_LEFT_AND_UP;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_RIGHT;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_RIGHT_AND_DOWN;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_RIGHT_AND_LEFT;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_RIGHT_AND_UP;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_UP;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_UP_AND_DOWN;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_UP_AND_LEFT;
+import static android.accessibilityservice.AccessibilityService.GESTURE_SWIPE_UP_AND_RIGHT;
+
+import static com.android.server.accessibility.gestures.Swipe.DOWN;
+import static com.android.server.accessibility.gestures.Swipe.LEFT;
+import static com.android.server.accessibility.gestures.Swipe.RIGHT;
+import static com.android.server.accessibility.gestures.Swipe.UP;
+import static com.android.server.accessibility.gestures.TouchExplorer.DEBUG;
+
+import android.accessibilityservice.AccessibilityGestureEvent;
+import android.content.Context;
+import android.os.Handler;
+import android.util.Slog;
+import android.view.MotionEvent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This class coordinates a series of individual gesture matchers to serve as a unified gesture
+ * detector. Gesture matchers are tied to a single gesture. It calls listener callback functions
+ * when a gesture starts or completes.
+ */
+class GestureManifold implements GestureMatcher.StateChangeListener {
+
+ private static final String LOG_TAG = "GestureManifold";
+
+ private final List<GestureMatcher> mGestures = new ArrayList<>();
+ private final Context mContext;
+ // Handler for performing asynchronous operations.
+ private final Handler mHandler;
+ // Listener to be notified of gesture start and end.
+ private Listener mListener;
+ // Shared state information.
+ private TouchState mState;
+
+ GestureManifold(Context context, Listener listener, TouchState state) {
+ mContext = context;
+ mHandler = new Handler(context.getMainLooper());
+ mListener = listener;
+ mState = state;
+ // Set up gestures.
+ // Start with double tap.
+ mGestures.add(new MultiTap(context, 2, GESTURE_DOUBLE_TAP, this));
+ mGestures.add(new MultiTapAndHold(context, 2, GESTURE_DOUBLE_TAP_AND_HOLD, this));
+ // One-direction swipes.
+ mGestures.add(new Swipe(context, RIGHT, GESTURE_SWIPE_RIGHT, this));
+ mGestures.add(new Swipe(context, LEFT, GESTURE_SWIPE_LEFT, this));
+ mGestures.add(new Swipe(context, UP, GESTURE_SWIPE_UP, this));
+ mGestures.add(new Swipe(context, DOWN, GESTURE_SWIPE_DOWN, this));
+ // Two-direction swipes.
+ mGestures.add(new Swipe(context, LEFT, RIGHT, GESTURE_SWIPE_LEFT_AND_RIGHT, this));
+ mGestures.add(new Swipe(context, LEFT, UP, GESTURE_SWIPE_LEFT_AND_UP, this));
+ mGestures.add(new Swipe(context, LEFT, DOWN, GESTURE_SWIPE_LEFT_AND_DOWN, this));
+ mGestures.add(new Swipe(context, RIGHT, UP, GESTURE_SWIPE_RIGHT_AND_UP, this));
+ mGestures.add(new Swipe(context, RIGHT, DOWN, GESTURE_SWIPE_RIGHT_AND_DOWN, this));
+ mGestures.add(new Swipe(context, RIGHT, LEFT, GESTURE_SWIPE_RIGHT_AND_LEFT, this));
+ mGestures.add(new Swipe(context, DOWN, UP, GESTURE_SWIPE_DOWN_AND_UP, this));
+ mGestures.add(new Swipe(context, DOWN, LEFT, GESTURE_SWIPE_DOWN_AND_LEFT, this));
+ mGestures.add(new Swipe(context, DOWN, RIGHT, GESTURE_SWIPE_DOWN_AND_RIGHT, this));
+ mGestures.add(new Swipe(context, UP, DOWN, GESTURE_SWIPE_UP_AND_DOWN, this));
+ mGestures.add(new Swipe(context, UP, LEFT, GESTURE_SWIPE_UP_AND_LEFT, this));
+ mGestures.add(new Swipe(context, UP, RIGHT, GESTURE_SWIPE_UP_AND_RIGHT, this));
+ }
+
+ /**
+ * Processes a motion event.
+ *
+ * @param event The event as received from the previous entry in the event stream.
+ * @param rawEvent The event without any transformations e.g. magnification.
+ * @param policyFlags
+ * @return True if the event has been appropriately handled by the gesture manifold and related
+ * callback functions, false if it should be handled further by the calling function.
+ */
+ boolean onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ if (mState.isClear()) {
+ if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
+ // Sanity safeguard: if touch state is clear, then matchers should always be clear
+ // before processing the next down event.
+ clear();
+ } else {
+ // If for some reason other events come through while in the clear state they could
+ // compromise the state of particular matchers, so we just ignore them.
+ return false;
+ }
+ }
+ for (GestureMatcher matcher : mGestures) {
+ if (matcher.getState() != GestureMatcher.STATE_GESTURE_CANCELED) {
+ if (DEBUG) {
+ Slog.d(LOG_TAG, matcher.toString());
+ }
+ matcher.onMotionEvent(event, rawEvent, policyFlags);
+ if (DEBUG) {
+ Slog.d(LOG_TAG, matcher.toString());
+ }
+ if (matcher.getState() == GestureMatcher.STATE_GESTURE_COMPLETED) {
+ // Here we just clear and return. The actual gesture dispatch is done in
+ // onStateChanged().
+ clear();
+ // No need to process this event any further.
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public void clear() {
+ for (GestureMatcher matcher : mGestures) {
+ matcher.clear();
+ }
+ }
+
+ /**
+ * Listener that receives notifications of the state of the gesture detector. Listener functions
+ * are called as a result of onMotionEvent(). The current MotionEvent in the context of these
+ * functions is the event passed into onMotionEvent.
+ */
+ public interface Listener {
+ /**
+ * Called when the user has performed a double tap and then held down the second tap.
+ */
+ void onDoubleTapAndHold();
+
+ /**
+ * Called when the user lifts their finger on the second tap of a double tap.
+ * @return true if the event is consumed, else false
+ */
+ boolean onDoubleTap();
+
+ /**
+ * Called when the system has decided the event stream is a gesture.
+ *
+ * @return true if the event is consumed, else false
+ */
+ boolean onGestureStarted();
+
+ /**
+ * Called when an event stream is recognized as a gesture.
+ *
+ * @param gestureEvent Information about the gesture.
+ * @return true if the event is consumed, else false
+ */
+ boolean onGestureCompleted(AccessibilityGestureEvent gestureEvent);
+
+ /**
+ * Called when the system has decided an event stream doesn't match any known gesture.
+ *
+ * @param event The most recent MotionEvent received.
+ * @param policyFlags The policy flags of the most recent event.
+ * @return true if the event is consumed, else false
+ */
+ boolean onGestureCancelled(MotionEvent event, MotionEvent rawEvent, int policyFlags);
+ }
+
+ @Override
+ public void onStateChanged(
+ int gestureId, int state, MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ if (state == GestureMatcher.STATE_GESTURE_STARTED && !mState.isGestureDetecting()) {
+ mListener.onGestureStarted();
+ } else if (state == GestureMatcher.STATE_GESTURE_COMPLETED) {
+ onGestureCompleted(gestureId);
+ } else if (state == GestureMatcher.STATE_GESTURE_CANCELED && mState.isGestureDetecting()) {
+ // We only want to call the cancelation callback if there are no other pending
+ // detectors.
+ for (GestureMatcher matcher : mGestures) {
+ if (matcher.getState() == GestureMatcher.STATE_GESTURE_STARTED) {
+ return;
+ }
+ }
+ if (DEBUG) {
+ Slog.d(LOG_TAG, "Cancelling.");
+ }
+ mListener.onGestureCancelled(event, rawEvent, policyFlags);
+ }
+ }
+
+ private void onGestureCompleted(int gestureId) {
+ MotionEvent event = mState.getLastReceivedEvent();
+ // Note that gestures that complete immediately call clear() from onMotionEvent.
+ // Gestures that complete on a delay call clear() here.
+ switch (gestureId) {
+ case GESTURE_DOUBLE_TAP:
+ mListener.onDoubleTap();
+ clear();
+ break;
+ case GESTURE_DOUBLE_TAP_AND_HOLD:
+ mListener.onDoubleTapAndHold();
+ clear();
+ break;
+ default:
+ AccessibilityGestureEvent gestureEvent =
+ new AccessibilityGestureEvent(gestureId, event.getDisplayId());
+ mListener.onGestureCompleted(gestureEvent);
+ break;
+ }
+ }
+}
diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/GestureMatcher.java b/services/accessibility/java/com/android/server/accessibility/gestures/GestureMatcher.java
new file mode 100644
index 0000000..0b30ff57
--- /dev/null
+++ b/services/accessibility/java/com/android/server/accessibility/gestures/GestureMatcher.java
@@ -0,0 +1,371 @@
+/*
+ * Copyright (C) 2019 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 com.android.server.accessibility.gestures;
+
+import static com.android.server.accessibility.gestures.TouchExplorer.DEBUG;
+
+import android.annotation.IntDef;
+import android.os.Handler;
+import android.util.Slog;
+import android.view.MotionEvent;
+import android.view.ViewConfiguration;
+
+/**
+ * This class describes a common base for gesture matchers. A gesture matcher checks a series of
+ * motion events against a single gesture. Coordinating the individual gesture matchers is done by
+ * the GestureManifold. To create a new Gesture, extend this class and override the onDown, onMove,
+ * onUp, etc methods as necessary. If you don't override a method your matcher will do nothing in
+ * response to that type of event. Finally, be sure to give your gesture a name by overriding
+ * getGestureName().
+ */
+abstract class GestureMatcher {
+ // Potential states for this individual gesture matcher.
+ // In STATE_CLEAR, this matcher is accepting new motion events but has not formally signaled
+ // that there is enough data to judge that a gesture has started.
+ static final int STATE_CLEAR = 0;
+ // In STATE_GESTURE_STARTED, this matcher continues to accept motion events and it has signaled
+ // to the gesture manifold that what looks like the specified gesture has started.
+ static final int STATE_GESTURE_STARTED = 1;
+ // In STATE_GESTURE_COMPLETED, this matcher has successfully matched the specified gesture. and
+ // will not accept motion events until it is cleared.
+ static final int STATE_GESTURE_COMPLETED = 2;
+ // In STATE_GESTURE_CANCELED, this matcher will not accept new motion events because it is
+ // impossible that this set of motion events will match the specified gesture.
+ static final int STATE_GESTURE_CANCELED = 3;
+
+ @IntDef({STATE_CLEAR, STATE_GESTURE_STARTED, STATE_GESTURE_COMPLETED, STATE_GESTURE_CANCELED})
+ public @interface State {}
+
+ @State private int mState = STATE_CLEAR;
+ // The id number of the gesture that gets passed to accessibility services.
+ private final int mGestureId;
+ // handler for asynchronous operations like timeouts
+ private final Handler mHandler;
+
+ private final StateChangeListener mListener;
+
+ // Use this to transition to new states after a delay.
+ // e.g. cancel or complete after some timeout.
+ // Convenience functions for tapTimeout and doubleTapTimeout are already defined here.
+ protected final DelayedTransition mDelayedTransition;
+
+ GestureMatcher(int gestureId, Handler handler, StateChangeListener listener) {
+ mGestureId = gestureId;
+ mHandler = handler;
+ mDelayedTransition = new DelayedTransition();
+ mListener = listener;
+ }
+
+ /**
+ * Resets all state information for this matcher. Subclasses that include their own state
+ * information should override this method to reset their own state information and call
+ * super.clear().
+ */
+ protected void clear() {
+ mState = STATE_CLEAR;
+ cancelPendingTransitions();
+ }
+
+ public int getState() {
+ return mState;
+ }
+
+ /**
+ * Transitions to a new state and notifies any listeners. Note that any pending transitions are
+ * canceled.
+ */
+ private void setState(
+ @State int state, MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ mState = state;
+ cancelPendingTransitions();
+ mListener.onStateChanged(mGestureId, mState, event, rawEvent, policyFlags);
+ }
+
+ /** Indicates that there is evidence to suggest that this gesture has started. */
+ protected final void startGesture(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ setState(STATE_GESTURE_STARTED, event, rawEvent, policyFlags);
+ }
+
+ /** Indicates this stream of motion events can no longer match this gesture. */
+ protected final void cancelGesture(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ setState(STATE_GESTURE_CANCELED, event, rawEvent, policyFlags);
+ }
+
+ /** Indicates this gesture is completed. */
+ protected final void completeGesture(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ setState(STATE_GESTURE_COMPLETED, event, rawEvent, policyFlags);
+ }
+
+ public int getGestureId() {
+ return mGestureId;
+ }
+
+ /**
+ * Process a motion event and attempt to match it to this gesture.
+ *
+ * @param event the event as passed in from the event stream.
+ * @param rawEvent the original un-modified event. Useful for calculating movements in physical
+ * space.
+ * @param policyFlags the policy flags as passed in from the event stream.
+ * @return the state of this matcher.
+ */
+ public final int onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ if (mState == STATE_GESTURE_CANCELED || mState == STATE_GESTURE_COMPLETED) {
+ return mState;
+ }
+ switch (event.getActionMasked()) {
+ case MotionEvent.ACTION_DOWN:
+ onDown(event, rawEvent, policyFlags);
+ break;
+ case MotionEvent.ACTION_POINTER_DOWN:
+ onPointerDown(event, rawEvent, policyFlags);
+ break;
+ case MotionEvent.ACTION_MOVE:
+ onMove(event, rawEvent, policyFlags);
+ break;
+ case MotionEvent.ACTION_POINTER_UP:
+ onPointerUp(event, rawEvent, policyFlags);
+ break;
+ case MotionEvent.ACTION_UP:
+ onUp(event, rawEvent, policyFlags);
+ break;
+ default:
+ // Cancel because of invalid event.
+ setState(STATE_GESTURE_CANCELED, event, rawEvent, policyFlags);
+ break;
+ }
+ return mState;
+ }
+
+ /**
+ * Matchers override this method to respond to ACTION_DOWN events. ACTION_DOWN events indicate
+ * the first finger has touched the screen. If not overridden the default response is to do
+ * nothing.
+ */
+ protected void onDown(MotionEvent event, MotionEvent rawEvent, int policyFlags) {}
+
+ /**
+ * Matchers override this method to respond to ACTION_POINTER_DOWN events. ACTION_POINTER_DOWN
+ * indicates that more than one finger has touched the screen. If not overridden the default
+ * response is to do nothing.
+ *
+ * @param event the event as passed in from the event stream.
+ * @param rawEvent the original un-modified event. Useful for calculating movements in physical
+ * space.
+ * @param policyFlags the policy flags as passed in from the event stream.
+ */
+ protected void onPointerDown(MotionEvent event, MotionEvent rawEvent, int policyFlags) {}
+
+ /**
+ * Matchers override this method to respond to ACTION_MOVE events. ACTION_MOVE indicates that
+ * one or fingers has moved. If not overridden the default response is to do nothing.
+ *
+ * @param event the event as passed in from the event stream.
+ * @param rawEvent the original un-modified event. Useful for calculating movements in physical
+ * space.
+ * @param policyFlags the policy flags as passed in from the event stream.
+ */
+ protected void onMove(MotionEvent event, MotionEvent rawEvent, int policyFlags) {}
+
+ /**
+ * Matchers override this method to respond to ACTION_POINTER_UP events. ACTION_POINTER_UP
+ * indicates that a finger has lifted from the screen but at least one finger continues to touch
+ * the screen. If not overridden the default response is to do nothing.
+ *
+ * @param event the event as passed in from the event stream.
+ * @param rawEvent the original un-modified event. Useful for calculating movements in physical
+ * space.
+ * @param policyFlags the policy flags as passed in from the event stream.
+ */
+ protected void onPointerUp(MotionEvent event, MotionEvent rawEvent, int policyFlags) {}
+
+ /**
+ * Matchers override this method to respond to ACTION_UP events. ACTION_UP indicates that there
+ * are no more fingers touching the screen. If not overridden the default response is to do
+ * nothing.
+ *
+ * @param event the event as passed in from the event stream.
+ * @param rawEvent the original un-modified event. Useful for calculating movements in physical
+ * space.
+ * @param policyFlags the policy flags as passed in from the event stream.
+ */
+ protected void onUp(MotionEvent event, MotionEvent rawEvent, int policyFlags) {}
+
+ /** Cancels this matcher after the tap timeout. Any pending state transitions are removed. */
+ protected void cancelAfterTapTimeout(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ cancelAfter(ViewConfiguration.getTapTimeout(), event, rawEvent, policyFlags);
+ }
+
+ /** Cancels this matcher after the double tap timeout. Any pending cancelations are removed. */
+ protected final void cancelAfterDoubleTapTimeout(
+ MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ cancelAfter(ViewConfiguration.getDoubleTapTimeout(), event, rawEvent, policyFlags);
+ }
+
+ /**
+ * Cancels this matcher after the specified timeout. Any pending cancelations are removed. Used
+ * to prevent this matcher from accepting motion events until it is cleared.
+ */
+ protected final void cancelAfter(
+ long timeout, MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ mDelayedTransition.cancel();
+ mDelayedTransition.post(STATE_GESTURE_CANCELED, timeout, event, rawEvent, policyFlags);
+ }
+
+ /** Cancels any delayed transitions between states scheduled for this matcher. */
+ protected final void cancelPendingTransitions() {
+ mDelayedTransition.cancel();
+ }
+
+ /**
+ * Signals that this gesture has been completed after the tap timeout has expired. Used to
+ * ensure that there is no conflict with another gesture or for gestures that explicitly require
+ * a hold.
+ */
+ protected final void completeAfterLongPressTimeout(
+ MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ completeAfter(ViewConfiguration.getLongPressTimeout(), event, rawEvent, policyFlags);
+ }
+
+ /**
+ * Signals that this gesture has been completed after the tap timeout has expired. Used to
+ * ensure that there is no conflict with another gesture or for gestures that explicitly require
+ * a hold.
+ */
+ protected final void completeAfterTapTimeout(
+ MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ completeAfter(ViewConfiguration.getTapTimeout(), event, rawEvent, policyFlags);
+ }
+
+ /**
+ * Signals that this gesture has been completed after the specified timeout has expired. Used to
+ * ensure that there is no conflict with another gesture or for gestures that explicitly require
+ * a hold.
+ */
+ protected final void completeAfter(
+ long timeout, MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ mDelayedTransition.cancel();
+ mDelayedTransition.post(STATE_GESTURE_COMPLETED, timeout, event, rawEvent, policyFlags);
+ }
+
+ /**
+ * Signals that this gesture has been completed after the double-tap timeout has expired. Used
+ * to ensure that there is no conflict with another gesture or for gestures that explicitly
+ * require a hold.
+ */
+ protected final void completeAfterDoubleTapTimeout(
+ MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ completeAfter(ViewConfiguration.getDoubleTapTimeout(), event, rawEvent, policyFlags);
+ }
+
+ public static String getStateSymbolicName(@State int state) {
+ switch (state) {
+ case STATE_CLEAR:
+ return "STATE_CLEAR";
+ case STATE_GESTURE_STARTED:
+ return "STATE_GESTURE_STARTED";
+ case STATE_GESTURE_COMPLETED:
+ return "STATE_GESTURE_COMPLETED";
+ case STATE_GESTURE_CANCELED:
+ return "STATE_GESTURE_CANCELED";
+ default:
+ return "Unknown state: " + state;
+ }
+ }
+
+ /**
+ * Returns a readable name for this matcher that can be displayed to the user and in system
+ * logs.
+ */
+ abstract String getGestureName();
+
+ /**
+ * Returns a String representation of this matcher. Each matcher can override this method to add
+ * extra state information to the string representation.
+ */
+ public String toString() {
+ return getGestureName() + ":" + getStateSymbolicName(mState);
+ }
+
+ /** This class allows matchers to transition between states on a delay. */
+ protected final class DelayedTransition implements Runnable {
+
+ private static final String LOG_TAG = "GestureMatcher.DelayedTransition";
+ int mTargetState;
+ MotionEvent mEvent;
+ MotionEvent mRawEvent;
+ int mPolicyFlags;
+
+ public void cancel() {
+ // Avoid meaningless debug messages.
+ if (DEBUG && isPending()) {
+ Slog.d(
+ LOG_TAG,
+ getGestureName()
+ + ": canceling delayed transition to "
+ + getStateSymbolicName(mTargetState));
+ }
+ mHandler.removeCallbacks(this);
+ }
+
+ public void post(
+ int state, long delay, MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ mTargetState = state;
+ mEvent = event;
+ mRawEvent = rawEvent;
+ mPolicyFlags = policyFlags;
+ mHandler.postDelayed(this, delay);
+ if (DEBUG) {
+ Slog.d(
+ LOG_TAG,
+ getGestureName()
+ + ": posting delayed transition to "
+ + getStateSymbolicName(mTargetState));
+ }
+ }
+
+ public boolean isPending() {
+ return mHandler.hasCallbacks(this);
+ }
+
+ public void forceSendAndRemove() {
+ if (isPending()) {
+ run();
+ cancel();
+ }
+ }
+
+ @Override
+ public void run() {
+ if (DEBUG) {
+ Slog.d(
+ LOG_TAG,
+ getGestureName()
+ + ": executing delayed transition to "
+ + getStateSymbolicName(mTargetState));
+ }
+ setState(mTargetState, mEvent, mRawEvent, mPolicyFlags);
+ }
+ }
+
+ /** Interface to allow a class to listen for state changes in a specific gesture matcher */
+ interface StateChangeListener {
+
+ void onStateChanged(
+ int gestureId, int state, MotionEvent event, MotionEvent rawEvent, int policyFlags);
+ }
+}
diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/MultiTap.java b/services/accessibility/java/com/android/server/accessibility/gestures/MultiTap.java
new file mode 100644
index 0000000..2891c6c
--- /dev/null
+++ b/services/accessibility/java/com/android/server/accessibility/gestures/MultiTap.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2019 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 com.android.server.accessibility.gestures;
+
+import android.content.Context;
+import android.os.Handler;
+import android.view.MotionEvent;
+import android.view.ViewConfiguration;
+
+/**
+ * This class matches multi-tap gestures. The number of taps for each instance is specified in the
+ * constructor.
+ */
+class MultiTap extends GestureMatcher {
+
+ // Maximum reasonable number of taps.
+ public static final int MAX_TAPS = 10;
+ final int mTargetTaps;
+ // The acceptable distance between two taps
+ int mDoubleTapSlop;
+ // The acceptable distance the pointer can move and still count as a tap.
+ int mTouchSlop;
+ int mTapTimeout;
+ int mDoubleTapTimeout;
+ int mCurrentTaps;
+ float mBaseX;
+ float mBaseY;
+
+ MultiTap(Context context, int taps, int gesture, GestureMatcher.StateChangeListener listener) {
+ super(gesture, new Handler(context.getMainLooper()), listener);
+ mTargetTaps = taps;
+ mDoubleTapSlop = ViewConfiguration.get(context).getScaledDoubleTapSlop();
+ mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
+ mTapTimeout = ViewConfiguration.getTapTimeout();
+ mDoubleTapTimeout = ViewConfiguration.getDoubleTapTimeout();
+ clear();
+ }
+
+ @Override
+ protected void clear() {
+ mCurrentTaps = 0;
+ mBaseX = Float.NaN;
+ mBaseY = Float.NaN;
+ super.clear();
+ }
+
+ @Override
+ protected void onDown(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ cancelAfterTapTimeout(event, rawEvent, policyFlags);
+ if (Float.isNaN(mBaseX) && Float.isNaN(mBaseY)) {
+ mBaseX = event.getX();
+ mBaseY = event.getY();
+ }
+ if (!isInsideSlop(rawEvent, mDoubleTapSlop)) {
+ cancelGesture(event, rawEvent, policyFlags);
+ }
+ mBaseX = event.getX();
+ mBaseY = event.getY();
+ }
+
+ @Override
+ protected void onUp(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ cancelAfterDoubleTapTimeout(event, rawEvent, policyFlags);
+ if (!isInsideSlop(rawEvent, mTouchSlop)) {
+ cancelGesture(event, rawEvent, policyFlags);
+ }
+ if (getState() == STATE_GESTURE_STARTED || getState() == STATE_CLEAR) {
+ mCurrentTaps++;
+ if (mCurrentTaps == mTargetTaps) {
+ // Done.
+ completeAfterTapTimeout(event, rawEvent, policyFlags);
+ return;
+ }
+ // Needs more taps.
+ cancelAfterDoubleTapTimeout(event, rawEvent, policyFlags);
+ } else {
+ // Either too many taps or nonsensical event stream.
+ cancelGesture(event, rawEvent, policyFlags);
+ }
+ }
+
+ @Override
+ protected void onMove(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ if (!isInsideSlop(rawEvent, mTouchSlop)) {
+ cancelGesture(event, rawEvent, policyFlags);
+ }
+ }
+
+ @Override
+ protected void onPointerDown(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ cancelGesture(event, rawEvent, policyFlags);
+ }
+
+ @Override
+ protected void onPointerUp(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ cancelGesture(event, rawEvent, policyFlags);
+ }
+
+ @Override
+ public String getGestureName() {
+ switch (mTargetTaps) {
+ case 2:
+ return "Double Tap";
+ case 3:
+ return "Triple Tap";
+ default:
+ return Integer.toString(mTargetTaps) + " Taps";
+ }
+ }
+
+ private boolean isInsideSlop(MotionEvent rawEvent, int slop) {
+ final float deltaX = mBaseX - rawEvent.getX();
+ final float deltaY = mBaseY - rawEvent.getY();
+ if (deltaX == 0 && deltaY == 0) {
+ return true;
+ }
+ final double moveDelta = Math.hypot(deltaX, deltaY);
+ return moveDelta <= slop;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString()
+ + ", Taps:"
+ + mCurrentTaps
+ + ", mBaseX: "
+ + Float.toString(mBaseX)
+ + ", mBaseY: "
+ + Float.toString(mBaseY);
+ }
+}
diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/MultiTapAndHold.java b/services/accessibility/java/com/android/server/accessibility/gestures/MultiTapAndHold.java
new file mode 100644
index 0000000..6a1f1a5
--- /dev/null
+++ b/services/accessibility/java/com/android/server/accessibility/gestures/MultiTapAndHold.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 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 com.android.server.accessibility.gestures;
+
+import android.content.Context;
+import android.view.MotionEvent;
+
+/**
+ * This class matches gestures of the form multi-tap and hold. The number of taps for each instance
+ * is specified in the constructor.
+ */
+class MultiTapAndHold extends MultiTap {
+ MultiTapAndHold(
+ Context context, int taps, int gesture, GestureMatcher.StateChangeListener listener) {
+ super(context, taps, gesture, listener);
+ }
+
+ @Override
+ protected void onDown(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ super.onDown(event, rawEvent, policyFlags);
+ if (mCurrentTaps + 1 == mTargetTaps) {
+ completeAfterLongPressTimeout(event, rawEvent, policyFlags);
+ }
+ }
+
+ @Override
+ public String getGestureName() {
+ switch (mTargetTaps) {
+ case 2:
+ return "Double Tap and Hold";
+ case 3:
+ return "Triple Tap and Hold";
+ default:
+ return Integer.toString(mTargetTaps) + " Taps and Hold";
+ }
+ }
+}
diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/Swipe.java b/services/accessibility/java/com/android/server/accessibility/gestures/Swipe.java
new file mode 100644
index 0000000..b246c67
--- /dev/null
+++ b/services/accessibility/java/com/android/server/accessibility/gestures/Swipe.java
@@ -0,0 +1,430 @@
+/*
+ * Copyright (C) 2019 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 com.android.server.accessibility.gestures;
+
+import static com.android.server.accessibility.gestures.TouchExplorer.DEBUG;
+
+import android.content.Context;
+import android.gesture.GesturePoint;
+import android.graphics.PointF;
+import android.os.Handler;
+import android.util.DisplayMetrics;
+import android.util.Slog;
+import android.util.TypedValue;
+import android.view.MotionEvent;
+
+import java.util.ArrayList;
+
+/**
+ * This class is responsible for matching one-finger swipe gestures. Each instance matches one swipe
+ * gesture. A swipe is specified as a series of one or more directions e.g. left, left and up, etc.
+ * At this time swipes with more than two directions are not supported.
+ */
+class Swipe extends GestureMatcher {
+
+ // Direction constants.
+ public static final int LEFT = 0;
+ public static final int RIGHT = 1;
+ public static final int UP = 2;
+ public static final int DOWN = 3;
+ // This is the calculated movement threshold used track if the user is still
+ // moving their finger.
+ private final float mGestureDetectionThreshold;
+
+ // Buffer for storing points for gesture detection.
+ private final ArrayList<GesturePoint> mStrokeBuffer = new ArrayList<GesturePoint>(100);
+
+ // The minimal delta between moves to add a gesture point.
+ private static final int TOUCH_TOLERANCE_PIX = 3;
+
+ // The minimal score for accepting a predicted gesture.
+ private static final float MIN_PREDICTION_SCORE = 2.0f;
+
+ // Distance a finger must travel before we decide if it is a gesture or not.
+ private static final int GESTURE_CONFIRM_CM = 1;
+
+ // Time threshold used to determine if an interaction is a gesture or not.
+ // If the first movement of 1cm takes longer than this value, we assume it's
+ // a slow movement, and therefore not a gesture.
+ //
+ // This value was determined by measuring the time for the first 1cm
+ // movement when gesturing, and touch exploring. Based on user testing,
+ // all gestures started with the initial movement taking less than 100ms.
+ // When touch exploring, the first movement almost always takes longer than
+ // 200ms.
+ private static final long CANCEL_ON_PAUSE_THRESHOLD_NOT_STARTED_MS = 150;
+
+ // Time threshold used to determine if a gesture should be cancelled. If
+ // the finger takes more than this time to move 1cm, the ongoing gesture is
+ // cancelled.
+ private static final long CANCEL_ON_PAUSE_THRESHOLD_STARTED_MS = 300;
+
+ private int[] mDirections;
+ private float mBaseX;
+ private float mBaseY;
+ private long mBaseTime;
+ private float mPreviousGestureX;
+ private float mPreviousGestureY;
+ // Constants for sampling motion event points.
+ // We sample based on a minimum distance between points, primarily to improve accuracy by
+ // reducing noisy minor changes in direction.
+ private static final float MIN_CM_BETWEEN_SAMPLES = 0.25f;
+ private final float mMinPixelsBetweenSamplesX;
+ private final float mMinPixelsBetweenSamplesY;
+
+ // Constants for separating gesture segments
+ private static final float ANGLE_THRESHOLD = 0.0f;
+
+ Swipe(
+ Context context,
+ int direction,
+ int gesture,
+ GestureMatcher.StateChangeListener listener) {
+ this(context, new int[] {direction}, gesture, listener);
+ }
+
+ Swipe(
+ Context context,
+ int direction1,
+ int direction2,
+ int gesture,
+ GestureMatcher.StateChangeListener listener) {
+ this(context, new int[] {direction1, direction2}, gesture, listener);
+ }
+
+ private Swipe(
+ Context context,
+ int[] directions,
+ int gesture,
+ GestureMatcher.StateChangeListener listener) {
+ super(gesture, new Handler(context.getMainLooper()), listener);
+ mDirections = directions;
+ DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
+ mGestureDetectionThreshold =
+ TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, 10, displayMetrics)
+ * GESTURE_CONFIRM_CM;
+ // Calculate minimum gesture velocity
+ final float pixelsPerCmX = displayMetrics.xdpi / 2.54f;
+ final float pixelsPerCmY = displayMetrics.ydpi / 2.54f;
+ mMinPixelsBetweenSamplesX = MIN_CM_BETWEEN_SAMPLES * pixelsPerCmX;
+ mMinPixelsBetweenSamplesY = MIN_CM_BETWEEN_SAMPLES * pixelsPerCmY;
+ clear();
+ }
+
+ @Override
+ protected void clear() {
+ mBaseX = Float.NaN;
+ mBaseY = Float.NaN;
+ mBaseTime = 0;
+ mStrokeBuffer.clear();
+ super.clear();
+ }
+
+ @Override
+ protected void onDown(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ cancelAfterDelay(event, rawEvent, policyFlags);
+ if (Float.isNaN(mBaseX) && Float.isNaN(mBaseY)) {
+ mBaseX = rawEvent.getX();
+ mBaseY = rawEvent.getY();
+ mBaseTime = event.getEventTime();
+ mPreviousGestureX = mBaseX;
+ mPreviousGestureY = mBaseY;
+ }
+ // Otherwise do nothing because this event doesn't make sense in the middle of a gesture.
+ }
+
+ @Override
+ protected void onMove(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ final float x = rawEvent.getX();
+ final float y = rawEvent.getY();
+ final long time = event.getEventTime();
+ final float dX = Math.abs(x - mPreviousGestureX);
+ final float dY = Math.abs(y - mPreviousGestureY);
+ final long timeDelta = time - mBaseTime;
+ final double moveDelta = Math.hypot(Math.abs(x - mBaseX), Math.abs(y - mBaseY));
+ if (DEBUG) {
+ Slog.d(
+ getGestureName(),
+ "moveDelta:"
+ + Double.toString(moveDelta)
+ + " mGestureDetectionThreshold: "
+ + Float.toString(mGestureDetectionThreshold));
+ }
+ if (getState() == STATE_CLEAR) {
+ if (mStrokeBuffer.size() == 0) {
+ // First, make sure the pointer is going in the right direction.
+ cancelAfterDelay(event, rawEvent, policyFlags);
+ int direction = toDirection(x - mBaseX, y - mBaseY);
+ if (direction != mDirections[0]) {
+ cancelGesture(event, rawEvent, policyFlags);
+ return;
+ } else {
+ // This is confirmed to be some kind of swipe so start tracking points.
+ mStrokeBuffer.add(new GesturePoint(mBaseX, mBaseY, mBaseTime));
+ }
+ }
+ if (moveDelta > mGestureDetectionThreshold) {
+ // If the pointer has moved more than the threshold,
+ // update the stored values.
+ mBaseX = x;
+ mBaseY = y;
+ mBaseTime = time;
+ if (getState() == STATE_CLEAR) {
+ startGesture(event, rawEvent, policyFlags);
+ cancelAfterDelay(event, rawEvent, policyFlags);
+ }
+ }
+ }
+ if (getState() == STATE_GESTURE_STARTED) {
+ if (dX >= mMinPixelsBetweenSamplesX || dY >= mMinPixelsBetweenSamplesY) {
+ mPreviousGestureX = x;
+ mPreviousGestureY = y;
+ mStrokeBuffer.add(new GesturePoint(x, y, time));
+ cancelAfterDelay(event, rawEvent, policyFlags);
+ }
+ }
+ }
+
+ @Override
+ protected void onUp(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ if (getState() != STATE_GESTURE_STARTED) {
+ cancelGesture(event, rawEvent, policyFlags);
+ return;
+ }
+
+ final float x = rawEvent.getX();
+ final float y = rawEvent.getY();
+ final long time = event.getEventTime();
+ final float dX = Math.abs(x - mPreviousGestureX);
+ final float dY = Math.abs(y - mPreviousGestureY);
+ if (dX >= mMinPixelsBetweenSamplesX || dY >= mMinPixelsBetweenSamplesY) {
+ mStrokeBuffer.add(new GesturePoint(x, y, time));
+ }
+ recognizeGesture(event, rawEvent, policyFlags);
+ }
+
+ @Override
+ protected void onPointerDown(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ cancelGesture(event, rawEvent, policyFlags);
+ }
+
+ @Override
+ protected void onPointerUp(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ cancelGesture(event, rawEvent, policyFlags);
+ }
+
+ /**
+ * queues a transition to STATE_GESTURE_CANCEL based on the current state. If we have
+ * transitioned to STATE_GESTURE_STARTED the delay is longer.
+ */
+ private void cancelAfterDelay(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ cancelPendingTransitions();
+ switch (getState()) {
+ case STATE_CLEAR:
+ cancelAfter(CANCEL_ON_PAUSE_THRESHOLD_NOT_STARTED_MS, event, rawEvent, policyFlags);
+ break;
+ case STATE_GESTURE_STARTED:
+ cancelAfter(CANCEL_ON_PAUSE_THRESHOLD_STARTED_MS, event, rawEvent, policyFlags);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * Looks at the sequence of motions in mStrokeBuffer, classifies the gesture, then calls
+ * Listener callbacks for success or failure.
+ *
+ * @param event The raw motion event to pass to the listener callbacks.
+ * @param policyFlags Policy flags for the event.
+ * @return true if the event is consumed, else false
+ */
+ private void recognizeGesture(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
+ if (mStrokeBuffer.size() < 2) {
+ cancelGesture(event, rawEvent, policyFlags);
+ return;
+ }
+
+ // Look at mStrokeBuffer and extract 2 line segments, delimited by near-perpendicular
+ // direction change.
+ // Method: for each sampled motion event, check the angle of the most recent motion vector
+ // versus the preceding motion vector, and segment the line if the angle is about
+ // 90 degrees.
+
+ ArrayList<PointF> path = new ArrayList<>();
+ PointF lastDelimiter = new PointF(mStrokeBuffer.get(0).x, mStrokeBuffer.get(0).y);
+ path.add(lastDelimiter);
+
+ float dX = 0; // Sum of unit vectors from last delimiter to each following point
+ float dY = 0;
+ int count = 0; // Number of points since last delimiter
+ float length = 0; // Vector length from delimiter to most recent point
+
+ PointF next = new PointF();
+ for (int i = 1; i < mStrokeBuffer.size(); ++i) {
+ next = new PointF(mStrokeBuffer.get(i).x, mStrokeBuffer.get(i).y);
+ if (count > 0) {
+ // Average of unit vectors from delimiter to following points
+ float currentDX = dX / count;
+ float currentDY = dY / count;
+
+ // newDelimiter is a possible new delimiter, based on a vector with length from
+ // the last delimiter to the previous point, but in the direction of the average
+ // unit vector from delimiter to previous points.
+ // Using the averaged vector has the effect of "squaring off the curve",
+ // creating a sharper angle between the last motion and the preceding motion from
+ // the delimiter. In turn, this sharper angle achieves the splitting threshold
+ // even in a gentle curve.
+ PointF newDelimiter =
+ new PointF(
+ length * currentDX + lastDelimiter.x,
+ length * currentDY + lastDelimiter.y);
+
+ // Unit vector from newDelimiter to the most recent point
+ float nextDX = next.x - newDelimiter.x;
+ float nextDY = next.y - newDelimiter.y;
+ float nextLength = (float) Math.sqrt(nextDX * nextDX + nextDY * nextDY);
+ nextDX = nextDX / nextLength;
+ nextDY = nextDY / nextLength;
+
+ // Compare the initial motion direction to the most recent motion direction,
+ // and segment the line if direction has changed by about 90 degrees.
+ float dot = currentDX * nextDX + currentDY * nextDY;
+ if (dot < ANGLE_THRESHOLD) {
+ path.add(newDelimiter);
+ lastDelimiter = newDelimiter;
+ dX = 0;
+ dY = 0;
+ count = 0;
+ }
+ }
+
+ // Vector from last delimiter to most recent point
+ float currentDX = next.x - lastDelimiter.x;
+ float currentDY = next.y - lastDelimiter.y;
+ length = (float) Math.sqrt(currentDX * currentDX + currentDY * currentDY);
+
+ // Increment sum of unit vectors from delimiter to each following point
+ count = count + 1;
+ dX = dX + currentDX / length;
+ dY = dY + currentDY / length;
+ }
+
+ path.add(next);
+ if (DEBUG) {
+ Slog.d(getGestureName(), "path=" + path.toString());
+ }
+ // Classify line segments, and call Listener callbacks.
+ recognizeGesturePath(event, rawEvent, policyFlags, path);
+ }
+
+ /**
+ * Classifies a pair of line segments, by direction. Calls Listener callbacks for success or
+ * failure.
+ *
+ * @param event The raw motion event to pass to the listener's onGestureCanceled method.
+ * @param policyFlags Policy flags for the event.
+ * @param path A sequence of motion line segments derived from motion points in mStrokeBuffer.
+ * @return true if the event is consumed, else false
+ */
+ private void recognizeGesturePath(
+ MotionEvent event, MotionEvent rawEvent, int policyFlags, ArrayList<PointF> path) {
+
+ final int displayId = event.getDisplayId();
+ if (path.size() != mDirections.length + 1) {
+ cancelGesture(event, rawEvent, policyFlags);
+ return;
+ }
+ for (int i = 0; i < path.size() - 1; ++i) {
+ PointF start = path.get(i);
+ PointF end = path.get(i + 1);
+
+ float dX = end.x - start.x;
+ float dY = end.y - start.y;
+ int direction = toDirection(dX, dY);
+ if (direction != mDirections[i]) {
+ if (DEBUG) {
+ Slog.d(
+ getGestureName(),
+ "Found direction "
+ + directionToString(direction)
+ + " when expecting "
+ + directionToString(mDirections[i]));
+ }
+ cancelGesture(event, rawEvent, policyFlags);
+ return;
+ }
+ }
+ if (DEBUG) {
+ Slog.d(getGestureName(), "Completed.");
+ }
+ completeGesture(event, rawEvent, policyFlags);
+ }
+
+ private static int toDirection(float dX, float dY) {
+ if (Math.abs(dX) > Math.abs(dY)) {
+ // Horizontal
+ return (dX < 0) ? LEFT : RIGHT;
+ } else {
+ // Vertical
+ return (dY < 0) ? UP : DOWN;
+ }
+ }
+
+ public static String directionToString(int direction) {
+ switch (direction) {
+ case LEFT:
+ return "left";
+ case RIGHT:
+ return "right";
+ case UP:
+ return "up";
+ case DOWN:
+ return "down";
+ default:
+ return "Unknown Direction";
+ }
+ }
+
+ @Override
+ String getGestureName() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("Swipe ").append(directionToString(mDirections[0]));
+ for (int i = 1; i < mDirections.length; ++i) {
+ builder.append(" and ").append(directionToString(mDirections[i]));
+ }
+ return builder.toString();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder(super.toString());
+ if (getState() != STATE_GESTURE_CANCELED) {
+ builder.append(", mBaseX: ")
+ .append(mBaseX)
+ .append(", mBaseY: ")
+ .append(mBaseY)
+ .append(", mGestureDetectionThreshold:")
+ .append(mGestureDetectionThreshold)
+ .append(", mMinPixelsBetweenSamplesX:")
+ .append(mMinPixelsBetweenSamplesX)
+ .append(", mMinPixelsBetweenSamplesY:")
+ .append(mMinPixelsBetweenSamplesY);
+ }
+ return builder.toString();
+ }
+}
diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java b/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java
index b62e260..5f41638 100644
--- a/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java
+++ b/services/accessibility/java/com/android/server/accessibility/gestures/TouchExplorer.java
@@ -59,7 +59,7 @@
* @hide
*/
public class TouchExplorer extends BaseEventStreamTransformation
- implements AccessibilityGestureDetector.Listener {
+ implements GestureManifold.Listener {
static final boolean DEBUG = false;
@@ -104,7 +104,7 @@
private final ExitGestureDetectionModeDelayed mExitGestureDetectionModeDelayed;
// Helper to detect gestures.
- private final AccessibilityGestureDetector mGestureDetector;
+ private final GestureManifold mGestureDetector;
// Helper class to track received pointers.
private final TouchState.ReceivedPointerTracker mReceivedPointerTracker;
@@ -142,7 +142,7 @@
* one created in place, or for testing purpose.
*/
public TouchExplorer(Context context, AccessibilityManagerService service,
- AccessibilityGestureDetector detector) {
+ GestureManifold detector) {
mContext = context;
mAms = service;
mState = new TouchState();
@@ -161,7 +161,7 @@
AccessibilityEvent.TYPE_TOUCH_INTERACTION_END,
mDetermineUserIntentTimeout);
if (detector == null) {
- mGestureDetector = new AccessibilityGestureDetector(context, this);
+ mGestureDetector = new GestureManifold(context, this, mState);
} else {
mGestureDetector = detector;
}
@@ -285,7 +285,7 @@
}
@Override
- public void onDoubleTapAndHold(MotionEvent event, int policyFlags) {
+ public void onDoubleTapAndHold() {
// Ignore the event if we aren't touch interacting.
if (!mState.isTouchInteracting()) {
return;
@@ -303,7 +303,7 @@
}
@Override
- public boolean onDoubleTap(MotionEvent event, int policyFlags) {
+ public boolean onDoubleTap() {
if (!mState.isTouchInteracting()) {
return false;
}
@@ -319,7 +319,7 @@
// Announce the end of a new touch interaction.
mDispatcher.sendAccessibilityEvent(AccessibilityEvent.TYPE_TOUCH_INTERACTION_END);
-
+ mSendTouchInteractionEndDelayed.cancel();
// Try to use the standard accessibility API to click
if (!mAms.performActionOnAccessibilityFocusedItem(
AccessibilityNodeInfo.AccessibilityAction.ACTION_CLICK)) {
@@ -356,7 +356,7 @@
}
@Override
- public boolean onGestureCancelled(MotionEvent event, int policyFlags) {
+ public boolean onGestureCancelled(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
if (mState.isGestureDetecting()) {
endGestureDetection(event.getActionMasked() == MotionEvent.ACTION_UP);
return true;
diff --git a/services/accessibility/java/com/android/server/accessibility/gestures/TouchState.java b/services/accessibility/java/com/android/server/accessibility/gestures/TouchState.java
index f463260..d23dbbe 100644
--- a/services/accessibility/java/com/android/server/accessibility/gestures/TouchState.java
+++ b/services/accessibility/java/com/android/server/accessibility/gestures/TouchState.java
@@ -71,7 +71,10 @@
// Helper class to track received pointers.
// Todo: collapse or hide this class so multiple classes don't modify it.
private final ReceivedPointerTracker mReceivedPointerTracker;
+ // The most recently received motion event.
private MotionEvent mLastReceivedEvent;
+ // The accompanying raw event without any transformations.
+ private MotionEvent mLastReceivedRawEvent;
public TouchState() {
mReceivedPointerTracker = new ReceivedPointerTracker();
@@ -97,6 +100,9 @@
if (mLastReceivedEvent != null) {
mLastReceivedEvent.recycle();
}
+ if (mLastReceivedRawEvent != null) {
+ mLastReceivedRawEvent.recycle();
+ }
mLastReceivedEvent = MotionEvent.obtain(rawEvent);
mReceivedPointerTracker.onMotionEvent(rawEvent);
}
@@ -246,7 +252,6 @@
// or if it goes up the next one that most recently went down.
private int mPrimaryPointerId;
-
ReceivedPointerTracker() {
clear();
}
diff --git a/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java b/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java
index 7e8edf2..26bb7c3 100644
--- a/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java
+++ b/services/autofill/java/com/android/server/autofill/ui/AutoFillUI.java
@@ -465,7 +465,7 @@
if (mCreateFillUiRunnable != null) {
if (sDebug) Slog.d(TAG, "start the pending fill UI request..");
- mCreateFillUiRunnable.run();
+ mHandler.post(mCreateFillUiRunnable);
mCreateFillUiRunnable = null;
}
}
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java
index e8c5299..3651a41 100644
--- a/services/backup/java/com/android/server/backup/BackupManagerService.java
+++ b/services/backup/java/com/android/server/backup/BackupManagerService.java
@@ -274,9 +274,14 @@
}
}
- // This method should not perform any I/O (e.g. do not call isBackupActivatedForUser),
- // it's used in multiple places where I/O waits would cause system lock-ups.
- private boolean isUserReadyForBackup(int userId) {
+ /**
+ * This method should not perform any I/O (e.g. do not call isBackupActivatedForUser),
+ * it's used in multiple places where I/O waits would cause system lock-ups.
+ * @param userId User id for which this operation should be performed.
+ * @return true if the user is ready for backup and false otherwise.
+ */
+ @Override
+ public boolean isUserReadyForBackup(int userId) {
return mUserServices.get(UserHandle.USER_SYSTEM) != null
&& mUserServices.get(userId) != null;
}
diff --git a/services/core/java/android/content/pm/PackageManagerInternal.java b/services/core/java/android/content/pm/PackageManagerInternal.java
index 53f306b..49046b2 100644
--- a/services/core/java/android/content/pm/PackageManagerInternal.java
+++ b/services/core/java/android/content/pm/PackageManagerInternal.java
@@ -275,6 +275,11 @@
public abstract ComponentName getDefaultHomeActivity(int userId);
/**
+ * @return The SystemUI service component name.
+ */
+ public abstract ComponentName getSystemUiServiceComponent();
+
+ /**
* Called by DeviceOwnerManagerService to set the package names of device owner and profile
* owners.
*/
@@ -336,14 +341,16 @@
* @param responseObj The response of the first phase of ephemeral resolution
* @param origIntent The original intent that triggered ephemeral resolution
* @param resolvedType The resolved type of the intent
- * @param callingPackage The name of the package requesting the ephemeral application
+ * @param callingPkg The app requesting the ephemeral application
+ * @param isRequesterInstantApp Whether or not the app requesting the ephemeral application
+ * is an instant app
* @param verificationBundle Optional bundle to pass to the installer for additional
* verification
* @param userId The ID of the user that triggered ephemeral resolution
*/
public abstract void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj,
- Intent origIntent, String resolvedType, String callingPackage,
- Bundle verificationBundle, int userId);
+ Intent origIntent, String resolvedType, String callingPkg,
+ boolean isRequesterInstantApp, Bundle verificationBundle, int userId);
/**
* Grants implicit access based on an interaction between two apps. This grants the target app
diff --git a/services/core/java/android/os/UserManagerInternal.java b/services/core/java/android/os/UserManagerInternal.java
index a2e9341..d84197c 100644
--- a/services/core/java/android/os/UserManagerInternal.java
+++ b/services/core/java/android/os/UserManagerInternal.java
@@ -57,7 +57,7 @@
* Called by {@link com.android.server.devicepolicy.DevicePolicyManagerService} to set
* restrictions enforced by the user.
*
- * @param userId target user id for the local restrictions.
+ * @param originatingUserId user id of the user where the restriction originated.
* @param restrictions a bundle of user restrictions.
* @param restrictionOwnerType determines which admin {@code userId} corresponds to.
* The admin can be either
@@ -70,8 +70,8 @@
* otherwise it will be applied just on the current user.
* @see OwnerType
*/
- public abstract void setDevicePolicyUserRestrictions(int userId, @Nullable Bundle restrictions,
- @OwnerType int restrictionOwnerType);
+ public abstract void setDevicePolicyUserRestrictions(int originatingUserId,
+ @Nullable Bundle restrictions, @OwnerType int restrictionOwnerType);
/**
* Returns the "base" user restrictions.
diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java
index 1e5b915..73b6c7a 100644
--- a/services/core/java/com/android/server/AlarmManagerService.java
+++ b/services/core/java/com/android/server/AlarmManagerService.java
@@ -22,6 +22,8 @@
import static android.app.AlarmManager.FLAG_ALLOW_WHILE_IDLE_UNRESTRICTED;
import static android.app.AlarmManager.RTC;
import static android.app.AlarmManager.RTC_WAKEUP;
+import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY;
+import static android.os.UserHandle.USER_SYSTEM;
import android.annotation.UserIdInt;
import android.app.Activity;
@@ -41,10 +43,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.PermissionInfo;
+import android.content.pm.PackageManagerInternal;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.BatteryManager;
@@ -223,15 +222,6 @@
long mLastTimeChangeRealtime;
int mNumTimeChanged;
- // Bookkeeping about the identity of the "System UI" package, determined at runtime.
-
- /**
- * This permission must be defined by the canonical System UI package,
- * with protection level "signature".
- */
- private static final String SYSTEM_UI_SELF_PERMISSION =
- "android.permission.systemui.IDENTITY";
-
/**
* At boot we use SYSTEM_UI_SELF_PERMISSION to look up the definer's uid.
*/
@@ -3201,7 +3191,7 @@
}
void removeUserLocked(int userHandle) {
- if (userHandle == UserHandle.USER_SYSTEM) {
+ if (userHandle == USER_SYSTEM) {
// If we're told we're removing the system user, ignore it.
return;
}
@@ -3845,21 +3835,9 @@
}
int getSystemUiUid() {
- int sysUiUid = -1;
- final PackageManager pm = mContext.getPackageManager();
- try {
- PermissionInfo sysUiPerm = pm.getPermissionInfo(SYSTEM_UI_SELF_PERMISSION, 0);
- ApplicationInfo sysUi = pm.getApplicationInfo(sysUiPerm.packageName, 0);
- if ((sysUi.privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0) {
- sysUiUid = sysUi.uid;
- } else {
- Slog.e(TAG, "SysUI permission " + SYSTEM_UI_SELF_PERMISSION
- + " defined by non-privileged app " + sysUi.packageName
- + " - ignoring");
- }
- } catch (NameNotFoundException e) {
- }
- return sysUiUid;
+ PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class);
+ return pm.getPackageUid(pm.getSystemUiServiceComponent().getPackageName(),
+ MATCH_SYSTEM_ONLY, USER_SYSTEM);
}
ClockReceiver getClockReceiver(AlarmManagerService service) {
diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java
index 119b987..470300e 100644
--- a/services/core/java/com/android/server/BluetoothManagerService.java
+++ b/services/core/java/com/android/server/BluetoothManagerService.java
@@ -16,6 +16,9 @@
package com.android.server;
+import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY;
+import static android.os.UserHandle.USER_SYSTEM;
+
import android.Manifest;
import android.app.ActivityManager;
import android.app.AppGlobals;
@@ -42,6 +45,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManagerInternal;
import android.content.pm.UserInfo;
import android.database.ContentObserver;
import android.os.Binder;
@@ -242,10 +246,10 @@
}
// DISALLOW_BLUETOOTH can only be set by DO or PO on the system user.
- if (userId == UserHandle.USER_SYSTEM
+ if (userId == USER_SYSTEM
&& UserRestrictionsUtils.restrictionsChanged(prevRestrictions,
newRestrictions, UserManager.DISALLOW_BLUETOOTH)) {
- if (userId == UserHandle.USER_SYSTEM && newRestrictions.getBoolean(
+ if (userId == USER_SYSTEM && newRestrictions.getBoolean(
UserManager.DISALLOW_BLUETOOTH)) {
updateOppLauncherComponentState(userId, true); // Sharing disallowed
sendDisableMsg(BluetoothProtoEnums.ENABLE_DISABLE_REASON_DISALLOWED,
@@ -437,18 +441,18 @@
}
int systemUiUid = -1;
- try {
- // Check if device is configured with no home screen, which implies no SystemUI.
- boolean noHome = mContext.getResources().getBoolean(R.bool.config_noHomeScreen);
- if (!noHome) {
- systemUiUid = mContext.getPackageManager()
- .getPackageUidAsUser("com.android.systemui", PackageManager.MATCH_SYSTEM_ONLY,
- UserHandle.USER_SYSTEM);
- }
+ // Check if device is configured with no home screen, which implies no SystemUI.
+ boolean noHome = mContext.getResources().getBoolean(R.bool.config_noHomeScreen);
+ if (!noHome) {
+ PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class);
+ systemUiUid = pm.getPackageUid(pm.getSystemUiServiceComponent().getPackageName(),
+ MATCH_SYSTEM_ONLY, USER_SYSTEM);
+ }
+ if (systemUiUid >= 0) {
Slog.d(TAG, "Detected SystemUiUid: " + Integer.toString(systemUiUid));
- } catch (PackageManager.NameNotFoundException e) {
+ } else {
// Some platforms, such as wearables do not have a system ui.
- Slog.w(TAG, "Unable to resolve SystemUI's UID.", e);
+ Slog.w(TAG, "Unable to resolve SystemUI's UID.");
}
mSystemUiUid = systemUiUid;
}
diff --git a/services/core/java/com/android/server/GnssManagerService.java b/services/core/java/com/android/server/GnssManagerService.java
index cbf2a62..bbcfdc6 100644
--- a/services/core/java/com/android/server/GnssManagerService.java
+++ b/services/core/java/com/android/server/GnssManagerService.java
@@ -56,6 +56,7 @@
import com.android.server.location.GnssMeasurementsProvider;
import com.android.server.location.GnssNavigationMessageProvider;
import com.android.server.location.GnssStatusListenerHelper;
+import com.android.server.location.LocationUsageLogger;
import com.android.server.location.RemoteListenerHelper;
import java.io.FileDescriptor;
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java
index 6300ab8..cad917b 100644
--- a/services/core/java/com/android/server/LocationManagerService.java
+++ b/services/core/java/com/android/server/LocationManagerService.java
@@ -104,6 +104,7 @@
import com.android.server.location.LocationRequestStatistics.PackageProviderKey;
import com.android.server.location.LocationRequestStatistics.PackageStatistics;
import com.android.server.location.LocationSettingsStore;
+import com.android.server.location.LocationUsageLogger;
import com.android.server.location.MockProvider;
import com.android.server.location.PassiveProvider;
import com.android.server.pm.permission.PermissionManagerServiceInternal;
@@ -158,21 +159,15 @@
}
}
- private static final String TAG = "LocationManagerService";
+ public static final String TAG = "LocationManagerService";
public static final boolean D = Log.isLoggable(TAG, Log.DEBUG);
private static final String WAKELOCK_KEY = "*location*";
- // Location resolution level: no location data whatsoever
private static final int RESOLUTION_LEVEL_NONE = 0;
- // Location resolution level: coarse location data only
private static final int RESOLUTION_LEVEL_COARSE = 1;
- // Location resolution level: fine location data
private static final int RESOLUTION_LEVEL_FINE = 2;
- private static final String ACCESS_LOCATION_EXTRA_COMMANDS =
- android.Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS;
-
private static final String NETWORK_LOCATION_SERVICE_ACTION =
"com.android.location.service.v3.NetworkLocationProvider";
private static final String FUSED_LOCATION_SERVICE_ACTION =
@@ -198,6 +193,8 @@
private final Object mLock = new Object();
private final Context mContext;
private final Handler mHandler;
+ private final LocationSettingsStore mSettingsStore;
+ private final LocationUsageLogger mLocationUsageLogger;
private AppOpsManager mAppOps;
private PackageManager mPackageManager;
@@ -205,8 +202,6 @@
private ActivityManager mActivityManager;
private UserManager mUserManager;
- private LocationSettingsStore mSettingsStore;
-
private GeofenceManager mGeofenceManager;
private LocationFudger mLocationFudger;
private GeocoderProxy mGeocodeProvider;
@@ -219,12 +214,12 @@
// list of currently active providers
@GuardedBy("mLock")
- private final ArrayList<LocationProvider> mProviders = new ArrayList<>();
+ private final ArrayList<LocationProviderManager> mProviders = new ArrayList<>();
// list of non-mock providers, so that when mock providers replace real providers, they can be
// later re-replaced
@GuardedBy("mLock")
- private final ArrayList<LocationProvider> mRealProviders = new ArrayList<>();
+ private final ArrayList<LocationProviderManager> mRealProviders = new ArrayList<>();
@GuardedBy("mLock")
private final HashMap<Object, Receiver> mReceivers = new HashMap<>();
@@ -251,12 +246,10 @@
@PowerManager.LocationPowerSaveMode
private int mBatterySaverMode;
- @GuardedBy("mLock")
- private final LocationUsageLogger mLocationUsageLogger;
-
private LocationManagerService(Context context) {
mContext = context;
mHandler = FgThread.getHandler();
+ mSettingsStore = new LocationSettingsStore(mContext, mHandler);
mLocationUsageLogger = new LocationUsageLogger();
// Let the package manager query which are the default location
@@ -274,6 +267,8 @@
}
private void onSystemReady() {
+ mSettingsStore.onSystemReady();
+
synchronized (mLock) {
mPackageManager = mContext.getPackageManager();
mAppOps = mContext.getSystemService(AppOpsManager.class);
@@ -281,7 +276,6 @@
mActivityManager = mContext.getSystemService(ActivityManager.class);
mUserManager = mContext.getSystemService(UserManager.class);
- mSettingsStore = new LocationSettingsStore(mContext, mHandler);
mLocationFudger = new LocationFudger(mContext, mHandler);
mGeofenceManager = new GeofenceManager(mContext, mSettingsStore);
@@ -421,14 +415,14 @@
for (Receiver receiver : mReceivers.values()) {
receiver.updateMonitoring(true);
}
- for (LocationProvider p : mProviders) {
+ for (LocationProviderManager p : mProviders) {
applyRequirementsLocked(p);
}
}
@GuardedBy("mLock")
private void onPermissionsChangedLocked() {
- for (LocationProvider p : mProviders) {
+ for (LocationProviderManager p : mProviders) {
applyRequirementsLocked(p);
}
}
@@ -448,7 +442,7 @@
mBatterySaverMode = newLocationMode;
- for (LocationProvider p : mProviders) {
+ for (LocationProviderManager p : mProviders) {
applyRequirementsLocked(p);
}
}
@@ -456,7 +450,7 @@
@GuardedBy("mLock")
private void onScreenStateChangedLocked() {
if (mBatterySaverMode == PowerManager.LOCATION_MODE_THROTTLE_REQUESTS_WHEN_SCREEN_OFF) {
- for (LocationProvider p : mProviders) {
+ for (LocationProviderManager p : mProviders) {
applyRequirementsLocked(p);
}
}
@@ -472,7 +466,7 @@
intent.putExtra(LocationManager.EXTRA_LOCATION_ENABLED, isLocationEnabledForUser(userId));
mContext.sendBroadcastAsUser(intent, UserHandle.of(userId));
- for (LocationProvider p : mProviders) {
+ for (LocationProviderManager p : mProviders) {
p.onUseableChangedLocked(userId);
}
}
@@ -527,21 +521,21 @@
@GuardedBy("mLock")
private void onBackgroundThrottleIntervalChangedLocked() {
- for (LocationProvider provider : mProviders) {
+ for (LocationProviderManager provider : mProviders) {
applyRequirementsLocked(provider);
}
}
@GuardedBy("mLock")
private void onBackgroundThrottleWhitelistChangedLocked() {
- for (LocationProvider p : mProviders) {
+ for (LocationProviderManager p : mProviders) {
applyRequirementsLocked(p);
}
}
@GuardedBy("lock")
private void onIgnoreSettingsWhitelistChangedLocked() {
- for (LocationProvider p : mProviders) {
+ for (LocationProviderManager p : mProviders) {
applyRequirementsLocked(p);
}
}
@@ -630,14 +624,15 @@
@GuardedBy("mLock")
private void initializeProvidersLocked() {
// create a passive location provider, which is always enabled
- LocationProvider passiveProviderManager = new LocationProvider(PASSIVE_PROVIDER);
+ LocationProviderManager passiveProviderManager = new LocationProviderManager(
+ PASSIVE_PROVIDER);
addProviderLocked(passiveProviderManager);
mPassiveProvider = new PassiveProvider(mContext, passiveProviderManager);
passiveProviderManager.attachLocked(mPassiveProvider);
if (GnssManagerService.isGnssSupported()) {
// Create a gps location provider manager
- LocationProvider gnssProviderManager = new LocationProvider(GPS_PROVIDER);
+ LocationProviderManager gnssProviderManager = new LocationProviderManager(GPS_PROVIDER);
mRealProviders.add(gnssProviderManager);
addProviderLocked(gnssProviderManager);
@@ -668,7 +663,8 @@
ensureFallbackFusedProviderPresentLocked(pkgs);
// bind to network provider
- LocationProvider networkProviderManager = new LocationProvider(NETWORK_PROVIDER);
+ LocationProviderManager networkProviderManager = new LocationProviderManager(
+ NETWORK_PROVIDER);
LocationProviderProxy networkProvider = LocationProviderProxy.createAndBind(
mContext,
networkProviderManager,
@@ -685,7 +681,7 @@
}
// bind to fused provider
- LocationProvider fusedProviderManager = new LocationProvider(FUSED_PROVIDER);
+ LocationProviderManager fusedProviderManager = new LocationProviderManager(FUSED_PROVIDER);
LocationProviderProxy fusedProvider = LocationProviderProxy.createAndBind(
mContext,
fusedProviderManager,
@@ -758,7 +754,7 @@
Boolean.parseBoolean(fragments[7]) /* supportsBearing */,
Integer.parseInt(fragments[8]) /* powerRequirement */,
Integer.parseInt(fragments[9]) /* accuracy */);
- LocationProvider testProviderManager = new LocationProvider(name);
+ LocationProviderManager testProviderManager = new LocationProviderManager(name);
addProviderLocked(testProviderManager);
testProviderManager.attachLocked(
new MockProvider(mContext, testProviderManager, properties));
@@ -780,7 +776,7 @@
onUserProfilesChangedLocked();
// let providers know the current user has changed
- for (LocationProvider p : mProviders) {
+ for (LocationProviderManager p : mProviders) {
p.onUseableChangedLocked(oldUserId);
p.onUseableChangedLocked(mCurrentUserId);
}
@@ -789,7 +785,7 @@
/**
* Location provider manager, manages a LocationProvider.
*/
- class LocationProvider implements AbstractLocationProvider.LocationProviderManager {
+ class LocationProviderManager implements AbstractLocationProvider.LocationProviderManager {
private final String mName;
@@ -807,7 +803,7 @@
@Nullable
private ProviderProperties mProperties;
- private LocationProvider(String name) {
+ private LocationProviderManager(String name) {
mName = name;
mProvider = null;
@@ -944,7 +940,7 @@
return;
}
synchronized (mLock) {
- LocationProvider gpsProvider = getLocationProviderLocked(GPS_PROVIDER);
+ LocationProviderManager gpsProvider = getLocationProviderLocked(GPS_PROVIDER);
if (gpsProvider == null || !gpsProvider.isUseableLocked()) {
Slog.w(TAG, "reportLocationBatch() called without user permission");
return;
@@ -1035,7 +1031,7 @@
}
}
- private class MockLocationProvider extends LocationProvider {
+ private class MockLocationProvider extends LocationProviderManager {
private ProviderRequest mCurrentRequest;
@@ -1185,7 +1181,8 @@
// See if receiver has any enabled update records. Also note if any update records
// are high power (has a high power provider with an interval under a threshold).
for (UpdateRecord updateRecord : mUpdateRecords.values()) {
- LocationProvider provider = getLocationProviderLocked(updateRecord.mProvider);
+ LocationProviderManager provider = getLocationProviderLocked(
+ updateRecord.mProvider);
if (provider == null) {
continue;
}
@@ -1461,7 +1458,7 @@
}
@GuardedBy("mLock")
- private void addProviderLocked(LocationProvider provider) {
+ private void addProviderLocked(LocationProviderManager provider) {
Preconditions.checkState(getLocationProviderLocked(provider.getName()) == null);
mProviders.add(provider);
@@ -1472,7 +1469,7 @@
}
@GuardedBy("mLock")
- private void removeProviderLocked(LocationProvider provider) {
+ private void removeProviderLocked(LocationProviderManager provider) {
if (mProviders.remove(provider)) {
// it would be more correct to call this for all users, but we know this can only
// affect the current user since providers are disabled for non-current users
@@ -1482,8 +1479,8 @@
@GuardedBy("mLock")
@Nullable
- private LocationProvider getLocationProviderLocked(String providerName) {
- for (LocationProvider provider : mProviders) {
+ private LocationProviderManager getLocationProviderLocked(String providerName) {
+ for (LocationProviderManager provider : mProviders) {
if (providerName.equals(provider.getName())) {
return provider;
}
@@ -1534,7 +1531,7 @@
// network and fused providers are ok with COARSE or FINE
return RESOLUTION_LEVEL_COARSE;
} else {
- for (LocationProvider lp : mProviders) {
+ for (LocationProviderManager lp : mProviders) {
if (!lp.getName().equals(provider)) {
continue;
}
@@ -1634,7 +1631,7 @@
public List<String> getAllProviders() {
synchronized (mLock) {
ArrayList<String> providers = new ArrayList<>(mProviders.size());
- for (LocationProvider provider : mProviders) {
+ for (LocationProviderManager provider : mProviders) {
String name = provider.getName();
if (FUSED_PROVIDER.equals(name)) {
continue;
@@ -1655,7 +1652,7 @@
int allowedResolutionLevel = getCallerAllowedResolutionLevel();
synchronized (mLock) {
ArrayList<String> providers = new ArrayList<>(mProviders.size());
- for (LocationProvider provider : mProviders) {
+ for (LocationProviderManager provider : mProviders) {
String name = provider.getName();
if (FUSED_PROVIDER.equals(name)) {
continue;
@@ -1705,7 +1702,7 @@
}
@GuardedBy("mLock")
- private void updateProviderUseableLocked(LocationProvider provider) {
+ private void updateProviderUseableLocked(LocationProviderManager provider) {
boolean useable = provider.isUseableLocked();
ArrayList<Receiver> deadReceivers = null;
@@ -1744,14 +1741,14 @@
@GuardedBy("mLock")
private void applyRequirementsLocked(String providerName) {
- LocationProvider provider = getLocationProviderLocked(providerName);
+ LocationProviderManager provider = getLocationProviderLocked(providerName);
if (provider != null) {
applyRequirementsLocked(provider);
}
}
@GuardedBy("mLock")
- private void applyRequirementsLocked(LocationProvider provider) {
+ private void applyRequirementsLocked(LocationProviderManager provider) {
ArrayList<UpdateRecord> records = mRecordsByProvider.get(provider.getName());
WorkSource worksource = new WorkSource();
ProviderRequest providerRequest = new ProviderRequest();
@@ -2201,7 +2198,7 @@
throw new IllegalArgumentException("provider name must not be null");
}
- LocationProvider provider = getLocationProviderLocked(name);
+ LocationProviderManager provider = getLocationProviderLocked(name);
if (provider == null) {
throw new IllegalArgumentException("provider doesn't exist: " + name);
}
@@ -2323,7 +2320,7 @@
// or use the fused provider
String name = request.getProvider();
if (name == null) name = LocationManager.FUSED_PROVIDER;
- LocationProvider provider = getLocationProviderLocked(name);
+ LocationProviderManager provider = getLocationProviderLocked(name);
if (provider == null) return null;
// only the current user or location providers may get location this way
@@ -2453,7 +2450,7 @@
"Access Fine Location permission not granted to inject Location");
synchronized (mLock) {
- LocationProvider provider = getLocationProviderLocked(location.getProvider());
+ LocationProviderManager provider = getLocationProviderLocked(location.getProvider());
if (provider == null || !provider.isUseableLocked()) {
return false;
}
@@ -2624,6 +2621,10 @@
// throw NullPointerException to remain compatible with previous implementation
throw new NullPointerException();
}
+
+ mContext.enforceCallingOrSelfPermission(
+ Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS, null);
+
synchronized (mLock) {
checkResolutionLevelIsSufficientForProviderUseLocked(getCallerAllowedResolutionLevel(),
providerName);
@@ -2633,13 +2634,7 @@
LocationStatsEnums.API_SEND_EXTRA_COMMAND,
providerName);
- // and check for ACCESS_LOCATION_EXTRA_COMMANDS
- if ((mContext.checkCallingOrSelfPermission(ACCESS_LOCATION_EXTRA_COMMANDS)
- != PERMISSION_GRANTED)) {
- throw new SecurityException("Requires ACCESS_LOCATION_EXTRA_COMMANDS permission");
- }
-
- LocationProvider provider = getLocationProviderLocked(providerName);
+ LocationProviderManager provider = getLocationProviderLocked(providerName);
if (provider != null) {
provider.sendExtraCommand(command, extras);
}
@@ -2662,7 +2657,7 @@
@Override
public ProviderProperties getProviderProperties(String providerName) {
synchronized (mLock) {
- LocationProvider provider = getLocationProviderLocked(providerName);
+ LocationProviderManager provider = getLocationProviderLocked(providerName);
if (provider == null) {
return null;
}
@@ -2675,7 +2670,7 @@
mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_DEVICE_CONFIG,
Manifest.permission.READ_DEVICE_CONFIG + " permission required");
synchronized (mLock) {
- for (LocationProvider provider : mProviders) {
+ for (LocationProviderManager provider : mProviders) {
if (provider.getPackagesLocked().contains(packageName)) {
return true;
}
@@ -2689,7 +2684,7 @@
mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_DEVICE_CONFIG,
Manifest.permission.READ_DEVICE_CONFIG + " permission required");
synchronized (mLock) {
- LocationProvider provider = getLocationProviderLocked(providerName);
+ LocationProviderManager provider = getLocationProviderLocked(providerName);
return provider == null ? Collections.emptyList() : provider.getPackagesLocked();
}
}
@@ -2758,7 +2753,7 @@
if (FUSED_PROVIDER.equals(providerName)) return false;
synchronized (mLock) {
- LocationProvider provider = getLocationProviderLocked(providerName);
+ LocationProviderManager provider = getLocationProviderLocked(providerName);
return provider != null && provider.isUseableLocked(userId);
}
}
@@ -2797,7 +2792,7 @@
}
@GuardedBy("mLock")
- private void handleLocationChangedLocked(Location location, LocationProvider provider) {
+ private void handleLocationChangedLocked(Location location, LocationProviderManager provider) {
if (!mProviders.contains(provider)) {
return;
}
@@ -3029,7 +3024,7 @@
synchronized (mLock) {
long identity = Binder.clearCallingIdentity();
try {
- LocationProvider oldProvider = getLocationProviderLocked(name);
+ LocationProviderManager oldProvider = getLocationProviderLocked(name);
if (oldProvider != null) {
removeProviderLocked(oldProvider);
}
@@ -3053,7 +3048,7 @@
synchronized (mLock) {
long identity = Binder.clearCallingIdentity();
try {
- LocationProvider testProvider = getLocationProviderLocked(name);
+ LocationProviderManager testProvider = getLocationProviderLocked(name);
if (testProvider == null || !testProvider.isMock()) {
return;
}
@@ -3061,8 +3056,8 @@
removeProviderLocked(testProvider);
// reinstate real provider if available
- LocationProvider realProvider = null;
- for (LocationProvider provider : mRealProviders) {
+ LocationProviderManager realProvider = null;
+ for (LocationProviderManager provider : mRealProviders) {
if (name.equals(provider.getName())) {
realProvider = provider;
break;
@@ -3086,7 +3081,7 @@
}
synchronized (mLock) {
- LocationProvider testProvider = getLocationProviderLocked(providerName);
+ LocationProviderManager testProvider = getLocationProviderLocked(providerName);
if (testProvider == null || !testProvider.isMock()) {
throw new IllegalArgumentException("Provider \"" + providerName + "\" unknown");
}
@@ -3110,7 +3105,7 @@
}
synchronized (mLock) {
- LocationProvider testProvider = getLocationProviderLocked(providerName);
+ LocationProviderManager testProvider = getLocationProviderLocked(providerName);
if (testProvider == null || !testProvider.isMock()) {
throw new IllegalArgumentException("Provider \"" + providerName + "\" unknown");
}
@@ -3128,7 +3123,7 @@
}
synchronized (mLock) {
- LocationProvider testProvider = getLocationProviderLocked(providerName);
+ LocationProviderManager testProvider = getLocationProviderLocked(providerName);
if (testProvider == null || !testProvider.isMock()) {
throw new IllegalArgumentException("Provider \"" + providerName + "\" unknown");
}
@@ -3237,7 +3232,7 @@
ipw.println("Location Providers:");
ipw.increaseIndent();
- for (LocationProvider provider : mProviders) {
+ for (LocationProviderManager provider : mProviders) {
provider.dumpLocked(fd, ipw, args);
}
ipw.decreaseIndent();
diff --git a/services/core/java/com/android/server/PackageWatchdog.java b/services/core/java/com/android/server/PackageWatchdog.java
index 9115a8e..deff440 100644
--- a/services/core/java/com/android/server/PackageWatchdog.java
+++ b/services/core/java/com/android/server/PackageWatchdog.java
@@ -532,6 +532,17 @@
default boolean isPersistent() {
return false;
}
+
+ /**
+ * Returns {@code true} if this observer wishes to observe the given package, {@code false}
+ * otherwise
+ *
+ * <p> A persistent observer may choose to start observing certain failing packages, even if
+ * it has not explicitly asked to watch the package with {@link #startObservingHealth}.
+ */
+ default boolean mayObservePackage(String packageName) {
+ return false;
+ }
}
long getTriggerFailureCount() {
@@ -1016,6 +1027,11 @@
*/
@GuardedBy("mLock")
public boolean onPackageFailureLocked(String packageName) {
+ if (packages.get(packageName) == null && registeredObserver.isPersistent()
+ && registeredObserver.mayObservePackage(packageName)) {
+ packages.put(packageName, sPackageWatchdog.newMonitoredPackage(
+ packageName, DEFAULT_OBSERVING_DURATION_MS, false));
+ }
MonitoredPackage p = packages.get(packageName);
if (p != null) {
return p.onFailureLocked();
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index 0a6473a..9b1d9e9 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -1584,10 +1584,8 @@
// Snapshot feature flag used for this boot
SystemProperties.set(StorageManager.PROP_ISOLATED_STORAGE_SNAPSHOT, Boolean.toString(
SystemProperties.getBoolean(StorageManager.PROP_ISOLATED_STORAGE, true)));
- SystemProperties.set(StorageManager.PROP_FUSE_SNAPSHOT, Boolean.toString(
- SystemProperties.getBoolean(StorageManager.PROP_FUSE, false)));
- mIsFuseEnabled = SystemProperties.getBoolean(StorageManager.PROP_FUSE_SNAPSHOT, false);
+ mIsFuseEnabled = SystemProperties.getBoolean(StorageManager.PROP_FUSE, false);
mContext = context;
mResolver = mContext.getContentResolver();
mCallbacks = new Callbacks(FgThread.get().getLooper());
@@ -1647,12 +1645,22 @@
* and updates PROP_FUSE (reboots if changed).
*/
private void updateFusePropFromSettings() {
- Boolean settingsFuseFlag = SystemProperties.getBoolean((FeatureFlagUtils.PERSIST_PREFIX
- + FeatureFlagUtils.SETTINGS_FUSE_FLAG), false);
- Slog.d(TAG, "The value of Settings Fuse Flag is " + settingsFuseFlag);
- if (SystemProperties.getBoolean(StorageManager.PROP_FUSE, false) != settingsFuseFlag) {
+ String settingsFuseFlag = SystemProperties.get(StorageManager.PROP_SETTINGS_FUSE);
+ Slog.d(TAG, "The value of Settings Fuse Flag is "
+ + (settingsFuseFlag == null || settingsFuseFlag.isEmpty()
+ ? "null" : settingsFuseFlag));
+ // Set default value of PROP_SETTINGS_FUSE and PROP_FUSE if it
+ // is unset (neither true nor false, this happens only on the first boot
+ // after wiping data partition).
+ if (settingsFuseFlag == null || settingsFuseFlag.isEmpty()) {
+ SystemProperties.set(StorageManager.PROP_SETTINGS_FUSE, "false");
+ SystemProperties.set(StorageManager.PROP_FUSE, "false");
+ return;
+ }
+
+ if (!SystemProperties.get(StorageManager.PROP_FUSE).equals(settingsFuseFlag)) {
Slog.d(TAG, "Set persist.sys.fuse to " + settingsFuseFlag);
- SystemProperties.set(StorageManager.PROP_FUSE, Boolean.toString(settingsFuseFlag));
+ SystemProperties.set(StorageManager.PROP_FUSE, settingsFuseFlag);
// Perform hard reboot to kick policy into place
mContext.getSystemService(PowerManager.class).reboot("Reboot device for FUSE system"
+ "property change to take effect");
@@ -3097,14 +3105,6 @@
@Override
public void mkdirs(String callingPkg, String appPath) {
- if (mIsFuseEnabled) {
- // TODO(b/144332951): Calling into Vold is risky because the FUSE daemon can go down
- // anytime and Vold will hang forever. We should either remove this call
- // or at least call into the FUSE daemon to mkdir instead
- Slog.w(TAG, "Not making dir for package " + callingPkg + " with path " + appPath);
- return;
- }
-
final int callingUid = Binder.getCallingUid();
final int userId = UserHandle.getUserId(callingUid);
final UserEnvironment userEnv = new UserEnvironment(userId);
@@ -3824,7 +3824,7 @@
}
}
if ((hasInstall || hasInstallOp) && hasWrite) {
- return Zygote.MOUNT_EXTERNAL_WRITE;
+ return Zygote.MOUNT_EXTERNAL_INSTALLER;
}
// Otherwise we're willing to give out sandboxed or non-sandboxed if
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index b560761..601d314 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -31,7 +31,6 @@
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.net.LinkProperties;
-import android.net.NetworkCapabilities;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
@@ -260,7 +259,9 @@
private final LocalLog mListenLog = new LocalLog(100);
- private PreciseDataConnectionState[] mPreciseDataConnectionState;
+ // Per-phoneMap of APN Type to DataConnectionState
+ private List<Map<String, PreciseDataConnectionState>> mPreciseDataConnectionStates =
+ new ArrayList<Map<String, PreciseDataConnectionState>>();
// Nothing here yet, but putting it here in case we want to add more in the future.
static final int ENFORCE_COARSE_LOCATION_PERMISSION_MASK = 0;
@@ -415,7 +416,6 @@
mCallQuality = copyOf(mCallQuality, mNumPhones);
mCallNetworkType = copyOf(mCallNetworkType, mNumPhones);
mCallAttributes = copyOf(mCallAttributes, mNumPhones);
- mPreciseDataConnectionState = copyOf(mPreciseDataConnectionState, mNumPhones);
mOutgoingCallEmergencyNumber = copyOf(mOutgoingCallEmergencyNumber, mNumPhones);
mOutgoingSmsEmergencyNumber = copyOf(mOutgoingSmsEmergencyNumber, mNumPhones);
@@ -423,6 +423,7 @@
if (mNumPhones < oldNumPhones) {
cutListToSize(mCellInfo, mNumPhones);
cutListToSize(mImsReasonInfo, mNumPhones);
+ cutListToSize(mPreciseDataConnectionStates, mNumPhones);
return;
}
@@ -454,7 +455,7 @@
mRingingCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mForegroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
- mPreciseDataConnectionState[i] = new PreciseDataConnectionState();
+ mPreciseDataConnectionStates.add(new HashMap<String, PreciseDataConnectionState>());
}
// Note that location can be null for non-phone builds like
@@ -516,7 +517,7 @@
mCallQuality = new CallQuality[numPhones];
mCallNetworkType = new int[numPhones];
mCallAttributes = new CallAttributes[numPhones];
- mPreciseDataConnectionState = new PreciseDataConnectionState[numPhones];
+ mPreciseDataConnectionStates = new ArrayList<>();
mCellInfo = new ArrayList<>();
mImsReasonInfo = new ArrayList<>();
mEmergencyNumberList = new HashMap<>();
@@ -549,7 +550,7 @@
mRingingCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mForegroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
- mPreciseDataConnectionState[i] = new PreciseDataConnectionState();
+ mPreciseDataConnectionStates.add(new HashMap<String, PreciseDataConnectionState>());
}
// Note that location can be null for non-phone builds like
@@ -922,8 +923,10 @@
}
if ((events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
try {
- r.callback.onPreciseDataConnectionStateChanged(
- mPreciseDataConnectionState[phoneId]);
+ for (PreciseDataConnectionState pdcs
+ : mPreciseDataConnectionStates.get(phoneId).values()) {
+ r.callback.onPreciseDataConnectionStateChanged(pdcs);
+ }
} catch (RemoteException ex) {
remove(r.binder);
}
@@ -937,7 +940,8 @@
}
if ((events & PhoneStateListener.LISTEN_VOICE_ACTIVATION_STATE) !=0) {
try {
- r.callback.onVoiceActivationStateChanged(mVoiceActivationState[phoneId]);
+ r.callback.onVoiceActivationStateChanged(
+ mVoiceActivationState[phoneId]);
} catch (RemoteException ex) {
remove(r.binder);
}
@@ -1313,7 +1317,8 @@
// only CarrierService with carrier privilege rule should have the permission
int[] subIds = Arrays.stream(SubscriptionManager.from(mContext)
.getActiveSubscriptionIdList(false))
- .filter(i -> TelephonyPermissions.checkCarrierPrivilegeForSubId(i)).toArray();
+ .filter(i -> TelephonyPermissions.checkCarrierPrivilegeForSubId(mContext,
+ i)).toArray();
if (ArrayUtils.isEmpty(subIds)) {
loge("notifyCarrierNetworkChange without carrier privilege");
// the active subId does not have carrier privilege.
@@ -1495,30 +1500,38 @@
}
}
- public void notifyDataConnection(int state, boolean isDataAllowed, String apn, String apnType,
- LinkProperties linkProperties,
- NetworkCapabilities networkCapabilities, int networkType,
- boolean roaming) {
- notifyDataConnectionForSubscriber(SubscriptionManager.DEFAULT_PHONE_INDEX,
- SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state,
- isDataAllowed, apn, apnType, linkProperties,
- networkCapabilities, networkType, roaming);
- }
-
- public void notifyDataConnectionForSubscriber(int phoneId, int subId, int state,
- boolean isDataAllowed,
- String apn, String apnType,
- LinkProperties linkProperties, NetworkCapabilities networkCapabilities,
- int networkType, boolean roaming) {
+ /**
+ * Send a notification to registrants that the data connection state has changed.
+ *
+ * @param phoneId the phoneId carrying the data connection
+ * @param subId the subscriptionId for the data connection
+ * @param apnType the APN type that triggered a change in the data connection
+ * @param preciseState a PreciseDataConnectionState that has info about the data connection
+ */
+ public void notifyDataConnectionForSubscriber(
+ int phoneId, int subId, String apnType, PreciseDataConnectionState preciseState) {
if (!checkNotifyPermission("notifyDataConnection()" )) {
return;
}
+
+ String apn = "";
+ int state = TelephonyManager.DATA_UNKNOWN;
+ int networkType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
+ LinkProperties linkProps = null;
+
+ if (preciseState != null) {
+ apn = preciseState.getDataConnectionApn();
+ state = preciseState.getState();
+ networkType = preciseState.getNetworkType();
+ linkProps = preciseState.getDataConnectionLinkProperties();
+ }
if (VDBG) {
log("notifyDataConnectionForSubscriber: subId=" + subId
- + " state=" + state + " isDataAllowed=" + isDataAllowed
- + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType
- + " mRecords.size()=" + mRecords.size());
+ + " state=" + state + "' apn='" + apn
+ + "' apnType=" + apnType + " networkType=" + networkType
+ + "' preciseState=" + preciseState);
}
+
synchronized (mRecords) {
if (validatePhoneId(phoneId)) {
// We only call the callback when the change is for default APN type.
@@ -1550,36 +1563,48 @@
mDataConnectionState[phoneId] = state;
mDataConnectionNetworkType[phoneId] = networkType;
}
- mPreciseDataConnectionState[phoneId] = new PreciseDataConnectionState(
- state, networkType,
- ApnSetting.getApnTypesBitmaskFromString(apnType), apn,
- linkProperties, DataFailCause.NONE);
- for (Record r : mRecords) {
- if (r.matchPhoneStateListenerEvent(
- PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)
- && idMatch(r.subId, subId, phoneId)) {
- try {
- r.callback.onPreciseDataConnectionStateChanged(
- mPreciseDataConnectionState[phoneId]);
- } catch (RemoteException ex) {
- mRemoveList.add(r.binder);
+
+ boolean needsNotify = false;
+ // State has been cleared for this APN Type
+ if (preciseState == null) {
+ // We try clear the state and check if the state was previously not cleared
+ needsNotify = mPreciseDataConnectionStates.get(phoneId).remove(apnType) != null;
+ } else {
+ // We need to check to see if the state actually changed
+ PreciseDataConnectionState oldPreciseState =
+ mPreciseDataConnectionStates.get(phoneId).put(apnType, preciseState);
+ needsNotify = !preciseState.equals(oldPreciseState);
+ }
+
+ if (needsNotify) {
+ for (Record r : mRecords) {
+ if (r.matchPhoneStateListenerEvent(
+ PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)
+ && idMatch(r.subId, subId, phoneId)) {
+ try {
+ r.callback.onPreciseDataConnectionStateChanged(preciseState);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
+ }
}
}
}
}
handleRemoveListLocked();
}
- broadcastDataConnectionStateChanged(state, isDataAllowed, apn, apnType, linkProperties,
- networkCapabilities, roaming, subId);
+
+ broadcastDataConnectionStateChanged(state, apn, apnType, subId);
}
+ /**
+ * Stub to satisfy the ITelephonyRegistry aidl interface; do not use this function.
+ * @see #notifyDataConnectionFailedForSubscriber
+ */
public void notifyDataConnectionFailed(String apnType) {
- notifyDataConnectionFailedForSubscriber(SubscriptionManager.DEFAULT_PHONE_INDEX,
- SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
- apnType);
+ loge("This function should not be invoked");
}
- public void notifyDataConnectionFailedForSubscriber(int phoneId, int subId, String apnType) {
+ private void notifyDataConnectionFailedForSubscriber(int phoneId, int subId, String apnType) {
if (!checkNotifyPermission("notifyDataConnectionFailed()")) {
return;
}
@@ -1589,17 +1614,20 @@
}
synchronized (mRecords) {
if (validatePhoneId(phoneId)) {
- mPreciseDataConnectionState[phoneId] = new PreciseDataConnectionState(
- TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN,
- ApnSetting.getApnTypesBitmaskFromString(apnType), null, null,
- DataFailCause.NONE);
+ mPreciseDataConnectionStates.get(phoneId).put(
+ apnType,
+ new PreciseDataConnectionState(
+ TelephonyManager.DATA_UNKNOWN,
+ TelephonyManager.NETWORK_TYPE_UNKNOWN,
+ ApnSetting.getApnTypesBitmaskFromString(apnType), null, null,
+ DataFailCause.NONE));
for (Record r : mRecords) {
if (r.matchPhoneStateListenerEvent(
PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)
&& idMatch(r.subId, subId, phoneId)) {
try {
r.callback.onPreciseDataConnectionStateChanged(
- mPreciseDataConnectionState[phoneId]);
+ mPreciseDataConnectionStates.get(phoneId).get(apnType));
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
@@ -1787,25 +1815,32 @@
if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) {
return;
}
+
+ // precise notify invokes imprecise notify
+ notifyDataConnectionFailedForSubscriber(phoneId, subId, apnType);
+
synchronized (mRecords) {
if (validatePhoneId(phoneId)) {
- mPreciseDataConnectionState[phoneId] = new PreciseDataConnectionState(
- TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN,
- ApnSetting.getApnTypesBitmaskFromString(apnType), apn, null, failCause);
+ mPreciseDataConnectionStates.get(phoneId).put(
+ apnType,
+ new PreciseDataConnectionState(
+ TelephonyManager.DATA_UNKNOWN,
+ TelephonyManager.NETWORK_TYPE_UNKNOWN,
+ ApnSetting.getApnTypesBitmaskFromString(apnType), null, null,
+ failCause));
for (Record r : mRecords) {
if (r.matchPhoneStateListenerEvent(
PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)
&& idMatch(r.subId, subId, phoneId)) {
try {
r.callback.onPreciseDataConnectionStateChanged(
- mPreciseDataConnectionState[phoneId]);
+ mPreciseDataConnectionStates.get(phoneId).get(apnType));
} catch (RemoteException ex) {
mRemoveList.add(r.binder);
}
}
}
}
-
handleRemoveListLocked();
}
}
@@ -2063,7 +2098,6 @@
}
}
-
@Override
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ");
@@ -2102,7 +2136,7 @@
pw.println("mCallQuality=" + mCallQuality[i]);
pw.println("mCallAttributes=" + mCallAttributes[i]);
pw.println("mCallNetworkType=" + mCallNetworkType[i]);
- pw.println("mPreciseDataConnectionState=" + mPreciseDataConnectionState[i]);
+ pw.println("mPreciseDataConnectionStates=" + mPreciseDataConnectionStates.get(i));
pw.println("mOutgoingCallEmergencyNumber=" + mOutgoingCallEmergencyNumber[i]);
pw.println("mOutgoingSmsEmergencyNumber=" + mOutgoingSmsEmergencyNumber[i]);
pw.decreaseIndent();
@@ -2262,29 +2296,13 @@
}
}
- private void broadcastDataConnectionStateChanged(int state, boolean isDataAllowed, String apn,
- String apnType, LinkProperties linkProperties,
- NetworkCapabilities networkCapabilities,
- boolean roaming, int subId) {
+ private void broadcastDataConnectionStateChanged(int state, String apn,
+ String apnType, int subId) {
// Note: not reporting to the battery stats service here, because the
// status bar takes care of that after taking into account all of the
// required info.
Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
intent.putExtra(TelephonyManager.EXTRA_STATE, dataStateToString(state));
- if (!isDataAllowed) {
- intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true);
- }
- if (linkProperties != null) {
- intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
- String iface = linkProperties.getInterfaceName();
- if (iface != null) {
- intent.putExtra(PhoneConstants.DATA_IFACE_NAME_KEY, iface);
- }
- }
- if (networkCapabilities != null) {
- intent.putExtra(PhoneConstants.DATA_NETWORK_CAPABILITIES_KEY, networkCapabilities);
- }
- if (roaming) intent.putExtra(PhoneConstants.DATA_NETWORK_ROAMING_KEY, true);
intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
@@ -2304,7 +2322,7 @@
return;
}
- TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege(
+ TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege(mContext,
SubscriptionManager.getDefaultSubscriptionId(), method);
}
diff --git a/services/core/java/com/android/server/VibratorService.java b/services/core/java/com/android/server/VibratorService.java
index 3330882..f6c11cd 100644
--- a/services/core/java/com/android/server/VibratorService.java
+++ b/services/core/java/com/android/server/VibratorService.java
@@ -25,6 +25,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManagerInternal;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.hardware.input.InputManager;
@@ -79,7 +80,6 @@
implements InputManager.InputDeviceListener {
private static final String TAG = "VibratorService";
private static final boolean DEBUG = false;
- private static final String SYSTEM_UI_PACKAGE = "com.android.systemui";
private static final String EXTERNAL_VIBRATOR_SERVICE = "external_vibrator_service";
private static final String RAMPING_RINGER_ENABLED = "ramping_ringer_enabled";
@@ -139,6 +139,7 @@
private final PowerManager.WakeLock mWakeLock;
private final AppOpsManager mAppOps;
private final IBatteryStats mBatteryStatsService;
+ private final String mSystemUiPackage;
private PowerManagerInternal mPowerManagerInternal;
private InputManager mIm;
private Vibrator mVibrator;
@@ -284,7 +285,7 @@
}
public boolean isFromSystem() {
- return uid == Process.SYSTEM_UID || uid == 0 || SYSTEM_UI_PACKAGE.equals(opPkg);
+ return uid == Process.SYSTEM_UID || uid == 0 || mSystemUiPackage.equals(opPkg);
}
public VibrationInfo toInfo() {
@@ -372,6 +373,8 @@
mAppOps = mContext.getSystemService(AppOpsManager.class);
mBatteryStatsService = IBatteryStats.Stub.asInterface(ServiceManager.getService(
BatteryStats.SERVICE_NAME));
+ mSystemUiPackage = LocalServices.getService(PackageManagerInternal.class)
+ .getSystemUiServiceComponent().getPackageName();
mPreviousVibrationsLimit = mContext.getResources().getInteger(
com.android.internal.R.integer.config_previousVibrationsDumpLimit);
diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java
index e101fe0..5996b7d 100644
--- a/services/core/java/com/android/server/accounts/AccountManagerService.java
+++ b/services/core/java/com/android/server/accounts/AccountManagerService.java
@@ -4409,7 +4409,6 @@
return true;
}
- @Override
public boolean renameSharedAccountAsUser(Account account, String newName, int userId) {
userId = handleIncomingUser(userId);
UserAccounts accounts = getUserAccounts(userId);
@@ -4425,7 +4424,6 @@
return r > 0;
}
- @Override
public boolean removeSharedAccountAsUser(Account account, int userId) {
return removeSharedAccountAsUser(account, userId, getCallingUid());
}
@@ -4443,7 +4441,6 @@
return deleted;
}
- @Override
public Account[] getSharedAccountsAsUser(int userId) {
userId = handleIncomingUser(userId);
UserAccounts accounts = getUserAccounts(userId);
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index c2dd046..f1cee034 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -490,7 +490,7 @@
static final String[] EMPTY_STRING_ARRAY = new String[0];
// How many bytes to write into the dropbox log before truncating
- static final int DROPBOX_MAX_SIZE = 192 * 1024;
+ static final int DROPBOX_DEFAULT_MAX_SIZE = 192 * 1024;
// Assumes logcat entries average around 100 bytes; that's not perfect stack traces count
// as one line, but close enough for now.
static final int RESERVED_BYTES_PER_LOGCAT_LINE = 100;
@@ -8389,6 +8389,18 @@
return BugReportHandlerUtil.launchBugReportHandlerApp(mContext);
}
+ /**
+ * Get packages of bugreport-whitelisted apps to handle a bug report.
+ *
+ * @return packages of bugreport-whitelisted apps to handle a bug report.
+ */
+ @Override
+ public List<String> getBugreportWhitelistedPackages() {
+ enforceCallingPermission(android.Manifest.permission.MANAGE_DEBUGGING,
+ "getBugreportWhitelistedPackages");
+ return new ArrayList<>(SystemConfig.getInstance().getBugreportWhitelistedPackages());
+ }
+
public void registerProcessObserver(IProcessObserver observer) {
enforceCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER,
"registerProcessObserver()");
@@ -9770,9 +9782,12 @@
sb.append(report);
}
- String setting = Settings.Global.ERROR_LOGCAT_PREFIX + dropboxTag;
- int lines = Settings.Global.getInt(mContext.getContentResolver(), setting, 0);
- int maxDataFileSize = DROPBOX_MAX_SIZE - sb.length()
+ String logcatSetting = Settings.Global.ERROR_LOGCAT_PREFIX + dropboxTag;
+ String maxBytesSetting = Settings.Global.MAX_ERROR_BYTES_PREFIX + dropboxTag;
+ int lines = Settings.Global.getInt(mContext.getContentResolver(), logcatSetting, 0);
+ int dropboxMaxSize = Settings.Global.getInt(
+ mContext.getContentResolver(), maxBytesSetting, DROPBOX_DEFAULT_MAX_SIZE);
+ int maxDataFileSize = dropboxMaxSize - sb.length()
- lines * RESERVED_BYTES_PER_LOGCAT_LINE;
if (dataFile != null && maxDataFileSize > 0) {
@@ -18433,7 +18448,7 @@
public ActivityPresentationInfo getActivityPresentationInfo(IBinder token) {
int displayId = Display.INVALID_DISPLAY;
try {
- displayId = mActivityTaskManager.getActivityDisplayId(token);
+ displayId = mActivityTaskManager.getDisplayId(token);
} catch (RemoteException e) {
}
diff --git a/services/core/java/com/android/server/am/LmkdConnection.java b/services/core/java/com/android/server/am/LmkdConnection.java
index d1e09db..f41c364 100644
--- a/services/core/java/com/android/server/am/LmkdConnection.java
+++ b/services/core/java/com/android/server/am/LmkdConnection.java
@@ -18,6 +18,7 @@
import static android.os.MessageQueue.OnFileDescriptorEventListener.EVENT_ERROR;
import static android.os.MessageQueue.OnFileDescriptorEventListener.EVENT_INPUT;
+
import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
@@ -35,9 +36,6 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
-import java.util.concurrent.TimeUnit;
/**
* Lmkd connection to communicate with lowmemorykiller daemon.
@@ -46,7 +44,7 @@
private static final String TAG = TAG_WITH_CLASS_NAME ? "LmkdConnection" : TAG_AM;
// lmkd reply max size in bytes
- private static final int LMKD_REPLY_MAX_SIZE = 8;
+ private static final int LMKD_REPLY_MAX_SIZE = 12;
// connection listener interface
interface LmkdConnectionListener {
@@ -64,6 +62,15 @@
*/
public boolean isReplyExpected(ByteBuffer replyBuf, ByteBuffer dataReceived,
int receivedLen);
+
+ /**
+ * Handle the received message if it's unsolicited.
+ *
+ * @param dataReceived The buffer holding received data
+ * @param receivedLen Size of the data received
+ * @return True if the message has been handled correctly, false otherwise.
+ */
+ boolean handleUnsolicitedMessage(ByteBuffer dataReceived, int receivedLen);
}
private final MessageQueue mMsgQueue;
@@ -187,17 +194,17 @@
mReplyBuf.rewind();
// wakeup the waiting thread
mReplyBufLock.notifyAll();
- } else {
- // received asynchronous or unexpected packet
+ } else if (!mListener.handleUnsolicitedMessage(mInputBuf, len)) {
+ // received unexpected packet
// treat this as an error
mReplyBuf = null;
mReplyBufLock.notifyAll();
- Slog.e(TAG, "Received unexpected packet from lmkd");
+ Slog.e(TAG, "Received an unexpected packet from lmkd");
}
- } else {
+ } else if (!mListener.handleUnsolicitedMessage(mInputBuf, len)) {
// received asynchronous communication from lmkd
- // we don't support this yet
- Slog.w(TAG, "Received an asynchronous packet from lmkd");
+ // but we don't recognize it.
+ Slog.w(TAG, "Received an unexpected packet from lmkd");
}
}
}
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index 209b1d2..5378f43 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -278,14 +278,16 @@
// LMK_PROCREMOVE <pid>
// LMK_PROCPURGE
// LMK_GETKILLCNT
+ // LMK_PROCKILL
static final byte LMK_TARGET = 0;
static final byte LMK_PROCPRIO = 1;
static final byte LMK_PROCREMOVE = 2;
static final byte LMK_PROCPURGE = 3;
static final byte LMK_GETKILLCNT = 4;
+ static final byte LMK_PROCKILL = 5; // Note: this is an unsolicated command
// lmkd reconnect delay in msecs
- private final static long LMDK_RECONNECT_DELAY_MS = 1000;
+ private static final long LMKD_RECONNECT_DELAY_MS = 1000;
/**
* How long between a process kill and we actually receive its death recipient
@@ -391,6 +393,12 @@
ActiveUids mActiveUids;
/**
+ * The listener who is intereted with the lmkd kills.
+ */
+ @GuardedBy("mService")
+ private LmkdKillListener mLmkdKillListener = null;
+
+ /**
* The currently running isolated processes.
*/
final SparseArray<ProcessRecord> mIsolatedProcesses = new SparseArray<>();
@@ -408,6 +416,13 @@
private PlatformCompat mPlatformCompat = null;
+ interface LmkdKillListener {
+ /**
+ * Called when there is a process kill by lmkd.
+ */
+ void onLmkdKillOccurred(int pid, int uid);
+ }
+
final class IsolatedUidRange {
@VisibleForTesting
public final int mFirstUid;
@@ -560,7 +575,8 @@
final class KillHandler extends Handler {
static final int KILL_PROCESS_GROUP_MSG = 4000;
- static final int LMDK_RECONNECT_MSG = 4001;
+ static final int LMKD_RECONNECT_MSG = 4001;
+ static final int LMKD_PROC_KILLED_MSG = 4002;
public KillHandler(Looper looper) {
super(looper, null, true);
@@ -574,15 +590,18 @@
Process.killProcessGroup(msg.arg1 /* uid */, msg.arg2 /* pid */);
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
break;
- case LMDK_RECONNECT_MSG:
+ case LMKD_RECONNECT_MSG:
if (!sLmkdConnection.connect()) {
Slog.i(TAG, "Failed to connect to lmkd, retry after " +
- LMDK_RECONNECT_DELAY_MS + " ms");
- // retry after LMDK_RECONNECT_DELAY_MS
+ LMKD_RECONNECT_DELAY_MS + " ms");
+ // retry after LMKD_RECONNECT_DELAY_MS
sKillHandler.sendMessageDelayed(sKillHandler.obtainMessage(
- KillHandler.LMDK_RECONNECT_MSG), LMDK_RECONNECT_DELAY_MS);
+ KillHandler.LMKD_RECONNECT_MSG), LMKD_RECONNECT_DELAY_MS);
}
break;
+ case LMKD_PROC_KILLED_MSG:
+ handleLmkdProcKilled(msg.arg1 /* pid */, msg.arg2 /* uid */);
+ break;
default:
super.handleMessage(msg);
@@ -623,7 +642,7 @@
Slog.w(TAG, "Lost connection to lmkd");
// start reconnection after delay to let lmkd restart
sKillHandler.sendMessageDelayed(sKillHandler.obtainMessage(
- KillHandler.LMDK_RECONNECT_MSG), LMDK_RECONNECT_DELAY_MS);
+ KillHandler.LMKD_RECONNECT_MSG), LMKD_RECONNECT_DELAY_MS);
}
@Override
@@ -634,6 +653,26 @@
return (receivedLen == replyBuf.array().length &&
dataReceived.getInt(0) == replyBuf.getInt(0));
}
+
+ @Override
+ public boolean handleUnsolicitedMessage(ByteBuffer dataReceived,
+ int receivedLen) {
+ if (receivedLen < 4) {
+ return false;
+ }
+ switch (dataReceived.getInt(0)) {
+ case LMK_PROCKILL:
+ if (receivedLen != 12) {
+ return false;
+ }
+ sKillHandler.obtainMessage(KillHandler.LMKD_PROC_KILLED_MSG,
+ dataReceived.getInt(4), dataReceived.getInt(8))
+ .sendToTarget();
+ return true;
+ default:
+ return false;
+ }
+ }
}
);
}
@@ -1310,10 +1349,10 @@
if (!sLmkdConnection.isConnected()) {
// try to connect immediately and then keep retrying
sKillHandler.sendMessage(
- sKillHandler.obtainMessage(KillHandler.LMDK_RECONNECT_MSG));
+ sKillHandler.obtainMessage(KillHandler.LMKD_RECONNECT_MSG));
// wait for connection retrying 3 times (up to 3 seconds)
- if (!sLmkdConnection.waitForConnection(3 * LMDK_RECONNECT_DELAY_MS)) {
+ if (!sLmkdConnection.waitForConnection(3 * LMKD_RECONNECT_DELAY_MS)) {
return false;
}
}
@@ -3405,4 +3444,28 @@
}
}
}
+
+ void setLmkdKillListener(final LmkdKillListener listener) {
+ synchronized (mService) {
+ mLmkdKillListener = listener;
+ }
+ }
+
+ private void handleLmkdProcKilled(final int pid, final int uid) {
+ // Log only now
+ if (DEBUG_PROCESSES) {
+ Slog.i(TAG, "lmkd kill: pid=" + pid + " uid=" + uid);
+ }
+
+ if (mService == null) {
+ return;
+ }
+ // Notify any interesed party regarding the lmkd kills
+ synchronized (mService) {
+ final LmkdKillListener listener = mLmkdKillListener;
+ if (listener != null) {
+ mService.mHandler.post(()-> listener.onLmkdKillOccurred(pid, uid));
+ }
+ }
+ }
}
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index 366766e..14f9654 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -20,6 +20,7 @@
import static android.app.AppOpsManager.MAX_PRIORITY_UID_STATE;
import static android.app.AppOpsManager.MIN_PRIORITY_UID_STATE;
import static android.app.AppOpsManager.OP_CAMERA;
+import static android.app.AppOpsManager.OP_COARSE_LOCATION;
import static android.app.AppOpsManager.OP_FLAGS_ALL;
import static android.app.AppOpsManager.OP_NONE;
import static android.app.AppOpsManager.OP_PLAY_AUDIO;
@@ -1642,6 +1643,13 @@
return;
}
+ // STOPSHIP: Remove this check once we are sure no one is doing it.
+ if (code == OP_COARSE_LOCATION && mode != AppOpsManager.opToDefaultMode(code)) {
+ Slog.wtf(TAG, "Trying to setMode() instead of setUidMode(), " + "code=" + code
+ + ", uid=" + uid + ", packageName=" + packageName + ", mode=" + mode
+ + ", callingUid=" + Binder.getCallingUid(), new RuntimeException());
+ }
+
synchronized (this) {
UidState uidState = getUidStateLocked(uid, false);
Op op = getOpLocked(code, uid, packageName, isPrivileged, true);
diff --git a/services/core/java/com/android/server/attention/AttentionManagerService.java b/services/core/java/com/android/server/attention/AttentionManagerService.java
index 232bc08e..fc67e24 100644
--- a/services/core/java/com/android/server/attention/AttentionManagerService.java
+++ b/services/core/java/com/android/server/attention/AttentionManagerService.java
@@ -77,21 +77,28 @@
private static final String LOG_TAG = "AttentionManagerService";
private static final boolean DEBUG = false;
- /** Default value in absence of {@link DeviceConfig} override. */
- private static final boolean DEFAULT_SERVICE_ENABLED = true;
-
/** Service will unbind if connection is not used for that amount of time. */
private static final long CONNECTION_TTL_MILLIS = 60_000;
- /** If the check attention called within that period - cached value will be returned. */
- private static final long STALE_AFTER_MILLIS = 5_000;
+ /** DeviceConfig flag name, if {@code true}, enables AttentionManagerService features. */
+ private static final String KEY_SERVICE_ENABLED = "service_enabled";
+
+ /** Default value in absence of {@link DeviceConfig} override. */
+ private static final boolean DEFAULT_SERVICE_ENABLED = true;
+
+ /**
+ * DeviceConfig flag name, describes how much time we consider a result fresh; if the check
+ * attention called within that period - cached value will be returned.
+ */
+ @VisibleForTesting static final String KEY_STALE_AFTER_MILLIS = "stale_after_millis";
+
+ /** Default value in absence of {@link DeviceConfig} override. */
+ @VisibleForTesting static final long DEFAULT_STALE_AFTER_MILLIS = 1_000;
/** The size of the buffer that stores recent attention check results. */
@VisibleForTesting
protected static final int ATTENTION_CACHE_BUFFER_SIZE = 5;
- /** DeviceConfig flag name, if {@code true}, enables AttentionManagerService features. */
- private static final String SERVICE_ENABLED = "service_enabled";
private static String sTestAttentionServicePackage;
private final Context mContext;
private final PowerManager mPowerManager;
@@ -160,11 +167,29 @@
@VisibleForTesting
protected boolean isServiceEnabled() {
- return DeviceConfig.getBoolean(NAMESPACE_ATTENTION_MANAGER_SERVICE, SERVICE_ENABLED,
+ return DeviceConfig.getBoolean(NAMESPACE_ATTENTION_MANAGER_SERVICE, KEY_SERVICE_ENABLED,
DEFAULT_SERVICE_ENABLED);
}
/**
+ * How much time we consider a result fresh; if the check attention called within that period -
+ * cached value will be returned.
+ */
+ @VisibleForTesting
+ protected long getStaleAfterMillis() {
+ final long millis = DeviceConfig.getLong(NAMESPACE_ATTENTION_MANAGER_SERVICE,
+ KEY_STALE_AFTER_MILLIS,
+ DEFAULT_STALE_AFTER_MILLIS);
+
+ if (millis < 0 || millis > 10_000) {
+ Slog.w(LOG_TAG, "Bad flag value supplied for: " + KEY_STALE_AFTER_MILLIS);
+ return DEFAULT_STALE_AFTER_MILLIS;
+ }
+
+ return millis;
+ }
+
+ /**
* Checks whether user attention is at the screen and calls in the provided callback.
*
* Calling this multiple times quickly in a row will result in either a) returning a cached
@@ -199,7 +224,7 @@
// throttle frequent requests
final AttentionCheckCache cache = userState.mAttentionCheckCacheBuffer == null ? null
: userState.mAttentionCheckCacheBuffer.getLast();
- if (cache != null && now < cache.mLastComputed + STALE_AFTER_MILLIS) {
+ if (cache != null && now < cache.mLastComputed + getStaleAfterMillis()) {
callbackInternal.onSuccess(cache.mResult, cache.mTimestamp);
return true;
}
diff --git a/services/core/java/com/android/server/audio/AudioDeviceBroker.java b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
index 8144a71..60f420e 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceBroker.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
@@ -600,19 +600,11 @@
sendMsgNoDelay(MSG_REPORT_NEW_ROUTES, SENDMSG_NOOP);
}
- /*package*/ void cancelA2dpDockTimeout() {
- mBrokerHandler.removeMessages(MSG_IL_BTA2DP_DOCK_TIMEOUT);
- }
-
/*package*/ void postA2dpActiveDeviceChange(
@NonNull BtHelper.BluetoothA2dpDeviceInfo btDeviceInfo) {
sendLMsgNoDelay(MSG_L_A2DP_ACTIVE_DEVICE_CHANGE, SENDMSG_QUEUE, btDeviceInfo);
}
- /*package*/ boolean hasScheduledA2dpDockTimeout() {
- return mBrokerHandler.hasMessages(MSG_IL_BTA2DP_DOCK_TIMEOUT);
- }
-
// must be called synchronized on mConnectedDevices
/*package*/ boolean hasScheduledA2dpSinkConnectionState(BluetoothDevice btDevice) {
return (mBrokerHandler.hasMessages(MSG_IL_SET_A2DP_SINK_CONNECTION_STATE_CONNECTED,
@@ -621,8 +613,8 @@
new BtHelper.BluetoothA2dpDeviceInfo(btDevice)));
}
- /*package*/ void setA2dpDockTimeout(String address, int a2dpCodec, int delayMs) {
- sendILMsg(MSG_IL_BTA2DP_DOCK_TIMEOUT, SENDMSG_QUEUE, a2dpCodec, address, delayMs);
+ /*package*/ void setA2dpTimeout(String address, int a2dpCodec, int delayMs) {
+ sendILMsg(MSG_IL_BTA2DP_TIMEOUT, SENDMSG_QUEUE, a2dpCodec, address, delayMs);
}
/*package*/ void setAvrcpAbsoluteVolumeSupported(boolean supported) {
@@ -781,7 +773,7 @@
}
}
break;
- case MSG_IL_BTA2DP_DOCK_TIMEOUT:
+ case MSG_IL_BTA2DP_TIMEOUT:
// msg.obj == address of BTA2DP device
synchronized (mDeviceStateLock) {
mDeviceInventory.onMakeA2dpDeviceUnavailableNow((String) msg.obj, msg.arg1);
@@ -945,7 +937,7 @@
private static final int MSG_IL_SET_A2DP_SOURCE_CONNECTION_STATE = 7;
private static final int MSG_IL_SET_HEARING_AID_CONNECTION_STATE = 8;
private static final int MSG_BT_HEADSET_CNCT_FAILED = 9;
- private static final int MSG_IL_BTA2DP_DOCK_TIMEOUT = 10;
+ private static final int MSG_IL_BTA2DP_TIMEOUT = 10;
private static final int MSG_L_A2DP_DEVICE_CONFIG_CHANGE = 11;
private static final int MSG_BROADCAST_AUDIO_BECOMING_NOISY = 12;
private static final int MSG_REPORT_NEW_ROUTES = 13;
@@ -981,7 +973,7 @@
case MSG_IL_SET_A2DP_SINK_CONNECTION_STATE_DISCONNECTED:
case MSG_IL_SET_A2DP_SOURCE_CONNECTION_STATE:
case MSG_IL_SET_HEARING_AID_CONNECTION_STATE:
- case MSG_IL_BTA2DP_DOCK_TIMEOUT:
+ case MSG_IL_BTA2DP_TIMEOUT:
case MSG_L_A2DP_DEVICE_CONFIG_CHANGE:
case MSG_TOGGLE_HDMI:
case MSG_L_A2DP_ACTIVE_DEVICE_CHANGE:
@@ -1071,7 +1063,7 @@
case MSG_IL_SET_A2DP_SINK_CONNECTION_STATE_DISCONNECTED:
case MSG_IL_SET_HEARING_AID_CONNECTION_STATE:
case MSG_L_SET_WIRED_DEVICE_CONNECTION_STATE:
- case MSG_IL_BTA2DP_DOCK_TIMEOUT:
+ case MSG_IL_BTA2DP_TIMEOUT:
case MSG_L_A2DP_DEVICE_CONFIG_CHANGE:
case MSG_L_A2DP_ACTIVE_DEVICE_CHANGE:
if (sLastDeviceConnectMsgTime >= time) {
diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
index 661451b..df56004 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
@@ -59,18 +59,26 @@
private static final String TAG = "AS.AudioDeviceInventory";
- // Actual list of connected devices
+ // lock to synchronize all access to mConnectedDevices and mApmConnectedDevices
+ private final Object mDevicesLock = new Object();
+
+ // List of connected devices
// Key for map created from DeviceInfo.makeDeviceListKey()
+ @GuardedBy("mDevicesLock")
private final LinkedHashMap<String, DeviceInfo> mConnectedDevices = new LinkedHashMap<>();
+ // List of devices actually connected to AudioPolicy (through AudioSystem), only one
+ // by device type, which is used as the key, value is the DeviceInfo generated key.
+ // For the moment only for A2DP sink devices.
+ // TODO: extend to all device types
+ @GuardedBy("mDevicesLock")
+ private final ArrayMap<Integer, String> mApmConnectedDevices = new ArrayMap<>();
+
// List of preferred devices for strategies
private final ArrayMap<Integer, AudioDeviceAddress> mPreferredDevices = new ArrayMap<>();
private @NonNull AudioDeviceBroker mDeviceBroker;
- // cache of the address of the last dock the device was connected to
- private String mDockAddress;
-
// Monitoring of audio routes. Protected by mAudioRoutes.
final AudioRoutesInfo mCurAudioRoutes = new AudioRoutesInfo();
final RemoteCallbackList<IAudioRoutesObserver> mRoutesObservers =
@@ -97,25 +105,30 @@
*/
private static class DeviceInfo {
final int mDeviceType;
- final String mDeviceName;
- final String mDeviceAddress;
+ final @NonNull String mDeviceName;
+ final @NonNull String mDeviceAddress;
int mDeviceCodecFormat;
DeviceInfo(int deviceType, String deviceName, String deviceAddress, int deviceCodecFormat) {
mDeviceType = deviceType;
- mDeviceName = deviceName;
- mDeviceAddress = deviceAddress;
+ mDeviceName = deviceName == null ? "" : deviceName;
+ mDeviceAddress = deviceAddress == null ? "" : deviceAddress;
mDeviceCodecFormat = deviceCodecFormat;
}
@Override
public String toString() {
return "[DeviceInfo: type:0x" + Integer.toHexString(mDeviceType)
- + " name:" + mDeviceName
+ + " (" + AudioSystem.getDeviceName(mDeviceType)
+ + ") name:" + mDeviceName
+ " addr:" + mDeviceAddress
+ " codec: " + Integer.toHexString(mDeviceCodecFormat) + "]";
}
+ String getKey() {
+ return makeDeviceListKey(mDeviceType, mDeviceAddress);
+ }
+
/**
* Generate a unique key for the mConnectedDevices List by composing the device "type"
* and the "address" associated with a specific instance of that device type
@@ -150,6 +163,14 @@
pw.println("\n" + prefix + "Preferred devices for strategy:");
mPreferredDevices.forEach((strategy, device) -> {
pw.println(" " + prefix + "strategy:" + strategy + " device:" + device); });
+ pw.println("\n" + prefix + "Connected devices:");
+ mConnectedDevices.forEach((key, deviceInfo) -> {
+ pw.println(" " + prefix + deviceInfo.toString()); });
+ pw.println("\n" + prefix + "APM Connected device (A2DP sink only):");
+ mApmConnectedDevices.forEach((keyType, valueAddress) -> {
+ pw.println(" " + prefix + " type:0x" + Integer.toHexString(keyType)
+ + " (" + AudioSystem.getDeviceName(keyType)
+ + ") addr:" + valueAddress); });
}
//------------------------------------------------------------
@@ -161,7 +182,8 @@
*/
// Always executed on AudioDeviceBroker message queue
/*package*/ void onRestoreDevices() {
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
+ //TODO iterate on mApmConnectedDevices instead once it handles all device types
for (DeviceInfo di : mConnectedDevices.values()) {
AudioSystem.setDeviceConnectionState(
di.mDeviceType,
@@ -171,7 +193,6 @@
di.mDeviceCodecFormat);
}
}
-
synchronized (mPreferredDevices) {
mPreferredDevices.forEach((strategy, device) -> {
AudioSystem.setPreferredDeviceForStrategy(strategy, device); });
@@ -187,9 +208,12 @@
int a2dpVolume = btInfo.getVolume();
if (AudioService.DEBUG_DEVICES) {
Log.d(TAG, "onSetA2dpSinkConnectionState btDevice=" + btDevice + " state="
- + state + " is dock=" + btDevice.isBluetoothDock() + " vol=" + a2dpVolume);
+ + state + " vol=" + a2dpVolume);
}
String address = btDevice.getAddress();
+ if (address == null) {
+ address = "";
+ }
if (!BluetoothAdapter.checkBluetoothAddress(address)) {
address = "";
}
@@ -201,7 +225,7 @@
+ " codec=" + a2dpCodec
+ " vol=" + a2dpVolume));
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
final String key = DeviceInfo.makeDeviceListKey(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
btDevice.getAddress());
final DeviceInfo di = mConnectedDevices.get(key);
@@ -215,42 +239,17 @@
mDeviceBroker.postBluetoothA2dpDeviceConfigChange(btDevice);
}
} else {
- if (btDevice.isBluetoothDock()) {
- if (state == BluetoothProfile.STATE_DISCONNECTED) {
- // introduction of a delay for transient disconnections of docks when
- // power is rapidly turned off/on, this message will be canceled if
- // we reconnect the dock under a preset delay
- makeA2dpDeviceUnavailableLater(address,
- AudioDeviceBroker.BTA2DP_DOCK_TIMEOUT_MS);
- // the next time isConnected is evaluated, it will be false for the dock
- }
- } else {
- makeA2dpDeviceUnavailableNow(address, di.mDeviceCodecFormat);
- }
+ makeA2dpDeviceUnavailableNow(address, di.mDeviceCodecFormat);
}
- } else if (!isConnected && state == BluetoothProfile.STATE_CONNECTED) {
- if (btDevice.isBluetoothDock()) {
- // this could be a reconnection after a transient disconnection
- mDeviceBroker.cancelA2dpDockTimeout();
- mDockAddress = address;
- } else {
- // this could be a connection of another A2DP device before the timeout of
- // a dock: cancel the dock timeout, and make the dock unavailable now
- if (mDeviceBroker.hasScheduledA2dpDockTimeout() && mDockAddress != null) {
- mDeviceBroker.cancelA2dpDockTimeout();
- makeA2dpDeviceUnavailableNow(mDockAddress,
- AudioSystem.AUDIO_FORMAT_DEFAULT);
- }
- }
- if (a2dpVolume != -1) {
- mDeviceBroker.postSetVolumeIndexOnDevice(AudioSystem.STREAM_MUSIC,
- // convert index to internal representation in VolumeStreamState
- a2dpVolume * 10,
- AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, "onSetA2dpSinkConnectionState");
- }
- makeA2dpDeviceAvailable(address, BtHelper.getName(btDevice),
- "onSetA2dpSinkConnectionState", a2dpCodec);
}
+ if (a2dpVolume != -1) {
+ mDeviceBroker.postSetVolumeIndexOnDevice(AudioSystem.STREAM_MUSIC,
+ // convert index to internal representation in VolumeStreamState
+ a2dpVolume * 10,
+ AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, "onSetA2dpSinkConnectionState");
+ }
+ makeA2dpDeviceAvailable(address, BtHelper.getName(btDevice),
+ "onSetA2dpSinkConnectionState", a2dpCodec);
}
}
@@ -266,7 +265,7 @@
address = "";
}
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
final String key = DeviceInfo.makeDeviceListKey(
AudioSystem.DEVICE_IN_BLUETOOTH_A2DP, address);
final DeviceInfo di = mConnectedDevices.get(key);
@@ -289,7 +288,7 @@
AudioService.sDeviceLogger.log(new AudioEventLogger.StringEvent(
"onSetHearingAidConnectionState addr=" + address));
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
final String key = DeviceInfo.makeDeviceListKey(AudioSystem.DEVICE_OUT_HEARING_AID,
btDevice.getAddress());
final DeviceInfo di = mConnectedDevices.get(key);
@@ -325,7 +324,7 @@
"onBluetoothA2dpActiveDeviceChange addr=" + address
+ " event=" + BtHelper.a2dpDeviceEventToString(event)));
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
if (mDeviceBroker.hasScheduledA2dpSinkConnectionState(btDevice)) {
AudioService.sDeviceLogger.log(new AudioEventLogger.StringEvent(
"A2dp config change ignored (scheduled connection change)"));
@@ -368,7 +367,7 @@
}
/*package*/ void onMakeA2dpDeviceUnavailableNow(String address, int a2dpCodec) {
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
makeA2dpDeviceUnavailableNow(address, a2dpCodec);
}
}
@@ -405,7 +404,7 @@
AudioDeviceInventory.WiredDeviceConnectionState wdcs) {
AudioService.sDeviceLogger.log(new AudioServiceEvents.WiredDevConnectEvent(wdcs));
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
if ((wdcs.mState == AudioService.CONNECTION_STATE_DISCONNECTED)
&& DEVICE_OVERRIDE_A2DP_ROUTE_ON_PLUG_SET.contains(wdcs.mType)) {
mDeviceBroker.setBluetoothA2dpOnInt(true,
@@ -433,7 +432,7 @@
}
/*package*/ void onToggleHdmi() {
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
// Is HDMI connected?
final String key = DeviceInfo.makeDeviceListKey(AudioSystem.DEVICE_OUT_HDMI, "");
final DeviceInfo di = mConnectedDevices.get(key);
@@ -500,7 +499,7 @@
+ Integer.toHexString(device) + " address:" + address
+ " name:" + deviceName + ")");
}
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
final String deviceKey = DeviceInfo.makeDeviceListKey(device, address);
if (AudioService.DEBUG_DEVICES) {
Slog.i(TAG, "deviceKey:" + deviceKey);
@@ -539,7 +538,7 @@
/*package*/ void disconnectA2dp() {
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
final ArraySet<String> toRemove = new ArraySet<>();
// Disconnect ALL DEVICE_OUT_BLUETOOTH_A2DP devices
mConnectedDevices.values().forEach(deviceInfo -> {
@@ -559,7 +558,7 @@
}
/*package*/ void disconnectA2dpSink() {
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
final ArraySet<String> toRemove = new ArraySet<>();
// Disconnect ALL DEVICE_IN_BLUETOOTH_A2DP devices
mConnectedDevices.values().forEach(deviceInfo -> {
@@ -572,7 +571,7 @@
}
/*package*/ void disconnectHearingAid() {
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
final ArraySet<String> toRemove = new ArraySet<>();
// Disconnect ALL DEVICE_OUT_HEARING_AID devices
mConnectedDevices.values().forEach(deviceInfo -> {
@@ -596,7 +595,7 @@
// from AudioSystem
/*package*/ int checkSendBecomingNoisyIntent(int device,
@AudioService.ConnectionState int state, int musicDevice) {
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
return checkSendBecomingNoisyIntentInt(device, state, musicDevice);
}
}
@@ -623,7 +622,7 @@
if (profile != BluetoothProfile.A2DP && profile != BluetoothProfile.A2DP_SINK) {
throw new IllegalArgumentException("invalid profile " + profile);
}
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
if (profile == BluetoothProfile.A2DP && !suppressNoisyIntent) {
@AudioService.ConnectionState int asState =
(state == BluetoothA2dp.STATE_CONNECTED)
@@ -663,7 +662,7 @@
/*package*/ int setWiredDeviceConnectionState(int type, @AudioService.ConnectionState int state,
String address, String name, String caller) {
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
int delay = checkSendBecomingNoisyIntentInt(type, state, AudioSystem.DEVICE_NONE);
mDeviceBroker.postSetWiredDeviceConnectionState(
new WiredDeviceConnectionState(type, state, address, name, caller),
@@ -676,7 +675,7 @@
@NonNull BluetoothDevice device, @AudioService.BtProfileConnectionState int state,
boolean suppressNoisyIntent, int musicDevice) {
int delay;
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
if (!suppressNoisyIntent) {
int intState = (state == BluetoothHearingAid.STATE_CONNECTED) ? 1 : 0;
delay = checkSendBecomingNoisyIntentInt(AudioSystem.DEVICE_OUT_HEARING_AID,
@@ -693,42 +692,58 @@
//-------------------------------------------------------------------
// Internal utilities
- @GuardedBy("mConnectedDevices")
+ @GuardedBy("mDevicesLock")
private void makeA2dpDeviceAvailable(String address, String name, String eventSource,
int a2dpCodec) {
// enable A2DP before notifying A2DP connection to avoid unnecessary processing in
// audio policy manager
mDeviceBroker.setBluetoothA2dpOnInt(true, eventSource);
+ // at this point there could be another A2DP device already connected in APM, but it
+ // doesn't matter as this new one will overwrite the previous one
AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
AudioSystem.DEVICE_STATE_AVAILABLE, address, name, a2dpCodec);
// Reset A2DP suspend state each time a new sink is connected
AudioSystem.setParameters("A2dpSuspended=false");
- mConnectedDevices.put(
- DeviceInfo.makeDeviceListKey(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, address),
- new DeviceInfo(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, name,
- address, a2dpCodec));
+
+ final DeviceInfo di = new DeviceInfo(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, name,
+ address, a2dpCodec);
+ final String diKey = di.getKey();
+ mConnectedDevices.put(diKey, di);
+ // on a connection always overwrite the device seen by AudioPolicy, see comment above when
+ // calling AudioSystem
+ mApmConnectedDevices.put(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, diKey);
+
mDeviceBroker.postAccessoryPlugMediaUnmute(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP);
setCurrentAudioRouteNameIfPossible(name);
}
- @GuardedBy("mConnectedDevices")
+ @GuardedBy("mDevicesLock")
private void makeA2dpDeviceUnavailableNow(String address, int a2dpCodec) {
if (address == null) {
return;
}
+ final String deviceToRemoveKey =
+ DeviceInfo.makeDeviceListKey(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, address);
+
+ mConnectedDevices.remove(deviceToRemoveKey);
+ if (!mApmConnectedDevices.get(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP)
+ .equals(deviceToRemoveKey)) {
+ // removing A2DP device not currently used by AudioPolicy, log but don't act on it
+ AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent(
+ "A2DP device " + address + " made unavailable, was not used")).printLog(TAG));
+ return;
+ }
+
+ // device to remove was visible by APM, update APM
mDeviceBroker.setAvrcpAbsoluteVolumeSupported(false);
AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
AudioSystem.DEVICE_STATE_UNAVAILABLE, address, "", a2dpCodec);
- mConnectedDevices.remove(
- DeviceInfo.makeDeviceListKey(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, address));
+ mApmConnectedDevices.remove(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP);
// Remove A2DP routes as well
setCurrentAudioRouteNameIfPossible(null);
- if (mDockAddress == address) {
- mDockAddress = null;
- }
}
- @GuardedBy("mConnectedDevices")
+ @GuardedBy("mDevicesLock")
private void makeA2dpDeviceUnavailableLater(String address, int delayMs) {
// prevent any activity on the A2DP audio output to avoid unwanted
// reconnection of the sink.
@@ -742,11 +757,11 @@
// the device will be made unavailable later, so consider it disconnected right away
mConnectedDevices.remove(deviceKey);
// send the delayed message to make the device unavailable later
- mDeviceBroker.setA2dpDockTimeout(address, a2dpCodec, delayMs);
+ mDeviceBroker.setA2dpTimeout(address, a2dpCodec, delayMs);
}
- @GuardedBy("mConnectedDevices")
+ @GuardedBy("mDevicesLock")
private void makeA2dpSrcAvailable(String address) {
AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_IN_BLUETOOTH_A2DP,
AudioSystem.DEVICE_STATE_AVAILABLE, address, "",
@@ -757,7 +772,7 @@
address, AudioSystem.AUDIO_FORMAT_DEFAULT));
}
- @GuardedBy("mConnectedDevices")
+ @GuardedBy("mDevicesLock")
private void makeA2dpSrcUnavailable(String address) {
AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_IN_BLUETOOTH_A2DP,
AudioSystem.DEVICE_STATE_UNAVAILABLE, address, "",
@@ -766,7 +781,7 @@
DeviceInfo.makeDeviceListKey(AudioSystem.DEVICE_IN_BLUETOOTH_A2DP, address));
}
- @GuardedBy("mConnectedDevices")
+ @GuardedBy("mDevicesLock")
private void makeHearingAidDeviceAvailable(
String address, String name, int streamType, String eventSource) {
final int hearingAidVolIndex = mDeviceBroker.getVssVolumeForDevice(streamType,
@@ -786,7 +801,7 @@
setCurrentAudioRouteNameIfPossible(name);
}
- @GuardedBy("mConnectedDevices")
+ @GuardedBy("mDevicesLock")
private void makeHearingAidDeviceUnavailable(String address) {
AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_HEARING_AID,
AudioSystem.DEVICE_STATE_UNAVAILABLE, address, "",
@@ -797,7 +812,7 @@
setCurrentAudioRouteNameIfPossible(null);
}
- @GuardedBy("mConnectedDevices")
+ @GuardedBy("mDevicesLock")
private void setCurrentAudioRouteNameIfPossible(String name) {
synchronized (mCurAudioRoutes) {
if (TextUtils.equals(mCurAudioRoutes.bluetoothName, name)) {
@@ -810,7 +825,7 @@
}
}
- @GuardedBy("mConnectedDevices")
+ @GuardedBy("mDevicesLock")
private boolean isCurrentDeviceConnected() {
return mConnectedDevices.values().stream().anyMatch(deviceInfo ->
TextUtils.equals(deviceInfo.mDeviceName, mCurAudioRoutes.bluetoothName));
@@ -838,7 +853,7 @@
// must be called before removing the device from mConnectedDevices
// musicDevice argument is used when not AudioSystem.DEVICE_NONE instead of querying
// from AudioSystem
- @GuardedBy("mConnectedDevices")
+ @GuardedBy("mDevicesLock")
private int checkSendBecomingNoisyIntentInt(int device,
@AudioService.ConnectionState int state, int musicDevice) {
if (state != AudioService.CONNECTION_STATE_DISCONNECTED) {
@@ -1046,7 +1061,7 @@
public boolean isA2dpDeviceConnected(@NonNull BluetoothDevice device) {
final String key = DeviceInfo.makeDeviceListKey(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
device.getAddress());
- synchronized (mConnectedDevices) {
+ synchronized (mDevicesLock) {
return (mConnectedDevices.get(key) != null);
}
}
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 1a62eb2..335cac8 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -4488,12 +4488,13 @@
}
if (mNm.getZenMode() != Settings.Global.ZEN_MODE_NO_INTERRUPTIONS
+ && !isStreamMutedByRingerOrZenMode(AudioSystem.STREAM_MUSIC)
&& DEVICE_MEDIA_UNMUTED_ON_PLUG_SET.contains(newDevice)
&& mStreamStates[AudioSystem.STREAM_MUSIC].mIsMuted
&& mStreamStates[AudioSystem.STREAM_MUSIC].getIndex(newDevice) != 0
&& (newDevice & AudioSystem.getDevicesForStream(AudioSystem.STREAM_MUSIC)) != 0) {
if (DEBUG_VOL) {
- Log.i(TAG, String.format(" onAccessoryPlugMediaUnmute unmuting device=%d [%s]",
+ Log.i(TAG, String.format("onAccessoryPlugMediaUnmute unmuting device=%d [%s]",
newDevice, AudioSystem.getOutputDeviceName(newDevice)));
}
mStreamStates[AudioSystem.STREAM_MUSIC].mute(false);
@@ -6167,6 +6168,7 @@
pw.println("\nRinger mode: ");
pw.println("- mode (internal) = " + RINGER_MODE_NAMES[mRingerMode]);
pw.println("- mode (external) = " + RINGER_MODE_NAMES[mRingerModeExternal]);
+ pw.println("- zen mode:" + Settings.Global.zenModeToString(mNm.getZenMode()));
dumpRingerModeStreams(pw, "affected", mRingerModeAffectedStreams);
dumpRingerModeStreams(pw, "muted", mRingerAndZenModeMutedStreams);
pw.print("- delegate = "); pw.println(mRingerModeDelegate);
diff --git a/services/core/java/com/android/server/biometrics/AuthService.java b/services/core/java/com/android/server/biometrics/AuthService.java
index 22cb507..0d88388 100644
--- a/services/core/java/com/android/server/biometrics/AuthService.java
+++ b/services/core/java/com/android/server/biometrics/AuthService.java
@@ -26,10 +26,12 @@
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_IRIS;
+import static android.hardware.biometrics.BiometricManager.Authenticators;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.biometrics.IAuthService;
+import android.hardware.biometrics.IBiometricAuthenticator;
import android.hardware.biometrics.IBiometricEnabledOnKeyguardCallback;
import android.hardware.biometrics.IBiometricService;
import android.hardware.biometrics.IBiometricServiceReceiver;
@@ -43,6 +45,7 @@
import android.os.UserHandle;
import android.util.Slog;
+import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.SystemService;
import com.android.server.biometrics.face.FaceAuthenticator;
@@ -57,9 +60,6 @@
private static final String TAG = "AuthService";
private static final boolean DEBUG = false;
- private final boolean mHasFeatureFace;
- private final boolean mHasFeatureFingerprint;
- private final boolean mHasFeatureIris;
private final Injector mInjector;
private IBiometricService mBiometricService;
@@ -89,6 +89,16 @@
public void publishBinderService(AuthService service, IAuthService.Stub impl) {
service.publishBinderService(Context.AUTH_SERVICE, impl);
}
+
+ /**
+ * Allows to test with various device sensor configurations.
+ * @param context
+ * @return
+ */
+ @VisibleForTesting
+ public String[] getConfiguration(Context context) {
+ return context.getResources().getStringArray(R.array.config_biometric_sensors);
+ }
}
private final class AuthServiceImpl extends IAuthService.Stub {
@@ -119,17 +129,17 @@
}
@Override
- public int canAuthenticate(String opPackageName, int userId) throws RemoteException {
+ public int canAuthenticate(String opPackageName, int userId,
+ @Authenticators.Types int authenticators) throws RemoteException {
final int callingUserId = UserHandle.getCallingUserId();
- Slog.d(TAG, "canAuthenticate, userId: " + userId
- + ", callingUserId: " + callingUserId);
-
+ Slog.d(TAG, "canAuthenticate, userId: " + userId + ", callingUserId: " + callingUserId
+ + ", authenticators: " + authenticators);
if (userId != callingUserId) {
checkInternalPermission();
} else {
checkPermission();
}
- return mBiometricService.canAuthenticate(opPackageName, userId);
+ return mBiometricService.canAuthenticate(opPackageName, userId, authenticators);
}
@Override
@@ -169,47 +179,56 @@
mInjector = injector;
mImpl = new AuthServiceImpl();
final PackageManager pm = context.getPackageManager();
- mHasFeatureFace = pm.hasSystemFeature(PackageManager.FEATURE_FACE);
- mHasFeatureFingerprint = pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT);
- mHasFeatureIris = pm.hasSystemFeature(PackageManager.FEATURE_IRIS);
+ }
+
+ private void registerAuthenticator(SensorConfig config) throws RemoteException {
+
+ Slog.d(TAG, "Registering ID: " + config.mId
+ + " Modality: " + config.mModality
+ + " Strength: " + config.mStrength);
+
+ final IBiometricAuthenticator.Stub authenticator;
+
+ switch (config.mModality) {
+ case TYPE_FINGERPRINT:
+ authenticator = new FingerprintAuthenticator(IFingerprintService.Stub.asInterface(
+ ServiceManager.getService(Context.FINGERPRINT_SERVICE)));
+ break;
+
+ case TYPE_FACE:
+ authenticator = new FaceAuthenticator(IFaceService.Stub.asInterface(
+ ServiceManager.getService(Context.FACE_SERVICE)));
+ break;
+
+ case TYPE_IRIS:
+ authenticator = new IrisAuthenticator(IIrisService.Stub.asInterface(
+ ServiceManager.getService(Context.IRIS_SERVICE)));
+ break;
+
+ default:
+ Slog.e(TAG, "Unknown modality: " + config.mModality);
+ return;
+ }
+
+ mBiometricService.registerAuthenticator(config.mId, config.mModality, config.mStrength,
+ authenticator);
}
@Override
public void onStart() {
mBiometricService = mInjector.getBiometricService();
- if (mHasFeatureFace) {
- final FaceAuthenticator faceAuthenticator = new FaceAuthenticator(
- IFaceService.Stub.asInterface(ServiceManager.getService(Context.FACE_SERVICE)));
+ final String[] configs = mInjector.getConfiguration(getContext());
+
+ for (int i = 0; i < configs.length; i++) {
try {
- // TODO(b/141025588): Pass down the real id, strength, and modality.
- mBiometricService.registerAuthenticator(0, 0, TYPE_FACE, faceAuthenticator);
+ registerAuthenticator(new SensorConfig(configs[i]));
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
}
+
}
- if (mHasFeatureFingerprint) {
- final FingerprintAuthenticator fingerprintAuthenticator = new FingerprintAuthenticator(
- IFingerprintService.Stub.asInterface(
- ServiceManager.getService(Context.FINGERPRINT_SERVICE)));
- try {
- // TODO(b/141025588): Pass down the real id, strength, and modality.
- mBiometricService.registerAuthenticator(1, 0, TYPE_FINGERPRINT,
- fingerprintAuthenticator);
- } catch (RemoteException e) {
- Slog.e(TAG, "Remote exception", e);
- }
- }
- if (mHasFeatureIris) {
- final IrisAuthenticator irisAuthenticator = new IrisAuthenticator(
- IIrisService.Stub.asInterface(ServiceManager.getService(Context.IRIS_SERVICE)));
- try {
- // TODO(b/141025588): Pass down the real id, strength, and modality.
- mBiometricService.registerAuthenticator(2, 0, TYPE_IRIS, irisAuthenticator);
- } catch (RemoteException e) {
- Slog.e(TAG, "Remote exception", e);
- }
- }
+
mInjector.publishBinderService(this, mImpl);
}
diff --git a/services/core/java/com/android/server/biometrics/BiometricService.java b/services/core/java/com/android/server/biometrics/BiometricService.java
index 5d36793..0f51e39 100644
--- a/services/core/java/com/android/server/biometrics/BiometricService.java
+++ b/services/core/java/com/android/server/biometrics/BiometricService.java
@@ -23,15 +23,16 @@
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_IRIS;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_NONE;
+import static android.hardware.biometrics.BiometricManager.Authenticators;
import android.app.ActivityManager;
import android.app.IActivityManager;
import android.app.UserSwitchObserver;
+import android.app.trust.ITrustManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageManager;
import android.database.ContentObserver;
-import android.hardware.biometrics.Authenticator;
import android.hardware.biometrics.BiometricAuthenticator;
import android.hardware.biometrics.BiometricConstants;
import android.hardware.biometrics.BiometricPrompt;
@@ -78,7 +79,7 @@
*/
public class BiometricService extends SystemService {
- private static final String TAG = "BiometricService";
+ static final String TAG = "BiometricService";
private static final boolean DEBUG = true;
private static final int MSG_ON_AUTHENTICATION_SUCCEEDED = 2;
@@ -220,11 +221,15 @@
IStatusBarService mStatusBarService;
@VisibleForTesting
KeyStore mKeyStore;
+ @VisibleForTesting
+ ITrustManager mTrustManager;
// Get and cache the available authenticator (manager) classes. Used since aidl doesn't support
// polymorphism :/
final ArrayList<AuthenticatorWrapper> mAuthenticators = new ArrayList<>();
+ BiometricStrengthController mBiometricStrengthController;
+
// The current authentication session, null if idle/done. We need to track both the current
// and pending sessions since errors may be sent to either.
@VisibleForTesting
@@ -345,17 +350,50 @@
@VisibleForTesting
public static final class AuthenticatorWrapper {
public final int id;
- public final int strength;
+ public final int OEMStrength; // strength as configured by the OEM
+ private int updatedStrength; // strength updated by BiometricStrengthController
public final int modality;
public final IBiometricAuthenticator impl;
- AuthenticatorWrapper(int id, int strength, int modality,
+ AuthenticatorWrapper(int id, int modality, int strength,
IBiometricAuthenticator impl) {
this.id = id;
- this.strength = strength;
this.modality = modality;
+ this.OEMStrength = strength;
+ this.updatedStrength = strength;
this.impl = impl;
}
+
+ /**
+ * Returns the actual strength, taking any updated strengths into effect. Since more bits
+ * means lower strength, the resulting strength is never stronger than the OEM's configured
+ * strength.
+ * @return a bitfield, see {@link Authenticators}
+ */
+ public int getActualStrength() {
+ return OEMStrength | updatedStrength;
+ }
+
+ /**
+ * Stores the updated strength, which takes effect whenever {@link #getActualStrength()}
+ * is checked.
+ * @param newStrength
+ */
+ public void updateStrength(int newStrength) {
+ String log = "updateStrength: Before(" + toString() + ")";
+ updatedStrength = newStrength;
+ log += " After(" + toString() + ")";
+ Slog.d(TAG, log);
+ }
+
+ @Override
+ public String toString() {
+ return "ID(" + id + ")"
+ + " OEMStrength: " + OEMStrength
+ + " updatedStrength: " + updatedStrength
+ + " modality " + modality
+ + " authenticator: " + impl;
+ }
}
@VisibleForTesting
@@ -606,14 +644,14 @@
return;
}
- if (bundle.get(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED) != null) {
- checkInternalPermission();
+ if (!Utils.isValidAuthenticatorConfig(bundle)) {
+ throw new SecurityException("Invalid authenticator configuration");
}
Utils.combineAuthenticatorBundles(bundle);
- // Check the usage of this in system server. Need to remove this check if it becomes
- // a public API.
+ // Check the usage of this in system server. Need to remove this check if it becomes a
+ // public API.
final boolean useDefaultTitle =
bundle.getBoolean(BiometricPrompt.KEY_USE_DEFAULT_TITLE, false);
if (useDefaultTitle) {
@@ -651,9 +689,11 @@
}
@Override // Binder call
- public int canAuthenticate(String opPackageName, int userId) {
+ public int canAuthenticate(String opPackageName, int userId,
+ @Authenticators.Types int authenticators) {
Slog.d(TAG, "canAuthenticate: User=" + userId
- + ", Caller=" + UserHandle.getCallingUserId());
+ + ", Caller=" + UserHandle.getCallingUserId()
+ + ", Authenticators=" + authenticators);
if (userId != UserHandle.getCallingUserId()) {
checkInternalPermission();
@@ -661,16 +701,39 @@
checkPermission();
}
+
+ if (!Utils.isValidAuthenticatorConfig(authenticators)) {
+ throw new SecurityException("Invalid authenticator configuration");
+ }
+
+ final Bundle bundle = new Bundle();
+ bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, authenticators);
+
+ int biometricConstantsResult = BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE;
final long ident = Binder.clearCallingIdentity();
- int error;
try {
- final Pair<Integer, Integer> result = checkAndGetBiometricModality(userId,
- opPackageName);
- error = result.second;
+ biometricConstantsResult =
+ checkAndGetAuthenticators(userId, bundle, opPackageName).second;
+ if (biometricConstantsResult != BiometricConstants.BIOMETRIC_SUCCESS
+ && Utils.isDeviceCredentialAllowed(bundle)) {
+ // If there's an issue with biometrics, but device credential is allowed and
+ // set up, return SUCCESS. If device credential isn't set up either, return
+ // ERROR_NO_DEVICE_CREDENTIAL.
+ if (mTrustManager.isDeviceSecure(userId)) {
+ biometricConstantsResult = BiometricConstants.BIOMETRIC_SUCCESS;
+ } else {
+ biometricConstantsResult =
+ BiometricConstants.BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL;
+ }
+ }
+
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Remote exception", e);
} finally {
Binder.restoreCallingIdentity(ident);
}
- return error;
+
+ return Utils.biometricConstantsToBiometricManager(biometricConstantsResult);
}
@Override
@@ -693,11 +756,46 @@
}
@Override
- public void registerAuthenticator(int id, int strength, int modality,
+ public void registerAuthenticator(int id, int modality, int strength,
IBiometricAuthenticator authenticator) {
checkInternalPermission();
- mAuthenticators.add(new AuthenticatorWrapper(id, strength, modality, authenticator));
+ Slog.d(TAG, "Registering ID: " + id
+ + " Modality: " + modality
+ + " Strength: " + strength);
+
+ if (authenticator == null) {
+ throw new IllegalArgumentException("Authenticator must not be null."
+ + " Did you forget to modify the core/res/res/values/xml overlay for"
+ + " config_biometric_sensors?");
+ }
+
+ if (strength != Authenticators.BIOMETRIC_STRONG
+ && strength != Authenticators.BIOMETRIC_WEAK) {
+ throw new IllegalStateException("Unsupported strength");
+ }
+
+ for (AuthenticatorWrapper wrapper : mAuthenticators) {
+ if (wrapper.id == id) {
+ throw new IllegalStateException("Cannot register duplicate authenticator");
+ }
+ }
+
+ // This happens infrequently enough, not worth caching.
+ final String[] configs = mInjector.getConfiguration(getContext());
+ boolean idFound = false;
+ for (int i = 0; i < configs.length; i++) {
+ SensorConfig config = new SensorConfig(configs[i]);
+ if (config.mId == id) {
+ idFound = true;
+ break;
+ }
+ }
+ if (!idFound) {
+ throw new IllegalStateException("Cannot register unknown id");
+ }
+
+ mAuthenticators.add(new AuthenticatorWrapper(id, modality, strength, authenticator));
}
@Override // Binder call
@@ -771,6 +869,11 @@
}
@VisibleForTesting
+ public ITrustManager getTrustManager() {
+ return ITrustManager.Stub.asInterface(ServiceManager.getService(Context.TRUST_SERVICE));
+ }
+
+ @VisibleForTesting
public IStatusBarService getStatusBarService() {
return IStatusBarService.Stub.asInterface(
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
@@ -805,6 +908,25 @@
public void publishBinderService(BiometricService service, IBiometricService.Stub impl) {
service.publishBinderService(Context.BIOMETRIC_SERVICE, impl);
}
+
+ /**
+ * Allows to mock BiometricStrengthController for testing.
+ */
+ @VisibleForTesting
+ public BiometricStrengthController getBiometricStrengthController(
+ BiometricService service) {
+ return new BiometricStrengthController(service);
+ }
+
+ /**
+ * Allows to test with various device sensor configurations.
+ * @param context System Server context
+ * @return the sensor configuration from core/res/res/values/config.xml
+ */
+ @VisibleForTesting
+ public String[] getConfiguration(Context context) {
+ return context.getResources().getStringArray(R.array.config_biometric_sensors);
+ }
}
/**
@@ -849,7 +971,10 @@
public void onStart() {
mKeyStore = mInjector.getKeyStore();
mStatusBarService = mInjector.getStatusBarService();
+ mTrustManager = mInjector.getTrustManager();
mInjector.publishBinderService(this, mImpl);
+ mBiometricStrengthController = mInjector.getBiometricStrengthController(this);
+ mBiometricStrengthController.startListening();
}
/**
@@ -857,25 +982,36 @@
* returns errors through the callback (no biometric feature, hardware not detected, no
* templates enrolled, etc). This service must not start authentication if errors are sent.
*
- * @Returns A pair [Modality, Error] with Modality being one of
+ * @param userId the user to check for
+ * @param bundle passed from {@link BiometricPrompt}
+ * @param opPackageName see {@link android.app.AppOpsManager}
+ *
+ * @return A pair [Modality, Error] with Modality being one of
* {@link BiometricAuthenticator#TYPE_NONE},
* {@link BiometricAuthenticator#TYPE_FINGERPRINT},
* {@link BiometricAuthenticator#TYPE_IRIS},
* {@link BiometricAuthenticator#TYPE_FACE}
* and the error containing one of the {@link BiometricConstants} errors.
+ *
+ * TODO(kchyn): Update this to handle DEVICE_CREDENTIAL better, reduce duplicate code in callers
*/
- private Pair<Integer, Integer> checkAndGetBiometricModality(int userId, String opPackageName) {
- // No biometric features, send error
- if (mAuthenticators.isEmpty()) {
- return new Pair<>(TYPE_NONE, BiometricConstants.BIOMETRIC_ERROR_HW_NOT_PRESENT);
+ private Pair<Integer, Integer> checkAndGetAuthenticators(int userId, Bundle bundle,
+ String opPackageName) throws RemoteException {
+ if (!Utils.isBiometricAllowed(bundle)
+ && Utils.isDeviceCredentialAllowed(bundle)
+ && !mTrustManager.isDeviceSecure(userId)) {
+ // If only device credential is being checked, and the user doesn't have one set up
+ return new Pair<>(TYPE_NONE, BiometricConstants.BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL);
}
// Assuming that authenticators are listed in priority-order, the rest of this function
- // will go through and find the first authenticator that's available, enrolled, and enabled.
- // The tricky part is returning the correct error. Error strings that are modality-specific
- // should also respect the priority-order.
+ // will attempt to find the first authenticator that's as strong or stronger than the
+ // requested strength, available, enrolled, and enabled. The tricky part is returning the
+ // correct error. Error strings that are modality-specific should also respect the
+ // priority-order.
- // Find first authenticator that's detected, enrolled, and enabled.
+ // Find first authenticator that's strong enough, detected, enrolled, and enabled.
+ boolean hasSufficientStrength = false;
boolean isHardwareDetected = false;
boolean hasTemplatesEnrolled = false;
boolean enabledForApps = false;
@@ -883,13 +1019,16 @@
int modality = TYPE_NONE;
int firstHwAvailable = TYPE_NONE;
for (AuthenticatorWrapper authenticator : mAuthenticators) {
- modality = authenticator.modality;
- try {
+ final int actualStrength = authenticator.getActualStrength();
+ final int requestedStrength = Utils.getPublicBiometricStrength(bundle);
+ if (Utils.isAtLeastStrength(actualStrength, requestedStrength)) {
+ hasSufficientStrength = true;
+ modality = authenticator.modality;
if (authenticator.impl.isHardwareDetected(opPackageName)) {
isHardwareDetected = true;
if (firstHwAvailable == TYPE_NONE) {
- // Store the first one since we want to return the error in correct priority
- // order.
+ // Store the first one since we want to return the error in correct
+ // priority order.
firstHwAvailable = modality;
}
if (authenticator.impl.hasEnrolledTemplates(userId, opPackageName)) {
@@ -900,18 +1039,18 @@
}
}
}
- } catch (RemoteException e) {
- Slog.e(TAG, "Remote exception", e);
}
}
- Slog.d(TAG, "checkAndGetBiometricModality: user=" + userId
+ Slog.d(TAG, "checkAndGetAuthenticators: user=" + userId
+ " isHardwareDetected=" + isHardwareDetected
+ " hasTemplatesEnrolled=" + hasTemplatesEnrolled
+ " enabledForApps=" + enabledForApps);
// Check error conditions
- if (!isHardwareDetected) {
+ if (!hasSufficientStrength) {
+ return new Pair<>(TYPE_NONE, BiometricConstants.BIOMETRIC_ERROR_HW_NOT_PRESENT);
+ } else if (!isHardwareDetected) {
return new Pair<>(TYPE_NONE, BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE);
} else if (!hasTemplatesEnrolled) {
// Return the modality here so the correct error string can be sent. This error is
@@ -1107,13 +1246,16 @@
// SystemUI handles transition from biometric to device credential.
mCurrentAuthSession.mState = STATE_SHOWING_DEVICE_CREDENTIAL;
mStatusBarService.onBiometricError(modality, error, vendorCode);
+ } else if (error == BiometricConstants.BIOMETRIC_ERROR_CANCELED) {
+ mStatusBarService.hideAuthenticationDialog();
+ // TODO: If multiple authenticators are simultaneously running, this will
+ // need to be modified. Send the error to the client here, instead of doing
+ // a round trip to SystemUI.
+ mCurrentAuthSession.mClientReceiver.onError(modality, error, vendorCode);
+ mCurrentAuthSession = null;
} else {
mCurrentAuthSession.mState = STATE_ERROR_PENDING_SYSUI;
- if (error == BiometricConstants.BIOMETRIC_ERROR_CANCELED) {
- mStatusBarService.hideAuthenticationDialog();
- } else {
- mStatusBarService.onBiometricError(modality, error, vendorCode);
- }
+ mStatusBarService.onBiometricError(modality, error, vendorCode);
}
} else if (mCurrentAuthSession.mState == STATE_AUTH_PAUSED) {
// In the "try again" state, we should forward canceled errors to
@@ -1135,10 +1277,11 @@
// If any error is received while preparing the auth session (lockout, etc),
// and if device credential is allowed, just show the credential UI.
if (mPendingAuthSession.isAllowDeviceCredential()) {
- int authenticators = mPendingAuthSession.mBundle
- .getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, 0);
+ @Authenticators.Types int authenticators =
+ mPendingAuthSession.mBundle.getInt(
+ BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, 0);
// Disallow biometric and notify SystemUI to show the authentication prompt.
- authenticators &= ~Authenticator.TYPE_BIOMETRIC;
+ authenticators &= ~Authenticators.BIOMETRIC_WEAK;
mPendingAuthSession.mBundle.putInt(
BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED,
authenticators);
@@ -1355,31 +1498,43 @@
int callingUid, int callingPid, int callingUserId) {
mHandler.post(() -> {
- final Pair<Integer, Integer> result = checkAndGetBiometricModality(userId,
- opPackageName);
- final int modality = result.first;
- final int error = result.second;
+ int modality = TYPE_NONE;
+ int result;
- final boolean credentialAllowed = Utils.isDeviceCredentialAllowed(bundle);
-
- if (error != BiometricConstants.BIOMETRIC_SUCCESS && credentialAllowed) {
- // If there's a problem but device credential is allowed, only show credential UI.
- bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED,
- Authenticator.TYPE_CREDENTIAL);
- } else if (error != BiometricConstants.BIOMETRIC_SUCCESS) {
- // Check for errors, notify callback, and return
- try {
- receiver.onError(modality, error, 0 /* vendorCode */);
- } catch (RemoteException e) {
- Slog.e(TAG, "Unable to send error", e);
- }
- return;
+ try {
+ final Pair<Integer, Integer> pair = checkAndGetAuthenticators(userId, bundle,
+ opPackageName);
+ modality = pair.first;
+ result = pair.second;
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Remote exception", e);
+ result = BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE;
}
- // Start preparing for authentication. Authentication starts when
- // all modalities requested have invoked onReadyForAuthentication.
- authenticateInternal(token, sessionId, userId, receiver, opPackageName, bundle,
- callingUid, callingPid, callingUserId, modality);
+ try {
+ if (result == BiometricConstants.BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL) {
+ // If the app allowed device credential but the user hasn't set it up yet,
+ // return this error.
+ receiver.onError(modality, result, 0 /* vendorCode */);
+ } else if (result != BiometricConstants.BIOMETRIC_SUCCESS) {
+ if (Utils.isDeviceCredentialAllowed(bundle)) {
+ // If there's a problem with biometrics but device credential is allowed,
+ // only show credential UI.
+ bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED,
+ Authenticators.DEVICE_CREDENTIAL);
+ authenticateInternal(token, sessionId, userId, receiver, opPackageName,
+ bundle, callingUid, callingPid, callingUserId, modality);
+ } else {
+ receiver.onError(modality, result, 0 /* vendorCode */);
+ }
+ } else {
+ // BIOMETRIC_SUCCESS, proceed to authentication
+ authenticateInternal(token, sessionId, userId, receiver, opPackageName, bundle,
+ callingUid, callingPid, callingUserId, modality);
+ }
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Remote exception", e);
+ }
});
}
@@ -1407,7 +1562,8 @@
// with the cookie. Once all cookies are received, we can show the prompt
// and let the services start authenticating. The cookie should be non-zero.
final int cookie = mRandom.nextInt(Integer.MAX_VALUE - 1) + 1;
- final int authenticators = bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED);
+ final @Authenticators.Types int authenticators = bundle.getInt(
+ BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, 0);
Slog.d(TAG, "Creating auth session. Modality: " + modality
+ ", cookie: " + cookie
+ ", authenticators: " + authenticators);
@@ -1415,7 +1571,7 @@
// If it's only device credential, we don't need to wait - LockSettingsService is
// always ready to check credential (SystemUI invokes that path).
- if ((authenticators & ~Authenticator.TYPE_CREDENTIAL) != 0) {
+ if ((authenticators & ~Authenticators.DEVICE_CREDENTIAL) != 0) {
modalities.put(modality, cookie);
}
mPendingAuthSession = new AuthSession(modalities, token, sessionId, userId,
@@ -1423,7 +1579,7 @@
modality, requireConfirmation);
try {
- if (authenticators == Authenticator.TYPE_CREDENTIAL) {
+ if (authenticators == Authenticators.DEVICE_CREDENTIAL) {
mPendingAuthSession.mState = STATE_SHOWING_DEVICE_CREDENTIAL;
mCurrentAuthSession = mPendingAuthSession;
mPendingAuthSession = null;
@@ -1438,9 +1594,13 @@
} else {
mPendingAuthSession.mState = STATE_AUTH_CALLED;
for (AuthenticatorWrapper authenticator : mAuthenticators) {
- authenticator.impl.prepareForAuthentication(requireConfirmation, token,
- sessionId, userId, mInternalReceiver, opPackageName, cookie, callingUid,
- callingPid, callingUserId);
+ // TODO(b/141025588): use ids instead of modalities to avoid ambiguity.
+ if (authenticator.modality == modality) {
+ authenticator.impl.prepareForAuthentication(requireConfirmation, token,
+ sessionId, userId, mInternalReceiver, opPackageName, cookie,
+ callingUid, callingPid, callingUserId);
+ break;
+ }
}
}
} catch (RemoteException e) {
diff --git a/services/core/java/com/android/server/biometrics/BiometricStrengthController.java b/services/core/java/com/android/server/biometrics/BiometricStrengthController.java
new file mode 100644
index 0000000..4e16189
--- /dev/null
+++ b/services/core/java/com/android/server/biometrics/BiometricStrengthController.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2019 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 com.android.server.biometrics;
+
+import android.annotation.NonNull;
+import android.provider.DeviceConfig;
+import android.util.Slog;
+
+import com.android.internal.os.BackgroundThread;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Class for maintaining and updating the strengths for biometric sensors. Strengths can only
+ * be downgraded from the device's default, and never upgraded.
+ */
+public class BiometricStrengthController implements DeviceConfig.OnPropertiesChangedListener {
+ private static final String TAG = "BiometricStrengthController";
+
+ private final BiometricService mService;
+
+ /**
+ * Flag stored in the DeviceConfig API: biometric modality strengths to downgrade.
+ * This is encoded as a key:value list, separated by comma, e.g.
+ *
+ * "id1:strength1,id2:strength2,id3:strength3"
+ *
+ * where strength is one of the values defined in
+ * {@link android.hardware.biometrics.Authenticators}
+ *
+ * Both id and strength should be int, otherwise Exception will be thrown when parsing and the
+ * downgrade will fail.
+ */
+ private static final String KEY_BIOMETRIC_STRENGTHS = "biometric_strengths";
+
+ /**
+ * Default (no-op) value of the flag KEY_BIOMETRIC_STRENGTHS
+ */
+ public static final String DEFAULT_BIOMETRIC_STRENGTHS = null;
+
+ BiometricStrengthController(@NonNull BiometricService service) {
+ mService = service;
+ }
+
+ void startListening() {
+ DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_BIOMETRICS,
+ BackgroundThread.getExecutor(), this);
+ updateStrengths();
+ }
+
+ @Override
+ public void onPropertiesChanged(@NonNull DeviceConfig.Properties properties) {
+ for (String name : properties.getKeyset()) {
+ if (KEY_BIOMETRIC_STRENGTHS.equals(name)) {
+ updateStrengths();
+ }
+ }
+ }
+
+ /**
+ * Updates the strengths of authenticators in BiometricService if a matching ID's configuration
+ * has been changed.
+ */
+ private void updateStrengths() {
+ final Map<Integer, Integer> idToStrength = getIdToStrengthMap();
+ if (idToStrength == null) {
+ return;
+ }
+
+ for (BiometricService.AuthenticatorWrapper authenticator : mService.mAuthenticators) {
+ final int id = authenticator.id;
+ if (idToStrength.containsKey(id)) {
+ final int newStrength = idToStrength.get(id);
+ authenticator.updateStrength(newStrength);
+ }
+ }
+ }
+
+ /**
+ * @return a map of <ID, Strength>
+ */
+ private Map<Integer, Integer> getIdToStrengthMap() {
+ final String flags = DeviceConfig.getString(DeviceConfig.NAMESPACE_BIOMETRICS,
+ KEY_BIOMETRIC_STRENGTHS, DEFAULT_BIOMETRIC_STRENGTHS);
+ if (flags == null || flags.isEmpty()) {
+ Slog.d(TAG, "Flags are null or empty");
+ return null;
+ }
+
+ Map<Integer, Integer> map = new HashMap<>();
+ try {
+ for (String item : flags.split(",")) {
+ String[] elems = item.split(":");
+ final int id = Integer.parseInt(elems[0]);
+ final int strength = Integer.parseInt(elems[1]);
+ map.put(id, strength);
+ }
+ } catch (Exception e) {
+ Slog.e(TAG, "Can't parse flag: " + flags);
+ map = null;
+ }
+ return map;
+ }
+}
diff --git a/services/core/java/com/android/server/biometrics/OWNERS b/services/core/java/com/android/server/biometrics/OWNERS
new file mode 100644
index 0000000..8765c9a
--- /dev/null
+++ b/services/core/java/com/android/server/biometrics/OWNERS
@@ -0,0 +1,7 @@
+set noparent
+
+kchyn@google.com
+jaggies@google.com
+curtislb@google.com
+ilyamaty@google.com
+joshmccloskey@google.com
diff --git a/services/core/java/com/android/server/biometrics/SensorConfig.java b/services/core/java/com/android/server/biometrics/SensorConfig.java
new file mode 100644
index 0000000..9eda6da
--- /dev/null
+++ b/services/core/java/com/android/server/biometrics/SensorConfig.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2019 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 com.android.server.biometrics;
+
+/**
+ * Parsed sensor config. See core/res/res/values/config.xml config_biometric_sensors
+ */
+class SensorConfig {
+ final int mId;
+ final int mModality;
+ final int mStrength;
+
+ public SensorConfig(String config) {
+ String[] elems = config.split(":");
+ mId = Integer.parseInt(elems[0]);
+ mModality = Integer.parseInt(elems[1]);
+ mStrength = Integer.parseInt(elems[2]);
+ }
+}
diff --git a/services/core/java/com/android/server/biometrics/Utils.java b/services/core/java/com/android/server/biometrics/Utils.java
index ed5f9de..19f5358 100644
--- a/services/core/java/com/android/server/biometrics/Utils.java
+++ b/services/core/java/com/android/server/biometrics/Utils.java
@@ -16,15 +16,17 @@
package com.android.server.biometrics;
+import static android.hardware.biometrics.BiometricManager.Authenticators;
+
import android.content.Context;
-import android.hardware.biometrics.Authenticator;
+import android.hardware.biometrics.BiometricConstants;
+import android.hardware.biometrics.BiometricManager;
import android.hardware.biometrics.BiometricPrompt;
import android.os.Build;
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;
-
-import com.android.internal.annotations.VisibleForTesting;
+import android.util.Slog;
public class Utils {
public static boolean isDebugEnabled(Context context, int targetUserId) {
@@ -45,41 +47,167 @@
}
/**
- * Combine {@link BiometricPrompt#KEY_ALLOW_DEVICE_CREDENTIAL} with
- * {@link BiometricPrompt#KEY_AUTHENTICATORS_ALLOWED}, as the former is not flexible
- * enough.
+ * Combines {@link BiometricPrompt#KEY_ALLOW_DEVICE_CREDENTIAL} with
+ * {@link BiometricPrompt#KEY_AUTHENTICATORS_ALLOWED}, as the former is not flexible enough.
*/
public static void combineAuthenticatorBundles(Bundle bundle) {
- boolean biometricEnabled = true; // enabled by default
- boolean credentialEnabled = bundle.getBoolean(
- BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL, false);
- if (bundle.get(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED) != null) {
- final int authenticatorFlags =
- bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED);
- biometricEnabled = (authenticatorFlags & Authenticator.TYPE_BIOMETRIC) != 0;
- // Using both KEY_ALLOW_DEVICE_CREDENTIAL and KEY_AUTHENTICATORS_ALLOWED together
- // is not supported. Default to overwriting.
- credentialEnabled = (authenticatorFlags & Authenticator.TYPE_CREDENTIAL) != 0;
- }
-
+ // Cache and remove explicit ALLOW_DEVICE_CREDENTIAL boolean flag from the bundle.
+ final boolean deviceCredentialAllowed =
+ bundle.getBoolean(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL, false);
bundle.remove(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL);
- int authenticators = 0;
- if (biometricEnabled) {
- authenticators |= Authenticator.TYPE_BIOMETRIC;
+ final @Authenticators.Types int authenticators;
+ if (bundle.containsKey(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED)) {
+ // Ignore ALLOW_DEVICE_CREDENTIAL flag if AUTH_TYPES_ALLOWED is defined.
+ authenticators = bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, 0);
+ } else {
+ // Otherwise, use ALLOW_DEVICE_CREDENTIAL flag along with Weak+ biometrics by default.
+ authenticators = deviceCredentialAllowed
+ ? Authenticators.DEVICE_CREDENTIAL | Authenticators.BIOMETRIC_WEAK
+ : Authenticators.BIOMETRIC_WEAK;
}
- if (credentialEnabled) {
- authenticators |= Authenticator.TYPE_CREDENTIAL;
- }
+
bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, authenticators);
}
/**
+ * @param authenticators composed of one or more values from {@link Authenticators}
+ * @return true if device credential is allowed.
+ */
+ public static boolean isDeviceCredentialAllowed(@Authenticators.Types int authenticators) {
+ return (authenticators & Authenticators.DEVICE_CREDENTIAL) != 0;
+ }
+
+ /**
* @param bundle should be first processed by {@link #combineAuthenticatorBundles(Bundle)}
- * @return true if device credential allowed.
+ * @return true if device credential is allowed.
*/
public static boolean isDeviceCredentialAllowed(Bundle bundle) {
+ return isDeviceCredentialAllowed(bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED));
+ }
+
+ /**
+ * Checks if any of the publicly defined strengths are set.
+ *
+ * @param authenticators composed of one or more values from {@link Authenticators}
+ * @return minimal allowed biometric strength or 0 if biometric authentication is not allowed.
+ */
+ public static int getPublicBiometricStrength(@Authenticators.Types int authenticators) {
+ // Only biometrics WEAK and above are allowed to integrate with the public APIs.
+ return authenticators & Authenticators.BIOMETRIC_WEAK;
+ }
+
+ /**
+ * Checks if any of the publicly defined strengths are set.
+ *
+ * @param bundle should be first processed by {@link #combineAuthenticatorBundles(Bundle)}
+ * @return minimal allowed biometric strength or 0 if biometric authentication is not allowed.
+ */
+ public static int getPublicBiometricStrength(Bundle bundle) {
+ return getPublicBiometricStrength(
+ bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED));
+ }
+
+ /**
+ * Checks if any of the publicly defined strengths are set.
+ *
+ * @param bundle should be first processed by {@link #combineAuthenticatorBundles(Bundle)}
+ * @return true if biometric authentication is allowed.
+ */
+ public static boolean isBiometricAllowed(Bundle bundle) {
+ return getPublicBiometricStrength(bundle) != 0;
+ }
+
+ /**
+ * @param sensorStrength the strength of the sensor
+ * @param requestedStrength the strength that it must meet
+ * @return true only if the sensor is at least as strong as the requested strength
+ */
+ public static boolean isAtLeastStrength(int sensorStrength, int requestedStrength) {
+ // If the authenticator contains bits outside of the requested strength, it is too weak.
+ return (~requestedStrength & sensorStrength) == 0;
+ }
+
+ /**
+ * Checks if the authenticator configuration is a valid combination of the public APIs
+ * @param bundle
+ * @return
+ */
+ public static boolean isValidAuthenticatorConfig(Bundle bundle) {
final int authenticators = bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED);
- return (authenticators & Authenticator.TYPE_CREDENTIAL) != 0;
+ return isValidAuthenticatorConfig(authenticators);
+ }
+
+ /**
+ * Checks if the authenticator configuration is a valid combination of the public APIs
+ * @param authenticators
+ * @return
+ */
+ public static boolean isValidAuthenticatorConfig(int authenticators) {
+ // The caller is not required to set the authenticators. But if they do, check the below.
+ if (authenticators == 0) {
+ return true;
+ }
+
+ // Check if any of the non-biometric and non-credential bits are set. If so, this is
+ // invalid.
+ final int testBits = ~(Authenticators.DEVICE_CREDENTIAL
+ | Authenticators.BIOMETRIC_MIN_STRENGTH);
+ if ((authenticators & testBits) != 0) {
+ Slog.e(BiometricService.TAG, "Non-biometric, non-credential bits found."
+ + " Authenticators: " + authenticators);
+ return false;
+ }
+
+ // Check that biometrics bits are either NONE, WEAK, or STRONG. If NONE, DEVICE_CREDENTIAL
+ // should be set.
+ final int biometricBits = authenticators & Authenticators.BIOMETRIC_MIN_STRENGTH;
+ if (biometricBits == Authenticators.EMPTY_SET
+ && isDeviceCredentialAllowed(authenticators)) {
+ return true;
+ } else if (biometricBits == Authenticators.BIOMETRIC_STRONG) {
+ return true;
+ } else if (biometricBits == Authenticators.BIOMETRIC_WEAK) {
+ return true;
+ }
+
+ Slog.e(BiometricService.TAG, "Unsupported biometric flags. Authenticators: "
+ + authenticators);
+ // Non-supported biometric flags are being used
+ return false;
+ }
+
+ /**
+ * Converts error codes from BiometricConstants, which are used in most of the internal plumbing
+ * and eventually returned to {@link BiometricPrompt.AuthenticationCallback} to public
+ * {@link BiometricManager} constants, which are used by APIs such as
+ * {@link BiometricManager#canAuthenticate(int)}
+ *
+ * @param biometricConstantsCode see {@link BiometricConstants}
+ * @return see {@link BiometricManager}
+ */
+ public static int biometricConstantsToBiometricManager(int biometricConstantsCode) {
+ final int biometricManagerCode;
+
+ switch (biometricConstantsCode) {
+ case BiometricConstants.BIOMETRIC_SUCCESS:
+ biometricManagerCode = BiometricManager.BIOMETRIC_SUCCESS;
+ break;
+ case BiometricConstants.BIOMETRIC_ERROR_NO_BIOMETRICS:
+ case BiometricConstants.BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL:
+ biometricManagerCode = BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED;
+ break;
+ case BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE:
+ biometricManagerCode = BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE;
+ break;
+ case BiometricConstants.BIOMETRIC_ERROR_HW_NOT_PRESENT:
+ biometricManagerCode = BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE;
+ break;
+ default:
+ Slog.e(BiometricService.TAG, "Unhandled result code: " + biometricConstantsCode);
+ biometricManagerCode = BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE;
+ break;
+ }
+ return biometricManagerCode;
}
}
diff --git a/services/core/java/com/android/server/connectivity/KeepaliveTracker.java b/services/core/java/com/android/server/connectivity/KeepaliveTracker.java
index 9bae902..af8a366 100644
--- a/services/core/java/com/android/server/connectivity/KeepaliveTracker.java
+++ b/services/core/java/com/android/server/connectivity/KeepaliveTracker.java
@@ -39,11 +39,11 @@
import android.annotation.Nullable;
import android.content.Context;
import android.net.ISocketKeepaliveCallback;
+import android.net.InvalidPacketException;
import android.net.KeepalivePacketData;
import android.net.NattKeepalivePacketData;
import android.net.NetworkAgent;
import android.net.NetworkUtils;
-import android.net.SocketKeepalive.InvalidPacketException;
import android.net.SocketKeepalive.InvalidSocketException;
import android.net.TcpKeepalivePacketData;
import android.net.util.IpUtils;
@@ -657,7 +657,10 @@
final TcpKeepalivePacketData packet;
try {
packet = TcpKeepaliveController.getTcpKeepalivePacket(fd);
- } catch (InvalidPacketException | InvalidSocketException e) {
+ } catch (InvalidSocketException e) {
+ notifyErrorCallback(cb, e.error);
+ return;
+ } catch (InvalidPacketException e) {
notifyErrorCallback(cb, e.error);
return;
}
diff --git a/services/core/java/com/android/server/connectivity/TcpKeepaliveController.java b/services/core/java/com/android/server/connectivity/TcpKeepaliveController.java
index e570ef1e..1129899 100644
--- a/services/core/java/com/android/server/connectivity/TcpKeepaliveController.java
+++ b/services/core/java/com/android/server/connectivity/TcpKeepaliveController.java
@@ -30,8 +30,8 @@
import static android.system.OsConstants.TIOCOUTQ;
import android.annotation.NonNull;
+import android.net.InvalidPacketException;
import android.net.NetworkUtils;
-import android.net.SocketKeepalive.InvalidPacketException;
import android.net.SocketKeepalive.InvalidSocketException;
import android.net.TcpKeepalivePacketData;
import android.net.TcpKeepalivePacketDataParcelable;
diff --git a/services/core/java/com/android/server/emergency/EmergencyAffordanceService.java b/services/core/java/com/android/server/emergency/EmergencyAffordanceService.java
index a91fe77..1cf27ff 100644
--- a/services/core/java/com/android/server/emergency/EmergencyAffordanceService.java
+++ b/services/core/java/com/android/server/emergency/EmergencyAffordanceService.java
@@ -231,7 +231,8 @@
// a Sim with a different mcc code was found
neededNow = false;
}
- String simOperator = mTelephonyManager.getSimOperator(info.getSubscriptionId());
+ String simOperator = mTelephonyManager
+ .createForSubscriptionId(info.getSubscriptionId()).getSimOperator();
mcc = 0;
if (simOperator != null && simOperator.length() >= 3) {
mcc = Integer.parseInt(simOperator.substring(0, 3));
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecKeycode.java b/services/core/java/com/android/server/hdmi/HdmiCecKeycode.java
index 52cede2..23b5c14 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecKeycode.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecKeycode.java
@@ -250,7 +250,11 @@
new KeycodeEntry(UNSUPPORTED_KEYCODE, CEC_KEYCODE_LEFT_UP),
// No Android keycode defined for CEC_KEYCODE_LEFT_DOWN
new KeycodeEntry(UNSUPPORTED_KEYCODE, CEC_KEYCODE_LEFT_DOWN),
+ // Both KEYCODE_HOME and KEYCODE_MENU keys are sent as CEC_KEYCODE_ROOT_MENU
+ // NOTE that the HOME key is not usually forwarded.
+ // When CEC_KEYCODE_ROOT_MENU is received, it is translated to KEYCODE_HOME
new KeycodeEntry(KeyEvent.KEYCODE_HOME, CEC_KEYCODE_ROOT_MENU),
+ new KeycodeEntry(KeyEvent.KEYCODE_MENU, CEC_KEYCODE_ROOT_MENU),
new KeycodeEntry(KeyEvent.KEYCODE_SETTINGS, CEC_KEYCODE_SETUP_MENU),
new KeycodeEntry(KeyEvent.KEYCODE_TV_CONTENTS_MENU, CEC_KEYCODE_CONTENTS_MENU, false),
// No Android keycode defined for CEC_KEYCODE_FAVORITE_MENU
diff --git a/services/core/java/com/android/server/incremental/IncrementalManagerService.java b/services/core/java/com/android/server/incremental/IncrementalManagerService.java
new file mode 100644
index 0000000..1b1a292
--- /dev/null
+++ b/services/core/java/com/android/server/incremental/IncrementalManagerService.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2019 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 com.android.server.incremental;
+
+import android.annotation.NonNull;
+import android.content.Context;
+import android.content.pm.DataLoaderManager;
+import android.content.pm.IDataLoader;
+import android.content.pm.IDataLoaderStatusListener;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.ResultReceiver;
+import android.os.ServiceManager;
+import android.os.ShellCallback;
+import android.os.incremental.IIncrementalManager;
+import android.os.incremental.IncrementalDataLoaderParamsParcel;
+import android.os.incremental.IncrementalFileSystemControlParcel;
+import android.util.Slog;
+
+import java.io.FileDescriptor;
+
+/**
+ * This service has the following purposes:
+ * 1) Starts the IIncrementalManager binder service.
+ * 1) Starts the native IIncrementalManagerService binder service.
+ * 2) Handles shell commands for "incremental" service.
+ * 3) Handles binder calls from the native IIncrementalManagerService binder service and pass
+ * them to a data loader binder service.
+ */
+
+public class IncrementalManagerService extends IIncrementalManager.Stub {
+ private static final String TAG = "IncrementalManagerService";
+ private static final String BINDER_SERVICE_NAME = "incremental";
+ // DataLoaderManagerService should have been started before us
+ private @NonNull DataLoaderManager mDataLoaderManager;
+ private long mNativeInstance;
+ private final @NonNull Context mContext;
+
+ /**
+ * Starts IIncrementalManager binder service and register to Service Manager.
+ * Starts the native IIncrementalManagerNative binder service.
+ */
+ public static IncrementalManagerService start(Context context) {
+ IncrementalManagerService self = new IncrementalManagerService(context);
+ if (self.mNativeInstance == 0) {
+ return null;
+ }
+ return self;
+ }
+
+ private IncrementalManagerService(Context context) {
+ mContext = context;
+ mDataLoaderManager = mContext.getSystemService(DataLoaderManager.class);
+ ServiceManager.addService(BINDER_SERVICE_NAME, this);
+ // Starts and register IIncrementalManagerNative service
+ // TODO(b/136132412): add jni implementation
+ }
+ /**
+ * Notifies native IIncrementalManager service that system is ready.
+ */
+ public void systemReady() {
+ // TODO(b/136132412): add jni implementation
+ }
+
+ /**
+ * Finds data loader service provider and binds to it. This requires PackageManager.
+ */
+ @Override
+ public boolean prepareDataLoader(int mountId, IncrementalFileSystemControlParcel control,
+ IncrementalDataLoaderParamsParcel params,
+ IDataLoaderStatusListener listener) {
+ Bundle dataLoaderParams = new Bundle();
+ dataLoaderParams.putCharSequence("packageName", params.packageName);
+ dataLoaderParams.putParcelable("control", control);
+ dataLoaderParams.putParcelable("params", params);
+ DataLoaderManager dataLoaderManager = mContext.getSystemService(DataLoaderManager.class);
+ if (dataLoaderManager == null) {
+ Slog.e(TAG, "Failed to find data loader manager service");
+ return false;
+ }
+ if (!dataLoaderManager.initializeDataLoader(mountId, dataLoaderParams, listener)) {
+ Slog.e(TAG, "Failed to initialize data loader");
+ return false;
+ }
+ return true;
+ }
+
+
+ @Override
+ public boolean startDataLoader(int mountId) {
+ IDataLoader dataLoader = mDataLoaderManager.getDataLoader(mountId);
+ if (dataLoader == null) {
+ Slog.e(TAG, "Start failed to retrieve data loader for ID=" + mountId);
+ return false;
+ }
+ try {
+ // TODO: fix file list
+ dataLoader.start(null);
+ return true;
+ } catch (RemoteException ex) {
+ return false;
+ }
+ }
+
+ @Override
+ public void destroyDataLoader(int mountId) {
+ IDataLoader dataLoader = mDataLoaderManager.getDataLoader(mountId);
+ if (dataLoader == null) {
+ Slog.e(TAG, "Destroy failed to retrieve data loader for ID=" + mountId);
+ return;
+ }
+ try {
+ dataLoader.destroy();
+ } catch (RemoteException ex) {
+ return;
+ }
+ }
+
+ // TODO: remove this
+ @Override
+ public void newFileForDataLoader(int mountId, long inode, byte[] metadata) {
+ IDataLoader dataLoader = mDataLoaderManager.getDataLoader(mountId);
+ if (dataLoader == null) {
+ Slog.e(TAG, "Failed to retrieve data loader for ID=" + mountId);
+ return;
+ }
+ try {
+ dataLoader.onFileCreated(inode, metadata);
+ } catch (RemoteException ex) {
+ }
+ }
+
+ @Override
+ public void showHealthBlockedUI(int mountId) {
+ // TODO(b/136132412): implement this
+ }
+
+ @Override
+ public void onShellCommand(@NonNull FileDescriptor in, @NonNull FileDescriptor out,
+ FileDescriptor err, @NonNull String[] args, ShellCallback callback,
+ @NonNull ResultReceiver resultReceiver) {
+ (new IncrementalManagerShellCommand(mContext)).exec(
+ this, in, out, err, args, callback, resultReceiver);
+ }
+}
diff --git a/services/core/java/com/android/server/incremental/IncrementalManagerShellCommand.java b/services/core/java/com/android/server/incremental/IncrementalManagerShellCommand.java
new file mode 100644
index 0000000..d35e806
--- /dev/null
+++ b/services/core/java/com/android/server/incremental/IncrementalManagerShellCommand.java
@@ -0,0 +1,295 @@
+/*
+ * Copyright (C) 2019 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 com.android.server.incremental;
+
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.content.Context;
+import android.content.IIntentReceiver;
+import android.content.IIntentSender;
+import android.content.Intent;
+import android.content.IntentSender;
+import android.content.pm.InstallationFile;
+import android.content.pm.PackageInstaller;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.ParcelFileDescriptor;
+import android.os.ShellCommand;
+import android.os.incremental.IncrementalDataLoaderParams;
+import android.util.Slog;
+
+import java.io.FileDescriptor;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Defines actions to handle adb commands like "adb abb incremental ...".
+ */
+public final class IncrementalManagerShellCommand extends ShellCommand {
+ private static final String TAG = "IncrementalShellCommand";
+ // Assuming the adb data loader is always installed on the device
+ private static final String LOADER_PACKAGE_NAME = "com.android.incremental.nativeadb";
+ private final @NonNull Context mContext;
+
+ private static final int ERROR_INVALID_ARGUMENTS = -1;
+ private static final int ERROR_DATA_LOADER_INIT = -2;
+ private static final int ERROR_COMMAND_EXECUTION = -3;
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({ERROR_INVALID_ARGUMENTS, ERROR_DATA_LOADER_INIT, ERROR_COMMAND_EXECUTION})
+ public @interface IncrementalShellCommandErrorCode {
+ }
+
+ IncrementalManagerShellCommand(@NonNull Context context) {
+ mContext = context;
+ }
+
+ @Override
+ public int onCommand(@Nullable String cmd) {
+ if (cmd == null) {
+ return handleDefaultCommands(null);
+ }
+ switch (cmd) {
+ case "install-start":
+ return runInstallStart();
+ case "install-finish":
+ return runInstallFinish();
+ default:
+ return handleDefaultCommands(cmd);
+ }
+ }
+
+ @Override
+ public void onHelp() {
+ PrintWriter pw = getOutPrintWriter();
+ pw.println("Incremental Service Commands:");
+ pw.println(" help");
+ pw.println(" Print this help text.");
+ pw.println(" install-start");
+ pw.println(" Opens an installation session");
+ pw.println(" install-finish SESSION_ID --file NAME:SIZE:INDEX --file NAME:SIZE:INDEX ...");
+ pw.println(" Commits an installation session specified by session ID for an APK ");
+ pw.println(" or a bundle of splits. Configures lib dirs or OBB files if specified.");
+ }
+
+ private int runInstallStart() {
+ final PrintWriter pw = getOutPrintWriter();
+ final PackageInstaller packageInstaller =
+ mContext.getPackageManager().getPackageInstaller();
+ if (packageInstaller == null) {
+ pw.println("Failed to get PackageInstaller.");
+ return ERROR_COMMAND_EXECUTION;
+ }
+
+ final Map<String, ParcelFileDescriptor> dataLoaderDynamicArgs = getDataLoaderDynamicArgs();
+ if (dataLoaderDynamicArgs == null) {
+ pw.println("File names and sizes don't match.");
+ return ERROR_DATA_LOADER_INIT;
+ }
+ final IncrementalDataLoaderParams params = new IncrementalDataLoaderParams(
+ "", LOADER_PACKAGE_NAME, dataLoaderDynamicArgs);
+ PackageInstaller.SessionParams sessionParams = new PackageInstaller.SessionParams(
+ PackageInstaller.SessionParams.MODE_FULL_INSTALL);
+ sessionParams.installFlags |= PackageManager.INSTALL_ALL_USERS;
+ // Replace existing if same package is already installed
+ sessionParams.installFlags |= PackageManager.INSTALL_REPLACE_EXISTING;
+ sessionParams.setIncrementalParams(params);
+
+ try {
+ int sessionId = packageInstaller.createSession(sessionParams);
+ pw.println("Successfully opened session: sessionId = " + sessionId);
+ } catch (Exception ex) {
+ pw.println("Failed to create session.");
+ return ERROR_COMMAND_EXECUTION;
+ } finally {
+ try {
+ for (Map.Entry<String, ParcelFileDescriptor> nfd
+ : dataLoaderDynamicArgs.entrySet()) {
+ nfd.getValue().close();
+ }
+ } catch (IOException ignored) {
+ }
+ }
+ return 0;
+ }
+
+ private int runInstallFinish() {
+ final PrintWriter pw = getOutPrintWriter();
+ final int sessionId = parseInt(getNextArgRequired());
+ final List<InstallationFile> installationFiles = parseFileArgs(pw);
+ if (installationFiles == null) {
+ pw.println("Must specify at least one file to install.");
+ return ERROR_INVALID_ARGUMENTS;
+ }
+ final int numFiles = installationFiles.size();
+ if (numFiles == 0) {
+ pw.println("Must specify at least one file to install.");
+ return ERROR_INVALID_ARGUMENTS;
+ }
+
+ final PackageInstaller packageInstaller = mContext.getPackageManager()
+ .getPackageInstaller();
+ if (packageInstaller == null) {
+ pw.println("Failed to get PackageInstaller.");
+ return ERROR_COMMAND_EXECUTION;
+ }
+
+ final LocalIntentReceiver localReceiver = new LocalIntentReceiver();
+ boolean success = false;
+
+ PackageInstaller.Session session = null;
+ try {
+ session = packageInstaller.openSession(sessionId);
+ for (int i = 0; i < numFiles; i++) {
+ InstallationFile file = installationFiles.get(i);
+ session.addFile(file.getName(), file.getSize(), file.getMetadata());
+ }
+ session.commit(localReceiver.getIntentSender());
+ final Intent result = localReceiver.getResult();
+ final int status = result.getIntExtra(PackageInstaller.EXTRA_STATUS,
+ PackageInstaller.STATUS_FAILURE);
+ if (status == PackageInstaller.STATUS_SUCCESS) {
+ success = true;
+ pw.println("Success");
+ return 0;
+ } else {
+ pw.println("Failure ["
+ + result.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE) + "]");
+ return ERROR_COMMAND_EXECUTION;
+ }
+ } catch (Exception e) {
+ e.printStackTrace(pw);
+ return ERROR_COMMAND_EXECUTION;
+ } finally {
+ if (!success) {
+ try {
+ if (session != null) {
+ session.abandon();
+ }
+ } catch (Exception ignore) {
+ }
+ }
+ }
+ }
+
+ private static class LocalIntentReceiver {
+ private final LinkedBlockingQueue<Intent> mResult = new LinkedBlockingQueue<>();
+
+ private IIntentSender.Stub mLocalSender = new IIntentSender.Stub() {
+ @Override
+ public void send(int code, Intent intent, String resolvedType, IBinder whitelistToken,
+ IIntentReceiver finishedReceiver, String requiredPermission,
+ Bundle options) {
+ try {
+ mResult.offer(intent, 5, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+
+ public IntentSender getIntentSender() {
+ return new IntentSender((IIntentSender) mLocalSender);
+ }
+
+ public Intent getResult() {
+ try {
+ return mResult.take();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ /** Helpers. */
+ private Map<String, ParcelFileDescriptor> getDataLoaderDynamicArgs() {
+ Map<String, ParcelFileDescriptor> dataLoaderDynamicArgs = new HashMap<>();
+ final FileDescriptor outFd = getOutFileDescriptor();
+ final FileDescriptor inFd = getInFileDescriptor();
+ try {
+ dataLoaderDynamicArgs.put("inFd", ParcelFileDescriptor.dup(inFd));
+ dataLoaderDynamicArgs.put("outFd", ParcelFileDescriptor.dup(outFd));
+ return dataLoaderDynamicArgs;
+ } catch (Exception ex) {
+ Slog.e(TAG, "Failed to dup FDs");
+ return null;
+ }
+ }
+
+ private long parseLong(String arg) {
+ long result = -1;
+ try {
+ result = Long.parseLong(arg);
+ } catch (NumberFormatException e) {
+ }
+ return result;
+ }
+
+ private int parseInt(String arg) {
+ int result = -1;
+ try {
+ result = Integer.parseInt(arg);
+ } catch (NumberFormatException e) {
+ }
+ return result;
+ }
+
+ private List<InstallationFile> parseFileArgs(PrintWriter pw) {
+ List<InstallationFile> fileList = new ArrayList<>();
+ String opt;
+ while ((opt = getNextOption()) != null) {
+ switch (opt) {
+ case "--file": {
+ final String fileArgs = getNextArgRequired();
+ final String[] args = fileArgs.split(":");
+ if (args.length != 3) {
+ pw.println("Invalid file args: " + fileArgs);
+ return null;
+ }
+ final String name = args[0];
+ final long size = parseLong(args[1]);
+ if (size < 0) {
+ pw.println("Invalid file size in: " + fileArgs);
+ return null;
+ }
+ final long index = parseLong(args[2]);
+ if (index < 0) {
+ pw.println("Invalid file index in: " + fileArgs);
+ return null;
+ }
+ final byte[] metadata = String.valueOf(index).getBytes(StandardCharsets.UTF_8);
+ fileList.add(new InstallationFile(name, size, metadata));
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ return fileList;
+ }
+}
diff --git a/services/core/java/com/android/server/location/LocationSettingsStore.java b/services/core/java/com/android/server/location/LocationSettingsStore.java
index 3d18d4a..f625452 100644
--- a/services/core/java/com/android/server/location/LocationSettingsStore.java
+++ b/services/core/java/com/android/server/location/LocationSettingsStore.java
@@ -34,6 +34,7 @@
import android.text.TextUtils;
import android.util.ArraySet;
+import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.Preconditions;
import com.android.server.SystemConfig;
@@ -113,6 +114,16 @@
() -> SystemConfig.getInstance().getAllowIgnoreLocationSettings(), handler);
}
+ /** Called when system is ready. */
+ public synchronized void onSystemReady() {
+ mLocationMode.register();
+ mBackgroundThrottleIntervalMs.register();
+ mLocationPackageBlacklist.register();
+ mLocationPackageWhitelist.register();
+ mBackgroundThrottlePackageWhitelist.register();
+ mIgnoreSettingsPackageWhitelist.register();
+ }
+
/**
* Retrieve if location is enabled or not.
*/
@@ -300,13 +311,25 @@
private abstract static class ObservingSetting extends ContentObserver {
private final CopyOnWriteArrayList<UserSettingChangedListener> mListeners;
+ private boolean mRegistered;
- private ObservingSetting(Context context, String settingName, Handler handler) {
+ private ObservingSetting(Handler handler) {
super(handler);
mListeners = new CopyOnWriteArrayList<>();
+ }
+
+ protected boolean isRegistered() {
+ return mRegistered;
+ }
+
+ protected void register(Context context, Uri uri) {
+ if (mRegistered) {
+ return;
+ }
context.getContentResolver().registerContentObserver(
- getUriFor(settingName), false, this, UserHandle.USER_ALL);
+ uri, false, this, UserHandle.USER_ALL);
+ mRegistered = true;
}
public void addListener(UserSettingChangedListener listener) {
@@ -317,8 +340,6 @@
mListeners.remove(listener);
}
- protected abstract Uri getUriFor(String settingName);
-
@Override
public void onChange(boolean selfChange, Uri uri, int userId) {
for (UserSettingChangedListener listener : mListeners) {
@@ -333,20 +354,19 @@
private final String mSettingName;
private IntegerSecureSetting(Context context, String settingName, Handler handler) {
- super(context, settingName, handler);
+ super(handler);
mContext = context;
mSettingName = settingName;
}
+ private void register() {
+ register(mContext, Settings.Secure.getUriFor(mSettingName));
+ }
+
public int getValueForUser(int defaultValue, int userId) {
return Settings.Secure.getIntForUser(mContext.getContentResolver(), mSettingName,
defaultValue, userId);
}
-
- @Override
- protected Uri getUriFor(String settingName) {
- return Settings.Secure.getUriFor(settingName);
- }
}
private static class StringListCachedSecureSetting extends ObservingSetting {
@@ -354,31 +374,44 @@
private final Context mContext;
private final String mSettingName;
- private int mCachedUserId = UserHandle.USER_NULL;
+ @GuardedBy("this")
+ private int mCachedUserId;
+ @GuardedBy("this")
private List<String> mCachedValue;
private StringListCachedSecureSetting(Context context, String settingName,
Handler handler) {
- super(context, settingName, handler);
+ super(handler);
mContext = context;
mSettingName = settingName;
+
+ mCachedUserId = UserHandle.USER_NULL;
+ }
+
+ public synchronized void register() {
+ register(mContext, Settings.Secure.getUriFor(mSettingName));
}
public synchronized List<String> getValueForUser(int userId) {
Preconditions.checkArgument(userId != UserHandle.USER_NULL);
+ List<String> value = mCachedValue;
if (userId != mCachedUserId) {
String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(),
mSettingName, userId);
if (TextUtils.isEmpty(setting)) {
- mCachedValue = Collections.emptyList();
+ value = Collections.emptyList();
} else {
- mCachedValue = Arrays.asList(setting.split(","));
+ value = Arrays.asList(setting.split(","));
}
- mCachedUserId = userId;
+
+ if (isRegistered()) {
+ mCachedUserId = userId;
+ mCachedValue = value;
+ }
}
- return mCachedValue;
+ return value;
}
public synchronized void invalidateForUser(int userId) {
@@ -393,11 +426,6 @@
invalidateForUser(userId);
super.onChange(selfChange, uri, userId);
}
-
- @Override
- protected Uri getUriFor(String settingName) {
- return Settings.Secure.getUriFor(settingName);
- }
}
private static class LongGlobalSetting extends ObservingSetting {
@@ -406,20 +434,19 @@
private final String mSettingName;
private LongGlobalSetting(Context context, String settingName, Handler handler) {
- super(context, settingName, handler);
+ super(handler);
mContext = context;
mSettingName = settingName;
}
+ public void register() {
+ register(mContext, Settings.Global.getUriFor(mSettingName));
+ }
+
public long getValue(long defaultValue) {
return Settings.Global.getLong(mContext.getContentResolver(), mSettingName,
defaultValue);
}
-
- @Override
- protected Uri getUriFor(String settingName) {
- return Settings.Global.getUriFor(settingName);
- }
}
private static class StringSetCachedGlobalSetting extends ObservingSetting {
@@ -428,29 +455,42 @@
private final String mSettingName;
private final Supplier<ArraySet<String>> mBaseValuesSupplier;
+ @GuardedBy("this")
private boolean mValid;
+ @GuardedBy("this")
private ArraySet<String> mCachedValue;
private StringSetCachedGlobalSetting(Context context, String settingName,
Supplier<ArraySet<String>> baseValuesSupplier, Handler handler) {
- super(context, settingName, handler);
+ super(handler);
mContext = context;
mSettingName = settingName;
mBaseValuesSupplier = baseValuesSupplier;
+
+ mValid = false;
+ }
+
+ public synchronized void register() {
+ register(mContext, Settings.Global.getUriFor(mSettingName));
}
public synchronized Set<String> getValue() {
+ ArraySet<String> value = mCachedValue;
if (!mValid) {
- mCachedValue = new ArraySet<>(mBaseValuesSupplier.get());
+ value = new ArraySet<>(mBaseValuesSupplier.get());
String setting = Settings.Global.getString(mContext.getContentResolver(),
mSettingName);
if (!TextUtils.isEmpty(setting)) {
- mCachedValue.addAll(Arrays.asList(setting.split(",")));
+ value.addAll(Arrays.asList(setting.split(",")));
}
- mValid = true;
+
+ if (isRegistered()) {
+ mValid = true;
+ mCachedValue = value;
+ }
}
- return mCachedValue;
+ return value;
}
public synchronized void invalidate() {
@@ -463,10 +503,5 @@
invalidate();
super.onChange(selfChange, uri, userId);
}
-
- @Override
- protected Uri getUriFor(String settingName) {
- return Settings.Global.getUriFor(settingName);
- }
}
}
diff --git a/services/core/java/com/android/server/LocationUsageLogger.java b/services/core/java/com/android/server/location/LocationUsageLogger.java
similarity index 72%
rename from services/core/java/com/android/server/LocationUsageLogger.java
rename to services/core/java/com/android/server/location/LocationUsageLogger.java
index a8a3cc4..755438b 100644
--- a/services/core/java/com/android/server/LocationUsageLogger.java
+++ b/services/core/java/com/android/server/location/LocationUsageLogger.java
@@ -14,37 +14,113 @@
* limitations under the License.
*/
-package com.android.server;
+package com.android.server.location;
+
+import static com.android.server.LocationManagerService.TAG;
import android.app.ActivityManager;
import android.location.Geofence;
import android.location.LocationManager;
import android.location.LocationRequest;
-import android.os.SystemClock;
import android.stats.location.LocationStatsEnums;
import android.util.Log;
import android.util.StatsLog;
+import com.android.internal.annotations.GuardedBy;
+
import java.time.Instant;
/**
* Logger for Location API usage logging.
*/
public class LocationUsageLogger {
- private static final String TAG = "LocationUsageLogger";
- private static final boolean D = Log.isLoggable(TAG, Log.DEBUG);
private static final int ONE_SEC_IN_MILLIS = 1000;
private static final int ONE_MINUTE_IN_MILLIS = 60000;
private static final int ONE_HOUR_IN_MILLIS = 3600000;
- private long mLastApiUsageLogHour = 0;
-
- private int mApiUsageLogHourlyCount = 0;
-
private static final int API_USAGE_LOG_HOURLY_CAP = 60;
- private static int providerNameToStatsdEnum(String provider) {
+ @GuardedBy("this")
+ private long mLastApiUsageLogHour = 0;
+ @GuardedBy("this")
+ private int mApiUsageLogHourlyCount = 0;
+
+ /**
+ * Log a location API usage event.
+ */
+ public void logLocationApiUsage(int usageType, int apiInUse,
+ String packageName, LocationRequest locationRequest,
+ boolean hasListener, boolean hasIntent,
+ Geofence geofence, int activityImportance) {
+ try {
+ if (hitApiUsageLogCap()) {
+ return;
+ }
+
+ boolean isLocationRequestNull = locationRequest == null;
+ boolean isGeofenceNull = geofence == null;
+
+ StatsLog.write(StatsLog.LOCATION_MANAGER_API_USAGE_REPORTED, usageType,
+ apiInUse, packageName,
+ isLocationRequestNull
+ ? LocationStatsEnums.PROVIDER_UNKNOWN
+ : bucketizeProvider(locationRequest.getProvider()),
+ isLocationRequestNull
+ ? LocationStatsEnums.QUALITY_UNKNOWN
+ : locationRequest.getQuality(),
+ isLocationRequestNull
+ ? LocationStatsEnums.INTERVAL_UNKNOWN
+ : bucketizeInterval(locationRequest.getInterval()),
+ isLocationRequestNull
+ ? LocationStatsEnums.DISTANCE_UNKNOWN
+ : bucketizeDistance(
+ locationRequest.getSmallestDisplacement()),
+ isLocationRequestNull ? 0 : locationRequest.getNumUpdates(),
+ // only log expireIn for USAGE_STARTED
+ isLocationRequestNull || usageType == LocationStatsEnums.USAGE_ENDED
+ ? LocationStatsEnums.EXPIRATION_UNKNOWN
+ : bucketizeExpireIn(locationRequest.getExpireIn()),
+ getCallbackType(apiInUse, hasListener, hasIntent),
+ isGeofenceNull
+ ? LocationStatsEnums.RADIUS_UNKNOWN
+ : bucketizeRadius(geofence.getRadius()),
+ categorizeActivityImportance(activityImportance));
+ } catch (Exception e) {
+ // Swallow exceptions to avoid crashing LMS.
+ Log.w(TAG, "Failed to log API usage to statsd.", e);
+ }
+ }
+
+ /**
+ * Log a location API usage event.
+ */
+ public void logLocationApiUsage(int usageType, int apiInUse, String providerName) {
+ try {
+ if (hitApiUsageLogCap()) {
+ return;
+ }
+
+ StatsLog.write(StatsLog.LOCATION_MANAGER_API_USAGE_REPORTED, usageType, apiInUse,
+ /* package_name= */ null,
+ bucketizeProvider(providerName),
+ LocationStatsEnums.QUALITY_UNKNOWN,
+ LocationStatsEnums.INTERVAL_UNKNOWN,
+ LocationStatsEnums.DISTANCE_UNKNOWN,
+ /* numUpdates= */ 0,
+ LocationStatsEnums.EXPIRATION_UNKNOWN,
+ getCallbackType(
+ apiInUse,
+ /* isListenerNull= */ true,
+ /* isIntentNull= */ true),
+ /* bucketizedRadius= */ 0,
+ LocationStatsEnums.IMPORTANCE_UNKNOWN);
+ } catch (Exception e) {
+ Log.w(TAG, "Failed to log API usage to statsd.", e);
+ }
+ }
+
+ private static int bucketizeProvider(String provider) {
if (LocationManager.NETWORK_PROVIDER.equals(provider)) {
return LocationStatsEnums.PROVIDER_NETWORK;
} else if (LocationManager.GPS_PROVIDER.equals(provider)) {
@@ -58,8 +134,7 @@
}
}
- private static int bucketizeIntervalToStatsdEnum(long interval) {
- // LocationManager already converts negative values to 0.
+ private static int bucketizeInterval(long interval) {
if (interval < ONE_SEC_IN_MILLIS) {
return LocationStatsEnums.INTERVAL_BETWEEN_0_SEC_AND_1_SEC;
} else if (interval < ONE_SEC_IN_MILLIS * 5) {
@@ -75,9 +150,8 @@
}
}
- private static int bucketizeSmallestDisplacementToStatsdEnum(float smallestDisplacement) {
- // LocationManager already converts negative values to 0.
- if (smallestDisplacement == 0) {
+ private static int bucketizeDistance(float smallestDisplacement) {
+ if (smallestDisplacement <= 0) {
return LocationStatsEnums.DISTANCE_ZERO;
} else if (smallestDisplacement > 0 && smallestDisplacement <= 100) {
return LocationStatsEnums.DISTANCE_BETWEEN_0_AND_100;
@@ -86,7 +160,7 @@
}
}
- private static int bucketizeRadiusToStatsdEnum(float radius) {
+ private static int bucketizeRadius(float radius) {
if (radius < 0) {
return LocationStatsEnums.RADIUS_NEGATIVE;
} else if (radius < 100) {
@@ -104,14 +178,11 @@
}
}
- private static int getBucketizedExpireIn(long expireAt) {
- if (expireAt == Long.MAX_VALUE) {
+ private static int bucketizeExpireIn(long expireIn) {
+ if (expireIn == Long.MAX_VALUE) {
return LocationStatsEnums.EXPIRATION_NO_EXPIRY;
}
- long elapsedRealtime = SystemClock.elapsedRealtime();
- long expireIn = Math.max(0, expireAt - elapsedRealtime);
-
if (expireIn < 20 * ONE_SEC_IN_MILLIS) {
return LocationStatsEnums.EXPIRATION_BETWEEN_0_AND_20_SEC;
} else if (expireIn < ONE_MINUTE_IN_MILLIS) {
@@ -129,8 +200,8 @@
if (importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
return LocationStatsEnums.IMPORTANCE_TOP;
} else if (importance == ActivityManager
- .RunningAppProcessInfo
- .IMPORTANCE_FOREGROUND_SERVICE) {
+ .RunningAppProcessInfo
+ .IMPORTANCE_FOREGROUND_SERVICE) {
return LocationStatsEnums.IMPORTANCE_FORGROUND_SERVICE;
} else {
return LocationStatsEnums.IMPORTANCE_BACKGROUND;
@@ -154,117 +225,16 @@
}
}
- // Update the hourly count of APIUsage log event.
- // Returns false if hit the hourly log cap.
- private boolean checkApiUsageLogCap() {
- if (D) {
- Log.d(TAG, "checking APIUsage log cap.");
- }
-
+ private synchronized boolean hitApiUsageLogCap() {
long currentHour = Instant.now().toEpochMilli() / ONE_HOUR_IN_MILLIS;
if (currentHour > mLastApiUsageLogHour) {
mLastApiUsageLogHour = currentHour;
mApiUsageLogHourlyCount = 0;
- return true;
+ return false;
} else {
mApiUsageLogHourlyCount = Math.min(
- mApiUsageLogHourlyCount + 1, API_USAGE_LOG_HOURLY_CAP);
- return mApiUsageLogHourlyCount < API_USAGE_LOG_HOURLY_CAP;
- }
- }
-
- /**
- * Log a Location API usage event to Statsd.
- * Logging event is capped at 60 per hour. Usage events exceeding
- * the cap will be dropped by LocationUsageLogger.
- */
- public void logLocationApiUsage(int usageType, int apiInUse,
- String packageName, LocationRequest locationRequest,
- boolean hasListener, boolean hasIntent,
- Geofence geofence, int activityImportance) {
- try {
- if (!checkApiUsageLogCap()) {
- return;
- }
-
- boolean isLocationRequestNull = locationRequest == null;
- boolean isGeofenceNull = geofence == null;
- if (D) {
- Log.d(TAG, "log API Usage to statsd. usageType: " + usageType + ", apiInUse: "
- + apiInUse + ", packageName: " + (packageName == null ? "" : packageName)
- + ", locationRequest: "
- + (isLocationRequestNull ? "" : locationRequest.toString())
- + ", hasListener: " + hasListener
- + ", hasIntent: " + hasIntent
- + ", geofence: "
- + (isGeofenceNull ? "" : geofence.toString())
- + ", importance: " + activityImportance);
- }
-
- StatsLog.write(StatsLog.LOCATION_MANAGER_API_USAGE_REPORTED, usageType,
- apiInUse, packageName,
- isLocationRequestNull
- ? LocationStatsEnums.PROVIDER_UNKNOWN
- : providerNameToStatsdEnum(locationRequest.getProvider()),
- isLocationRequestNull
- ? LocationStatsEnums.QUALITY_UNKNOWN
- : locationRequest.getQuality(),
- isLocationRequestNull
- ? LocationStatsEnums.INTERVAL_UNKNOWN
- : bucketizeIntervalToStatsdEnum(locationRequest.getInterval()),
- isLocationRequestNull
- ? LocationStatsEnums.DISTANCE_UNKNOWN
- : bucketizeSmallestDisplacementToStatsdEnum(
- locationRequest.getSmallestDisplacement()),
- isLocationRequestNull ? 0 : locationRequest.getNumUpdates(),
- // only log expireIn for USAGE_STARTED
- isLocationRequestNull || usageType == LocationStatsEnums.USAGE_ENDED
- ? LocationStatsEnums.EXPIRATION_UNKNOWN
- : getBucketizedExpireIn(locationRequest.getExpireAt()),
- getCallbackType(apiInUse, hasListener, hasIntent),
- isGeofenceNull
- ? LocationStatsEnums.RADIUS_UNKNOWN
- : bucketizeRadiusToStatsdEnum(geofence.getRadius()),
- categorizeActivityImportance(activityImportance));
- } catch (Exception e) {
- // Swallow exceptions to avoid crashing LMS.
- Log.w(TAG, "Failed to log API usage to statsd.", e);
- }
- }
-
- /**
- * Log a Location API usage event to Statsd.
- * Logging event is capped at 60 per hour. Usage events exceeding
- * the cap will be dropped by LocationUsageLogger.
- */
- public void logLocationApiUsage(int usageType, int apiInUse, String providerName) {
- try {
- if (!checkApiUsageLogCap()) {
- return;
- }
-
- if (D) {
- Log.d(TAG, "log API Usage to statsd. usageType: " + usageType + ", apiInUse: "
- + apiInUse + ", providerName: " + providerName);
- }
-
- StatsLog.write(StatsLog.LOCATION_MANAGER_API_USAGE_REPORTED, usageType, apiInUse,
- /* package_name= */ null,
- providerNameToStatsdEnum(providerName),
- LocationStatsEnums.QUALITY_UNKNOWN,
- LocationStatsEnums.INTERVAL_UNKNOWN,
- LocationStatsEnums.DISTANCE_UNKNOWN,
- /* numUpdates= */ 0,
- LocationStatsEnums.EXPIRATION_UNKNOWN,
- getCallbackType(
- apiInUse,
- /* isListenerNull= */ true,
- /* isIntentNull= */ true),
- /* bucketizedRadius= */ 0,
- LocationStatsEnums.IMPORTANCE_UNKNOWN);
- } catch (Exception e) {
- // Swallow exceptions to avoid crashing LMS.
- Log.w(TAG, "Failed to log API usage to statsd.", e);
+ mApiUsageLogHourlyCount + 1, API_USAGE_LOG_HOURLY_CAP);
+ return mApiUsageLogHourlyCount >= API_USAGE_LOG_HOURLY_CAP;
}
}
}
diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java
index c25e206..069aeef 100644
--- a/services/core/java/com/android/server/media/MediaSessionService.java
+++ b/services/core/java/com/android/server/media/MediaSessionService.java
@@ -47,7 +47,8 @@
import android.media.Session2CommandGroup;
import android.media.Session2Token;
import android.media.session.IActiveSessionsListener;
-import android.media.session.ICallback;
+import android.media.session.IOnMediaKeyEventDispatchedListener;
+import android.media.session.IOnMediaKeyEventSessionChangedListener;
import android.media.session.IOnMediaKeyListener;
import android.media.session.IOnVolumeKeyLongPressListener;
import android.media.session.ISession;
@@ -70,6 +71,7 @@
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.ServiceManager;
+import android.os.ShellCallback;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
@@ -749,7 +751,10 @@
private final int mFullUserId;
private final MediaSessionStack mPriorityStack;
- private final HashMap<IBinder, CallbackRecord> mCallbacks = new HashMap<>();
+ private final HashMap<IBinder, OnMediaKeyEventDispatchedListenerRecord>
+ mOnMediaKeyEventDispatchedListeners = new HashMap<>();
+ private final HashMap<IBinder, OnMediaKeyEventSessionChangedListenerRecord>
+ mOnMediaKeyEventSessionChangedListeners = new HashMap<>();
private PendingIntent mLastMediaButtonReceiver;
private ComponentName mRestoredMediaButtonReceiver;
@@ -795,21 +800,47 @@
}
}
- public void registerCallbackLocked(ICallback callback, int uid) {
- IBinder cbBinder = callback.asBinder();
- CallbackRecord cr = new CallbackRecord(callback, uid);
- mCallbacks.put(cbBinder, cr);
+ public void addOnMediaKeyEventDispatchedListenerLocked(
+ IOnMediaKeyEventDispatchedListener listener, int uid) {
+ IBinder cbBinder = listener.asBinder();
+ OnMediaKeyEventDispatchedListenerRecord cr =
+ new OnMediaKeyEventDispatchedListenerRecord(listener, uid);
+ mOnMediaKeyEventDispatchedListeners.put(cbBinder, cr);
try {
cbBinder.linkToDeath(cr, 0);
} catch (RemoteException e) {
- Log.w(TAG, "Failed to register callback", e);
- mCallbacks.remove(cbBinder);
+ Log.w(TAG, "Failed to add listener", e);
+ mOnMediaKeyEventDispatchedListeners.remove(cbBinder);
}
}
- public void unregisterCallbackLocked(ICallback callback) {
- IBinder cbBinder = callback.asBinder();
- CallbackRecord cr = mCallbacks.remove(cbBinder);
+ public void removeOnMediaKeyEventDispatchedListenerLocked(
+ IOnMediaKeyEventDispatchedListener listener) {
+ IBinder cbBinder = listener.asBinder();
+ OnMediaKeyEventDispatchedListenerRecord cr =
+ mOnMediaKeyEventDispatchedListeners.remove(cbBinder);
+ cbBinder.unlinkToDeath(cr, 0);
+ }
+
+ public void addOnMediaKeyEventSessionChangedListenerLocked(
+ IOnMediaKeyEventSessionChangedListener listener, int uid) {
+ IBinder cbBinder = listener.asBinder();
+ OnMediaKeyEventSessionChangedListenerRecord cr =
+ new OnMediaKeyEventSessionChangedListenerRecord(listener, uid);
+ mOnMediaKeyEventSessionChangedListeners.put(cbBinder, cr);
+ try {
+ cbBinder.linkToDeath(cr, 0);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to add listener", e);
+ mOnMediaKeyEventSessionChangedListeners.remove(cbBinder);
+ }
+ }
+
+ public void removeOnMediaKeyEventSessionChangedListener(
+ IOnMediaKeyEventSessionChangedListener listener) {
+ IBinder cbBinder = listener.asBinder();
+ OnMediaKeyEventSessionChangedListenerRecord cr =
+ mOnMediaKeyEventSessionChangedListeners.remove(cbBinder);
cbBinder.unlinkToDeath(cr, 0);
}
@@ -831,8 +862,16 @@
pw.println(indent + "Media key listener: " + mOnMediaKeyListener);
pw.println(indent + "Media key listener package: "
+ getCallingPackageName(mOnMediaKeyListenerUid));
- pw.println(indent + "Callbacks: registered " + mCallbacks.size() + " callback(s)");
- for (CallbackRecord cr : mCallbacks.values()) {
+ pw.println(indent + "OnMediaKeyEventDispatchedListener: added "
+ + mOnMediaKeyEventDispatchedListeners.size() + " listener(s)");
+ for (OnMediaKeyEventDispatchedListenerRecord cr
+ : mOnMediaKeyEventDispatchedListeners.values()) {
+ pw.println(indent + " from " + getCallingPackageName(cr.uid));
+ }
+ pw.println(indent + "OnMediaKeyEventSessionChangedListener: added "
+ + mOnMediaKeyEventSessionChangedListeners.size() + " listener(s)");
+ for (OnMediaKeyEventSessionChangedListenerRecord cr
+ : mOnMediaKeyEventSessionChangedListeners.values()) {
pw.println(indent + " from " + getCallingPackageName(cr.uid));
}
pw.println(indent + "Last MediaButtonReceiver: " + mLastMediaButtonReceiver);
@@ -894,19 +933,22 @@
mFullUserId);
}
- private void pushAddressedPlayerChangedLocked(ICallback callback) {
+ private void pushAddressedPlayerChangedLocked(
+ IOnMediaKeyEventSessionChangedListener callback) {
try {
MediaSessionRecord mediaButtonSession = getMediaButtonSessionLocked();
if (mediaButtonSession != null) {
- callback.onAddressedPlayerChangedToMediaSession(
+ callback.onMediaKeyEventSessionChanged(mediaButtonSession.getPackageName(),
mediaButtonSession.getSessionToken());
} else if (mCurrentFullUserRecord.mLastMediaButtonReceiver != null) {
- callback.onAddressedPlayerChangedToMediaButtonReceiver(
+ callback.onMediaKeyEventSessionChanged(
mCurrentFullUserRecord.mLastMediaButtonReceiver
- .getIntent().getComponent());
+ .getIntent().getComponent().getPackageName(),
+ null);
} else if (mCurrentFullUserRecord.mRestoredMediaButtonReceiver != null) {
- callback.onAddressedPlayerChangedToMediaButtonReceiver(
- mCurrentFullUserRecord.mRestoredMediaButtonReceiver);
+ callback.onMediaKeyEventSessionChanged(
+ mCurrentFullUserRecord.mRestoredMediaButtonReceiver.getPackageName(),
+ null);
}
} catch (RemoteException e) {
Log.w(TAG, "Failed to pushAddressedPlayerChangedLocked", e);
@@ -914,7 +956,8 @@
}
private void pushAddressedPlayerChangedLocked() {
- for (CallbackRecord cr : mCallbacks.values()) {
+ for (OnMediaKeyEventSessionChangedListenerRecord cr
+ : mOnMediaKeyEventSessionChangedListeners.values()) {
pushAddressedPlayerChangedLocked(cr.callback);
}
}
@@ -953,11 +996,12 @@
return COMPONENT_TYPE_BROADCAST;
}
- final class CallbackRecord implements IBinder.DeathRecipient {
- public final ICallback callback;
+ final class OnMediaKeyEventDispatchedListenerRecord implements IBinder.DeathRecipient {
+ public final IOnMediaKeyEventDispatchedListener callback;
public final int uid;
- CallbackRecord(ICallback callback, int uid) {
+ OnMediaKeyEventDispatchedListenerRecord(IOnMediaKeyEventDispatchedListener callback,
+ int uid) {
this.callback = callback;
this.uid = uid;
}
@@ -965,7 +1009,25 @@
@Override
public void binderDied() {
synchronized (mLock) {
- mCallbacks.remove(callback.asBinder());
+ mOnMediaKeyEventDispatchedListeners.remove(callback.asBinder());
+ }
+ }
+ }
+
+ final class OnMediaKeyEventSessionChangedListenerRecord implements IBinder.DeathRecipient {
+ public final IOnMediaKeyEventSessionChangedListener callback;
+ public final int uid;
+
+ OnMediaKeyEventSessionChangedListenerRecord(
+ IOnMediaKeyEventSessionChangedListener callback, int uid) {
+ this.callback = callback;
+ this.uid = uid;
+ }
+
+ @Override
+ public void binderDied() {
+ synchronized (mLock) {
+ mOnMediaKeyEventSessionChangedListeners.remove(callback.asBinder());
}
}
}
@@ -1042,6 +1104,13 @@
private boolean mVoiceButtonHandled = false;
@Override
+ public void onShellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err,
+ String[] args, ShellCallback callback, ResultReceiver resultReceiver) {
+ (new MediaShellCommand()).exec(this, in, out, err, args, callback,
+ resultReceiver);
+ }
+
+ @Override
public ISession createSession(String packageName, ISessionCallback cb, String tag,
Bundle sessionInfo, int userId) throws RemoteException {
final int pid = Binder.getCallingPid();
@@ -1347,7 +1416,8 @@
}
@Override
- public void registerCallback(final ICallback callback) {
+ public void addOnMediaKeyEventDispatchedListener(
+ final IOnMediaKeyEventDispatchedListener listener) {
final int pid = Binder.getCallingPid();
final int uid = Binder.getCallingUid();
final int userId = UserHandle.getUserId(uid);
@@ -1355,18 +1425,18 @@
try {
if (!hasMediaControlPermission(pid, uid)) {
throw new SecurityException("MEDIA_CONTENT_CONTROL permission is required to"
- + " register Callback");
+ + " add MediaKeyEventDispatchedListener");
}
synchronized (mLock) {
FullUserRecord user = getFullUserRecordLocked(userId);
if (user == null || user.mFullUserId != userId) {
- Log.w(TAG, "Only the full user can register the callback"
+ Log.w(TAG, "Only the full user can add the listener"
+ ", userId=" + userId);
return;
}
- user.registerCallbackLocked(callback, uid);
- Log.d(TAG, "The callback (" + callback.asBinder()
- + ") is registered by " + getCallingPackageName(uid));
+ user.addOnMediaKeyEventDispatchedListenerLocked(listener, uid);
+ Log.d(TAG, "The MediaKeyEventDispatchedListener (" + listener.asBinder()
+ + ") is added by " + getCallingPackageName(uid));
}
} finally {
Binder.restoreCallingIdentity(token);
@@ -1374,7 +1444,8 @@
}
@Override
- public void unregisterCallback(final ICallback callback) {
+ public void removeOnMediaKeyEventDispatchedListener(
+ final IOnMediaKeyEventDispatchedListener listener) {
final int pid = Binder.getCallingPid();
final int uid = Binder.getCallingUid();
final int userId = UserHandle.getUserId(uid);
@@ -1382,18 +1453,74 @@
try {
if (!hasMediaControlPermission(pid, uid)) {
throw new SecurityException("MEDIA_CONTENT_CONTROL permission is required to"
- + " unregister Callback");
+ + " remove MediaKeyEventDispatchedListener");
}
synchronized (mLock) {
FullUserRecord user = getFullUserRecordLocked(userId);
if (user == null || user.mFullUserId != userId) {
- Log.w(TAG, "Only the full user can unregister the callback"
+ Log.w(TAG, "Only the full user can remove the listener"
+ ", userId=" + userId);
return;
}
- user.unregisterCallbackLocked(callback);
- Log.d(TAG, "The callback (" + callback.asBinder()
- + ") is unregistered by " + getCallingPackageName(uid));
+ user.removeOnMediaKeyEventDispatchedListenerLocked(listener);
+ Log.d(TAG, "The MediaKeyEventDispatchedListener (" + listener.asBinder()
+ + ") is removed by " + getCallingPackageName(uid));
+ }
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
+ @Override
+ public void addOnMediaKeyEventSessionChangedListener(
+ final IOnMediaKeyEventSessionChangedListener listener) {
+ final int pid = Binder.getCallingPid();
+ final int uid = Binder.getCallingUid();
+ final int userId = UserHandle.getUserId(uid);
+ final long token = Binder.clearCallingIdentity();
+ try {
+ if (!hasMediaControlPermission(pid, uid)) {
+ throw new SecurityException("MEDIA_CONTENT_CONTROL permission is required to"
+ + " add MediaKeyEventSessionChangedListener");
+ }
+ synchronized (mLock) {
+ FullUserRecord user = getFullUserRecordLocked(userId);
+ if (user == null || user.mFullUserId != userId) {
+ Log.w(TAG, "Only the full user can add the listener"
+ + ", userId=" + userId);
+ return;
+ }
+ user.addOnMediaKeyEventSessionChangedListenerLocked(listener, uid);
+ Log.d(TAG, "The MediaKeyEventSessionChangedListener (" + listener.asBinder()
+ + ") is added by " + getCallingPackageName(uid));
+ }
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
+ @Override
+ public void removeOnMediaKeyEventSessionChangedListener(
+ final IOnMediaKeyEventSessionChangedListener listener) {
+ final int pid = Binder.getCallingPid();
+ final int uid = Binder.getCallingUid();
+ final int userId = UserHandle.getUserId(uid);
+ final long token = Binder.clearCallingIdentity();
+ try {
+ if (!hasMediaControlPermission(pid, uid)) {
+ throw new SecurityException("MEDIA_CONTENT_CONTROL permission is required to"
+ + " remove MediaKeyEventSessionChangedListener");
+ }
+ synchronized (mLock) {
+ FullUserRecord user = getFullUserRecordLocked(userId);
+ if (user == null || user.mFullUserId != userId) {
+ Log.w(TAG, "Only the full user can remove the listener"
+ + ", userId=" + userId);
+ return;
+ }
+ user.removeOnMediaKeyEventSessionChangedListener(listener);
+ Log.d(TAG, "The MediaKeyEventSessionChangedListener (" + listener.asBinder()
+ + ") is removed by " + getCallingPackageName(uid));
}
} finally {
Binder.restoreCallingIdentity(token);
@@ -2007,10 +2134,10 @@
needWakeLock ? mKeyEventReceiver.mLastTimeoutId : -1,
mKeyEventReceiver);
try {
- for (FullUserRecord.CallbackRecord cr
- : mCurrentFullUserRecord.mCallbacks.values()) {
- cr.callback.onMediaKeyEventDispatchedToMediaSession(
- keyEvent, session.getSessionToken());
+ for (FullUserRecord.OnMediaKeyEventDispatchedListenerRecord cr
+ : mCurrentFullUserRecord.mOnMediaKeyEventDispatchedListeners.values()) {
+ cr.callback.onMediaKeyEventDispatched(
+ keyEvent, session.getPackageName(), session.getSessionToken());
}
} catch (RemoteException e) {
Log.w(TAG, "Failed to send callback", e);
@@ -2040,10 +2167,11 @@
ComponentName componentName = mCurrentFullUserRecord
.mLastMediaButtonReceiver.getIntent().getComponent();
if (componentName != null) {
- for (FullUserRecord.CallbackRecord cr
- : mCurrentFullUserRecord.mCallbacks.values()) {
- cr.callback.onMediaKeyEventDispatchedToMediaButtonReceiver(
- keyEvent, componentName);
+ for (FullUserRecord.OnMediaKeyEventDispatchedListenerRecord cr
+ : mCurrentFullUserRecord
+ .mOnMediaKeyEventDispatchedListeners.values()) {
+ cr.callback.onMediaKeyEventDispatched(keyEvent,
+ componentName.getPackageName(), null);
}
}
} else {
@@ -2075,10 +2203,11 @@
Log.w(TAG, "Error sending media button to the restored intent "
+ receiver + ", type=" + componentType, e);
}
- for (FullUserRecord.CallbackRecord cr
- : mCurrentFullUserRecord.mCallbacks.values()) {
- cr.callback.onMediaKeyEventDispatchedToMediaButtonReceiver(
- keyEvent, receiver);
+ for (FullUserRecord.OnMediaKeyEventDispatchedListenerRecord cr
+ : mCurrentFullUserRecord
+ .mOnMediaKeyEventDispatchedListeners.values()) {
+ cr.callback.onMediaKeyEventDispatched(keyEvent,
+ receiver.getPackageName(), null);
}
}
} catch (CanceledException e) {
diff --git a/cmds/media/src/com/android/commands/media/Media.java b/services/core/java/com/android/server/media/MediaShellCommand.java
similarity index 64%
rename from cmds/media/src/com/android/commands/media/Media.java
rename to services/core/java/com/android/server/media/MediaShellCommand.java
index 1e915f8..20df271 100644
--- a/cmds/media/src/com/android/commands/media/Media.java
+++ b/services/core/java/com/android/server/media/MediaShellCommand.java
@@ -1,29 +1,27 @@
/*
-**
-** Copyright 2013, 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.
-*/
+ * Copyright (C) 2019 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 com.android.commands.media;
+package com.android.server.media;
import android.app.ActivityThread;
import android.content.Context;
import android.media.MediaMetadata;
import android.media.session.ISessionManager;
import android.media.session.MediaController;
-import android.media.session.MediaController.PlaybackInfo;
-import android.media.session.MediaSession.QueueItem;
+import android.media.session.MediaSession;
import android.media.session.MediaSessionManager;
import android.media.session.PlaybackState;
import android.os.Bundle;
@@ -31,59 +29,41 @@
import android.os.Looper;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.ShellCommand;
import android.os.SystemClock;
-import android.util.AndroidException;
+import android.text.TextUtils;
import android.view.InputDevice;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
-import com.android.internal.os.BaseCommand;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.io.PrintStream;
+import java.io.PrintWriter;
import java.util.List;
-public class Media extends BaseCommand {
+/**
+ * ShellCommand for MediaSessionService.
+ */
+public class MediaShellCommand extends ShellCommand {
// This doesn't belongs to any package. Setting the package name to empty string.
private static final String PACKAGE_NAME = "";
private static ActivityThread sThread;
private static MediaSessionManager sMediaSessionManager;
private ISessionManager mSessionService;
-
- /**
- * Command-line entry point.
- *
- * @param args The command-line arguments
- */
- public static void main(String[] args) {
- (new Media()).run(args);
- }
+ private PrintWriter mWriter;
+ private PrintWriter mErrorWriter;
@Override
- public void onShowUsage(PrintStream out) {
- out.println(
- "usage: media [subcommand] [options]\n" +
- " media dispatch KEY\n" +
- " media list-sessions\n" +
- " media monitor <tag>\n" +
- " media volume [options]\n" +
- "\n" +
- "media dispatch: dispatch a media key to the system.\n" +
- " KEY may be: play, pause, play-pause, mute, headsethook,\n" +
- " stop, next, previous, rewind, record, fast-forword.\n" +
- "media list-sessions: print a list of the current sessions.\n" +
- "media monitor: monitor updates to the specified session.\n" +
- " Use the tag from list-sessions.\n" +
- "media volume: " + VolumeCtrl.USAGE
- );
- }
+ public int onCommand(String cmd) {
+ mWriter = getOutPrintWriter();
+ mErrorWriter = getErrPrintWriter();
- @Override
- public void onRun() throws Exception {
+ if (TextUtils.isEmpty(cmd)) {
+ return handleDefaultCommands(cmd);
+ }
if (sThread == null) {
- Looper.prepareMainLooper();
+ Looper.prepare();
sThread = ActivityThread.systemMain();
Context context = sThread.getSystemContext();
sMediaSessionManager =
@@ -92,25 +72,47 @@
mSessionService = ISessionManager.Stub.asInterface(ServiceManager.checkService(
Context.MEDIA_SESSION_SERVICE));
if (mSessionService == null) {
- System.err.println(NO_SYSTEM_ERROR_CODE);
- throw new AndroidException(
+ throw new IllegalStateException(
"Can't connect to media session service; is the system running?");
}
- String op = nextArgRequired();
-
- if (op.equals("dispatch")) {
- runDispatch();
- } else if (op.equals("list-sessions")) {
- runListSessions();
- } else if (op.equals("monitor")) {
- runMonitor();
- } else if (op.equals("volume")) {
- runVolume();
- } else {
- showError("Error: unknown command '" + op + "'");
- return;
+ try {
+ if (cmd.equals("dispatch")) {
+ runDispatch();
+ } else if (cmd.equals("list-sessions")) {
+ runListSessions();
+ } else if (cmd.equals("monitor")) {
+ runMonitor();
+ } else if (cmd.equals("volume")) {
+ runVolume();
+ } else {
+ showError("Error: unknown command '" + cmd + "'");
+ return -1;
+ }
+ } catch (Exception e) {
+ showError(e.toString());
+ return -1;
}
+ return 0;
+ }
+
+ @Override
+ public void onHelp() {
+ mWriter.println("usage: media_session [subcommand] [options]");
+ mWriter.println(" media_session dispatch KEY");
+ mWriter.println(" media_session dispatch KEY");
+ mWriter.println(" media_session list-sessions");
+ mWriter.println(" media_session monitor <tag>");
+ mWriter.println(" media_session volume [options]");
+ mWriter.println();
+ mWriter.println("media_session dispatch: dispatch a media key to the system.");
+ mWriter.println(" KEY may be: play, pause, play-pause, mute, headsethook,");
+ mWriter.println(" stop, next, previous, rewind, record, fast-forword.");
+ mWriter.println("media_session list-sessions: print a list of the current sessions.");
+ mWriter.println("media_session monitor: monitor updates to the specified session.");
+ mWriter.println(" Use the tag from list-sessions.");
+ mWriter.println("media_session volume: " + VolumeCtrl.USAGE);
+ mWriter.println();
}
private void sendMediaKey(KeyEvent event) {
@@ -121,7 +123,7 @@
}
private void runMonitor() throws Exception {
- String id = nextArgRequired();
+ String id = getNextArgRequired();
if (id == null) {
showError("Error: must include a session id");
return;
@@ -133,7 +135,8 @@
for (MediaController controller : controllers) {
try {
if (controller != null && id.equals(controller.getTag())) {
- ControllerMonitor monitor = new ControllerMonitor(controller);
+ MediaShellCommand.ControllerMonitor monitor =
+ new MediaShellCommand.ControllerMonitor(controller);
monitor.run();
success = true;
break;
@@ -143,15 +146,15 @@
}
}
} catch (Exception e) {
- System.out.println("***Error monitoring session*** " + e.getMessage());
+ mErrorWriter.println("***Error monitoring session*** " + e.getMessage());
}
if (!success) {
- System.out.println("No session found with id " + id);
+ mErrorWriter.println("No session found with id " + id);
}
}
private void runDispatch() throws Exception {
- String cmd = nextArgRequired();
+ String cmd = getNextArgRequired();
int keycode;
if ("play".equals(cmd)) {
keycode = KeyEvent.KEYCODE_MEDIA_PLAY;
@@ -186,68 +189,73 @@
KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, InputDevice.SOURCE_KEYBOARD));
}
+ void showError(String errMsg) {
+ onHelp();
+ mErrorWriter.println(errMsg);
+ }
+
class ControllerCallback extends MediaController.Callback {
@Override
public void onSessionDestroyed() {
- System.out.println("onSessionDestroyed. Enter q to quit.");
+ mWriter.println("onSessionDestroyed. Enter q to quit.");
}
@Override
public void onSessionEvent(String event, Bundle extras) {
- System.out.println("onSessionEvent event=" + event + ", extras=" + extras);
+ mWriter.println("onSessionEvent event=" + event + ", extras=" + extras);
}
@Override
public void onPlaybackStateChanged(PlaybackState state) {
- System.out.println("onPlaybackStateChanged " + state);
+ mWriter.println("onPlaybackStateChanged " + state);
}
@Override
public void onMetadataChanged(MediaMetadata metadata) {
String mmString = metadata == null ? null : "title=" + metadata
.getDescription();
- System.out.println("onMetadataChanged " + mmString);
+ mWriter.println("onMetadataChanged " + mmString);
}
@Override
- public void onQueueChanged(List<QueueItem> queue) {
- System.out.println("onQueueChanged, "
+ public void onQueueChanged(List<MediaSession.QueueItem> queue) {
+ mWriter.println("onQueueChanged, "
+ (queue == null ? "null queue" : " size=" + queue.size()));
}
@Override
public void onQueueTitleChanged(CharSequence title) {
- System.out.println("onQueueTitleChange " + title);
+ mWriter.println("onQueueTitleChange " + title);
}
@Override
public void onExtrasChanged(Bundle extras) {
- System.out.println("onExtrasChanged " + extras);
+ mWriter.println("onExtrasChanged " + extras);
}
@Override
- public void onAudioInfoChanged(PlaybackInfo info) {
- System.out.println("onAudioInfoChanged " + info);
+ public void onAudioInfoChanged(MediaController.PlaybackInfo info) {
+ mWriter.println("onAudioInfoChanged " + info);
}
}
private class ControllerMonitor {
private final MediaController mController;
- private final ControllerCallback mControllerCallback;
+ private final MediaShellCommand.ControllerCallback mControllerCallback;
ControllerMonitor(MediaController controller) {
mController = controller;
- mControllerCallback = new ControllerCallback();
+ mControllerCallback = new MediaShellCommand.ControllerCallback();
}
void printUsageMessage() {
try {
- System.out.println("V2Monitoring session " + mController.getTag()
+ mWriter.println("V2Monitoring session " + mController.getTag()
+ "... available commands: play, pause, next, previous");
} catch (RuntimeException e) {
- System.out.println("Error trying to monitor session!");
+ mWriter.println("Error trying to monitor session!");
}
- System.out.println("(q)uit: finish monitoring");
+ mWriter.println("(q)uit: finish monitoring");
}
void run() throws RemoteException {
@@ -258,7 +266,7 @@
try {
mController.registerCallback(mControllerCallback);
} catch (RuntimeException e) {
- System.out.println("Error registering monitor callback");
+ mErrorWriter.println("Error registering monitor callback");
}
}
};
@@ -284,7 +292,7 @@
} else if ("previous".equals(line)) {
dispatchKeyCode(KeyEvent.KEYCODE_MEDIA_PREVIOUS);
} else {
- System.out.println("Invalid command: " + line);
+ mErrorWriter.println("Invalid command: " + line);
}
synchronized (this) {
@@ -316,19 +324,19 @@
mController.dispatchMediaButtonEvent(down);
mController.dispatchMediaButtonEvent(up);
} catch (RuntimeException e) {
- System.out.println("Failed to dispatch " + keyCode);
+ mErrorWriter.println("Failed to dispatch " + keyCode);
}
}
}
private void runListSessions() {
- System.out.println("Sessions:");
+ mWriter.println("Sessions:");
try {
List<MediaController> controllers = sMediaSessionManager.getActiveSessions(null);
for (MediaController controller : controllers) {
if (controller != null) {
try {
- System.out.println(" tag=" + controller.getTag()
+ mWriter.println(" tag=" + controller.getTag()
+ ", package=" + controller.getPackageName());
} catch (RuntimeException e) {
// ignore
@@ -336,7 +344,7 @@
}
}
} catch (Exception e) {
- System.out.println("***Error listing sessions***");
+ mErrorWriter.println("***Error listing sessions***");
}
}
diff --git a/cmds/media/src/com/android/commands/media/VolumeCtrl.java b/services/core/java/com/android/server/media/VolumeCtrl.java
old mode 100755
new mode 100644
similarity index 64%
rename from cmds/media/src/com/android/commands/media/VolumeCtrl.java
rename to services/core/java/com/android/server/media/VolumeCtrl.java
index 1629c6f..7a26665
--- a/cmds/media/src/com/android/commands/media/VolumeCtrl.java
+++ b/services/core/java/com/android/server/media/VolumeCtrl.java
@@ -1,21 +1,20 @@
/*
-**
-** Copyright 2016, 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.
-*/
+ * Copyright (C) 2019 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 com.android.commands.media;
+package com.android.server.media;
import android.content.Context;
import android.media.AudioManager;
@@ -26,45 +25,41 @@
import com.android.internal.os.BaseCommand;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.lang.ArrayIndexOutOfBoundsException;
-
/**
* Command line tool to exercise AudioService.setStreamVolume()
* and AudioService.adjustStreamVolume()
*/
public class VolumeCtrl {
- private final static String TAG = "VolumeCtrl";
+ private static final String TAG = "VolumeCtrl";
// --stream affects --set, --adj or --get options.
// --show affects --set and --adj options.
// --get can be used with --set, --adj or by itself.
- public final static String USAGE = new String(
- "the options are as follows: \n" +
- "\t\t--stream STREAM selects the stream to control, see AudioManager.STREAM_*\n" +
- "\t\t controls AudioManager.STREAM_MUSIC if no stream is specified\n"+
- "\t\t--set INDEX sets the volume index value\n" +
- "\t\t--adj DIRECTION adjusts the volume, use raise|same|lower for the direction\n" +
- "\t\t--get outputs the current volume\n" +
- "\t\t--show shows the UI during the volume change\n" +
- "\texamples:\n" +
- "\t\tadb shell media volume --show --stream 3 --set 11\n" +
- "\t\tadb shell media volume --stream 0 --adj lower\n" +
- "\t\tadb shell media volume --stream 3 --get\n"
- );
+ public static final String USAGE = new String("the options are as follows: \n"
+ + "\t\t--stream STREAM selects the stream to control, see AudioManager.STREAM_*\n"
+ + "\t\t controls AudioManager.STREAM_MUSIC if no stream is specified\n"
+ + "\t\t--set INDEX sets the volume index value\n"
+ + "\t\t--adj DIRECTION adjusts the volume, use raise|same|lower for the direction\n"
+ + "\t\t--get outputs the current volume\n"
+ + "\t\t--show shows the UI during the volume change\n"
+ + "\texamples:\n"
+ + "\t\tadb shell media volume --show --stream 3 --set 11\n"
+ + "\t\tadb shell media volume --stream 0 --adj lower\n"
+ + "\t\tadb shell media volume --stream 3 --get\n"
+ );
- private final static int VOLUME_CONTROL_MODE_SET = 1;
- private final static int VOLUME_CONTROL_MODE_ADJUST = 2;
+ private static final int VOLUME_CONTROL_MODE_SET = 1;
+ private static final int VOLUME_CONTROL_MODE_ADJUST = 2;
- private final static String ADJUST_LOWER = "lower";
- private final static String ADJUST_SAME = "same";
- private final static String ADJUST_RAISE = "raise";
+ private static final String ADJUST_LOWER = "lower";
+ private static final String ADJUST_SAME = "same";
+ private static final String ADJUST_RAISE = "raise";
- public static void run(BaseCommand cmd) throws Exception {
+ /**
+ * Runs a given MediaShellCommand
+ */
+ public static void run(MediaShellCommand cmd) throws Exception {
//----------------------------------------
// Default parameters
int stream = AudioManager.STREAM_MUSIC;
@@ -78,7 +73,7 @@
// read options
String option;
String adjustment = null;
- while ((option = cmd.nextOption()) != null) {
+ while ((option = cmd.getNextOption()) != null) {
switch (option) {
case "--show":
showUi = true;
@@ -88,17 +83,17 @@
log(LOG_V, "will get volume");
break;
case "--stream":
- stream = Integer.decode(cmd.nextArgRequired()).intValue();
+ stream = Integer.decode(cmd.getNextArgRequired()).intValue();
log(LOG_V, "will control stream=" + stream + " (" + streamName(stream) + ")");
break;
case "--set":
- volIndex = Integer.decode(cmd.nextArgRequired()).intValue();
+ volIndex = Integer.decode(cmd.getNextArgRequired()).intValue();
mode = VOLUME_CONTROL_MODE_SET;
log(LOG_V, "will set volume to index=" + volIndex);
break;
case "--adj":
mode = VOLUME_CONTROL_MODE_ADJUST;
- adjustment = cmd.nextArgRequired();
+ adjustment = cmd.getNextArgRequired();
log(LOG_V, "will adjust volume");
break;
default:
@@ -140,7 +135,7 @@
if ((volIndex > audioService.getStreamMaxVolume(stream))
|| (volIndex < audioService.getStreamMinVolume(stream))) {
cmd.showError(String.format("Error: invalid volume index %d for stream %d "
- + "(should be in [%d..%d])", volIndex, stream,
+ + "(should be in [%d..%d])", volIndex, stream,
audioService.getStreamMinVolume(stream),
audioService.getStreamMaxVolume(stream)));
return;
@@ -149,7 +144,7 @@
//----------------------------------------
// Non-interactive test
- final int flag = showUi? AudioManager.FLAG_SHOW_UI : 0;
+ final int flag = showUi ? AudioManager.FLAG_SHOW_UI : 0;
final String pack = cmd.getClass().getPackage().getName();
if (mode == VOLUME_CONTROL_MODE_SET) {
audioService.setStreamVolume(stream, volIndex, flag, pack/*callingPackage*/);
@@ -157,9 +152,9 @@
audioService.adjustStreamVolume(stream, adjDir, flag, pack);
}
if (doGet) {
- log(LOG_V, "volume is " + audioService.getStreamVolume(stream) +
- " in range [" + audioService.getStreamMinVolume(stream) +
- ".." + audioService.getStreamMaxVolume(stream) + "]");
+ log(LOG_V, "volume is " + audioService.getStreamVolume(stream)
+ + " in range [" + audioService.getStreamMinVolume(stream)
+ + ".." + audioService.getStreamMaxVolume(stream) + "]");
}
}
@@ -181,5 +176,4 @@
return "invalid stream";
}
}
-
}
diff --git a/services/core/java/com/android/server/notification/NotificationComparator.java b/services/core/java/com/android/server/notification/NotificationComparator.java
index bc05154..a7e40cb 100644
--- a/services/core/java/com/android/server/notification/NotificationComparator.java
+++ b/services/core/java/com/android/server/notification/NotificationComparator.java
@@ -23,7 +23,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.provider.Settings;
import android.telecom.TelecomManager;
import com.android.internal.util.NotificationMessagingUtil;
@@ -55,14 +54,15 @@
final boolean isLeftHighImportance = leftImportance >= IMPORTANCE_DEFAULT;
final boolean isRightHighImportance = rightImportance >= IMPORTANCE_DEFAULT;
- // With new interruption model, prefer importance bucket above all other criteria
- // (to ensure buckets are contiguous)
- if (Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL, 1) == 1) {
- if (isLeftHighImportance != isRightHighImportance) {
- // by importance bucket, high importance higher than low importance
- return -1 * Boolean.compare(isLeftHighImportance, isRightHighImportance);
- }
+ if (isLeftHighImportance != isRightHighImportance) {
+ // by importance bucket, high importance higher than low importance
+ return -1 * Boolean.compare(isLeftHighImportance, isRightHighImportance);
+ }
+
+ // If a score has been assigned by notification assistant service, use this service
+ // rank results within each bucket instead of this comparator implementation.
+ if (left.getRankingScore() != right.getRankingScore()) {
+ return -1 * Float.compare(left.getRankingScore(), right.getRankingScore());
}
// first all colorized notifications
diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java
index b57bfa0..c8afcc9 100644
--- a/services/core/java/com/android/server/notification/NotificationRecord.java
+++ b/services/core/java/com/android/server/notification/NotificationRecord.java
@@ -144,6 +144,7 @@
private int mSystemImportance = IMPORTANCE_UNSPECIFIED;
private int mAssistantImportance = IMPORTANCE_UNSPECIFIED;
private int mImportance = IMPORTANCE_UNSPECIFIED;
+ private float mRankingScore = 0f;
// Field used in global sort key to bypass normal notifications
private int mCriticality = CriticalNotificationExtractor.NORMAL;
// A MetricsEvent.NotificationImportanceExplanation, tracking source of mImportance.
@@ -655,6 +656,9 @@
importance = Math.min(IMPORTANCE_HIGH, importance);
setAssistantImportance(importance);
}
+ if (signals.containsKey(Adjustment.KEY_RANKING_SCORE)) {
+ mRankingScore = signals.getFloat(Adjustment.KEY_RANKING_SCORE);
+ }
if (!signals.isEmpty() && adjustment.getIssuer() != null) {
mAdjustmentIssuer = adjustment.getIssuer();
}
@@ -772,6 +776,10 @@
return mImportance;
}
+ public float getRankingScore() {
+ return mRankingScore;
+ }
+
public CharSequence getImportanceExplanation() {
switch (mImportanceExplanationCode) {
case MetricsEvent.IMPORTANCE_EXPLANATION_UNKNOWN:
@@ -1289,6 +1297,18 @@
return getLogMaker().setCategory(MetricsEvent.NOTIFICATION_ITEM);
}
+ public boolean hasUndecoratedRemoteView() {
+ Notification notification = getNotification();
+ Class<? extends Notification.Style> style = notification.getNotificationStyle();
+ boolean hasDecoratedStyle = style != null
+ && (Notification.DecoratedCustomViewStyle.class.equals(style)
+ || Notification.DecoratedMediaCustomViewStyle.class.equals(style));
+ boolean hasCustomRemoteView = notification.contentView != null
+ || notification.bigContentView != null
+ || notification.headsUpContentView != null;
+ return hasCustomRemoteView && !hasDecoratedStyle;
+ }
+
@VisibleForTesting
static final class Light {
public final int color;
diff --git a/services/core/java/com/android/server/notification/NotificationUsageStats.java b/services/core/java/com/android/server/notification/NotificationUsageStats.java
index ac8d1a9..d1fe0d9 100644
--- a/services/core/java/com/android/server/notification/NotificationUsageStats.java
+++ b/services/core/java/com/android/server/notification/NotificationUsageStats.java
@@ -149,7 +149,7 @@
stats.numPostedByApp++;
stats.updateInterarrivalEstimate(now);
stats.countApiUse(notification);
- stats.numUndecoratedRemoteViews += (isUndecoratedRemoteView(notification) ? 1 : 0);
+ stats.numUndecoratedRemoteViews += (notification.hasUndecoratedRemoteView() ? 1 : 0);
}
releaseAggregatedStatsLocked(aggregatedStatsArray);
if (ENABLE_SQLITE_LOG) {
@@ -158,13 +158,6 @@
}
/**
- * Does this notification use RemoveViews without a platform decoration?
- */
- protected static boolean isUndecoratedRemoteView(NotificationRecord notification) {
- return (notification.getNotification().getNotificationStyle() == null);
- }
-
- /**
* Called when a notification has been updated.
*/
public synchronized void registerUpdatedByApp(NotificationRecord notification,
@@ -1303,7 +1296,7 @@
} else {
putPosttimeVisibility(r, cv);
}
- cv.put(COL_UNDECORATED, (isUndecoratedRemoteView(r) ? 1 : 0));
+ cv.put(COL_UNDECORATED, (r.hasUndecoratedRemoteView() ? 1 : 0));
SQLiteDatabase db = mHelper.getWritableDatabase();
if (db.insert(TAB_LOG, null, cv) < 0) {
Log.wtf(TAG, "Error while trying to insert values: " + cv);
diff --git a/services/core/java/com/android/server/om/OverlayActorEnforcer.java b/services/core/java/com/android/server/om/OverlayActorEnforcer.java
index e055116..ac3bf9a 100644
--- a/services/core/java/com/android/server/om/OverlayActorEnforcer.java
+++ b/services/core/java/com/android/server/om/OverlayActorEnforcer.java
@@ -26,6 +26,7 @@
import android.os.Process;
import android.os.RemoteException;
import android.text.TextUtils;
+import android.util.Pair;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.CollectionUtils;
@@ -44,6 +45,38 @@
private final VerifyCallback mVerifyCallback;
+ /**
+ * @return nullable actor result with {@link ActorState} failure status
+ */
+ static Pair<String, ActorState> getPackageNameForActor(String actorUriString,
+ Map<String, Map<String, String>> namedActors) {
+ if (namedActors.isEmpty()) {
+ return Pair.create(null, ActorState.NO_NAMED_ACTORS);
+ }
+
+ Uri actorUri = Uri.parse(actorUriString);
+
+ String actorScheme = actorUri.getScheme();
+ List<String> actorPathSegments = actorUri.getPathSegments();
+ if (!"overlay".equals(actorScheme) || CollectionUtils.size(actorPathSegments) != 1) {
+ return Pair.create(null, ActorState.INVALID_OVERLAYABLE_ACTOR_NAME);
+ }
+
+ String actorNamespace = actorUri.getAuthority();
+ Map<String, String> namespace = namedActors.get(actorNamespace);
+ if (namespace == null) {
+ return Pair.create(null, ActorState.MISSING_NAMESPACE);
+ }
+
+ String actorName = actorPathSegments.get(0);
+ String packageName = namespace.get(actorName);
+ if (TextUtils.isEmpty(packageName)) {
+ return Pair.create(null, ActorState.MISSING_ACTOR_NAME);
+ }
+
+ return Pair.create(packageName, ActorState.ALLOWED);
+ }
+
public OverlayActorEnforcer(@NonNull VerifyCallback verifyCallback) {
mVerifyCallback = verifyCallback;
}
@@ -141,31 +174,14 @@
}
}
- Map<String, ? extends Map<String, String>> namedActors = mVerifyCallback.getNamedActors();
- if (namedActors.isEmpty()) {
- return ActorState.NO_NAMED_ACTORS;
+ Map<String, Map<String, String>> namedActors = mVerifyCallback.getNamedActors();
+ Pair<String, ActorState> actorUriPair = getPackageNameForActor(actor, namedActors);
+ ActorState actorUriState = actorUriPair.second;
+ if (actorUriState != ActorState.ALLOWED) {
+ return actorUriState;
}
- Uri actorUri = Uri.parse(actor);
-
- String actorScheme = actorUri.getScheme();
- List<String> actorPathSegments = actorUri.getPathSegments();
- if (!"overlay".equals(actorScheme) || CollectionUtils.size(actorPathSegments) != 1) {
- return ActorState.INVALID_OVERLAYABLE_ACTOR_NAME;
- }
-
- String actorNamespace = actorUri.getAuthority();
- Map<String, String> namespace = namedActors.get(actorNamespace);
- if (namespace == null) {
- return ActorState.MISSING_NAMESPACE;
- }
-
- String actorName = actorPathSegments.get(0);
- String packageName = namespace.get(actorName);
- if (TextUtils.isEmpty(packageName)) {
- return ActorState.MISSING_ACTOR_NAME;
- }
-
+ String packageName = actorUriPair.first;
PackageInfo packageInfo = mVerifyCallback.getPackageInfo(packageName, userId);
if (packageInfo == null) {
return ActorState.MISSING_APP_INFO;
@@ -192,7 +208,7 @@
* For easier logging/debugging, a set of all possible failure/success states when running
* enforcement.
*/
- private enum ActorState {
+ enum ActorState {
ALLOWED,
INVALID_ACTOR,
MISSING_NAMESPACE,
@@ -244,7 +260,7 @@
* value maps actor name to package name
*/
@NonNull
- Map<String, ? extends Map<String, String>> getNamedActors();
+ Map<String, Map<String, String>> getNamedActors();
/**
* @return true if the target package has declared an overlayable
diff --git a/services/core/java/com/android/server/om/OverlayManagerService.java b/services/core/java/com/android/server/om/OverlayManagerService.java
index 8b69946..f1947ac 100644
--- a/services/core/java/com/android/server/om/OverlayManagerService.java
+++ b/services/core/java/com/android/server/om/OverlayManagerService.java
@@ -1073,8 +1073,6 @@
mPackageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
}
- // TODO(b/143096091): Remove PackageInfo cache so that PackageManager is always queried
- // to enforce visibility/other permission checks
public PackageInfo getPackageInfo(@NonNull final String packageName, final int userId,
final boolean useCache) {
if (useCache) {
@@ -1097,18 +1095,12 @@
@Override
public PackageInfo getPackageInfo(@NonNull final String packageName, final int userId) {
- // TODO(b/143096091): Remove clearing calling ID
- long callingIdentity = Binder.clearCallingIdentity();
- try {
- return getPackageInfo(packageName, userId, true);
- } finally {
- Binder.restoreCallingIdentity(callingIdentity);
- }
+ return getPackageInfo(packageName, userId, true);
}
@NonNull
@Override
- public Map<String, ? extends Map<String, String>> getNamedActors() {
+ public Map<String, Map<String, String>> getNamedActors() {
return SystemConfig.getInstance().getNamedActors();
}
@@ -1136,57 +1128,45 @@
public OverlayableInfo getOverlayableForTarget(@NonNull String packageName,
@Nullable String targetOverlayableName, int userId)
throws IOException {
- // TODO(b/143096091): Remove clearing calling ID
- long callingIdentity = Binder.clearCallingIdentity();
+ PackageInfo packageInfo = getPackageInfo(packageName, userId);
+ if (packageInfo == null) {
+ throw new IOException("Unable to get target package");
+ }
+
+ String baseCodePath = packageInfo.applicationInfo.getBaseCodePath();
+
+ ApkAssets apkAssets = null;
try {
- PackageInfo packageInfo = getPackageInfo(packageName, userId);
- if (packageInfo == null) {
- throw new IOException("Unable to get target package");
- }
-
- String baseCodePath = packageInfo.applicationInfo.getBaseCodePath();
-
- ApkAssets apkAssets = null;
- try {
- apkAssets = ApkAssets.loadFromPath(baseCodePath);
- return apkAssets.getOverlayableInfo(targetOverlayableName);
- } finally {
- if (apkAssets != null) {
- try {
- apkAssets.close();
- } catch (Throwable ignored) {
- }
+ apkAssets = ApkAssets.loadFromPath(baseCodePath);
+ return apkAssets.getOverlayableInfo(targetOverlayableName);
+ } finally {
+ if (apkAssets != null) {
+ try {
+ apkAssets.close();
+ } catch (Throwable ignored) {
}
}
- } finally {
- Binder.restoreCallingIdentity(callingIdentity);
}
}
@Override
public boolean doesTargetDefineOverlayable(String targetPackageName, int userId)
throws RemoteException, IOException {
- // TODO(b/143096091): Remove clearing calling ID
- long callingIdentity = Binder.clearCallingIdentity();
- try {
- PackageInfo packageInfo = mPackageManager.getPackageInfo(targetPackageName, 0,
- userId);
- String baseCodePath = packageInfo.applicationInfo.getBaseCodePath();
+ PackageInfo packageInfo = mPackageManager.getPackageInfo(targetPackageName, 0,
+ userId);
+ String baseCodePath = packageInfo.applicationInfo.getBaseCodePath();
- ApkAssets apkAssets = null;
- try {
- apkAssets = ApkAssets.loadFromPath(baseCodePath);
- return apkAssets.definesOverlayable();
- } finally {
- if (apkAssets != null) {
- try {
- apkAssets.close();
- } catch (Throwable ignored) {
- }
+ ApkAssets apkAssets = null;
+ try {
+ apkAssets = ApkAssets.loadFromPath(baseCodePath);
+ return apkAssets.definesOverlayable();
+ } finally {
+ if (apkAssets != null) {
+ try {
+ apkAssets.close();
+ } catch (Throwable ignored) {
}
}
- } finally {
- Binder.restoreCallingIdentity(callingIdentity);
}
}
@@ -1229,16 +1209,10 @@
@Nullable
@Override
public String[] getPackagesForUid(int uid) {
- // TODO(b/143096091): Remove clearing calling ID
- long callingIdentity = Binder.clearCallingIdentity();
try {
- try {
- return mPackageManager.getPackagesForUid(uid);
- } catch (RemoteException ignored) {
- return null;
- }
- } finally {
- Binder.restoreCallingIdentity(callingIdentity);
+ return mPackageManager.getPackagesForUid(uid);
+ } catch (RemoteException ignored) {
+ return null;
}
}
diff --git a/services/core/java/com/android/server/om/OverlayReferenceMapper.java b/services/core/java/com/android/server/om/OverlayReferenceMapper.java
new file mode 100644
index 0000000..8bea119
--- /dev/null
+++ b/services/core/java/com/android/server/om/OverlayReferenceMapper.java
@@ -0,0 +1,375 @@
+/*
+ * Copyright (C) 2019 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 com.android.server.om;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.content.pm.parsing.AndroidPackage;
+import android.text.TextUtils;
+import android.util.ArraySet;
+import android.util.Pair;
+
+import com.android.internal.annotations.GuardedBy;
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.util.CollectionUtils;
+import com.android.server.SystemConfig;
+import com.android.server.pm.PackageSetting;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Track visibility of a targets and overlays to actors.
+ *
+ * 4 cases to handle:
+ * <ol>
+ * <li>Target adds/changes an overlayable to add a reference to an actor
+ * <ul>
+ * <li>Must expose target to actor</li>
+ * <li>Must expose any overlays that pointed to that overlayable name to the actor</li>
+ * </ul>
+ * </li>
+ * <li>Target removes/changes an overlayable to remove a reference to an actor
+ * <ul>
+ * <li>If this target has no other overlayables referencing the actor, hide the
+ * target</li>
+ * <li>For all overlays targeting this overlayable, if the overlay is only visible to
+ * the actor through this overlayable, hide the overlay</li>
+ * </ul>
+ * </li>
+ * <li>Overlay adds/changes an overlay tag to add a reference to an overlayable name
+ * <ul>
+ * <li>Expose this overlay to the actor defined by the target overlayable</li>
+ * </ul>
+ * </li>
+ * <li>Overlay removes/changes an overlay tag to remove a reference to an overlayable name
+ * <ul>
+ * <li>If this overlay is only visible to an actor through this overlayable name's
+ * target's actor</li>
+ * </ul>
+ * </li>
+ * </ol>
+ *
+ * In this class, the names "actor", "target", and "overlay" all refer to the ID representations.
+ * All other use cases are named appropriate. "actor" is actor name, "target" is target package
+ * name, and "overlay" is overlay package name.
+ */
+public class OverlayReferenceMapper {
+
+ private final Object mLock = new Object();
+
+ /**
+ * Keys are actors, values are maps which map target to a set of overlays targeting it.
+ * The presence of a target in the value map means the actor and targets are connected, even
+ * if the corresponding target's set is empty.
+ * See class comment for specific types.
+ */
+ @GuardedBy("mLock")
+ private final Map<String, Map<String, Set<String>>> mActorToTargetToOverlays = new HashMap<>();
+
+ /**
+ * Keys are actor package names, values are generic package names the actor should be able
+ * to see.
+ */
+ @GuardedBy("mLock")
+ private final Map<String, Set<String>> mActorPkgToPkgs = new HashMap<>();
+
+ @GuardedBy("mLock")
+ private boolean mDeferRebuild;
+
+ @NonNull
+ private final Provider mProvider;
+
+ /**
+ * @param deferRebuild whether or not to defer rebuild calls on add/remove until first get call;
+ * useful during boot when multiple packages are added in rapid succession
+ * and queries in-between are not expected
+ */
+ public OverlayReferenceMapper(boolean deferRebuild, @Nullable Provider provider) {
+ this.mDeferRebuild = deferRebuild;
+ this.mProvider = provider != null ? provider : new Provider() {
+ @Nullable
+ @Override
+ public String getActorPkg(String actor) {
+ Map<String, Map<String, String>> namedActors = SystemConfig.getInstance()
+ .getNamedActors();
+
+ Pair<String, OverlayActorEnforcer.ActorState> actorPair =
+ OverlayActorEnforcer.getPackageNameForActor(actor, namedActors);
+ return actorPair.first;
+ }
+
+ @NonNull
+ @Override
+ public Map<String, Set<String>> getTargetToOverlayables(@NonNull AndroidPackage pkg) {
+ String target = pkg.getOverlayTarget();
+ if (TextUtils.isEmpty(target)) {
+ return Collections.emptyMap();
+ }
+
+ String overlayable = pkg.getOverlayTargetName();
+ Map<String, Set<String>> targetToOverlayables = new HashMap<>();
+ Set<String> overlayables = new HashSet<>();
+ overlayables.add(overlayable);
+ targetToOverlayables.put(target, overlayables);
+ return targetToOverlayables;
+ }
+ };
+ }
+
+ /**
+ * @return mapping of actor package to a set of packages it can view
+ */
+ @NonNull
+ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
+ public Map<String, Set<String>> getActorPkgToPkgs() {
+ return mActorPkgToPkgs;
+ }
+
+ public boolean isValidActor(@NonNull String targetName, @NonNull String actorPackageName) {
+ synchronized (mLock) {
+ assertMapBuilt();
+ Set<String> validSet = mActorPkgToPkgs.get(actorPackageName);
+ return validSet != null && validSet.contains(targetName);
+ }
+ }
+
+ /**
+ * Add a package to be considered for visibility. Currently supports adding as a target and/or
+ * an overlay. Adding an actor is not supported. Those are configured as part of
+ * {@link SystemConfig#getNamedActors()}.
+ *
+ * @param pkg the package to add
+ * @param otherPkgs map of other packages to consider, excluding {@param pkg}
+ */
+ public void addPkg(AndroidPackage pkg, Map<String, AndroidPackage> otherPkgs) {
+ synchronized (mLock) {
+ if (!pkg.getOverlayables().isEmpty()) {
+ addTarget(pkg, otherPkgs);
+ }
+
+ // TODO(b/135203078): Replace with isOverlay boolean flag check; fix test mocks
+ if (!mProvider.getTargetToOverlayables(pkg).isEmpty()) {
+ addOverlay(pkg, otherPkgs);
+ }
+
+ if (!mDeferRebuild) {
+ rebuild();
+ }
+ }
+ }
+
+ /**
+ * Removes a package to be considered for visibility. Currently supports removing as a target
+ * and/or an overlay. Removing an actor is not supported. Those are staticly configured as part
+ * of {@link SystemConfig#getNamedActors()}.
+ *
+ * @param pkgName name to remove, as was added through {@link #addPkg(AndroidPackage, Map)}
+ */
+ public void removePkg(String pkgName) {
+ synchronized (mLock) {
+ removeTarget(pkgName);
+ removeOverlay(pkgName);
+
+ if (!mDeferRebuild) {
+ rebuild();
+ }
+ }
+ }
+
+ private void removeTarget(String target) {
+ synchronized (mLock) {
+ Iterator<Map<String, Set<String>>> iterator =
+ mActorToTargetToOverlays.values().iterator();
+ while (iterator.hasNext()) {
+ Map<String, Set<String>> next = iterator.next();
+ next.remove(target);
+ if (next.isEmpty()) {
+ iterator.remove();
+ }
+ }
+ }
+ }
+
+ /**
+ * Associate an actor with an association of a new target to overlays for that target.
+ *
+ * If a target overlays itself, it will not be associated with itself, as only one half of the
+ * relationship needs to exist for visibility purposes.
+ */
+ private void addTarget(AndroidPackage targetPkg, Map<String, AndroidPackage> otherPkgs) {
+ synchronized (mLock) {
+ String target = targetPkg.getPackageName();
+ removeTarget(target);
+
+ Map<String, String> overlayablesToActors = targetPkg.getOverlayables();
+ for (String overlayable : overlayablesToActors.keySet()) {
+ String actor = overlayablesToActors.get(overlayable);
+ addTargetToMap(actor, target);
+
+ for (AndroidPackage overlayPkg : otherPkgs.values()) {
+ Map<String, Set<String>> targetToOverlayables =
+ mProvider.getTargetToOverlayables(overlayPkg);
+ Set<String> overlayables = targetToOverlayables.get(target);
+ if (CollectionUtils.isEmpty(overlayables)) {
+ continue;
+ }
+
+ if (overlayables.contains(overlayable)) {
+ addOverlayToMap(actor, target, overlayPkg.getPackageName());
+ }
+ }
+ }
+ }
+ }
+
+ private void removeOverlay(String overlay) {
+ synchronized (mLock) {
+ for (Map<String, Set<String>> targetToOverlays : mActorToTargetToOverlays.values()) {
+ for (Set<String> overlays : targetToOverlays.values()) {
+ overlays.remove(overlay);
+ }
+ }
+ }
+ }
+
+ /**
+ * Associate an actor with an association of targets to overlays for a new overlay.
+ *
+ * If an overlay targets itself, it will not be associated with itself, as only one half of the
+ * relationship needs to exist for visibility purposes.
+ */
+ private void addOverlay(AndroidPackage overlayPkg, Map<String, AndroidPackage> otherPkgs) {
+ synchronized (mLock) {
+ String overlay = overlayPkg.getPackageName();
+ removeOverlay(overlay);
+
+ Map<String, Set<String>> targetToOverlayables =
+ mProvider.getTargetToOverlayables(overlayPkg);
+ for (Map.Entry<String, Set<String>> entry : targetToOverlayables.entrySet()) {
+ String target = entry.getKey();
+ Set<String> overlayables = entry.getValue();
+ AndroidPackage targetPkg = otherPkgs.get(target);
+ if (targetPkg == null) {
+ continue;
+ }
+
+ String targetPkgName = targetPkg.getPackageName();
+ Map<String, String> overlayableToActor = targetPkg.getOverlayables();
+ for (String overlayable : overlayables) {
+ String actor = overlayableToActor.get(overlayable);
+ if (TextUtils.isEmpty(actor)) {
+ continue;
+ }
+ addOverlayToMap(actor, targetPkgName, overlay);
+ }
+ }
+ }
+ }
+
+ public void rebuildIfDeferred() {
+ synchronized (mLock) {
+ if (mDeferRebuild) {
+ rebuild();
+ mDeferRebuild = false;
+ }
+ }
+ }
+
+ private void assertMapBuilt() {
+ if (mDeferRebuild) {
+ throw new IllegalStateException("The actor map must be built by calling "
+ + "rebuildIfDeferred before it is queried");
+ }
+ }
+
+ private void rebuild() {
+ synchronized (mLock) {
+ mActorPkgToPkgs.clear();
+ for (String actor : mActorToTargetToOverlays.keySet()) {
+ String actorPkg = mProvider.getActorPkg(actor);
+ if (TextUtils.isEmpty(actorPkg)) {
+ continue;
+ }
+
+ Map<String, Set<String>> targetToOverlays = mActorToTargetToOverlays.get(actor);
+ Set<String> pkgs = new HashSet<>();
+
+ for (String target : targetToOverlays.keySet()) {
+ Set<String> overlays = targetToOverlays.get(target);
+ pkgs.add(target);
+ pkgs.addAll(overlays);
+ }
+
+ mActorPkgToPkgs.put(actorPkg, pkgs);
+ }
+ }
+ }
+
+ private void addTargetToMap(String actor, String target) {
+ Map<String, Set<String>> targetToOverlays = mActorToTargetToOverlays.get(actor);
+ if (targetToOverlays == null) {
+ targetToOverlays = new HashMap<>();
+ mActorToTargetToOverlays.put(actor, targetToOverlays);
+ }
+
+ Set<String> overlays = targetToOverlays.get(target);
+ if (overlays == null) {
+ overlays = new HashSet<>();
+ targetToOverlays.put(target, overlays);
+ }
+ }
+
+ private void addOverlayToMap(String actor, String target, String overlay) {
+ synchronized (mLock) {
+ Map<String, Set<String>> targetToOverlays = mActorToTargetToOverlays.get(actor);
+ if (targetToOverlays == null) {
+ targetToOverlays = new HashMap<>();
+ mActorToTargetToOverlays.put(actor, targetToOverlays);
+ }
+
+ Set<String> overlays = targetToOverlays.get(target);
+ if (overlays == null) {
+ overlays = new HashSet<>();
+ targetToOverlays.put(target, overlays);
+ }
+
+ overlays.add(overlay);
+ }
+ }
+
+ public interface Provider {
+
+ /**
+ * Given the actor string from an overlayable definition, return the actor's package name.
+ */
+ @Nullable
+ String getActorPkg(String actor);
+
+ /**
+ * Mock response of multiple overlay tags.
+ *
+ * TODO(b/119899133): Replace with actual implementation; fix OverlayReferenceMapperTests
+ */
+ @NonNull
+ Map<String, Set<String>> getTargetToOverlayables(@NonNull AndroidPackage pkg);
+ }
+}
diff --git a/services/core/java/com/android/server/pm/ApexManager.java b/services/core/java/com/android/server/pm/ApexManager.java
index 2b4b409..5ae8c58 100644
--- a/services/core/java/com/android/server/pm/ApexManager.java
+++ b/services/core/java/com/android/server/pm/ApexManager.java
@@ -17,11 +17,11 @@
package com.android.server.pm;
import android.annotation.IntDef;
-import android.annotation.NonNull;
import android.annotation.Nullable;
import android.apex.ApexInfo;
import android.apex.ApexInfoList;
import android.apex.ApexSessionInfo;
+import android.apex.ApexSessionParams;
import android.apex.IApexService;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -176,13 +176,9 @@
* enough for it to be activated at the next boot, the caller needs to call
* {@link #markStagedSessionReady(int)}.
*
- * @param sessionId the identifier of the {@link PackageInstallerSession} being submitted.
- * @param childSessionIds if {@code sessionId} is a multi-package session, this should contain
- * an array of identifiers of all the child sessions. Otherwise it should
- * be an empty array.
* @throws PackageManagerException if call to apexd fails
*/
- abstract ApexInfoList submitStagedSession(int sessionId, @NonNull int[] childSessionIds)
+ abstract ApexInfoList submitStagedSession(ApexSessionParams params)
throws PackageManagerException;
/**
@@ -450,11 +446,10 @@
}
@Override
- ApexInfoList submitStagedSession(int sessionId, @NonNull int[] childSessionIds)
- throws PackageManagerException {
+ ApexInfoList submitStagedSession(ApexSessionParams params) throws PackageManagerException {
try {
final ApexInfoList apexInfoList = new ApexInfoList();
- mApexService.submitStagedSession(sessionId, childSessionIds, apexInfoList);
+ mApexService.submitStagedSession(params, apexInfoList);
return apexInfoList;
} catch (RemoteException re) {
Slog.e(TAG, "Unable to contact apexservice", re);
@@ -686,7 +681,7 @@
}
@Override
- ApexInfoList submitStagedSession(int sessionId, int[] childSessionIds)
+ ApexInfoList submitStagedSession(ApexSessionParams params)
throws PackageManagerException {
throw new PackageManagerException(PackageManager.INSTALL_FAILED_INTERNAL_ERROR,
"Device doesn't support updating APEX");
diff --git a/services/core/java/com/android/server/pm/AppsFilter.java b/services/core/java/com/android/server/pm/AppsFilter.java
index 8374ee6..c4bcf80 100644
--- a/services/core/java/com/android/server/pm/AppsFilter.java
+++ b/services/core/java/com/android/server/pm/AppsFilter.java
@@ -16,8 +16,6 @@
package com.android.server.pm;
-import static android.content.pm.PackageParser.Component;
-import static android.content.pm.PackageParser.IntentInfo;
import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER;
import static android.provider.DeviceConfig.NAMESPACE_PACKAGE_MANAGER_SERVICE;
@@ -26,7 +24,6 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
-import android.content.pm.PackageParser;
import android.content.pm.parsing.AndroidPackage;
import android.content.pm.parsing.ComponentParseUtils;
import android.content.pm.parsing.ComponentParseUtils.ParsedActivity;
@@ -50,9 +47,9 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
import com.android.server.FgThread;
+import com.android.server.om.OverlayReferenceMapper;
import java.io.PrintWriter;
-import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
@@ -109,11 +106,16 @@
private final FeatureConfig mFeatureConfig;
+ private final OverlayReferenceMapper mOverlayReferenceMapper;
+
AppsFilter(FeatureConfig featureConfig, String[] forceQueryableWhitelist,
- boolean systemAppsQueryable) {
+ boolean systemAppsQueryable,
+ @Nullable OverlayReferenceMapper.Provider overlayProvider) {
mFeatureConfig = featureConfig;
mForceQueryableByDevicePackageNames = forceQueryableWhitelist;
mSystemAppsQueryable = systemAppsQueryable;
+ mOverlayReferenceMapper = new OverlayReferenceMapper(true /*deferRebuild*/,
+ overlayProvider);
}
public interface FeatureConfig {
@@ -193,7 +195,7 @@
}
}
return new AppsFilter(featureConfig, forcedQueryablePackageNames,
- forceSystemAppsQueryable);
+ forceSystemAppsQueryable, null);
}
/** Returns true if the querying package may query for the potential target package */
@@ -282,6 +284,7 @@
public void onSystemReady() {
mFeatureConfig.onSystemReady();
+ mOverlayReferenceMapper.rebuildIfDeferred();
}
/**
@@ -338,6 +341,16 @@
}
}
}
+
+ int existingSize = existingSettings.size();
+ ArrayMap<String, AndroidPackage> existingPkgs = new ArrayMap<>(existingSize);
+ for (int index = 0; index < existingSize; index++) {
+ PackageSetting pkgSetting = existingSettings.valueAt(index);
+ if (pkgSetting.pkg != null) {
+ existingPkgs.put(pkgSetting.name, pkgSetting.pkg);
+ }
+ }
+ mOverlayReferenceMapper.addPkg(newPkgSetting.pkg, existingPkgs);
} finally {
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
}
@@ -381,6 +394,8 @@
addPackage(setting.sharedUser.packages.valueAt(i), existingSettings);
}
}
+
+ mOverlayReferenceMapper.removePkg(setting.name);
}
/**
@@ -397,8 +412,7 @@
PackageSetting targetPkgSetting, int userId) {
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "shouldFilterApplication");
try {
- if (!shouldFilterApplicationInternal(callingUid, callingSetting,
- targetPkgSetting,
+ if (!shouldFilterApplicationInternal(callingUid, callingSetting, targetPkgSetting,
userId)) {
return false;
}
@@ -412,8 +426,8 @@
}
}
- private boolean shouldFilterApplicationInternal(int callingUid,
- SettingBase callingSetting, PackageSetting targetPkgSetting, int userId) {
+ private boolean shouldFilterApplicationInternal(int callingUid, SettingBase callingSetting,
+ PackageSetting targetPkgSetting, int userId) {
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "shouldFilterApplicationInternal");
try {
final boolean featureEnabled = mFeatureConfig.isGloballyEnabled();
@@ -530,6 +544,29 @@
}
}
}
+
+ if (callingSharedPkgSettings != null) {
+ int size = callingSharedPkgSettings.size();
+ for (int index = 0; index < size; index++) {
+ PackageSetting pkgSetting = callingSharedPkgSettings.valueAt(index);
+ if (mOverlayReferenceMapper.isValidActor(targetName, pkgSetting.name)) {
+ if (DEBUG_LOGGING) {
+ log(callingPkgSetting, targetPkgSetting,
+ "matches shared user of package that acts on target of "
+ + "overlay");
+ }
+ return false;
+ }
+ }
+ } else {
+ if (mOverlayReferenceMapper.isValidActor(targetName, callingPkgSetting.name)) {
+ if (DEBUG_LOGGING) {
+ log(callingPkgSetting, targetPkgSetting, "acts on target of overlay");
+ }
+ return false;
+ }
+ }
+
return true;
} finally {
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
diff --git a/services/core/java/com/android/server/pm/ComponentResolver.java b/services/core/java/com/android/server/pm/ComponentResolver.java
index f2a2e65..13bd7e5 100644
--- a/services/core/java/com/android/server/pm/ComponentResolver.java
+++ b/services/core/java/com/android/server/pm/ComponentResolver.java
@@ -627,11 +627,13 @@
final int providersSize = ArrayUtils.size(pkg.getProviders());
StringBuilder r = null;
for (int i = 0; i < providersSize; i++) {
- EffectiveProvider p = new EffectiveProvider(pkg.getProviders().get(i));
+ ParsedProvider p = pkg.getProviders().get(i);
mProviders.addProvider(p);
if (p.getAuthority() != null) {
String[] names = p.getAuthority().split(";");
- p.setEffectiveAuthority(null);
+
+ // TODO(b/135203078): Remove this mutation
+ p.setAuthority(null);
for (int j = 0; j < names.length; j++) {
if (j == 1 && p.isSyncable()) {
// We only want the first authority for a provider to possibly be
@@ -641,15 +643,15 @@
// to a provider that we don't want to change.
// Only do this for the second authority since the resulting provider
// object can be the same for all future authorities for this provider.
- p = new EffectiveProvider(p);
- p.setEffectiveSyncable(false);
+ p = new ParsedProvider(p);
+ p.setSyncable(false);
}
if (!mProvidersByAuthority.containsKey(names[j])) {
mProvidersByAuthority.put(names[j], p);
if (p.getAuthority() == null) {
- p.setEffectiveAuthority(names[j]);
+ p.setAuthority(names[j]);
} else {
- p.setEffectiveAuthority(p.getAuthority() + ";" + names[j]);
+ p.setAuthority(p.getAuthority() + ";" + names[j]);
}
if (DEBUG_PACKAGE_SCANNING && chatty) {
Log.d(TAG, "Registered content provider: " + names[j]
@@ -2113,35 +2115,4 @@
return info.authoritiesIterator();
}
}
-
- // TODO(b/135203078): Document or remove this if possible.
- class EffectiveProvider extends ParsedProvider {
-
- private String mEffectiveAuthority;
- private boolean mEffectiveSyncable;
-
- public EffectiveProvider(ParsedProvider parsedProvider) {
- this.setFrom(parsedProvider);
- this.mEffectiveAuthority = parsedProvider.getAuthority();
- this.mEffectiveSyncable = parsedProvider.isSyncable();
- }
-
- public void setEffectiveAuthority(String authority) {
- this.mEffectiveAuthority = authority;
- }
-
- public void setEffectiveSyncable(boolean syncable) {
- this.mEffectiveSyncable = syncable;
- }
-
- @Override
- public String getAuthority() {
- return mEffectiveAuthority;
- }
-
- @Override
- public boolean isSyncable() {
- return mEffectiveSyncable;
- }
- }
}
diff --git a/services/core/java/com/android/server/pm/InstantAppResolver.java b/services/core/java/com/android/server/pm/InstantAppResolver.java
index 30b2c9d..8333ae5 100644
--- a/services/core/java/com/android/server/pm/InstantAppResolver.java
+++ b/services/core/java/com/android/server/pm/InstantAppResolver.java
@@ -39,6 +39,7 @@
import android.content.pm.AuxiliaryResolveInfo;
import android.content.pm.InstantAppIntentFilter;
import android.content.pm.InstantAppRequest;
+import android.content.pm.InstantAppRequestInfo;
import android.content.pm.InstantAppResolveInfo;
import android.content.pm.InstantAppResolveInfo.InstantAppDigest;
import android.metrics.LogMaker;
@@ -47,6 +48,8 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
+import android.os.UserHandle;
+import android.text.TextUtils;
import android.util.Log;
import android.util.Slog;
@@ -63,7 +66,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import java.util.UUID;
/** @hide */
public abstract class InstantAppResolver {
@@ -117,26 +119,40 @@
return sanitizedIntent;
}
+ /**
+ * Generate an {@link InstantAppDigest} from an {@link Intent} which contains hashes of the
+ * host. The object contains both secure and insecure hash array variants, and the secure
+ * version must be passed along to ensure the random data is consistent.
+ */
+ @NonNull
+ public static InstantAppDigest parseDigest(@NonNull Intent origIntent) {
+ if (origIntent.getData() != null && !TextUtils.isEmpty(origIntent.getData().getHost())) {
+ return new InstantAppResolveInfo.InstantAppDigest(origIntent.getData().getHost(),
+ 5 /*maxDigests*/);
+ } else {
+ return InstantAppResolveInfo.InstantAppDigest.UNDEFINED;
+ }
+ }
+
public static AuxiliaryResolveInfo doInstantAppResolutionPhaseOne(
InstantAppResolverConnection connection, InstantAppRequest requestObj) {
final long startTime = System.currentTimeMillis();
- final String token = UUID.randomUUID().toString();
+ final String token = requestObj.token;
if (DEBUG_INSTANT) {
Log.d(TAG, "[" + token + "] Phase1; resolving");
}
- final Intent origIntent = requestObj.origIntent;
- final Intent sanitizedIntent = sanitizeIntent(origIntent);
AuxiliaryResolveInfo resolveInfo = null;
@ResolutionStatus int resolutionStatus = RESOLUTION_SUCCESS;
+ Intent origIntent = requestObj.origIntent;
try {
final List<InstantAppResolveInfo> instantAppResolveInfoList =
- connection.getInstantAppResolveInfoList(sanitizedIntent,
- requestObj.digest.getDigestPrefixSecure(), requestObj.userId, token);
+ connection.getInstantAppResolveInfoList(buildRequestInfo(requestObj));
if (instantAppResolveInfoList != null && instantAppResolveInfoList.size() > 0) {
resolveInfo = InstantAppResolver.filterInstantAppIntent(
instantAppResolveInfoList, origIntent, requestObj.resolvedType,
- requestObj.userId, origIntent.getPackage(), requestObj.digest, token);
+ requestObj.userId, origIntent.getPackage(), token,
+ requestObj.hostDigestPrefixSecure);
}
} catch (ConnectionException e) {
if (e.failure == ConnectionException.FAILURE_BIND) {
@@ -166,7 +182,7 @@
// if the match external flag is set, return an empty resolve info instead of a null result.
if (resolveInfo == null && (origIntent.getFlags() & FLAG_ACTIVITY_MATCH_EXTERNAL) != 0) {
return new AuxiliaryResolveInfo(token, false, createFailureIntent(origIntent, token),
- null /* filters */);
+ null /* filters */, requestObj.hostDigestPrefixSecure);
}
return resolveInfo;
}
@@ -175,7 +191,7 @@
InstantAppResolverConnection connection, InstantAppRequest requestObj,
ActivityInfo instantAppInstaller, Handler callbackHandler) {
final long startTime = System.currentTimeMillis();
- final String token = requestObj.responseObj.token;
+ final String token = requestObj.token;
if (DEBUG_INSTANT) {
Log.d(TAG, "[" + token + "] Phase2; resolving");
}
@@ -191,8 +207,8 @@
final AuxiliaryResolveInfo instantAppIntentInfo =
InstantAppResolver.filterInstantAppIntent(
instantAppResolveInfoList, origIntent, null /*resolvedType*/,
- 0 /*userId*/, origIntent.getPackage(), requestObj.digest,
- token);
+ 0 /*userId*/, origIntent.getPackage(),
+ token, requestObj.hostDigestPrefixSecure);
if (instantAppIntentInfo != null) {
failureIntent = instantAppIntentInfo.failureIntent;
} else {
@@ -223,8 +239,7 @@
}
};
try {
- connection.getInstantAppIntentFilterList(sanitizedIntent,
- requestObj.digest.getDigestPrefixSecure(), requestObj.userId, token, callback,
+ connection.getInstantAppIntentFilterList(buildRequestInfo(requestObj), callback,
callbackHandler, startTime);
} catch (ConnectionException e) {
@ResolutionStatus int resolutionStatus = RESOLUTION_FAILURE;
@@ -356,10 +371,22 @@
return intent;
}
+ private static InstantAppRequestInfo buildRequestInfo(InstantAppRequest request) {
+ return new InstantAppRequestInfo(
+ sanitizeIntent(request.origIntent),
+ // This must only expose the secured version of the host
+ request.hostDigestPrefixSecure,
+ UserHandle.getUserHandleForUid(request.userId),
+ request.isRequesterInstantApp,
+ request.token
+ );
+ }
+
private static AuxiliaryResolveInfo filterInstantAppIntent(
- List<InstantAppResolveInfo> instantAppResolveInfoList,
- Intent origIntent, String resolvedType, int userId, String packageName,
- InstantAppDigest digest, String token) {
+ List<InstantAppResolveInfo> instantAppResolveInfoList, Intent origIntent,
+ String resolvedType, int userId, String packageName, String token,
+ int[] hostDigestPrefixSecure) {
+ InstantAppDigest digest = InstantAppResolver.parseDigest(origIntent);
final int[] shaPrefix = digest.getDigestPrefix();
final byte[][] digestBytes = digest.getDigestBytes();
boolean requiresSecondPhase = false;
@@ -404,7 +431,7 @@
}
if (filters != null && !filters.isEmpty()) {
return new AuxiliaryResolveInfo(token, requiresSecondPhase,
- createFailureIntent(origIntent, token), filters);
+ createFailureIntent(origIntent, token), filters, hostDigestPrefixSecure);
}
// Hash or filter mis-match; no instant apps for this domain.
return null;
diff --git a/services/core/java/com/android/server/pm/InstantAppResolverConnection.java b/services/core/java/com/android/server/pm/InstantAppResolverConnection.java
index c0e9f58..0fe2eb1 100644
--- a/services/core/java/com/android/server/pm/InstantAppResolverConnection.java
+++ b/services/core/java/com/android/server/pm/InstantAppResolverConnection.java
@@ -24,6 +24,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.content.pm.InstantAppRequestInfo;
import android.content.pm.InstantAppResolveInfo;
import android.os.Binder;
import android.os.Build;
@@ -85,13 +86,13 @@
mBgHandler = BackgroundThread.getHandler();
}
- public List<InstantAppResolveInfo> getInstantAppResolveInfoList(Intent sanitizedIntent,
- int[] hashPrefix, int userId, String token) throws ConnectionException {
+ public List<InstantAppResolveInfo> getInstantAppResolveInfoList(InstantAppRequestInfo request)
+ throws ConnectionException {
throwIfCalledOnMainThread();
IInstantAppResolver target = null;
try {
try {
- target = getRemoteInstanceLazy(token);
+ target = getRemoteInstanceLazy(request.token);
} catch (TimeoutException e) {
throw new ConnectionException(ConnectionException.FAILURE_BIND);
} catch (InterruptedException e) {
@@ -99,8 +100,7 @@
}
try {
return mGetInstantAppResolveInfoCaller
- .getInstantAppResolveInfoList(target, sanitizedIntent, hashPrefix, userId,
- token);
+ .getInstantAppResolveInfoList(target, request);
} catch (TimeoutException e) {
throw new ConnectionException(ConnectionException.FAILURE_CALL);
} catch (RemoteException ignore) {
@@ -113,8 +113,8 @@
return null;
}
- public void getInstantAppIntentFilterList(Intent sanitizedIntent, int[] hashPrefix, int userId,
- String token, PhaseTwoCallback callback, Handler callbackHandler, final long startTime)
+ public void getInstantAppIntentFilterList(InstantAppRequestInfo request,
+ PhaseTwoCallback callback, Handler callbackHandler, final long startTime)
throws ConnectionException {
final IRemoteCallback remoteCallback = new IRemoteCallback.Stub() {
@Override
@@ -126,9 +126,8 @@
}
};
try {
- getRemoteInstanceLazy(token)
- .getInstantAppIntentFilterList(sanitizedIntent, hashPrefix, userId, token,
- remoteCallback);
+ getRemoteInstanceLazy(request.token)
+ .getInstantAppIntentFilterList(request, remoteCallback);
} catch (TimeoutException e) {
throw new ConnectionException(ConnectionException.FAILURE_BIND);
} catch (InterruptedException e) {
@@ -352,12 +351,10 @@
};
}
- public List<InstantAppResolveInfo> getInstantAppResolveInfoList(
- IInstantAppResolver target, Intent sanitizedIntent, int[] hashPrefix, int userId,
- String token) throws RemoteException, TimeoutException {
+ public List<InstantAppResolveInfo> getInstantAppResolveInfoList(IInstantAppResolver target,
+ InstantAppRequestInfo request) throws RemoteException, TimeoutException {
final int sequence = onBeforeRemoteCall();
- target.getInstantAppResolveInfoList(sanitizedIntent, hashPrefix, userId, token,
- sequence, mCallback);
+ target.getInstantAppResolveInfoList(request, sequence, mCallback);
return getResultTimed(sequence);
}
}
diff --git a/services/core/java/com/android/server/pm/PackageInstallerService.java b/services/core/java/com/android/server/pm/PackageInstallerService.java
index dceca0a..a54534b 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerService.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerService.java
@@ -637,7 +637,7 @@
session = new PackageInstallerSession(mInternalCallback, mContext, mPm, this,
mInstallThread.getLooper(), mStagingManager, sessionId, userId, callingUid,
installSource, params, createdMillis,
- stageDir, stageCid, false, false, false, null, SessionInfo.INVALID_ID,
+ stageDir, stageCid, null, false, false, false, null, SessionInfo.INVALID_ID,
false, false, false, SessionInfo.STAGED_SESSION_NO_ERROR, "");
synchronized (mSessions) {
@@ -1014,12 +1014,28 @@
}
}
+ static void sendPendingStreaming(Context context, IntentSender target, int sessionId,
+ Throwable cause) {
+ final Intent intent = new Intent();
+ intent.putExtra(PackageInstaller.EXTRA_SESSION_ID, sessionId);
+ intent.putExtra(PackageInstaller.EXTRA_STATUS, PackageInstaller.STATUS_PENDING_STREAMING);
+ if (cause != null && !TextUtils.isEmpty(cause.getMessage())) {
+ intent.putExtra(PackageInstaller.EXTRA_STATUS_MESSAGE,
+ "Staging Image Not Ready [" + cause.getMessage() + "]");
+ } else {
+ intent.putExtra(PackageInstaller.EXTRA_STATUS_MESSAGE, "Staging Image Not Ready");
+ }
+ try {
+ target.sendIntent(context, 0, intent, null, null);
+ } catch (SendIntentException ignored) {
+ }
+ }
+
static void sendOnUserActionRequired(Context context, IntentSender target, int sessionId,
Intent intent) {
final Intent fillIn = new Intent();
fillIn.putExtra(PackageInstaller.EXTRA_SESSION_ID, sessionId);
- fillIn.putExtra(PackageInstaller.EXTRA_STATUS,
- PackageInstaller.STATUS_PENDING_USER_ACTION);
+ fillIn.putExtra(PackageInstaller.EXTRA_STATUS, PackageInstaller.STATUS_PENDING_USER_ACTION);
fillIn.putExtra(Intent.EXTRA_INTENT, intent);
try {
target.sendIntent(context, 0, fillIn, null, null);
diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java
index 518ec50..286d291 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerSession.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java
@@ -21,6 +21,7 @@
import static android.content.pm.PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
import static android.content.pm.PackageManager.INSTALL_FAILED_INTERNAL_ERROR;
import static android.content.pm.PackageManager.INSTALL_FAILED_INVALID_APK;
+import static android.content.pm.PackageManager.INSTALL_FAILED_MEDIA_UNAVAILABLE;
import static android.content.pm.PackageManager.INSTALL_FAILED_MISSING_SPLIT;
import static android.content.pm.PackageParser.APEX_FILE_EXTENSION;
import static android.content.pm.PackageParser.APK_FILE_EXTENSION;
@@ -30,11 +31,13 @@
import static com.android.internal.util.XmlUtils.readBitmapAttribute;
import static com.android.internal.util.XmlUtils.readBooleanAttribute;
+import static com.android.internal.util.XmlUtils.readByteArrayAttribute;
import static com.android.internal.util.XmlUtils.readIntAttribute;
import static com.android.internal.util.XmlUtils.readLongAttribute;
import static com.android.internal.util.XmlUtils.readStringAttribute;
import static com.android.internal.util.XmlUtils.readUriAttribute;
import static com.android.internal.util.XmlUtils.writeBooleanAttribute;
+import static com.android.internal.util.XmlUtils.writeByteArrayAttribute;
import static com.android.internal.util.XmlUtils.writeIntAttribute;
import static com.android.internal.util.XmlUtils.writeLongAttribute;
import static com.android.internal.util.XmlUtils.writeStringAttribute;
@@ -123,6 +126,7 @@
import java.io.FileFilter;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
@@ -142,6 +146,7 @@
/** XML constants used for persisting a session */
static final String TAG_SESSION = "session";
static final String TAG_CHILD_SESSION = "childSession";
+ static final String TAG_SESSION_FILE = "sessionFile";
private static final String TAG_GRANTED_RUNTIME_PERMISSION = "granted-runtime-permission";
private static final String TAG_WHITELISTED_RESTRICTED_PERMISSION =
"whitelisted-restricted-permission";
@@ -183,6 +188,9 @@
private static final String ATTR_VOLUME_UUID = "volumeUuid";
private static final String ATTR_NAME = "name";
private static final String ATTR_INSTALL_REASON = "installRason";
+ private static final String ATTR_DATA_LOADER_PACKAGE_NAME = "dataLoaderPackageName";
+ private static final String ATTR_LENGTH_BYTES = "lengthBytes";
+ private static final String ATTR_METADATA = "metadata";
private static final String PROPERTY_NAME_INHERIT_NATIVE = "pi.inherit_native_on_dont_kill";
private static final int[] EMPTY_CHILD_SESSION_ARRAY = {};
@@ -278,6 +286,29 @@
@GuardedBy("mLock")
private int mParentSessionId;
+ static class FileInfo {
+ public final String name;
+ public final Long lengthBytes;
+ public final byte[] metadata;
+
+ public static FileInfo added(String name, Long lengthBytes, byte[] metadata) {
+ return new FileInfo(name, lengthBytes, metadata);
+ }
+
+ public static FileInfo removed(String name) {
+ return new FileInfo(name, -1L, null);
+ }
+
+ FileInfo(String name, Long lengthBytes, byte[] metadata) {
+ this.name = name;
+ this.lengthBytes = lengthBytes;
+ this.metadata = metadata;
+ }
+ }
+
+ @GuardedBy("mLock")
+ private ArrayList<FileInfo> mFiles = new ArrayList<>();
+
@GuardedBy("mLock")
private boolean mStagedSessionApplied;
@GuardedBy("mLock")
@@ -313,6 +344,7 @@
@GuardedBy("mLock")
private boolean mVerityFound;
+ // TODO(b/146080380): merge file list with Callback installation.
private IncrementalFileStorages mIncrementalFileStorages;
private static final FileFilter sAddedFilter = new FileFilter() {
@@ -344,7 +376,9 @@
IntentSender statusReceiver;
switch (msg.what) {
case MSG_SEAL:
- handleSeal((IntentSender) msg.obj);
+ statusReceiver = (IntentSender) msg.obj;
+
+ handleSeal(statusReceiver);
break;
case MSG_COMMIT:
handleCommit();
@@ -378,6 +412,10 @@
}
};
+ private boolean isDataLoaderInstallation() {
+ return !TextUtils.isEmpty(params.dataLoaderPackageName);
+ }
+
/**
* @return {@code true} iff the installing is app an device owner or affiliated profile owner.
*/
@@ -435,7 +473,8 @@
PackageSessionProvider sessionProvider, Looper looper, StagingManager stagingManager,
int sessionId, int userId, int installerUid, @NonNull InstallSource installSource,
SessionParams params, long createdMillis,
- File stageDir, String stageCid, boolean prepared, boolean committed, boolean sealed,
+ File stageDir, String stageCid, FileInfo[] files, boolean prepared,
+ boolean committed, boolean sealed,
@Nullable int[] childSessionIds, int parentSessionId, boolean isReady,
boolean isFailed, boolean isApplied, int stagedSessionErrorCode,
String stagedSessionErrorMessage) {
@@ -464,6 +503,12 @@
}
this.mParentSessionId = parentSessionId;
+ if (files != null) {
+ for (FileInfo file : files) {
+ mFiles.add(file);
+ }
+ }
+
if (!params.isMultiPackage && (stageDir == null) == (stageCid == null)) {
throw new IllegalArgumentException(
"Exactly one of stageDir or stageCid stage must be set");
@@ -592,15 +637,19 @@
}
}
+ @GuardedBy("mLock")
+ private void setClientProgressLocked(float progress) {
+ // Always publish first staging movement
+ final boolean forcePublish = (mClientProgress == 0);
+ mClientProgress = progress;
+ computeProgressLocked(forcePublish);
+ }
+
@Override
public void setClientProgress(float progress) {
synchronized (mLock) {
assertCallerIsOwnerOrRootLocked();
-
- // Always publish first staging movement
- final boolean forcePublish = (mClientProgress == 0);
- mClientProgress = progress;
- computeProgressLocked(forcePublish);
+ setClientProgressLocked(progress);
}
}
@@ -608,8 +657,7 @@
public void addClientProgress(float progress) {
synchronized (mLock) {
assertCallerIsOwnerOrRootLocked();
-
- setClientProgress(mClientProgress + progress);
+ setClientProgressLocked(mClientProgress + progress);
}
}
@@ -637,7 +685,10 @@
@GuardedBy("mLock")
private String[] getNamesLocked() {
- return stageDir.list();
+ if (!isDataLoaderInstallation()) {
+ return stageDir.list();
+ }
+ return mFiles.stream().map(fileInfo -> fileInfo.name).toArray(String[]::new);
}
private static File[] filterFiles(File parent, String[] names, FileFilter filter) {
@@ -659,6 +710,10 @@
@Override
public void removeSplit(String splitName) {
+ if (isDataLoaderInstallation()) {
+ throw new IllegalStateException(
+ "Cannot remove splits in a callback installation session.");
+ }
if (TextUtils.isEmpty(params.appPackageName)) {
throw new IllegalStateException("Must specify package name to remove a split");
}
@@ -693,8 +748,31 @@
}
}
+ private void assertCanWrite(boolean reverseMode) {
+ if (isDataLoaderInstallation()) {
+ throw new IllegalStateException(
+ "Cannot write regular files in a callback installation session.");
+ }
+ synchronized (mLock) {
+ assertCallerIsOwnerOrRootLocked();
+ assertPreparedAndNotSealedLocked("assertCanWrite");
+ }
+ if (reverseMode) {
+ switch (Binder.getCallingUid()) {
+ case android.os.Process.SHELL_UID:
+ case android.os.Process.ROOT_UID:
+ case android.os.Process.SYSTEM_UID:
+ break;
+ default:
+ throw new SecurityException(
+ "Reverse mode only supported from shell or system");
+ }
+ }
+ }
+
@Override
public ParcelFileDescriptor openWrite(String name, long offsetBytes, long lengthBytes) {
+ assertCanWrite(false);
try {
return doWriteInternal(name, offsetBytes, lengthBytes, null);
} catch (IOException e) {
@@ -705,6 +783,7 @@
@Override
public void write(String name, long offsetBytes, long lengthBytes,
ParcelFileDescriptor fd) {
+ assertCanWrite(fd != null);
try {
doWriteInternal(name, offsetBytes, lengthBytes, fd);
} catch (IOException e) {
@@ -720,9 +799,6 @@
final RevocableFileDescriptor fd;
final FileBridge bridge;
synchronized (mLock) {
- assertCallerIsOwnerOrRootLocked();
- assertPreparedAndNotSealedLocked("openWrite");
-
if (PackageInstaller.ENABLE_REVOCABLE_FD) {
fd = new RevocableFileDescriptor();
bridge = null;
@@ -765,16 +841,6 @@
}
if (incomingFd != null) {
- switch (Binder.getCallingUid()) {
- case android.os.Process.SHELL_UID:
- case android.os.Process.ROOT_UID:
- case android.os.Process.SYSTEM_UID:
- break;
- default:
- throw new SecurityException(
- "Reverse mode only supported from shell or system");
- }
-
// In "reverse" mode, we're streaming data ourselves from the
// incoming FD, which means we never have to hand out our
// sensitive internal FD. We still rely on a "bridge" being
@@ -786,7 +852,10 @@
if (params.sizeBytes > 0) {
final long delta = progress - last.value;
last.value = progress;
- addClientProgress((float) delta / (float) params.sizeBytes);
+ synchronized (mLock) {
+ setClientProgressLocked(mClientProgress
+ + (float) delta / (float) params.sizeBytes);
+ }
}
});
} finally {
@@ -821,6 +890,10 @@
@Override
public ParcelFileDescriptor openRead(String name) {
+ if (isDataLoaderInstallation()) {
+ throw new IllegalStateException(
+ "Cannot read regular files in a callback installation session.");
+ }
synchronized (mLock) {
assertCallerIsOwnerOrRootLocked();
assertPreparedAndNotCommittedOrDestroyedLocked("openRead");
@@ -926,6 +999,7 @@
return;
}
}
+
mHandler.obtainMessage(MSG_COMMIT).sendToTarget();
}
@@ -988,6 +1062,14 @@
}
}
+ /** {@hide} */
+ private class StreamingException extends Exception {
+ StreamingException(Throwable cause) {
+ super(cause);
+ }
+ }
+
+
/**
* Sanity checks to make sure it's ok to commit the session.
*/
@@ -1039,12 +1121,22 @@
}
wasSealed = mSealed;
- if (!mSealed) {
+ try {
+ if (!mSealed) {
+ sealLocked(childSessions);
+ }
+
try {
- sealAndValidateLocked(childSessions);
- } catch (PackageManagerException e) {
+ streamAndValidateLocked();
+ } catch (StreamingException e) {
+ // In case of streaming failure we don't want to fail or commit the session.
+ // Just return from this method and allow caller to commit again.
+ PackageInstallerService.sendPendingStreaming(mContext, mRemoteStatusReceiver,
+ sessionId, e);
return false;
}
+ } catch (PackageManagerException e) {
+ return false;
}
// Client staging is fully done at this point
@@ -1131,17 +1223,26 @@
}
/**
- * Seal the session to prevent further modification and validate the contents of it.
+ * Convenience wrapper, see {@link #sealLocked(List<PackageInstallerSession>) seal} and
+ * {@link #streamAndValidateLocked()}.
+ */
+ @GuardedBy("mLock")
+ private void sealAndValidateLocked(List<PackageInstallerSession> childSessions)
+ throws PackageManagerException, StreamingException {
+ sealLocked(childSessions);
+ streamAndValidateLocked();
+ }
+
+ /**
+ * Seal the session to prevent further modification.
*
* <p>The session will be sealed after calling this method even if it failed.
*
- * @param childSessions the child sessions of a multipackage that will be checked for
- * consistency. Can be null if session is not multipackage.
* @throws PackageManagerException if the session was sealed but something went wrong. If the
* session was sealed this is the only possible exception.
*/
@GuardedBy("mLock")
- private void sealAndValidateLocked(List<PackageInstallerSession> childSessions)
+ private void sealLocked(List<PackageInstallerSession> childSessions)
throws PackageManagerException {
try {
assertNoWriteFileTransfersOpenLocked();
@@ -1152,7 +1253,26 @@
if (childSessions != null) {
assertMultiPackageConsistencyLocked(childSessions);
}
+ } catch (PackageManagerException e) {
+ throw onSessionVerificationFailure(e);
+ } catch (Throwable e) {
+ // Convert all exceptions into package manager exceptions as only those are handled
+ // in the code above.
+ throw onSessionVerificationFailure(new PackageManagerException(e));
+ }
+ }
+ /**
+ * Prepare DataLoader and stream content for DataLoader sessions.
+ * Validate the contents of all session.
+ *
+ * @throws StreamingException if streaming failed.
+ * @throws PackageManagerException if validation failed.
+ */
+ @GuardedBy("mLock")
+ private void streamAndValidateLocked()
+ throws PackageManagerException, StreamingException {
+ try {
// Read transfers from the original owner stay open, but as the session's data cannot
// be modified anymore, there is no leak of information. For staged sessions, further
// validation is performed by the staging manager.
@@ -1161,6 +1281,8 @@
params.appPackageName, PackageManager.GET_SIGNATURES
| PackageManager.MATCH_STATIC_SHARED_LIBRARIES /*flags*/, userId);
+ prepareDataLoader();
+
if ((params.installFlags & PackageManager.INSTALL_APEX) != 0) {
validateApexInstallLocked();
} else {
@@ -1173,6 +1295,8 @@
}
} catch (PackageManagerException e) {
throw onSessionVerificationFailure(e);
+ } catch (StreamingException e) {
+ throw e;
} catch (Throwable e) {
// Convert all exceptions into package manager exceptions as only those are handled
// in the code above.
@@ -1208,6 +1332,8 @@
synchronized (mLock) {
try {
sealAndValidateLocked(childSessions);
+ } catch (StreamingException e) {
+ Slog.e(TAG, "Streaming failed", e);
} catch (PackageManagerException e) {
Slog.e(TAG, "Package not valid", e);
}
@@ -1277,6 +1403,8 @@
try {
sealAndValidateLocked(childSessions);
+ } catch (StreamingException e) {
+ throw new IllegalArgumentException("Streaming failed", e);
} catch (PackageManagerException e) {
throw new IllegalArgumentException("Package is not valid", e);
}
@@ -1517,9 +1645,10 @@
mInternalProgress = 0.5f;
computeProgressLocked(true);
- // Unpack native libraries
- // TODO(b/136132412): skip for incremental installation
- extractNativeLibraries(stageDir, params.abiOverride, mayInheritNativeLibs());
+ // Unpack native libraries for non-incremental installation
+ if (params.incrementalParams == null) {
+ extractNativeLibraries(stageDir, params.abiOverride, mayInheritNativeLibs());
+ }
}
// We've reached point of no return; call into PMS to install the stage.
@@ -2223,6 +2352,132 @@
}
@Override
+ public void addFile(String name, long lengthBytes, byte[] metadata) {
+ if (mIncrementalFileStorages != null) {
+ try {
+ mIncrementalFileStorages.addFile(new InstallationFile(name, lengthBytes, metadata));
+ } catch (IOException ex) {
+ throw new IllegalStateException(
+ "Failed to add and configure Incremental File: " + name, ex);
+ }
+ }
+ if (!isDataLoaderInstallation()) {
+ throw new IllegalStateException(
+ "Cannot add files to non-callback installation session.");
+ }
+ // Use installer provided name for now; we always rename later
+ if (!FileUtils.isValidExtFilename(name)) {
+ throw new IllegalArgumentException("Invalid name: " + name);
+ }
+
+ synchronized (mLock) {
+ assertCallerIsOwnerOrRootLocked();
+ assertPreparedAndNotSealedLocked("addFile");
+
+ mFiles.add(FileInfo.added(name, lengthBytes, metadata));
+ }
+ }
+
+ @Override
+ public void removeFile(String name) {
+ if (!isDataLoaderInstallation()) {
+ throw new IllegalStateException(
+ "Cannot add files to non-callback installation session.");
+ }
+ if (TextUtils.isEmpty(params.appPackageName)) {
+ throw new IllegalStateException("Must specify package name to remove a split");
+ }
+
+ synchronized (mLock) {
+ assertCallerIsOwnerOrRootLocked();
+ assertPreparedAndNotSealedLocked("removeFile");
+
+ mFiles.add(FileInfo.removed(getRemoveMarkerName(name)));
+ }
+ }
+
+ /**
+ * Makes sure files are present in staging location.
+ */
+ private void prepareDataLoader()
+ throws PackageManagerException, StreamingException {
+ if (!isDataLoaderInstallation()) {
+ return;
+ }
+
+ FilesystemConnector connector = new FilesystemConnector();
+
+ FileInfo[] addedFiles = mFiles.stream().filter(
+ file -> sAddedFilter.accept(new File(file.name))).toArray(FileInfo[]::new);
+ String[] removedFiles = mFiles.stream().filter(
+ file -> sRemovedFilter.accept(new File(file.name))).map(
+ file -> file.name.substring(0,
+ file.name.length() - REMOVE_MARKER_EXTENSION.length())).toArray(
+ String[]::new);
+
+ DataLoader dataLoader = new DataLoader();
+ try {
+ dataLoader.onCreate(connector);
+
+ if (!dataLoader.onPrepareImage(addedFiles, removedFiles)) {
+ throw new PackageManagerException(INSTALL_FAILED_MEDIA_UNAVAILABLE,
+ "Failed to prepare image.");
+ }
+ } catch (IOException e) {
+ throw new StreamingException(e);
+ } finally {
+ dataLoader.onDestroy();
+ }
+ }
+
+ // TODO(b/146080380): implement DataLoader using Incremental infrastructure.
+ class FilesystemConnector {
+ void writeData(FileInfo fileInfo, long offset, long lengthBytes,
+ ParcelFileDescriptor incomingFd) throws IOException {
+ doWriteInternal(fileInfo.name, offset, lengthBytes, incomingFd);
+ }
+ }
+
+ static class DataLoader {
+ private ParcelFileDescriptor mInFd = null;
+ private FilesystemConnector mConnector = null;
+
+ void onCreate(FilesystemConnector connector) throws IOException {
+ mConnector = connector;
+ }
+
+ void onDestroy() {
+ IoUtils.closeQuietly(mInFd);
+ }
+
+ private static final String STDIN_PATH = "-";
+ boolean onPrepareImage(FileInfo[] addedFiles, String[] removedFiles) throws IOException {
+ for (FileInfo fileInfo : addedFiles) {
+ String filePath = new String(fileInfo.metadata, StandardCharsets.UTF_8);
+ if (STDIN_PATH.equals(filePath) || TextUtils.isEmpty(filePath)) {
+ if (mInFd == null) {
+ Slog.e(TAG, "Invalid stdin file descriptor.");
+ return false;
+ }
+ ParcelFileDescriptor inFd = ParcelFileDescriptor.dup(mInFd.getFileDescriptor());
+ mConnector.writeData(fileInfo, 0, fileInfo.lengthBytes, inFd);
+ } else {
+ File localFile = new File(filePath);
+ ParcelFileDescriptor incomingFd = null;
+ try {
+ incomingFd = ParcelFileDescriptor.open(localFile,
+ ParcelFileDescriptor.MODE_READ_ONLY);
+ mConnector.writeData(fileInfo, 0, localFile.length(), incomingFd);
+ } finally {
+ IoUtils.closeQuietly(incomingFd);
+ }
+ }
+ }
+ return true;
+ }
+ }
+
+ @Override
public int[] getChildSessionIds() {
final int[] childSessionIds = mChildSessionIds.copyKeys();
if (childSessionIds != null) {
@@ -2294,20 +2549,6 @@
return mParentSessionId;
}
- @Override
- public void addFile(@NonNull String name, long size, @NonNull byte[] metadata) {
- if (mIncrementalFileStorages == null) {
- throw new IllegalStateException(
- "Cannot add Incremental File to a non-Incremental session.");
- }
- try {
- mIncrementalFileStorages.addFile(new InstallationFile(name, size, metadata));
- } catch (IOException ex) {
- throw new IllegalStateException(
- "Failed to add and configure Incremental File: " + name, ex);
- }
- }
-
private void dispatchSessionFinished(int returnCode, String msg, Bundle extras) {
final IntentSender statusReceiver;
final String packageName;
@@ -2320,7 +2561,7 @@
}
if (statusReceiver != null) {
- // Execute observer.onPackageInstalled on different tread as we don't want callers
+ // Execute observer.onPackageInstalled on different thread as we don't want callers
// inside the system server have to worry about catching the callbacks while they are
// calling into the session
final SomeArgs args = SomeArgs.obtain();
@@ -2594,6 +2835,8 @@
writeStringAttribute(out, ATTR_VOLUME_UUID, params.volumeUuid);
writeIntAttribute(out, ATTR_INSTALL_REASON, params.installReason);
+ writeStringAttribute(out, ATTR_DATA_LOADER_PACKAGE_NAME, params.dataLoaderPackageName);
+
writeGrantedRuntimePermissionsLocked(out, params.grantedRuntimePermissions);
writeWhitelistedRestrictedPermissionsLocked(out,
params.whitelistedRestrictedPermissions);
@@ -2623,6 +2866,13 @@
writeIntAttribute(out, ATTR_SESSION_ID, childSessionId);
out.endTag(null, TAG_CHILD_SESSION);
}
+ for (FileInfo fileInfo : mFiles) {
+ out.startTag(null, TAG_SESSION_FILE);
+ writeStringAttribute(out, ATTR_NAME, fileInfo.name);
+ writeLongAttribute(out, ATTR_LENGTH_BYTES, fileInfo.lengthBytes);
+ writeByteArrayAttribute(out, ATTR_METADATA, fileInfo.metadata);
+ out.endTag(null, TAG_SESSION_FILE);
+ }
}
out.endTag(null, TAG_SESSION);
@@ -2696,6 +2946,8 @@
params.volumeUuid = readStringAttribute(in, ATTR_VOLUME_UUID);
params.installReason = readIntAttribute(in, ATTR_INSTALL_REASON);
+ params.dataLoaderPackageName = readStringAttribute(in, ATTR_DATA_LOADER_PACKAGE_NAME);
+
final File appIconFile = buildAppIconFile(sessionId, sessionsDir);
if (appIconFile.exists()) {
params.appIcon = BitmapFactory.decodeFile(appIconFile.getAbsolutePath());
@@ -2722,6 +2974,7 @@
List<String> grantedRuntimePermissions = new ArrayList<>();
List<String> whitelistedRestrictedPermissions = new ArrayList<>();
List<Integer> childSessionIds = new ArrayList<>();
+ List<FileInfo> files = new ArrayList<>();
int outerDepth = in.getDepth();
int type;
while ((type = in.next()) != XmlPullParser.END_DOCUMENT
@@ -2739,6 +2992,11 @@
if (TAG_CHILD_SESSION.equals(in.getName())) {
childSessionIds.add(readIntAttribute(in, ATTR_SESSION_ID, SessionInfo.INVALID_ID));
}
+ if (TAG_SESSION_FILE.equals(in.getName())) {
+ files.add(new FileInfo(readStringAttribute(in, ATTR_NAME),
+ readLongAttribute(in, ATTR_LENGTH_BYTES, -1),
+ readByteArrayAttribute(in, ATTR_METADATA)));
+ }
}
if (grantedRuntimePermissions.size() > 0) {
@@ -2757,11 +3015,16 @@
childSessionIdsArray = EMPTY_CHILD_SESSION_ARRAY;
}
+ FileInfo[] fileInfosArray = null;
+ if (!files.isEmpty()) {
+ fileInfosArray = files.stream().toArray(FileInfo[]::new);
+ }
+
InstallSource installSource = InstallSource.create(installInitiatingPackageName,
installOriginatingPackageName, installerPackageName, false);
return new PackageInstallerSession(callback, context, pm, sessionProvider,
installerThread, stagingManager, sessionId, userId, installerUid,
- installSource, params, createdMillis, stageDir, stageCid,
+ installSource, params, createdMillis, stageDir, stageCid, fileInfosArray,
prepared, committed, sealed, childSessionIdsArray, parentSessionId,
isReady, isFailed, isApplied, stagedSessionErrorCode, stagedSessionErrorMessage);
}
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 642b500..1153fb5 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -155,6 +155,7 @@
import android.content.pm.InstallSourceInfo;
import android.content.pm.InstantAppInfo;
import android.content.pm.InstantAppRequest;
+import android.content.pm.InstantAppResolveInfo.InstantAppDigest;
import android.content.pm.InstrumentationInfo;
import android.content.pm.IntentFilterVerificationInfo;
import android.content.pm.KeySet;
@@ -376,6 +377,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -6143,10 +6145,12 @@
private void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj,
Intent origIntent, String resolvedType, String callingPackage,
- Bundle verificationBundle, int userId) {
+ boolean isRequesterInstantApp, Bundle verificationBundle, int userId) {
final Message msg = mHandler.obtainMessage(INSTANT_APP_RESOLUTION_PHASE_TWO,
new InstantAppRequest(responseObj, origIntent, resolvedType,
- callingPackage, userId, verificationBundle, false /*resolveForStart*/));
+ callingPackage, isRequesterInstantApp, userId, verificationBundle,
+ false /*resolveForStart*/, responseObj.hostDigestPrefixSecure,
+ responseObj.token));
mHandler.sendMessage(msg);
}
@@ -6765,8 +6769,10 @@
}
}
if (addInstant) {
- result = maybeAddInstantAppInstaller(
- result, intent, resolvedType, flags, userId, resolveForStart);
+ String callingPkgName = getInstantAppPackageName(filterCallingUid);
+ boolean isRequesterInstantApp = isInstantApp(callingPkgName, userId);
+ result = maybeAddInstantAppInstaller(result, intent, resolvedType, flags, userId,
+ resolveForStart, isRequesterInstantApp);
}
if (sortResult) {
Collections.sort(result, RESOLVE_PRIORITY_SORTER);
@@ -6777,7 +6783,8 @@
}
private List<ResolveInfo> maybeAddInstantAppInstaller(List<ResolveInfo> result, Intent intent,
- String resolvedType, int flags, int userId, boolean resolveForStart) {
+ String resolvedType, int flags, int userId, boolean resolveForStart,
+ boolean isRequesterInstantApp) {
// first, check to see if we've got an instant app already installed
final boolean alreadyResolvedLocally = (flags & PackageManager.MATCH_INSTANT) != 0;
ResolveInfo localInstantApp = null;
@@ -6825,10 +6832,13 @@
if (localInstantApp == null) {
// we don't have an instant app locally, resolve externally
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "resolveEphemeral");
+ String token = UUID.randomUUID().toString();
+ InstantAppDigest digest = InstantAppResolver.parseDigest(intent);
final InstantAppRequest requestObject = new InstantAppRequest(
null /*responseObj*/, intent /*origIntent*/, resolvedType,
- null /*callingPackage*/, userId, null /*verificationBundle*/,
- resolveForStart);
+ null /*callingPackage*/, isRequesterInstantApp,
+ userId, null /*verificationBundle*/, resolveForStart,
+ digest.getDigestPrefixSecure(), token);
auxiliaryResponse = InstantAppResolver.doInstantAppResolutionPhaseOne(
mInstantAppResolverConnection, requestObject);
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
@@ -13487,10 +13497,12 @@
}
Trace.asyncTraceBegin(TRACE_TAG_PACKAGE_MANAGER, "restore", token);
try {
- if (bm.isBackupServiceActive(userId)) {
+ if (bm.isUserReadyForBackup(userId)) {
bm.restoreAtInstallForUser(
userId, res.pkg.getAppInfoPackageName(), token);
} else {
+ Slog.w(TAG, "User " + userId + " is not ready. Restore at install "
+ + "didn't take place.");
return false;
}
} catch (RemoteException e) {
@@ -14144,7 +14156,7 @@
verification.putExtra(PackageManager.EXTRA_VERIFICATION_ID, verificationId);
verification.putExtra(PackageManager.EXTRA_VERIFICATION_INSTALLER_PACKAGE,
- installSource.installerPackageName);
+ installSource.initiatingPackageName);
verification.putExtra(PackageManager.EXTRA_VERIFICATION_INSTALL_FLAGS,
installFlags);
@@ -14606,7 +14618,8 @@
return false;
}
- if (!SELinux.restoreconRecursive(afterCodeFile)) {
+ //TODO(b/136132412): enable selinux restorecon for incremental directories
+ if (!onIncremental && !SELinux.restoreconRecursive(afterCodeFile)) {
Slog.w(TAG, "Failed to restorecon");
return false;
}
@@ -15707,7 +15720,9 @@
// TODO(patb): create a more descriptive reason than unknown in future release
// mark all non-failure installs as UNKNOWN so we do not treat them as success
for (InstallRequest request : requests) {
- request.installResult.freezer.close();
+ if (request.installResult.freezer != null) {
+ request.installResult.freezer.close();
+ }
if (request.installResult.returnCode == PackageManager.INSTALL_SUCCEEDED) {
request.installResult.returnCode = PackageManager.INSTALL_UNKNOWN;
}
@@ -22743,6 +22758,12 @@
}
@Override
+ public ComponentName getSystemUiServiceComponent() {
+ return ComponentName.unflattenFromString(mContext.getResources().getString(
+ com.android.internal.R.string.config_systemUIServiceComponent));
+ }
+
+ @Override
public void setDeviceAndProfileOwnerPackages(
int deviceOwnerUserId, String deviceOwnerPackage,
SparseArray<String> profileOwnerPackages) {
@@ -22822,10 +22843,10 @@
@Override
public void requestInstantAppResolutionPhaseTwo(AuxiliaryResolveInfo responseObj,
Intent origIntent, String resolvedType, String callingPackage,
- Bundle verificationBundle, int userId) {
+ boolean isRequesterInstantApp, Bundle verificationBundle, int userId) {
PackageManagerService.this.requestInstantAppResolutionPhaseTwo(
- responseObj, origIntent, resolvedType, callingPackage, verificationBundle,
- userId);
+ responseObj, origIntent, resolvedType, callingPackage, isRequesterInstantApp,
+ verificationBundle, userId);
}
@Override
diff --git a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
index fff404f..dfffbd6 100644
--- a/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
+++ b/services/core/java/com/android/server/pm/PackageManagerShellCommand.java
@@ -114,6 +114,7 @@
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -135,6 +136,8 @@
private final static String ART_PROFILE_SNAPSHOT_DEBUG_LOCATION = "/data/misc/profman/";
private static final int DEFAULT_WAIT_MS = 60 * 1000;
+ private static final String PM_SHELL_DATALOADER = "com.android.pm.dataloader";
+
final IPackageManager mInterface;
final IPermissionManager mPermissionManager;
final private WeakHashMap<String, Resources> mResourceCache =
@@ -175,6 +178,8 @@
return runQueryIntentReceivers();
case "install":
return runInstall();
+ case "install-streaming":
+ return runStreamingInstall();
case "install-abandon":
case "install-destroy":
return runInstallAbandon();
@@ -1152,9 +1157,21 @@
return 0;
}
- private int runInstall() throws RemoteException {
- final PrintWriter pw = getOutPrintWriter();
+ private int runStreamingInstall() throws RemoteException {
final InstallParams params = makeInstallParams();
+ if (TextUtils.isEmpty(params.sessionParams.dataLoaderPackageName)) {
+ params.sessionParams.setDataLoaderPackageName(PM_SHELL_DATALOADER);
+ }
+ return doRunInstall(params);
+ }
+
+ private int runInstall() throws RemoteException {
+ return doRunInstall(makeInstallParams());
+ }
+
+ private int doRunInstall(final InstallParams params) throws RemoteException {
+ final PrintWriter pw = getOutPrintWriter();
+ final boolean streaming = !TextUtils.isEmpty(params.sessionParams.dataLoaderPackageName);
ArrayList<String> inPaths = getRemainingArgs();
if (inPaths.isEmpty()) {
@@ -1181,17 +1198,30 @@
return 1;
}
- setParamsSize(params, inPaths);
+ if (!streaming) {
+ setParamsSize(params, inPaths);
+ }
+
final int sessionId = doCreateSession(params.sessionParams,
params.installerPackageName, params.userId);
boolean abandonSession = true;
try {
for (String inPath : inPaths) {
- String splitName = hasSplits ? (new File(inPath)).getName()
- : "base." + (isApex ? "apex" : "apk");
- if (doWriteSplit(sessionId, inPath, params.sessionParams.sizeBytes, splitName,
- false /*logSuccess*/) != PackageInstaller.STATUS_SUCCESS) {
- return 1;
+ if (streaming) {
+ String name = new File(inPath).getName();
+ byte[] metadata = inPath.getBytes(StandardCharsets.UTF_8);
+ if (doAddFile(sessionId, name, params.sessionParams.sizeBytes, metadata,
+ false /*logSuccess*/) != PackageInstaller.STATUS_SUCCESS) {
+ return 1;
+ }
+ } else {
+ String splitName = hasSplits ? new File(inPath).getName()
+ : "base." + (isApex ? "apex" : "apk");
+
+ if (doWriteSplit(sessionId, inPath, params.sessionParams.sizeBytes, splitName,
+ false /*logSuccess*/) != PackageInstaller.STATUS_SUCCESS) {
+ return 1;
+ }
}
}
if (doCommitSession(sessionId, false /*logSuccess*/)
@@ -2927,11 +2957,32 @@
return sessionId;
}
+ private int doAddFile(int sessionId, String name, long sizeBytes, byte[] metadata,
+ boolean logSuccess) throws RemoteException {
+ PackageInstaller.Session session = new PackageInstaller.Session(
+ mInterface.getPackageInstaller().openSession(sessionId));
+ try {
+ session.addFile(name, sizeBytes, metadata);
+
+ if (logSuccess) {
+ getOutPrintWriter().println("Success");
+ }
+
+ return 0;
+ } finally {
+ IoUtils.closeQuietly(session);
+ }
+ }
+
private int doWriteSplit(int sessionId, String inPath, long sizeBytes, String splitName,
boolean logSuccess) throws RemoteException {
PackageInstaller.Session session = null;
try {
+ session = new PackageInstaller.Session(
+ mInterface.getPackageInstaller().openSession(sessionId));
+
final PrintWriter pw = getOutPrintWriter();
+
final ParcelFileDescriptor fd;
if (STDIN_PATH.equals(inPath)) {
fd = ParcelFileDescriptor.dup(getInFileDescriptor());
@@ -2953,8 +3004,6 @@
return 1;
}
- session = new PackageInstaller.Session(
- mInterface.getPackageInstaller().openSession(sessionId));
session.write(splitName, 0, sizeBytes, fd);
if (logSuccess) {
@@ -3000,7 +3049,6 @@
try {
session = new PackageInstaller.Session(
mInterface.getPackageInstaller().openSession(sessionId));
-
for (String splitName : splitNames) {
session.removeSplit(splitName);
}
diff --git a/services/core/java/com/android/server/pm/StagingManager.java b/services/core/java/com/android/server/pm/StagingManager.java
index 7ea4e98..688c34f 100644
--- a/services/core/java/com/android/server/pm/StagingManager.java
+++ b/services/core/java/com/android/server/pm/StagingManager.java
@@ -21,6 +21,7 @@
import android.apex.ApexInfo;
import android.apex.ApexInfoList;
import android.apex.ApexSessionInfo;
+import android.apex.ApexSessionParams;
import android.content.Context;
import android.content.IIntentReceiver;
import android.content.IIntentSender;
@@ -36,6 +37,8 @@
import android.content.pm.PackageParser.SigningDetails.SignatureSchemeVersion;
import android.content.pm.ParceledListSlice;
import android.content.rollback.IRollbackManager;
+import android.content.rollback.RollbackInfo;
+import android.content.rollback.RollbackManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -49,6 +52,7 @@
import android.util.IntArray;
import android.util.Slog;
import android.util.SparseArray;
+import android.util.SparseIntArray;
import android.util.apk.ApkSignatureVerifier;
import com.android.internal.annotations.GuardedBy;
@@ -82,6 +86,9 @@
@GuardedBy("mStagedSessions")
private final SparseArray<PackageInstallerSession> mStagedSessions = new SparseArray<>();
+ @GuardedBy("mStagedSessions")
+ private final SparseIntArray mSessionRollbackIds = new SparseIntArray();
+
StagingManager(PackageInstallerService pi, ApexManager am, Context context) {
mPi = pi;
mApexManager = am;
@@ -166,18 +173,32 @@
private List<PackageInfo> submitSessionToApexService(
@NonNull PackageInstallerSession session) throws PackageManagerException {
- final IntArray childSessionsIds = new IntArray();
+ final IntArray childSessionIds = new IntArray();
if (session.isMultiPackage()) {
for (int id : session.getChildSessionIds()) {
if (isApexSession(mStagedSessions.get(id))) {
- childSessionsIds.add(id);
+ childSessionIds.add(id);
+ }
+ }
+ }
+ ApexSessionParams apexSessionParams = new ApexSessionParams();
+ apexSessionParams.sessionId = session.sessionId;
+ apexSessionParams.childSessionIds = childSessionIds.toArray();
+ if (session.params.installReason == PackageManager.INSTALL_REASON_ROLLBACK) {
+ apexSessionParams.isRollback = true;
+ apexSessionParams.rollbackId = retrieveRollbackIdForCommitSession(session.sessionId);
+ } else {
+ synchronized (mStagedSessions) {
+ int rollbackId = mSessionRollbackIds.get(session.sessionId, -1);
+ if (rollbackId != -1) {
+ apexSessionParams.hasRollbackEnabled = true;
+ apexSessionParams.rollbackId = rollbackId;
}
}
}
// submitStagedSession will throw a PackageManagerException if apexd verification fails,
// which will be propagated to populate stagedSessionErrorMessage of this session.
- final ApexInfoList apexInfoList = mApexManager.submitStagedSession(session.sessionId,
- childSessionsIds.toArray());
+ final ApexInfoList apexInfoList = mApexManager.submitStagedSession(apexSessionParams);
final List<PackageInfo> result = new ArrayList<>();
for (ApexInfo apexInfo : apexInfoList.apexInfos) {
final PackageInfo packageInfo;
@@ -208,6 +229,19 @@
return result;
}
+ private int retrieveRollbackIdForCommitSession(int sessionId) throws PackageManagerException {
+ RollbackManager rm = mContext.getSystemService(RollbackManager.class);
+
+ List<RollbackInfo> rollbacks = rm.getRecentlyCommittedRollbacks();
+ for (RollbackInfo rollback : rollbacks) {
+ if (rollback.getCommittedSessionId() == sessionId) {
+ return rollback.getRollbackId();
+ }
+ }
+ throw new PackageManagerException(
+ "Could not find rollback id for commit session: " + sessionId);
+ }
+
private void checkRequiredVersionCode(final PackageInstallerSession session,
final PackageInfo activePackage) throws PackageManagerException {
if (session.params.requiredInstalledVersionCode == PackageManager.VERSION_CODE_HIGHEST) {
@@ -633,6 +667,7 @@
void abortSession(@NonNull PackageInstallerSession session) {
synchronized (mStagedSessions) {
mStagedSessions.remove(session.sessionId);
+ mSessionRollbackIds.delete(session.sessionId);
}
}
@@ -865,6 +900,28 @@
*/
private void handlePreRebootVerification_Start(@NonNull PackageInstallerSession session) {
Slog.d(TAG, "Starting preRebootVerification for session " + session.sessionId);
+
+ if ((session.params.installFlags & PackageManager.INSTALL_ENABLE_ROLLBACK) != 0) {
+ // If rollback is enabled for this session, we call through to the RollbackManager
+ // with the list of sessions it must enable rollback for. Note that
+ // notifyStagedSession is a synchronous operation.
+ final IRollbackManager rm = IRollbackManager.Stub.asInterface(
+ ServiceManager.getService(Context.ROLLBACK_SERVICE));
+ try {
+ // NOTE: To stay consistent with the non-staged install flow, we don't fail the
+ // entire install if rollbacks can't be enabled.
+ int rollbackId = rm.notifyStagedSession(session.sessionId);
+ if (rollbackId != -1) {
+ synchronized (mStagedSessions) {
+ mSessionRollbackIds.put(session.sessionId, rollbackId);
+ }
+ }
+ } catch (RemoteException re) {
+ Slog.e(TAG, "Failed to notifyStagedSession for session: "
+ + session.sessionId, re);
+ }
+ }
+
notifyPreRebootVerification_Start_Complete(session.sessionId);
}
@@ -929,25 +986,6 @@
* </ul></p>
*/
private void handlePreRebootVerification_End(@NonNull PackageInstallerSession session) {
- if ((session.params.installFlags & PackageManager.INSTALL_ENABLE_ROLLBACK) != 0) {
- // If rollback is enabled for this session, we call through to the RollbackManager
- // with the list of sessions it must enable rollback for. Note that
- // notifyStagedSession is a synchronous operation.
- final IRollbackManager rm = IRollbackManager.Stub.asInterface(
- ServiceManager.getService(Context.ROLLBACK_SERVICE));
- try {
- // NOTE: To stay consistent with the non-staged install flow, we don't fail the
- // entire install if rollbacks can't be enabled.
- if (!rm.notifyStagedSession(session.sessionId)) {
- Slog.e(TAG, "Unable to enable rollback for session: "
- + session.sessionId);
- }
- } catch (RemoteException re) {
- Slog.e(TAG, "Failed to notifyStagedSession for session: "
- + session.sessionId, re);
- }
- }
-
// Proactively mark session as ready before calling apexd. Although this call order
// looks counter-intuitive, this is the easiest way to ensure that session won't end up
// in the inconsistent state:
diff --git a/services/core/java/com/android/server/pm/TEST_MAPPING b/services/core/java/com/android/server/pm/TEST_MAPPING
index e8798ff..59a5804 100644
--- a/services/core/java/com/android/server/pm/TEST_MAPPING
+++ b/services/core/java/com/android/server/pm/TEST_MAPPING
@@ -24,7 +24,20 @@
]
},
{
- "name": "PackageManagerShellCommandTest"
+ "name": "CtsContentTestCases",
+ "options": [
+ {
+ "include-filter": "android.content.pm.cts.PackageManagerShellCommandTest"
+ }
+ ]
+ },
+ {
+ "name": "GtsSecurityHostTestCases",
+ "options": [
+ {
+ "include-filter": "com.google.android.security.gts.PackageVerifierTest"
+ }
+ ]
}
],
"postsubmit": [
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index ad4411c..5fabdb6 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -351,6 +351,7 @@
* User restrictions set by {@link com.android.server.devicepolicy.DevicePolicyManagerService}
* that should be applied to all users, including guests. Only non-empty restriction bundles are
* stored.
+ * The key is the user id of the user whom the restriction originated from.
*/
@GuardedBy("mRestrictionsLock")
private final SparseArray<Bundle> mDevicePolicyGlobalUserRestrictions = new SparseArray<>();
@@ -364,6 +365,7 @@
/**
* User restrictions set by {@link com.android.server.devicepolicy.DevicePolicyManagerService}
* for each user. Only non-empty restriction bundles are stored.
+ * The key is the user id of the user whom the restriction originated from.
*/
@GuardedBy("mRestrictionsLock")
private final SparseArray<Bundle> mDevicePolicyLocalUserRestrictions = new SparseArray<>();
@@ -579,15 +581,6 @@
applyUserRestrictionsLR(UserHandle.USER_SYSTEM);
}
- UserInfo currentGuestUser = findCurrentGuestUser();
- if (currentGuestUser != null && !hasUserRestriction(
- UserManager.DISALLOW_CONFIG_WIFI, currentGuestUser.id)) {
- // If a guest user currently exists, apply the DISALLOW_CONFIG_WIFI option
- // to it, in case this guest was created in a previous version where this
- // user restriction was not a default guest restriction.
- setUserRestriction(UserManager.DISALLOW_CONFIG_WIFI, true, currentGuestUser.id);
- }
-
mContext.registerReceiver(mDisableQuietModeCallback,
new IntentFilter(ACTION_DISABLE_QUIET_MODE_AFTER_UNLOCK),
null, mHandler);
@@ -1118,11 +1111,6 @@
info.flags ^= UserInfo.FLAG_ADMIN;
writeUserLP(getUserDataLU(info.id));
}
-
- // Remove non-admin restrictions.
- // Keep synchronized with createUserEvenWhenDisallowed.
- setUserRestriction(UserManager.DISALLOW_SMS, false, userId);
- setUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS, false, userId);
}
/**
@@ -1602,10 +1590,12 @@
private void initDefaultGuestRestrictions() {
synchronized (mGuestRestrictions) {
if (mGuestRestrictions.isEmpty()) {
- mGuestRestrictions.putBoolean(UserManager.DISALLOW_CONFIG_WIFI, true);
- mGuestRestrictions.putBoolean(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES, true);
- mGuestRestrictions.putBoolean(UserManager.DISALLOW_OUTGOING_CALLS, true);
- mGuestRestrictions.putBoolean(UserManager.DISALLOW_SMS, true);
+ UserTypeDetails guestType = mUserTypes.get(UserManager.USER_TYPE_FULL_GUEST);
+ if (guestType == null) {
+ Slog.wtf(LOG_TAG, "Can't set default guest restrictions: type doesn't exist.");
+ return;
+ }
+ guestType.addDefaultRestrictionsTo(mGuestRestrictions);
}
}
}
@@ -1633,7 +1623,7 @@
/**
* See {@link UserManagerInternal#setDevicePolicyUserRestrictions}
*/
- private void setDevicePolicyUserRestrictionsInner(@UserIdInt int userId,
+ private void setDevicePolicyUserRestrictionsInner(@UserIdInt int originatingUserId,
@Nullable Bundle restrictions,
@UserManagerInternal.OwnerType int restrictionOwnerType) {
final Bundle global = new Bundle();
@@ -1647,16 +1637,16 @@
synchronized (mRestrictionsLock) {
// Update global and local restrictions if they were changed.
globalChanged = updateRestrictionsIfNeededLR(
- userId, global, mDevicePolicyGlobalUserRestrictions);
+ originatingUserId, global, mDevicePolicyGlobalUserRestrictions);
localChanged = updateRestrictionsIfNeededLR(
- userId, local, mDevicePolicyLocalUserRestrictions);
+ originatingUserId, local, mDevicePolicyLocalUserRestrictions);
if (restrictionOwnerType == UserManagerInternal.OWNER_TYPE_DEVICE_OWNER) {
// Remember the global restriction owner userId to be able to make a distinction
// in getUserRestrictionSource on who set local policies.
- mDeviceOwnerUserId = userId;
+ mDeviceOwnerUserId = originatingUserId;
} else {
- if (mDeviceOwnerUserId == userId) {
+ if (mDeviceOwnerUserId == originatingUserId) {
// When profile owner sets restrictions it passes null global bundle and we
// reset global restriction owner userId.
// This means this user used to have DO, but now the DO is gone and the user
@@ -1666,15 +1656,16 @@
}
}
if (DBG) {
- Log.d(LOG_TAG, "setDevicePolicyUserRestrictions: userId=" + userId
- + " global=" + global + (globalChanged ? " (changed)" : "")
- + " local=" + local + (localChanged ? " (changed)" : "")
+ Log.d(LOG_TAG, "setDevicePolicyUserRestrictions: "
+ + " originatingUserId=" + originatingUserId
+ + " global=" + global + (globalChanged ? " (changed)" : "")
+ + " local=" + local + (localChanged ? " (changed)" : "")
);
}
// Don't call them within the mRestrictionsLock.
synchronized (mPackagesLock) {
if (localChanged || globalChanged) {
- writeUserLP(getUserDataNoChecks(userId));
+ writeUserLP(getUserDataNoChecks(originatingUserId));
}
}
@@ -1682,7 +1673,7 @@
if (globalChanged) {
applyUserRestrictionsForAllUsersLR();
} else if (localChanged) {
- applyUserRestrictionsLR(userId);
+ applyUserRestrictionsLR(originatingUserId);
}
}
}
@@ -2494,6 +2485,12 @@
mDevicePolicyLocalUserRestrictions, mDevicePolicyGlobalUserRestrictions
);
}
+ // DISALLOW_CONFIG_WIFI was made a default guest restriction some time during version 6.
+ final UserInfo currentGuestUser = findCurrentGuestUser();
+ if (currentGuestUser != null && !hasUserRestriction(
+ UserManager.DISALLOW_CONFIG_WIFI, currentGuestUser.id)) {
+ setUserRestriction(UserManager.DISALLOW_CONFIG_WIFI, true, currentGuestUser.id);
+ }
userVersion = 7;
}
@@ -3245,12 +3242,15 @@
writeUserLP(userData);
}
updateUserIds();
+
Bundle restrictions = new Bundle();
- // TODO(b/142482943): Generalize this using UserTypeDetails default restrictions.
if (isGuest) {
+ // Guest default restrictions can be modified via setDefaultGuestRestrictions.
synchronized (mGuestRestrictions) {
restrictions.putAll(mGuestRestrictions);
}
+ } else {
+ userTypeDetails.addDefaultRestrictionsTo(restrictions);
}
synchronized (mRestrictionsLock) {
mBaseUserRestrictions.append(userId, restrictions);
@@ -4510,9 +4510,10 @@
private class LocalService extends UserManagerInternal {
@Override
- public void setDevicePolicyUserRestrictions(@UserIdInt int userId,
- @Nullable Bundle restrictions, @OwnerType int restrictionOwnerType) {
- UserManagerService.this.setDevicePolicyUserRestrictionsInner(userId,
+ public void setDevicePolicyUserRestrictions(@UserIdInt int originatingUserId,
+ @Nullable Bundle restrictions,
+ @OwnerType int restrictionOwnerType) {
+ UserManagerService.this.setDevicePolicyUserRestrictionsInner(originatingUserId,
restrictions, restrictionOwnerType);
}
@@ -4666,14 +4667,8 @@
@Override
public UserInfo createUserEvenWhenDisallowed(String name, @NonNull String userType,
@UserInfoFlag int flags, String[] disallowedPackages) {
- UserInfo user = createUserInternalUnchecked(name, userType, flags,
+ return createUserInternalUnchecked(name, userType, flags,
UserHandle.USER_NULL, /* preCreated= */ false, disallowedPackages);
- // Keep this in sync with UserManager.createUser
- if (user != null && !user.isAdmin() && !user.isDemo()) {
- setUserRestriction(UserManager.DISALLOW_SMS, true, user.id);
- setUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS, true, user.id);
- }
- return user;
}
@Override
diff --git a/services/core/java/com/android/server/pm/UserRestrictionsUtils.java b/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
index 0beff7a..e0bd0b4 100644
--- a/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
+++ b/services/core/java/com/android/server/pm/UserRestrictionsUtils.java
@@ -411,6 +411,13 @@
}
/**
+ * @return true if a restriction is settable by profile owner of an organization owned device.
+ */
+ public static boolean canProfileOwnerOfOrganizationOwnedDeviceChange(String restriction) {
+ return PROFILE_OWNER_ORGANIZATION_OWNED_GLOBAL_RESTRICTIONS.contains(restriction);
+ }
+
+ /**
* Returns the user restrictions that default to {@code true} for device owners.
* These user restrictions are local, though. ie only for the device owner's user id.
*/
diff --git a/services/core/java/com/android/server/pm/UserTypeDetails.java b/services/core/java/com/android/server/pm/UserTypeDetails.java
index 1631df3..826cd3f 100644
--- a/services/core/java/com/android/server/pm/UserTypeDetails.java
+++ b/services/core/java/com/android/server/pm/UserTypeDetails.java
@@ -19,18 +19,17 @@
import android.annotation.ColorRes;
import android.annotation.DrawableRes;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.annotation.StringRes;
import android.content.pm.UserInfo;
import android.content.pm.UserInfo.UserInfoFlag;
import android.content.res.Resources;
+import android.os.Bundle;
import android.os.UserManager;
import com.android.internal.util.Preconditions;
import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
/**
* Contains the details about a multiuser "user type", such as a
@@ -75,8 +74,13 @@
/** The {@link UserInfo.UserInfoFlag}s that all users of this type will automatically have. */
private final @UserInfoFlag int mDefaultUserInfoPropertyFlags;
- // TODO(b/142482943): Hook these up to something and set them for each type.
- private final List<String> mDefaultRestrictions;
+ /**
+ * List of User Restrictions to apply by default to newly created users of this type.
+ * <p>Does not apply to SYSTEM users (since they are not formally created); for them use
+ * {@link com.android.internal.R.array#config_defaultFirstUserRestrictions} instead.
+ * The Bundle is of the form used by {@link UserRestrictionsUtils}.
+ */
+ private final @Nullable Bundle mDefaultRestrictions;
// Fields for profiles only, controlling the nature of their badges.
@@ -99,7 +103,7 @@
*
* <p>Must be set if mIconBadge is set.
*/
- private final int[] mBadgeLabels;
+ private final @Nullable int[] mBadgeLabels;
/**
* Resource ID ({@link ColorRes}) of the colors badge put on icons.
@@ -110,22 +114,21 @@
*
* <p>Must be set if mIconBadge is set.
*/
- private final int[] mBadgeColors;
+ private final @Nullable int[] mBadgeColors;
private UserTypeDetails(@NonNull String name, boolean enabled, int maxAllowed,
@UserInfoFlag int baseType, @UserInfoFlag int defaultUserInfoPropertyFlags, int label,
int maxAllowedPerParent,
int iconBadge, int badgePlain, int badgeNoBackground,
- int[] badgeLabels, int[] badgeColors,
- ArrayList<String> defaultRestrictions) {
+ @Nullable int[] badgeLabels, @Nullable int[] badgeColors,
+ @Nullable Bundle defaultRestrictions) {
this.mName = name;
this.mEnabled = enabled;
this.mMaxAllowed = maxAllowed;
this.mMaxAllowedPerParent = maxAllowedPerParent;
this.mBaseType = baseType;
this.mDefaultUserInfoPropertyFlags = defaultUserInfoPropertyFlags;
- this.mDefaultRestrictions =
- Collections.unmodifiableList(new ArrayList<>(defaultRestrictions));
+ this.mDefaultRestrictions = defaultRestrictions;
this.mIconBadge = iconBadge;
this.mBadgePlain = badgePlain;
@@ -180,7 +183,7 @@
return mIconBadge != Resources.ID_NULL;
}
- /** Resource ID of the badge put on icons. */
+ /** Resource ID of the badge to put on icons. */
public @DrawableRes int getIconBadge() {
return mIconBadge;
}
@@ -231,9 +234,14 @@
return (mBaseType & UserInfo.FLAG_SYSTEM) != 0;
}
- // TODO(b/142482943): Hook this up and don't return the original.
- public List<String> getDefaultRestrictions() {
- return mDefaultRestrictions;
+ /** Returns a Bundle representing the default user restrictions. */
+ @NonNull Bundle getDefaultRestrictions() {
+ return UserRestrictionsUtils.clone(mDefaultRestrictions);
+ }
+
+ /** Adds the default user restrictions to the given bundle of restrictions. */
+ public void addDefaultRestrictionsTo(@NonNull Bundle currentRestrictions) {
+ UserRestrictionsUtils.merge(currentRestrictions, mDefaultRestrictions);
}
/** Dumps details of the UserTypeDetails. Do not parse this. */
@@ -247,7 +255,8 @@
pw.print(prefix); pw.print("mDefaultUserInfoFlags: ");
pw.println(UserInfo.flagsToString(mDefaultUserInfoPropertyFlags));
pw.print(prefix); pw.print("mLabel: "); pw.println(mLabel);
- pw.print(prefix); pw.print("mDefaultRestrictions: "); pw.println(mDefaultRestrictions);
+ pw.print(prefix); pw.println("mDefaultRestrictions: ");
+ UserRestrictionsUtils.dumpRestrictions(pw, prefix + " ", mDefaultRestrictions);
pw.print(prefix); pw.print("mIconBadge: "); pw.println(mIconBadge);
pw.print(prefix); pw.print("mBadgePlain: "); pw.println(mBadgePlain);
pw.print(prefix); pw.print("mBadgeNoBackground: "); pw.println(mBadgeNoBackground);
@@ -265,14 +274,14 @@
private int mMaxAllowed = UNLIMITED_NUMBER_OF_USERS;
private int mMaxAllowedPerParent = UNLIMITED_NUMBER_OF_USERS;
private int mDefaultUserInfoPropertyFlags = 0;
- private ArrayList<String> mDefaultRestrictions = new ArrayList<>();
+ private @Nullable Bundle mDefaultRestrictions = null;
private boolean mEnabled = true;
private int mLabel = Resources.ID_NULL;
- private int[] mBadgeLabels = null;
- private int[] mBadgeColors = null;
- private int mIconBadge = Resources.ID_NULL;
- private int mBadgePlain = Resources.ID_NULL;
- private int mBadgeNoBackground = Resources.ID_NULL;
+ private @Nullable int[] mBadgeLabels = null;
+ private @Nullable int[] mBadgeColors = null;
+ private @DrawableRes int mIconBadge = Resources.ID_NULL;
+ private @DrawableRes int mBadgePlain = Resources.ID_NULL;
+ private @DrawableRes int mBadgeNoBackground = Resources.ID_NULL;
public Builder setName(String name) {
mName = name;
@@ -304,27 +313,27 @@
return this;
}
- public Builder setBadgeLabels(int ... badgeLabels) {
+ public Builder setBadgeLabels(@StringRes int ... badgeLabels) {
mBadgeLabels = badgeLabels;
return this;
}
- public Builder setBadgeColors(int ... badgeColors) {
+ public Builder setBadgeColors(@ColorRes int ... badgeColors) {
mBadgeColors = badgeColors;
return this;
}
- public Builder setIconBadge(int badgeIcon) {
+ public Builder setIconBadge(@DrawableRes int badgeIcon) {
mIconBadge = badgeIcon;
return this;
}
- public Builder setBadgePlain(int badgePlain) {
+ public Builder setBadgePlain(@DrawableRes int badgePlain) {
mBadgePlain = badgePlain;
return this;
}
- public Builder setBadgeNoBackground(int badgeNoBackground) {
+ public Builder setBadgeNoBackground(@DrawableRes int badgeNoBackground) {
mBadgeNoBackground = badgeNoBackground;
return this;
}
@@ -334,11 +343,15 @@
return this;
}
- public Builder setDefaultRestrictions(ArrayList<String> restrictions) {
+ public Builder setDefaultRestrictions(@Nullable Bundle restrictions) {
mDefaultRestrictions = restrictions;
return this;
}
+ @UserInfoFlag int getBaseType() {
+ return mBaseType;
+ }
+
public UserTypeDetails createUserTypeDetails() {
Preconditions.checkArgument(mName != null,
"Cannot create a UserTypeDetails with no name.");
diff --git a/services/core/java/com/android/server/pm/UserTypeFactory.java b/services/core/java/com/android/server/pm/UserTypeFactory.java
index 43bbab1..7d45516 100644
--- a/services/core/java/com/android/server/pm/UserTypeFactory.java
+++ b/services/core/java/com/android/server/pm/UserTypeFactory.java
@@ -34,18 +34,36 @@
import static com.android.server.pm.UserTypeDetails.UNLIMITED_NUMBER_OF_USERS;
+import android.content.pm.UserInfo;
import android.content.res.Resources;
+import android.content.res.XmlResourceParser;
+import android.os.Bundle;
import android.os.UserManager;
import android.util.ArrayMap;
+import android.util.Slog;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.util.XmlUtils;
+
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.function.Consumer;
/**
* Class for creating all {@link UserTypeDetails} on the device.
*
+ * This class is responsible both for defining the AOSP use types, as well as reading in customized
+ * user types from {@link com.android.internal.R.xml#config_user_types}.
+ *
* Tests are located in UserManagerServiceUserTypeTest.java.
* @hide
*/
public final class UserTypeFactory {
+ private static final String LOG_TAG = "UserTypeFactory";
+
/** This is a utility class, so no instantiable constructor. */
private UserTypeFactory() {}
@@ -55,21 +73,25 @@
* @return mapping from the name of each user type to its {@link UserTypeDetails} object
*/
public static ArrayMap<String, UserTypeDetails> getUserTypes() {
- final ArrayMap<String, UserTypeDetails> map = new ArrayMap<>();
- // TODO(b/142482943): Read an xml file for OEM customized types.
- // Remember to disallow "android." namespace
- // TODO(b/142482943): Read an xml file to get any overrides for the built-in types.
- final int maxManagedProfiles = 1;
- map.put(USER_TYPE_PROFILE_MANAGED,
- getDefaultTypeProfileManaged().setMaxAllowedPerParent(maxManagedProfiles)
- .createUserTypeDetails());
- map.put(USER_TYPE_FULL_SYSTEM, getDefaultTypeSystemFull().createUserTypeDetails());
- map.put(USER_TYPE_FULL_SECONDARY, getDefaultTypeFullSecondary().createUserTypeDetails());
- map.put(USER_TYPE_FULL_GUEST, getDefaultTypeFullGuest().createUserTypeDetails());
- map.put(USER_TYPE_FULL_DEMO, getDefaultTypeFullDemo().createUserTypeDetails());
- map.put(USER_TYPE_FULL_RESTRICTED, getDefaultTypeFullRestricted().createUserTypeDetails());
- map.put(USER_TYPE_SYSTEM_HEADLESS, getDefaultTypeSystemHeadless().createUserTypeDetails());
- return map;
+ final ArrayMap<String, UserTypeDetails.Builder> builders = new ArrayMap<>();
+ builders.put(USER_TYPE_PROFILE_MANAGED, getDefaultTypeProfileManaged());
+ builders.put(USER_TYPE_FULL_SYSTEM, getDefaultTypeFullSystem());
+ builders.put(USER_TYPE_FULL_SECONDARY, getDefaultTypeFullSecondary());
+ builders.put(USER_TYPE_FULL_GUEST, getDefaultTypeFullGuest());
+ builders.put(USER_TYPE_FULL_DEMO, getDefaultTypeFullDemo());
+ builders.put(USER_TYPE_FULL_RESTRICTED, getDefaultTypeFullRestricted());
+ builders.put(USER_TYPE_SYSTEM_HEADLESS, getDefaultTypeSystemHeadless());
+
+ try (XmlResourceParser parser =
+ Resources.getSystem().getXml(com.android.internal.R.xml.config_user_types)) {
+ customizeBuilders(builders, parser);
+ }
+
+ final ArrayMap<String, UserTypeDetails> types = new ArrayMap<>(builders.size());
+ for (int i = 0; i < builders.size(); i++) {
+ types.put(builders.keyAt(i), builders.valueAt(i).createUserTypeDetails());
+ }
+ return types;
}
/**
@@ -93,7 +115,8 @@
.setBadgeColors(
com.android.internal.R.color.profile_badge_1,
com.android.internal.R.color.profile_badge_2,
- com.android.internal.R.color.profile_badge_3);
+ com.android.internal.R.color.profile_badge_3)
+ .setDefaultRestrictions(null);
}
/**
@@ -104,7 +127,8 @@
return new UserTypeDetails.Builder()
.setName(USER_TYPE_FULL_SECONDARY)
.setBaseType(FLAG_FULL)
- .setMaxAllowed(UNLIMITED_NUMBER_OF_USERS);
+ .setMaxAllowed(UNLIMITED_NUMBER_OF_USERS)
+ .setDefaultRestrictions(getDefaultSecondaryUserRestrictions());
}
/**
@@ -115,13 +139,12 @@
.getBoolean(com.android.internal.R.bool.config_guestUserEphemeral);
final int flags = FLAG_GUEST | (ephemeralGuests ? FLAG_EPHEMERAL : 0);
- // TODO(b/142482943): Put UMS.initDefaultGuestRestrictions() here; then fetch them from here
-
return new UserTypeDetails.Builder()
.setName(USER_TYPE_FULL_GUEST)
.setBaseType(FLAG_FULL)
.setDefaultUserInfoPropertyFlags(flags)
- .setMaxAllowed(1);
+ .setMaxAllowed(1)
+ .setDefaultRestrictions(getDefaultGuestUserRestrictions());
}
/**
@@ -132,7 +155,8 @@
.setName(USER_TYPE_FULL_DEMO)
.setBaseType(FLAG_FULL)
.setDefaultUserInfoPropertyFlags(FLAG_DEMO)
- .setMaxAllowed(UNLIMITED_NUMBER_OF_USERS);
+ .setMaxAllowed(UNLIMITED_NUMBER_OF_USERS)
+ .setDefaultRestrictions(null);
}
/**
@@ -144,13 +168,15 @@
.setName(USER_TYPE_FULL_RESTRICTED)
.setBaseType(FLAG_FULL)
.setDefaultUserInfoPropertyFlags(FLAG_RESTRICTED)
- .setMaxAllowed(UNLIMITED_NUMBER_OF_USERS);
+ .setMaxAllowed(UNLIMITED_NUMBER_OF_USERS)
+ // NB: UserManagerService.createRestrictedProfile() applies hardcoded restrictions.
+ .setDefaultRestrictions(null);
}
/**
* Returns the Builder for the default {@link UserManager#USER_TYPE_FULL_SYSTEM} configuration.
*/
- private static UserTypeDetails.Builder getDefaultTypeSystemFull() {
+ private static UserTypeDetails.Builder getDefaultTypeFullSystem() {
return new UserTypeDetails.Builder()
.setName(USER_TYPE_FULL_SYSTEM)
.setBaseType(FLAG_SYSTEM | FLAG_FULL);
@@ -165,4 +191,193 @@
.setName(USER_TYPE_SYSTEM_HEADLESS)
.setBaseType(FLAG_SYSTEM);
}
+
+ private static Bundle getDefaultSecondaryUserRestrictions() {
+ final Bundle restrictions = new Bundle();
+ restrictions.putBoolean(UserManager.DISALLOW_OUTGOING_CALLS, true);
+ restrictions.putBoolean(UserManager.DISALLOW_SMS, true);
+ return restrictions;
+ }
+
+ private static Bundle getDefaultGuestUserRestrictions() {
+ // Guest inherits the secondary user's restrictions, plus has some extra ones.
+ final Bundle restrictions = getDefaultSecondaryUserRestrictions();
+ restrictions.putBoolean(UserManager.DISALLOW_CONFIG_WIFI, true);
+ restrictions.putBoolean(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES, true);
+ return restrictions;
+ }
+
+ /**
+ * Reads the given xml parser to obtain device user-type customization, and updates the given
+ * map of {@link UserTypeDetails.Builder}s accordingly.
+ * <p>
+ * The xml file can specify the attributes according to the set... methods below.
+ */
+ @VisibleForTesting
+ static void customizeBuilders(ArrayMap<String, UserTypeDetails.Builder> builders,
+ XmlResourceParser parser) {
+ try {
+ XmlUtils.beginDocument(parser, "user-types");
+ for (XmlUtils.nextElement(parser);
+ parser.getEventType() != XmlResourceParser.END_DOCUMENT;
+ XmlUtils.nextElement(parser)) {
+ final boolean isProfile;
+ final String elementName = parser.getName();
+ if ("profile-type".equals(elementName)) {
+ isProfile = true;
+ } else if ("full-type".equals(elementName)) {
+ isProfile = false;
+ } else {
+ Slog.w(LOG_TAG, "Skipping unknown element " + elementName + " in "
+ + parser.getPositionDescription());
+ XmlUtils.skipCurrentTag(parser);
+ continue;
+ }
+
+ String typeName = parser.getAttributeValue(null, "name");
+ if (typeName == null) {
+ Slog.w(LOG_TAG, "Skipping user type with no name in "
+ + parser.getPositionDescription());
+ XmlUtils.skipCurrentTag(parser);
+ continue;
+ }
+ typeName.intern();
+
+ UserTypeDetails.Builder builder;
+ if (typeName.startsWith("android.")) {
+ // typeName refers to a AOSP-defined type which we are modifying.
+ Slog.i(LOG_TAG, "Customizing user type " + typeName);
+ builder = builders.get(typeName);
+ if (builder == null) {
+ throw new IllegalArgumentException("Illegal custom user type name "
+ + typeName + ": Non-AOSP user types cannot start with 'android.'");
+ }
+ final boolean isValid =
+ (isProfile && builder.getBaseType() == UserInfo.FLAG_PROFILE)
+ || (!isProfile && builder.getBaseType() == UserInfo.FLAG_FULL);
+ if (!isValid) {
+ throw new IllegalArgumentException("Wrong base type to customize user type "
+ + "(" + typeName + "), which is type "
+ + UserInfo.flagsToString(builder.getBaseType()));
+ }
+ } else if (isProfile) {
+ // typeName refers to a new OEM-defined profile type which we are defining.
+ Slog.i(LOG_TAG, "Creating custom user type " + typeName);
+ builder = new UserTypeDetails.Builder();
+ builder.setName(typeName);
+ builder.setBaseType(FLAG_PROFILE);
+ builders.put(typeName, builder);
+ } else {
+ throw new IllegalArgumentException("Creation of non-profile user type "
+ + "(" + typeName + ") is not currently supported.");
+ }
+
+ // Process the attributes (other than name).
+ if (isProfile) {
+ setIntAttribute(parser, "max-allowed-per-parent",
+ builder::setMaxAllowedPerParent);
+ setResAttribute(parser, "icon-badge", builder::setIconBadge);
+ setResAttribute(parser, "badge-plain", builder::setBadgePlain);
+ setResAttribute(parser, "badge-no-background", builder::setBadgeNoBackground);
+ }
+
+ // Process child elements.
+ final int depth = parser.getDepth();
+ while (XmlUtils.nextElementWithin(parser, depth)) {
+ final String childName = parser.getName();
+ if ("default-restrictions".equals(childName)) {
+ final Bundle restrictions = UserRestrictionsUtils.readRestrictions(parser);
+ builder.setDefaultRestrictions(restrictions);
+ } else if (isProfile && "badge-labels".equals(childName)) {
+ setResAttributeArray(parser, builder::setBadgeLabels);
+ } else if (isProfile && "badge-colors".equals(childName)) {
+ setResAttributeArray(parser, builder::setBadgeColors);
+ } else {
+ Slog.w(LOG_TAG, "Unrecognized tag " + childName + " in "
+ + parser.getPositionDescription());
+ }
+ }
+ }
+ } catch (XmlPullParserException | IOException e) {
+ Slog.w(LOG_TAG, "Cannot read user type configuration file.", e);
+ }
+ }
+
+ /**
+ * If the given attribute exists, gets the int stored in it and performs the given fcn using it.
+ * The stored value must be an int or NumberFormatException will be thrown.
+ *
+ * @param parser xml parser from which to read the attribute
+ * @param attributeName name of the attribute
+ * @param fcn one-int-argument function,
+ * like {@link UserTypeDetails.Builder#setMaxAllowedPerParent(int)}
+ */
+ private static void setIntAttribute(XmlResourceParser parser, String attributeName,
+ Consumer<Integer> fcn) {
+ final String intValue = parser.getAttributeValue(null, attributeName);
+ if (intValue == null) {
+ return;
+ }
+ try {
+ fcn.accept(Integer.parseInt(intValue));
+ } catch (NumberFormatException e) {
+ Slog.e(LOG_TAG, "Cannot parse value of '" + intValue + "' for " + attributeName
+ + " in " + parser.getPositionDescription(), e);
+ throw e;
+ }
+ }
+
+ /**
+ * If the given attribute exists, gets the resId stored in it (or 0 if it is not a valid resId)
+ * and performs the given fcn using it.
+ *
+ * @param parser xml parser from which to read the attribute
+ * @param attributeName name of the attribute
+ * @param fcn one-argument function, like {@link UserTypeDetails.Builder#setIconBadge(int)}
+ */
+ private static void setResAttribute(XmlResourceParser parser, String attributeName,
+ Consumer<Integer> fcn) {
+ if (parser.getAttributeValue(null, attributeName) == null) {
+ // Attribute is not present, i.e. use the default value.
+ return;
+ }
+ final int resId = parser.getAttributeResourceValue(null, attributeName, Resources.ID_NULL);
+ fcn.accept(resId);
+ }
+
+ /**
+ * Gets the resIds stored in "item" elements (in their "res" attribute) at the current depth.
+ * Then performs the given fcn using the int[] array of these resIds.
+ * <p>
+ * Each xml element is expected to be of the form {@code <item res="someResValue" />}.
+ *
+ * @param parser xml parser from which to read the elements and their attributes
+ * @param fcn function, like {@link UserTypeDetails.Builder#setBadgeColors(int...)}
+ */
+ private static void setResAttributeArray(XmlResourceParser parser, Consumer<int[]> fcn)
+ throws IOException, XmlPullParserException {
+
+ ArrayList<Integer> resList = new ArrayList<>();
+ final int depth = parser.getDepth();
+ while (XmlUtils.nextElementWithin(parser, depth)) {
+ final String elementName = parser.getName();
+ if (!"item".equals(elementName)) {
+ Slog.w(LOG_TAG, "Skipping unknown child element " + elementName + " in "
+ + parser.getPositionDescription());
+ XmlUtils.skipCurrentTag(parser);
+ continue;
+ }
+ final int resId = parser.getAttributeResourceValue(null, "res", -1);
+ if (resId == -1) {
+ continue;
+ }
+ resList.add(resId);
+ }
+
+ int[] result = new int[resList.size()];
+ for (int i = 0; i < resList.size(); i++) {
+ result[i] = resList.get(i);
+ }
+ fcn.accept(result);
+ }
}
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 8435a82..0d8f257 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -157,6 +157,7 @@
import android.os.StrictMode;
import android.os.SystemClock;
import android.os.SystemProperties;
+import android.os.Trace;
import android.os.UEventObserver;
import android.os.UserHandle;
import android.os.VibrationEffect;
@@ -4603,6 +4604,7 @@
public void screenTurningOn(final ScreenOnListener screenOnListener) {
if (DEBUG_WAKEUP) Slog.i(TAG, "Screen turning on...");
+ Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "screenTurningOn", 0 /* cookie */);
updateScreenOffSleepToken(false);
mDefaultDisplayPolicy.screenTurnedOn(screenOnListener);
@@ -4665,6 +4667,7 @@
if (!mDefaultDisplayPolicy.finishScreenTurningOn()) {
return; // Spurious or not ready yet.
}
+ Trace.asyncTraceEnd(Trace.TRACE_TAG_WINDOW_MANAGER, "screenTurningOn", 0 /* cookie */);
final boolean enableScreen;
final boolean awake = mDefaultDisplayPolicy.isAwake();
@@ -4949,6 +4952,7 @@
mBootMsgDialog.getWindow().setDimAmount(1);
WindowManager.LayoutParams lp = mBootMsgDialog.getWindow().getAttributes();
lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
+ lp.setFitWindowInsetsTypes(0 /* types */);
mBootMsgDialog.getWindow().setAttributes(lp);
mBootMsgDialog.setCancelable(false);
mBootMsgDialog.show();
diff --git a/services/core/java/com/android/server/power/ShutdownThread.java b/services/core/java/com/android/server/power/ShutdownThread.java
index 6da8fb4..cc1cddd 100644
--- a/services/core/java/com/android/server/power/ShutdownThread.java
+++ b/services/core/java/com/android/server/power/ShutdownThread.java
@@ -41,12 +41,12 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.os.Vibrator;
+import android.telephony.TelephonyManager;
import android.util.ArrayMap;
import android.util.Log;
import android.util.TimingsTraceLog;
import android.view.WindowManager;
-import com.android.internal.telephony.ITelephony;
import com.android.server.LocalServices;
import com.android.server.RescueParty;
import com.android.server.pm.PackageManagerService;
@@ -586,19 +586,15 @@
TimingsTraceLog shutdownTimingsTraceLog = newTimingsLog();
boolean radioOff;
- final ITelephony phone =
- ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
+ TelephonyManager telephonyManager = mContext.getSystemService(
+ TelephonyManager.class);
- try {
- radioOff = phone == null || !phone.needMobileRadioShutdown();
- if (!radioOff) {
- Log.w(TAG, "Turning off cellular radios...");
- metricStarted(METRIC_RADIO);
- phone.shutdownMobileRadios();
- }
- } catch (RemoteException ex) {
- Log.e(TAG, "RemoteException during radio shutdown", ex);
- radioOff = true;
+ radioOff = telephonyManager == null
+ || !telephonyManager.isAnyRadioPoweredOn();
+ if (!radioOff) {
+ Log.w(TAG, "Turning off cellular radios...");
+ metricStarted(METRIC_RADIO);
+ telephonyManager.shutdownAllRadios();
}
Log.i(TAG, "Waiting for Radio...");
@@ -613,12 +609,7 @@
}
if (!radioOff) {
- try {
- radioOff = !phone.needMobileRadioShutdown();
- } catch (RemoteException ex) {
- Log.e(TAG, "RemoteException during radio shutdown", ex);
- radioOff = true;
- }
+ radioOff = !telephonyManager.isAnyRadioPoweredOn();
if (radioOff) {
Log.i(TAG, "Radio turned off.");
metricEnded(METRIC_RADIO);
diff --git a/services/core/java/com/android/server/rollback/Rollback.java b/services/core/java/com/android/server/rollback/Rollback.java
index 8b79c3f..6898e1c 100644
--- a/services/core/java/com/android/server/rollback/Rollback.java
+++ b/services/core/java/com/android/server/rollback/Rollback.java
@@ -418,6 +418,7 @@
if (isStaged()) {
parentParams.setStaged();
}
+ parentParams.setInstallReason(PackageManager.INSTALL_REASON_ROLLBACK);
int parentSessionId = packageInstaller.createSession(parentParams);
PackageInstaller.Session parentSession = packageInstaller.openSession(
@@ -484,6 +485,7 @@
synchronized (mLock) {
mState = ROLLBACK_STATE_AVAILABLE;
mRestoreUserDataInProgress = false;
+ info.setCommittedSessionId(-1);
}
sendFailure(context, statusReceiver,
RollbackManager.STATUS_FAILURE_INSTALL,
@@ -500,7 +502,6 @@
mRestoreUserDataInProgress = false;
}
- info.setCommittedSessionId(parentSessionId);
info.getCausePackages().addAll(causePackages);
RollbackStore.deletePackageCodePaths(this);
RollbackStore.saveRollback(this);
@@ -528,6 +529,7 @@
);
mState = ROLLBACK_STATE_COMMITTED;
+ info.setCommittedSessionId(parentSessionId);
mRestoreUserDataInProgress = true;
parentSession.commit(receiver.getIntentSender());
} catch (IOException e) {
diff --git a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java
index 3f5e2a4..9324870 100644
--- a/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java
+++ b/services/core/java/com/android/server/rollback/RollbackManagerServiceImpl.java
@@ -897,11 +897,11 @@
}
@Override
- public boolean notifyStagedSession(int sessionId) {
+ public int notifyStagedSession(int sessionId) {
if (Binder.getCallingUid() != Process.SYSTEM_UID) {
throw new SecurityException("notifyStagedSession may only be called by the system.");
}
- final LinkedBlockingQueue<Boolean> result = new LinkedBlockingQueue<>();
+ final LinkedBlockingQueue<Integer> result = new LinkedBlockingQueue<>();
// NOTE: We post this runnable on the RollbackManager's binder thread because we'd prefer
// to preserve the invariant that all operations that modify state happen there.
@@ -911,7 +911,7 @@
final PackageInstaller.SessionInfo session = installer.getSessionInfo(sessionId);
if (session == null) {
Slog.e(TAG, "No matching install session for: " + sessionId);
- result.offer(false);
+ result.offer(-1);
return;
}
@@ -923,7 +923,7 @@
if (!session.isMultiPackage()) {
if (!enableRollbackForPackageSession(newRollback.rollback, session)) {
Slog.e(TAG, "Unable to enable rollback for session: " + sessionId);
- result.offer(false);
+ result.offer(-1);
return;
}
} else {
@@ -932,25 +932,30 @@
installer.getSessionInfo(childSessionId);
if (childSession == null) {
Slog.e(TAG, "No matching child install session for: " + childSessionId);
- result.offer(false);
+ result.offer(-1);
return;
}
if (!enableRollbackForPackageSession(newRollback.rollback, childSession)) {
Slog.e(TAG, "Unable to enable rollback for session: " + sessionId);
- result.offer(false);
+ result.offer(-1);
return;
}
}
}
- result.offer(completeEnableRollback(newRollback, true) != null);
+ Rollback rollback = completeEnableRollback(newRollback, true);
+ if (rollback == null) {
+ result.offer(-1);
+ } else {
+ result.offer(rollback.info.getRollbackId());
+ }
});
try {
return result.take();
} catch (InterruptedException ie) {
Slog.e(TAG, "Interrupted while waiting for notifyStagedSession response");
- return false;
+ return -1;
}
}
diff --git a/services/core/java/com/android/server/storage/StorageSessionController.java b/services/core/java/com/android/server/storage/StorageSessionController.java
index 46dd366..aa3ab63 100644
--- a/services/core/java/com/android/server/storage/StorageSessionController.java
+++ b/services/core/java/com/android/server/storage/StorageSessionController.java
@@ -308,34 +308,6 @@
}
/**
- * Throws an {@link IllegalStateException} if {@code path} is not ready to be accessed by
- * {@code userId}.
- */
- // TODO(b/144332951): This is not used because it is racy. Right after checking a path
- // we can call into vold with that path and the FUSE daemon can go down. Improve or remove
- public void checkPathReadyForUser(int userId, String path) {
- if (!mIsFuseEnabled) {
- return;
- }
-
- if (mIsResetting) {
- throw new IllegalStateException("Connection resetting for user " + userId
- + " with path " + path);
- }
-
- StorageUserConnection connection = null;
- synchronized (mLock) {
- connection = mConnections.get(userId);
- }
-
- if (connection == null) {
- throw new IllegalStateException("Connection not ready for user " + userId
- + " with path " + path);
- }
- connection.checkPathReady(path);
- }
-
- /**
* Returns {@code true} if {@code vol} is an emulated or public volume,
* {@code false} otherwise
**/
diff --git a/services/core/java/com/android/server/storage/StorageUserConnection.java b/services/core/java/com/android/server/storage/StorageUserConnection.java
index 5c44eee..10514ad 100644
--- a/services/core/java/com/android/server/storage/StorageUserConnection.java
+++ b/services/core/java/com/android/server/storage/StorageUserConnection.java
@@ -163,20 +163,6 @@
mActiveConnection.close();
}
- /** Throws an {@link IllegalArgumentException} if {@code path} is not ready for access */
- public void checkPathReady(String path) {
- synchronized (mLock) {
- for (Session session : mSessions.values()) {
- if (session.upperPath != null && path.startsWith(session.upperPath)) {
- if (mActiveConnection.isActiveLocked(session)) {
- return;
- }
- }
- }
- throw new IllegalStateException("Path not ready " + path);
- }
- }
-
/** Returns all created sessions. */
public Set<String> getAllSessionIds() {
synchronized (mLock) {
diff --git a/services/core/java/com/android/server/timedetector/TimeDetectorStrategyImpl.java b/services/core/java/com/android/server/timedetector/TimeDetectorStrategyImpl.java
index 8441edb..1b1ac6d 100644
--- a/services/core/java/com/android/server/timedetector/TimeDetectorStrategyImpl.java
+++ b/services/core/java/com/android/server/timedetector/TimeDetectorStrategyImpl.java
@@ -114,16 +114,10 @@
}
@Override
- public synchronized void suggestManualTime(ManualTimeSuggestion suggestion) {
+ public synchronized void suggestManualTime(@NonNull ManualTimeSuggestion suggestion) {
final TimestampedValue<Long> newUtcTime = suggestion.getUtcTime();
- // We can validate the suggestion against the reference time clock.
- long elapsedRealtimeMillis = mCallback.elapsedRealtimeMillis();
- if (elapsedRealtimeMillis < newUtcTime.getReferenceTimeMillis()) {
- // elapsedRealtime clock went backwards?
- Slog.w(LOG_TAG, "New reference time is in the future? Ignoring."
- + " elapsedRealtimeMillis=" + elapsedRealtimeMillis
- + ", timeSuggestion=" + suggestion);
+ if (!validateSuggestionTime(newUtcTime, suggestion)) {
return;
}
@@ -202,62 +196,76 @@
}
@GuardedBy("this")
- private boolean validateAndStorePhoneSuggestion(@NonNull PhoneTimeSuggestion timeSuggestion) {
- if (timeSuggestion.getUtcTime().getValue() == null) {
- Slog.w(LOG_TAG, "Suggestion utcTime contains null value"
- + " timeSuggestion=" + timeSuggestion);
+ private boolean validateAndStorePhoneSuggestion(@NonNull PhoneTimeSuggestion suggestion) {
+ TimestampedValue<Long> newUtcTime = suggestion.getUtcTime();
+ if (!validateSuggestionTime(newUtcTime, suggestion)) {
+ // There's probably nothing useful we can do: elsewhere we assume that reference
+ // times are in the past so just stop here.
return false;
}
- int phoneId = timeSuggestion.getPhoneId();
+ int phoneId = suggestion.getPhoneId();
LinkedList<PhoneTimeSuggestion> phoneSuggestions = mSuggestionByPhoneId.get(phoneId);
if (phoneSuggestions == null) {
// The first time we've seen this phoneId.
phoneSuggestions = new LinkedList<>();
mSuggestionByPhoneId.put(phoneId, phoneSuggestions);
} else if (phoneSuggestions.isEmpty()) {
- Slog.w(LOG_TAG, "Suggestions unexpectedly empty when adding"
- + " timeSuggestion=" + timeSuggestion);
+ Slog.w(LOG_TAG, "Suggestions unexpectedly empty when adding suggestion=" + suggestion);
}
if (!phoneSuggestions.isEmpty()) {
- PhoneTimeSuggestion previousSuggestion = phoneSuggestions.getFirst();
-
// We can log / discard suggestions with obvious issues with the reference time clock.
- long elapsedRealtimeMillis = mCallback.elapsedRealtimeMillis();
- TimestampedValue<Long> newTime = timeSuggestion.getUtcTime();
- if (elapsedRealtimeMillis < newTime.getReferenceTimeMillis()) {
- // elapsedRealtime clock went backwards?
- Slog.w(LOG_TAG, "New reference time is in the future?"
- + " elapsedRealtimeMillis=" + elapsedRealtimeMillis
- + ", timeSuggestion=" + timeSuggestion);
- // There's probably nothing useful we can do: elsewhere we assume that reference
- // times are in the past so just stop here.
+ PhoneTimeSuggestion previousSuggestion = phoneSuggestions.getFirst();
+ if (previousSuggestion == null
+ || previousSuggestion.getUtcTime() == null
+ || previousSuggestion.getUtcTime().getValue() == null) {
+ // This should be impossible given we only store validated suggestions.
+ Slog.w(LOG_TAG, "Previous suggestion is null or has a null time."
+ + " previousSuggestion=" + previousSuggestion
+ + ", suggestion=" + suggestion);
return false;
}
- if (previousSuggestion.getUtcTime() != null) {
- long referenceTimeDifference = TimestampedValue.referenceTimeDifference(
- timeSuggestion.getUtcTime(), previousSuggestion.getUtcTime());
- if (referenceTimeDifference < 0) {
- // The reference time is before the previously received suggestion. Ignore it.
- Slog.w(LOG_TAG, "Out of order phone suggestion received."
- + " referenceTimeDifference=" + referenceTimeDifference
- + " lastSuggestion=" + previousSuggestion
- + " newSuggestion=" + timeSuggestion);
- return false;
- }
+ long referenceTimeDifference = TimestampedValue.referenceTimeDifference(
+ newUtcTime, previousSuggestion.getUtcTime());
+ if (referenceTimeDifference < 0) {
+ // The reference time is before the previously received suggestion. Ignore it.
+ Slog.w(LOG_TAG, "Out of order phone suggestion received."
+ + " referenceTimeDifference=" + referenceTimeDifference
+ + " previousSuggestion=" + previousSuggestion
+ + " suggestion=" + suggestion);
+ return false;
}
}
// Store the latest suggestion.
- phoneSuggestions.addFirst(timeSuggestion);
+ phoneSuggestions.addFirst(suggestion);
if (phoneSuggestions.size() > KEEP_SUGGESTION_HISTORY_SIZE) {
phoneSuggestions.removeLast();
}
return true;
}
+ private boolean validateSuggestionTime(
+ @NonNull TimestampedValue<Long> newUtcTime, @NonNull Object suggestion) {
+ if (newUtcTime.getValue() == null) {
+ Slog.w(LOG_TAG, "Suggested time value is null. suggestion=" + suggestion);
+ return false;
+ }
+
+ // We can validate the suggestion against the reference time clock.
+ long elapsedRealtimeMillis = mCallback.elapsedRealtimeMillis();
+ if (elapsedRealtimeMillis < newUtcTime.getReferenceTimeMillis()) {
+ // elapsedRealtime clock went backwards?
+ Slog.w(LOG_TAG, "New reference time is in the future? Ignoring."
+ + " elapsedRealtimeMillis=" + elapsedRealtimeMillis
+ + ", suggestion=" + suggestion);
+ return false;
+ }
+ return true;
+ }
+
@GuardedBy("this")
private void doAutoTimeDetection(@NonNull String detectionReason) {
if (!mCallback.isAutoTimeDetectionEnabled()) {
diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java
old mode 100644
new mode 100755
index 8e66b14..18ed51a
--- a/services/core/java/com/android/server/tv/TvInputManagerService.java
+++ b/services/core/java/com/android/server/tv/TvInputManagerService.java
@@ -2943,6 +2943,16 @@
if (state != null) {
setStateLocked(inputId, state, mCurrentUserId);
}
+ UserState userState = getOrCreateUserStateLocked(mCurrentUserId);
+ // Broadcast the event to all hardware inputs.
+ for (ServiceState serviceState : userState.serviceStateMap.values()) {
+ if (!serviceState.isHardware || serviceState.service == null) continue;
+ try {
+ serviceState.service.notifyHdmiDeviceUpdated(deviceInfo);
+ } catch (RemoteException e) {
+ Slog.e(TAG, "error in notifyHdmiDeviceUpdated", e);
+ }
+ }
}
}
}
diff --git a/services/core/java/com/android/server/wm/ActivityDisplay.java b/services/core/java/com/android/server/wm/ActivityDisplay.java
deleted file mode 100644
index 35b64e7..0000000
--- a/services/core/java/com/android/server/wm/ActivityDisplay.java
+++ /dev/null
@@ -1,1384 +0,0 @@
-/*
- * Copyright (C) 2017 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 com.android.server.wm;
-
-import static android.app.ActivityTaskManager.INVALID_STACK_ID;
-import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
-import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
-import static android.app.WindowConfiguration.ROTATION_UNDEFINED;
-import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
-import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
-import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY;
-import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
-import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
-import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
-import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
-import static android.os.Build.VERSION_CODES.N;
-import static android.view.Display.DEFAULT_DISPLAY;
-import static android.view.Display.FLAG_PRIVATE;
-import static android.view.Display.REMOVE_MODE_DESTROY_CONTENT;
-
-import static com.android.server.am.ActivityDisplayProto.DISPLAY;
-import static com.android.server.am.ActivityDisplayProto.FOCUSED_STACK_ID;
-import static com.android.server.am.ActivityDisplayProto.ID;
-import static com.android.server.am.ActivityDisplayProto.RESUMED_ACTIVITY;
-import static com.android.server.am.ActivityDisplayProto.SINGLE_TASK_INSTANCE;
-import static com.android.server.am.ActivityDisplayProto.STACKS;
-import static com.android.server.wm.ActivityStack.ActivityState.RESUMED;
-import static com.android.server.wm.ActivityStack.STACK_VISIBILITY_VISIBLE;
-import static com.android.server.wm.ActivityStackSupervisor.TAG_TASKS;
-import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_STACK;
-import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_STATES;
-import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_TASKS;
-import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_STACK;
-import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;
-import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME;
-import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT;
-import static com.android.server.wm.RootActivityContainer.FindTaskResult;
-import static com.android.server.wm.RootActivityContainer.TAG_STATES;
-import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DISPLAY;
-import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
-import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL;
-
-import android.annotation.Nullable;
-import android.app.ActivityManager;
-import android.app.ActivityManagerInternal;
-import android.app.ActivityOptions;
-import android.app.WindowConfiguration;
-import android.content.pm.ActivityInfo;
-import android.content.res.Configuration;
-import android.graphics.Point;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.UserHandle;
-import android.provider.Settings;
-import android.util.IntArray;
-import android.util.Slog;
-import android.util.proto.ProtoOutputStream;
-import android.view.Display;
-
-import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.util.function.pooled.PooledConsumer;
-import com.android.internal.util.function.pooled.PooledLambda;
-import com.android.internal.util.function.pooled.PooledPredicate;
-import com.android.server.protolog.common.ProtoLog;
-
-import java.io.PrintWriter;
-import java.util.ArrayList;
-
-/**
- * Exactly one of these classes per Display in the system. Capable of holding zero or more
- * attached {@link ActivityStack}s.
- */
-class ActivityDisplay extends DisplayContent {
- private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityDisplay" : TAG_ATM;
- private static final String TAG_STACK = TAG + POSTFIX_STACK;
-
- static final int POSITION_TOP = Integer.MAX_VALUE;
- static final int POSITION_BOTTOM = Integer.MIN_VALUE;
-
- /**
- * Counter for next free stack ID to use for dynamic activity stacks. Unique across displays.
- */
- private static int sNextFreeStackId = 0;
-
- private RootActivityContainer mRootActivityContainer;
- /** Actual Display this object tracks. */
- int mDisplayId;
- Display mDisplay;
-
- /**
- * All of the stacks on this display. Order matters, topmost stack is in front of all other
- * stacks, bottommost behind. Accessed directly by ActivityManager package classes. Any calls
- * changing the list should also call {@link #onStackOrderChanged()}.
- */
- private ArrayList<OnStackOrderChangedListener> mStackOrderChangedCallbacks = new ArrayList<>();
-
- /** Array of all UIDs that are present on the display. */
- private IntArray mDisplayAccessUIDs = new IntArray();
-
- /** All tokens used to put activities on this stack to sleep (including mOffToken) */
- final ArrayList<ActivityTaskManagerInternal.SleepToken> mAllSleepTokens = new ArrayList<>();
- /** The token acquired by ActivityStackSupervisor to put stacks on the display to sleep */
- ActivityTaskManagerInternal.SleepToken mOffToken;
-
- private boolean mSleeping;
-
- /** We started the process of removing the display from the system. */
- private boolean mRemoving;
-
- /**
- * The display is removed from the system and we are just waiting for all activities on it to be
- * finished before removing this object.
- */
- private boolean mRemoved;
-
- /** The display can only contain one task. */
- private boolean mSingleTaskInstance;
-
- /**
- * Non-null if the last size compatibility mode activity is using non-native screen
- * configuration. The activity is not able to put in multi-window mode, so it exists only one
- * per display.
- */
- private ActivityRecord mLastCompatModeActivity;
-
- /**
- * A focusable stack that is purposely to be positioned at the top. Although the stack may not
- * have the topmost index, it is used as a preferred candidate to prevent being unable to resume
- * target stack properly when there are other focusable always-on-top stacks.
- */
- private ActivityStack mPreferredTopFocusableStack;
-
- /**
- * If this is the same as {@link #getFocusedStack} then the activity on the top of the focused
- * stack has been resumed. If stacks are changing position this will hold the old stack until
- * the new stack becomes resumed after which it will be set to current focused stack.
- */
- private ActivityStack mLastFocusedStack;
-
- // Used in updating the display size
- private Point mTmpDisplaySize = new Point();
-
- // Used in updating override configurations
- private final Configuration mTempConfig = new Configuration();
-
- private final FindTaskResult mTmpFindTaskResult = new FindTaskResult();
-
- ActivityDisplay(RootActivityContainer root, Display display) {
- super(display, root.mWindowManager);
- mRootActivityContainer = root;
- mDisplayId = display.getDisplayId();
- mDisplay = display;
-
- if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Adding display=" + display);
-
- mWmService.mDisplayWindowSettings.applySettingsToDisplayLocked(this);
-
- if (mWmService.mDisplayManagerInternal != null) {
- mWmService.mDisplayManagerInternal
- .setDisplayInfoOverrideFromWindowManager(mDisplayId, getDisplayInfo());
- configureDisplayPolicy();
- }
-
- reconfigureDisplayLocked();
- onRequestedOverrideConfigurationChanged(getRequestedOverrideConfiguration());
- mWmService.mDisplayNotificationController.dispatchDisplayAdded(this);
- }
-
- void onDisplayChanged() {
- // The window policy is responsible for stopping activities on the default display.
- final int displayId = mDisplay.getDisplayId();
- if (displayId != DEFAULT_DISPLAY) {
- final int displayState = mDisplay.getState();
- if (displayState == Display.STATE_OFF && mOffToken == null) {
- mOffToken = mAtmService.acquireSleepToken("Display-off", displayId);
- } else if (displayState == Display.STATE_ON && mOffToken != null) {
- mOffToken.release();
- mOffToken = null;
- }
- }
-
- mDisplay.getRealSize(mTmpDisplaySize);
- setBounds(0, 0, mTmpDisplaySize.x, mTmpDisplaySize.y);
- updateDisplayInfo();
- mWmService.requestTraversal();
- }
-
- void addStack(ActivityStack stack, int position) {
- setStackOnDisplay(stack, position);
- positionStackAt(stack, position);
- mAtmService.updateSleepIfNeededLocked();
- }
-
- void onStackRemoved(ActivityStack stack) {
- if (DEBUG_STACK) {
- Slog.v(TAG_STACK, "removeStack: detaching " + stack + " from displayId=" + mDisplayId);
- }
- if (mPreferredTopFocusableStack == stack) {
- mPreferredTopFocusableStack = null;
- }
- releaseSelfIfNeeded();
- mAtmService.updateSleepIfNeededLocked();
- onStackOrderChanged(stack);
- }
-
- void positionStackAtTop(ActivityStack stack, boolean includingParents) {
- positionStackAtTop(stack, includingParents, null /* updateLastFocusedStackReason */);
- }
-
- void positionStackAtTop(ActivityStack stack, boolean includingParents,
- String updateLastFocusedStackReason) {
- positionStackAt(stack, getStackCount(), includingParents, updateLastFocusedStackReason);
- }
-
- void positionStackAtBottom(ActivityStack stack) {
- positionStackAtBottom(stack, null /* updateLastFocusedStackReason */);
- }
-
- void positionStackAtBottom(ActivityStack stack, String updateLastFocusedStackReason) {
- positionStackAt(stack, 0, false /* includingParents */, updateLastFocusedStackReason);
- }
-
- private void positionStackAt(ActivityStack stack, int position) {
- positionStackAt(stack, position, false /* includingParents */,
- null /* updateLastFocusedStackReason */);
- }
-
- private void positionStackAt(ActivityStack stack, int position, boolean includingParents,
- String updateLastFocusedStackReason) {
- // TODO: Keep in sync with WindowContainer.positionChildAt(), once we change that to adjust
- // the position internally, also update the logic here
- final ActivityStack prevFocusedStack = updateLastFocusedStackReason != null
- ? getFocusedStack() : null;
- final boolean wasContained = getIndexOf(stack) >= 0;
- if (mSingleTaskInstance && getStackCount() == 1 && !wasContained) {
- throw new IllegalStateException(
- "positionStackAt: Can only have one task on display=" + this);
- }
-
- // Since positionChildAt() is called during the creation process of pinned stacks,
- // ActivityStack#getStack() can be null.
- positionStackAt(position, stack, includingParents);
-
- // The insert position may be adjusted to non-top when there is always-on-top stack. Since
- // the original position is preferred to be top, the stack should have higher priority when
- // we are looking for top focusable stack. The condition {@code wasContained} restricts the
- // preferred stack is set only when moving an existing stack to top instead of adding a new
- // stack that may be too early (e.g. in the middle of launching or reparenting).
- if (wasContained && position >= getStackCount() - 1 && stack.isFocusableAndVisible()) {
- mPreferredTopFocusableStack = stack;
- } else if (mPreferredTopFocusableStack == stack) {
- mPreferredTopFocusableStack = null;
- }
-
- if (updateLastFocusedStackReason != null) {
- final ActivityStack currentFocusedStack = getFocusedStack();
- if (currentFocusedStack != prevFocusedStack) {
- mLastFocusedStack = prevFocusedStack;
- EventLogTags.writeWmFocusedStack(mRootActivityContainer.mCurrentUser, mDisplayId,
- currentFocusedStack == null ? -1 : currentFocusedStack.getStackId(),
- mLastFocusedStack == null ? -1 : mLastFocusedStack.getStackId(),
- updateLastFocusedStackReason);
- }
- }
-
- onStackOrderChanged(stack);
- }
-
- ActivityStack getStack(int stackId) {
- for (int i = getStackCount() - 1; i >= 0; --i) {
- final ActivityStack stack = getStackAt(i);
- if (stack.mStackId == stackId) {
- return stack;
- }
- }
- return null;
- }
-
- boolean alwaysCreateStack(int windowingMode, int activityType) {
- // Always create a stack for fullscreen, freeform, and split-screen-secondary windowing
- // modes so that we can manage visual ordering and return types correctly.
- return activityType == ACTIVITY_TYPE_STANDARD
- && (windowingMode == WINDOWING_MODE_FULLSCREEN
- || windowingMode == WINDOWING_MODE_FREEFORM
- || windowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY);
- }
-
- /**
- * Returns an existing stack compatible with the windowing mode and activity type or creates one
- * if a compatible stack doesn't exist.
- * @see #getStack(int, int)
- * @see #createStack(int, int, boolean)
- */
- ActivityStack getOrCreateStack(int windowingMode, int activityType,
- boolean onTop) {
- if (!alwaysCreateStack(windowingMode, activityType)) {
- ActivityStack stack = getStack(windowingMode, activityType);
- if (stack != null) {
- return stack;
- }
- }
- return createStack(windowingMode, activityType, onTop);
- }
-
- /**
- * Returns an existing stack compatible with the input params or creates one
- * if a compatible stack doesn't exist.
- * @see #getOrCreateStack(int, int, boolean)
- */
- ActivityStack getOrCreateStack(@Nullable ActivityRecord r,
- @Nullable ActivityOptions options, @Nullable Task candidateTask, int activityType,
- boolean onTop) {
- // First preference is the windowing mode in the activity options if set.
- int windowingMode = (options != null)
- ? options.getLaunchWindowingMode() : WINDOWING_MODE_UNDEFINED;
- // Validate that our desired windowingMode will work under the current conditions.
- // UNDEFINED windowing mode is a valid result and means that the new stack will inherit
- // it's display's windowing mode.
- windowingMode = validateWindowingMode(windowingMode, r, candidateTask, activityType);
- return getOrCreateStack(windowingMode, activityType, onTop);
- }
-
- @VisibleForTesting
- int getNextStackId() {
- return sNextFreeStackId++;
- }
-
- /**
- * Creates a stack matching the input windowing mode and activity type on this display.
- * @param windowingMode The windowing mode the stack should be created in. If
- * {@link WindowConfiguration#WINDOWING_MODE_UNDEFINED} then the stack will
- * inherit it's parent's windowing mode.
- * @param activityType The activityType the stack should be created in. If
- * {@link WindowConfiguration#ACTIVITY_TYPE_UNDEFINED} then the stack will
- * be created in {@link WindowConfiguration#ACTIVITY_TYPE_STANDARD}.
- * @param onTop If true the stack will be created at the top of the display, else at the bottom.
- * @return The newly created stack.
- */
- ActivityStack createStack(int windowingMode, int activityType, boolean onTop) {
-
- if (mSingleTaskInstance && getStackCount() > 0) {
- // Create stack on default display instead since this display can only contain 1 stack.
- // TODO: Kinda a hack, but better that having the decision at each call point. Hoping
- // this goes away once ActivityView is no longer using virtual displays.
- return mRootActivityContainer.getDefaultDisplay().createStack(
- windowingMode, activityType, onTop);
- }
-
- if (activityType == ACTIVITY_TYPE_UNDEFINED) {
- // Can't have an undefined stack type yet...so re-map to standard. Anyone that wants
- // anything else should be passing it in anyways...
- activityType = ACTIVITY_TYPE_STANDARD;
- }
-
- if (activityType != ACTIVITY_TYPE_STANDARD) {
- // For now there can be only one stack of a particular non-standard activity type on a
- // display. So, get that ignoring whatever windowing mode it is currently in.
- ActivityStack stack = getStack(WINDOWING_MODE_UNDEFINED, activityType);
- if (stack != null) {
- throw new IllegalArgumentException("Stack=" + stack + " of activityType="
- + activityType + " already on display=" + this + ". Can't have multiple.");
- }
- }
-
- if (!isWindowingModeSupported(windowingMode, mAtmService.mSupportsMultiWindow,
- mAtmService.mSupportsSplitScreenMultiWindow,
- mAtmService.mSupportsFreeformWindowManagement,
- mAtmService.mSupportsPictureInPicture, activityType)) {
- throw new IllegalArgumentException("Can't create stack for unsupported windowingMode="
- + windowingMode);
- }
-
- final int stackId = getNextStackId();
- return createStackUnchecked(windowingMode, activityType, stackId, onTop);
- }
-
- @VisibleForTesting
- ActivityStack createStackUnchecked(int windowingMode, int activityType,
- int stackId, boolean onTop) {
- if (windowingMode == WINDOWING_MODE_PINNED && activityType != ACTIVITY_TYPE_STANDARD) {
- throw new IllegalArgumentException("Stack with windowing mode cannot with non standard "
- + "activity type.");
- }
- return new ActivityStack(this, stackId,
- mRootActivityContainer.mStackSupervisor, windowingMode, activityType, onTop);
- }
-
- /**
- * Get the preferred focusable stack in priority. If the preferred stack does not exist, find a
- * focusable and visible stack from the top of stacks in this display.
- */
- ActivityStack getFocusedStack() {
- if (mPreferredTopFocusableStack != null) {
- return mPreferredTopFocusableStack;
- }
-
- for (int i = getStackCount() - 1; i >= 0; --i) {
- final ActivityStack stack = getStackAt(i);
- if (stack.isFocusableAndVisible()) {
- return stack;
- }
- }
-
- return null;
- }
-
- ActivityStack getNextFocusableStack(ActivityStack currentFocus, boolean ignoreCurrent) {
- final int currentWindowingMode = currentFocus != null
- ? currentFocus.getWindowingMode() : WINDOWING_MODE_UNDEFINED;
-
- ActivityStack candidate = null;
- for (int i = getStackCount() - 1; i >= 0; --i) {
- final ActivityStack stack = getStackAt(i);
- if (ignoreCurrent && stack == currentFocus) {
- continue;
- }
- if (!stack.isFocusableAndVisible()) {
- continue;
- }
-
- if (currentWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY
- && candidate == null && stack.inSplitScreenPrimaryWindowingMode()) {
- // If the currently focused stack is in split-screen secondary we save off the
- // top primary split-screen stack as a candidate for focus because we might
- // prefer focus to move to an other stack to avoid primary split-screen stack
- // overlapping with a fullscreen stack when a fullscreen stack is higher in z
- // than the next split-screen stack. Assistant stack, I am looking at you...
- // We only move the focus to the primary-split screen stack if there isn't a
- // better alternative.
- candidate = stack;
- continue;
- }
- if (candidate != null && stack.inSplitScreenSecondaryWindowingMode()) {
- // Use the candidate stack since we are now at the secondary split-screen.
- return candidate;
- }
- return stack;
- }
- return candidate;
- }
-
- ActivityRecord getResumedActivity() {
- final ActivityStack focusedStack = getFocusedStack();
- if (focusedStack == null) {
- return null;
- }
- // TODO(b/111541062): Move this into ActivityStack#getResumedActivity()
- // Check if the focused stack has the resumed activity
- ActivityRecord resumedActivity = focusedStack.getResumedActivity();
- if (resumedActivity == null || resumedActivity.app == null) {
- // If there is no registered resumed activity in the stack or it is not running -
- // try to use previously resumed one.
- resumedActivity = focusedStack.mPausingActivity;
- if (resumedActivity == null || resumedActivity.app == null) {
- // If previously resumed activity doesn't work either - find the topmost running
- // activity that can be focused.
- resumedActivity = focusedStack.topRunningActivity(true /* focusableOnly */);
- }
- }
- return resumedActivity;
- }
-
- ActivityStack getLastFocusedStack() {
- return mLastFocusedStack;
- }
-
- boolean allResumedActivitiesComplete() {
- for (int stackNdx = getStackCount() - 1; stackNdx >= 0; --stackNdx) {
- final ActivityRecord r = getStackAt(stackNdx).getResumedActivity();
- if (r != null && !r.isState(RESUMED)) {
- return false;
- }
- }
- final ActivityStack currentFocusedStack = getFocusedStack();
- if (DEBUG_STACK) {
- Slog.d(TAG_STACK, "allResumedActivitiesComplete: mLastFocusedStack changing from="
- + mLastFocusedStack + " to=" + currentFocusedStack);
- }
- mLastFocusedStack = currentFocusedStack;
- return true;
- }
-
- /**
- * Pause all activities in either all of the stacks or just the back stacks. This is done before
- * resuming a new activity and to make sure that previously active activities are
- * paused in stacks that are no longer visible or in pinned windowing mode. This does not
- * pause activities in visible stacks, so if an activity is launched within the same stack/task,
- * then we should explicitly pause that stack's top activity.
- * @param userLeaving Passed to pauseActivity() to indicate whether to call onUserLeaving().
- * @param resuming The resuming activity.
- * @return {@code true} if any activity was paused as a result of this call.
- */
- boolean pauseBackStacks(boolean userLeaving, ActivityRecord resuming) {
- boolean someActivityPaused = false;
- for (int stackNdx = getStackCount() - 1; stackNdx >= 0; --stackNdx) {
- final ActivityStack stack = getStackAt(stackNdx);
- final ActivityRecord resumedActivity = stack.getResumedActivity();
- if (resumedActivity != null
- && (stack.getVisibility(resuming) != STACK_VISIBILITY_VISIBLE
- || !stack.isFocusable())) {
- if (DEBUG_STATES) Slog.d(TAG_STATES, "pauseBackStacks: stack=" + stack +
- " mResumedActivity=" + resumedActivity);
- someActivityPaused |= stack.startPausingLocked(userLeaving, false /* uiSleeping*/,
- resuming);
- }
- }
- return someActivityPaused;
- }
-
- /**
- * Find task for putting the Activity in.
- */
- void findTaskLocked(final ActivityRecord r, final boolean isPreferredDisplay,
- FindTaskResult result) {
- mTmpFindTaskResult.clear();
- for (int stackNdx = getStackCount() - 1; stackNdx >= 0; --stackNdx) {
- final ActivityStack stack = getStackAt(stackNdx);
- if (!r.hasCompatibleActivityType(stack)) {
- if (DEBUG_TASKS) {
- Slog.d(TAG_TASKS, "Skipping stack: (mismatch activity/stack) " + stack);
- }
- continue;
- }
-
- mTmpFindTaskResult.process(r, stack);
- // It is possible to have tasks in multiple stacks with the same root affinity, so
- // we should keep looking after finding an affinity match to see if there is a
- // better match in another stack. Also, task affinity isn't a good enough reason
- // to target a display which isn't the source of the intent, so skip any affinity
- // matches not on the specified display.
- if (mTmpFindTaskResult.mRecord != null) {
- if (mTmpFindTaskResult.mIdealMatch) {
- result.setTo(mTmpFindTaskResult);
- return;
- } else if (isPreferredDisplay) {
- // Note: since the traversing through the stacks is top down, the floating
- // tasks should always have lower priority than any affinity-matching tasks
- // in the fullscreen stacks
- result.setTo(mTmpFindTaskResult);
- }
- }
- }
- }
-
- /**
- * Removes stacks in the input windowing modes from the system if they are of activity type
- * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
- */
- void removeStacksInWindowingModes(int... windowingModes) {
- if (windowingModes == null || windowingModes.length == 0) {
- return;
- }
-
- // Collect the stacks that are necessary to be removed instead of performing the removal
- // by looping mStacks, so that we don't miss any stacks after the stack size changed or
- // stacks reordered.
- final ArrayList<ActivityStack> stacks = new ArrayList<>();
- for (int j = windowingModes.length - 1 ; j >= 0; --j) {
- final int windowingMode = windowingModes[j];
- for (int i = getStackCount() - 1; i >= 0; --i) {
- final ActivityStack stack = getStackAt(i);
- if (!stack.isActivityTypeStandardOrUndefined()) {
- continue;
- }
- if (stack.getWindowingMode() != windowingMode) {
- continue;
- }
- stacks.add(stack);
- }
- }
-
- for (int i = stacks.size() - 1; i >= 0; --i) {
- mRootActivityContainer.mStackSupervisor.removeStack(stacks.get(i));
- }
- }
-
- void removeStacksWithActivityTypes(int... activityTypes) {
- if (activityTypes == null || activityTypes.length == 0) {
- return;
- }
-
- // Collect the stacks that are necessary to be removed instead of performing the removal
- // by looping mStacks, so that we don't miss any stacks after the stack size changed or
- // stacks reordered.
- final ArrayList<ActivityStack> stacks = new ArrayList<>();
- for (int j = activityTypes.length - 1 ; j >= 0; --j) {
- final int activityType = activityTypes[j];
- for (int i = getStackCount() - 1; i >= 0; --i) {
- final ActivityStack stack = getStackAt(i);
- if (stack.getActivityType() == activityType) {
- stacks.add(stack);
- }
- }
- }
-
- for (int i = stacks.size() - 1; i >= 0; --i) {
- mRootActivityContainer.mStackSupervisor.removeStack(stacks.get(i));
- }
- }
-
- void onSplitScreenModeDismissed() {
- mAtmService.deferWindowLayout();
- try {
- // Adjust the windowing mode of any stack in secondary split-screen to fullscreen.
- for (int i = getStackCount() - 1; i >= 0; --i) {
- final ActivityStack otherStack = getStackAt(i);
- if (!otherStack.inSplitScreenSecondaryWindowingMode()) {
- continue;
- }
- otherStack.setWindowingMode(WINDOWING_MODE_UNDEFINED, false /* animate */,
- false /* showRecents */, false /* enteringSplitScreenMode */,
- true /* deferEnsuringVisibility */, false /* creating */);
- }
- } finally {
- final ActivityStack topFullscreenStack =
- getTopStackInWindowingMode(WINDOWING_MODE_FULLSCREEN);
- final ActivityStack homeStack = getHomeStack();
- if (topFullscreenStack != null && homeStack != null && !isTopStack(homeStack)) {
- // Whenever split-screen is dismissed we want the home stack directly behind the
- // current top fullscreen stack so it shows up when the top stack is finished.
- // TODO: Would be better to use ActivityDisplay.positionChildAt() for this, however
- // ActivityDisplay doesn't have a direct controller to WM side yet. We can switch
- // once we have that.
- homeStack.moveToFront("onSplitScreenModeDismissed");
- topFullscreenStack.moveToFront("onSplitScreenModeDismissed");
- }
- mAtmService.continueWindowLayout();
- }
- }
-
- void onSplitScreenModeActivated() {
- mAtmService.deferWindowLayout();
- try {
- // Adjust the windowing mode of any affected by split-screen to split-screen secondary.
- final ActivityStack splitScreenPrimaryStack = getSplitScreenPrimaryStack();
- for (int i = getStackCount() - 1; i >= 0; --i) {
- final ActivityStack otherStack = getStackAt(i);
- if (otherStack == splitScreenPrimaryStack
- || !otherStack.affectedBySplitScreenResize()) {
- continue;
- }
- otherStack.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_SECONDARY,
- false /* animate */, false /* showRecents */,
- true /* enteringSplitScreenMode */, true /* deferEnsuringVisibility */,
- false /* creating */);
- }
- } finally {
- mAtmService.continueWindowLayout();
- }
- }
-
- /**
- * Returns true if the {@param windowingMode} is supported based on other parameters passed in.
- * @param windowingMode The windowing mode we are checking support for.
- * @param supportsMultiWindow If we should consider support for multi-window mode in general.
- * @param supportsSplitScreen If we should consider support for split-screen multi-window.
- * @param supportsFreeform If we should consider support for freeform multi-window.
- * @param supportsPip If we should consider support for picture-in-picture mutli-window.
- * @param activityType The activity type under consideration.
- * @return true if the windowing mode is supported.
- */
- private boolean isWindowingModeSupported(int windowingMode, boolean supportsMultiWindow,
- boolean supportsSplitScreen, boolean supportsFreeform, boolean supportsPip,
- int activityType) {
-
- if (windowingMode == WINDOWING_MODE_UNDEFINED
- || windowingMode == WINDOWING_MODE_FULLSCREEN) {
- return true;
- }
- if (!supportsMultiWindow) {
- return false;
- }
-
- final int displayWindowingMode = getWindowingMode();
- if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY
- || windowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY) {
- return supportsSplitScreen
- && WindowConfiguration.supportSplitScreenWindowingMode(activityType)
- // Freeform windows and split-screen windows don't mix well, so prevent
- // split windowing modes on freeform displays.
- && displayWindowingMode != WINDOWING_MODE_FREEFORM;
- }
-
- if (!supportsFreeform && windowingMode == WINDOWING_MODE_FREEFORM) {
- return false;
- }
-
- if (!supportsPip && windowingMode == WINDOWING_MODE_PINNED) {
- return false;
- }
- return true;
- }
-
- /**
- * Resolves the windowing mode that an {@link ActivityRecord} would be in if started on this
- * display with the provided parameters.
- *
- * @param r The ActivityRecord in question.
- * @param options Options to start with.
- * @param task The task within-which the activity would start.
- * @param activityType The type of activity to start.
- * @return The resolved (not UNDEFINED) windowing-mode that the activity would be in.
- */
- int resolveWindowingMode(@Nullable ActivityRecord r, @Nullable ActivityOptions options,
- @Nullable Task task, int activityType) {
-
- // First preference if the windowing mode in the activity options if set.
- int windowingMode = (options != null)
- ? options.getLaunchWindowingMode() : WINDOWING_MODE_UNDEFINED;
-
- // If windowing mode is unset, then next preference is the candidate task, then the
- // activity record.
- if (windowingMode == WINDOWING_MODE_UNDEFINED) {
- if (task != null) {
- windowingMode = task.getWindowingMode();
- }
- if (windowingMode == WINDOWING_MODE_UNDEFINED && r != null) {
- windowingMode = r.getWindowingMode();
- }
- if (windowingMode == WINDOWING_MODE_UNDEFINED) {
- // Use the display's windowing mode.
- windowingMode = getWindowingMode();
- }
- }
- windowingMode = validateWindowingMode(windowingMode, r, task, activityType);
- return windowingMode != WINDOWING_MODE_UNDEFINED
- ? windowingMode : WINDOWING_MODE_FULLSCREEN;
- }
-
- /**
- * Check that the requested windowing-mode is appropriate for the specified task and/or activity
- * on this display.
- *
- * @param windowingMode The windowing-mode to validate.
- * @param r The {@link ActivityRecord} to check against.
- * @param task The {@link Task} to check against.
- * @param activityType An activity type.
- * @return The provided windowingMode or the closest valid mode which is appropriate.
- */
- int validateWindowingMode(int windowingMode, @Nullable ActivityRecord r, @Nullable Task task,
- int activityType) {
- // Make sure the windowing mode we are trying to use makes sense for what is supported.
- boolean supportsMultiWindow = mAtmService.mSupportsMultiWindow;
- boolean supportsSplitScreen = mAtmService.mSupportsSplitScreenMultiWindow;
- boolean supportsFreeform = mAtmService.mSupportsFreeformWindowManagement;
- boolean supportsPip = mAtmService.mSupportsPictureInPicture;
- if (supportsMultiWindow) {
- if (task != null) {
- supportsMultiWindow = task.isResizeable();
- supportsSplitScreen = task.supportsSplitScreenWindowingMode();
- // TODO: Do we need to check for freeform and Pip support here?
- } else if (r != null) {
- supportsMultiWindow = r.isResizeable();
- supportsSplitScreen = r.supportsSplitScreenWindowingMode();
- supportsFreeform = r.supportsFreeform();
- supportsPip = r.supportsPictureInPicture();
- }
- }
-
- final boolean inSplitScreenMode = hasSplitScreenPrimaryStack();
- if (!inSplitScreenMode
- && windowingMode == WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY) {
- // Switch to the display's windowing mode if we are not in split-screen mode and we are
- // trying to launch in split-screen secondary.
- windowingMode = WINDOWING_MODE_UNDEFINED;
- } else if (inSplitScreenMode && (windowingMode == WINDOWING_MODE_FULLSCREEN
- || windowingMode == WINDOWING_MODE_UNDEFINED)
- && supportsSplitScreen) {
- windowingMode = WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
- }
-
- if (windowingMode != WINDOWING_MODE_UNDEFINED
- && isWindowingModeSupported(windowingMode, supportsMultiWindow, supportsSplitScreen,
- supportsFreeform, supportsPip, activityType)) {
- return windowingMode;
- }
- return WINDOWING_MODE_UNDEFINED;
- }
-
- boolean isTopStack(ActivityStack stack) {
- return stack == getTopStack();
- }
-
- boolean isTopNotPinnedStack(ActivityStack stack) {
- for (int i = getStackCount() - 1; i >= 0; --i) {
- final ActivityStack current = getStackAt(i);
- if (!current.inPinnedWindowingMode()) {
- return current == stack;
- }
- }
- return false;
- }
-
- ActivityStack getTopStackInWindowingMode(int windowingMode) {
- for (int i = getStackCount() - 1; i >= 0; --i) {
- final ActivityStack current = getStackAt(i);
- if (windowingMode == current.getWindowingMode()) {
- return current;
- }
- }
- return null;
- }
-
- ActivityRecord topRunningActivity() {
- return topRunningActivity(false /* considerKeyguardState */);
- }
-
- /**
- * Returns the top running activity in the focused stack. In the case the focused stack has no
- * such activity, the next focusable stack on this display is returned.
- *
- * @param considerKeyguardState Indicates whether the locked state should be considered. if
- * {@code true} and the keyguard is locked, only activities that
- * can be shown on top of the keyguard will be considered.
- * @return The top running activity. {@code null} if none is available.
- */
- ActivityRecord topRunningActivity(boolean considerKeyguardState) {
- ActivityRecord topRunning = null;
- final ActivityStack focusedStack = getFocusedStack();
- if (focusedStack != null) {
- topRunning = focusedStack.topRunningActivity();
- }
-
- // Look in other focusable stacks.
- if (topRunning == null) {
- for (int i = getStackCount() - 1; i >= 0; --i) {
- final ActivityStack stack = getStackAt(i);
- // Only consider focusable stacks other than the current focused one.
- if (stack == focusedStack || !stack.isFocusable()) {
- continue;
- }
- topRunning = stack.topRunningActivity();
- if (topRunning != null) {
- break;
- }
- }
- }
-
- // This activity can be considered the top running activity if we are not considering
- // the locked state, the keyguard isn't locked, or we can show when locked.
- if (topRunning != null && considerKeyguardState
- && mRootActivityContainer.mStackSupervisor.getKeyguardController().isKeyguardLocked()
- && !topRunning.canShowWhenLocked()) {
- return null;
- }
-
- return topRunning;
- }
-
- boolean updateDisplayOverrideConfigurationLocked() {
- Configuration values = new Configuration();
- computeScreenConfiguration(values);
-
- mAtmService.mH.sendMessage(PooledLambda.obtainMessage(
- ActivityManagerInternal::updateOomLevelsForDisplay, mAtmService.mAmInternal,
- mDisplayId));
-
- Settings.System.clearConfiguration(values);
- updateDisplayOverrideConfigurationLocked(values, null /* starting */,
- false /* deferResume */, mAtmService.mTmpUpdateConfigurationResult);
- return mAtmService.mTmpUpdateConfigurationResult.changes != 0;
- }
-
- /**
- * Updates override configuration specific for the selected display. If no config is provided,
- * new one will be computed in WM based on current display info.
- */
- boolean updateDisplayOverrideConfigurationLocked(Configuration values,
- ActivityRecord starting, boolean deferResume,
- ActivityTaskManagerService.UpdateConfigurationResult result) {
-
- int changes = 0;
- boolean kept = true;
-
- mAtmService.deferWindowLayout();
- try {
- if (values != null) {
- if (mDisplayId == DEFAULT_DISPLAY) {
- // Override configuration of the default display duplicates global config, so
- // we're calling global config update instead for default display. It will also
- // apply the correct override config.
- changes = mAtmService.updateGlobalConfigurationLocked(values,
- false /* initLocale */, false /* persistent */,
- UserHandle.USER_NULL /* userId */, deferResume);
- } else {
- changes = performDisplayOverrideConfigUpdate(values, deferResume);
- }
- }
-
- kept = mAtmService.ensureConfigAndVisibilityAfterUpdate(starting, changes);
- } finally {
- mAtmService.continueWindowLayout();
- }
-
- if (result != null) {
- result.changes = changes;
- result.activityRelaunched = !kept;
- }
- return kept;
- }
-
- int performDisplayOverrideConfigUpdate(Configuration values, boolean deferResume) {
- mTempConfig.setTo(getRequestedOverrideConfiguration());
- final int changes = mTempConfig.updateFrom(values);
- if (changes != 0) {
- Slog.i(TAG, "Override config changes=" + Integer.toHexString(changes) + " "
- + mTempConfig + " for displayId=" + mDisplayId);
- onRequestedOverrideConfigurationChanged(mTempConfig);
-
- final boolean isDensityChange = (changes & ActivityInfo.CONFIG_DENSITY) != 0;
- if (isDensityChange && mDisplayId == DEFAULT_DISPLAY) {
- mAtmService.mAppWarnings.onDensityChanged();
-
- // Post message to start process to avoid possible deadlock of calling into AMS with
- // the ATMS lock held.
- final Message msg = PooledLambda.obtainMessage(
- ActivityManagerInternal::killAllBackgroundProcessesExcept,
- mAtmService.mAmInternal, N,
- ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND);
- mAtmService.mH.sendMessage(msg);
- }
- mWmService.mDisplayNotificationController.dispatchDisplayChanged(
- this, getConfiguration());
- }
- return changes;
- }
-
- @Override
- public void onRequestedOverrideConfigurationChanged(Configuration overrideConfiguration) {
- final int currRotation =
- getRequestedOverrideConfiguration().windowConfiguration.getRotation();
- if (currRotation != ROTATION_UNDEFINED
- && currRotation != overrideConfiguration.windowConfiguration.getRotation()) {
- applyRotationLocked(currRotation,
- overrideConfiguration.windowConfiguration.getRotation());
- }
- super.onRequestedOverrideConfigurationChanged(overrideConfiguration);
- mWmService.setNewDisplayOverrideConfiguration(overrideConfiguration, this);
- mAtmService.addWindowLayoutReasons(
- ActivityTaskManagerService.LAYOUT_REASON_CONFIG_CHANGED);
- }
-
- @Override
- public void onConfigurationChanged(Configuration newParentConfig) {
- // update resources before cascade so that docked/pinned stacks use the correct info
- preOnConfigurationChanged();
- super.onConfigurationChanged(newParentConfig);
- }
-
- /** Checks whether the given activity is in size compatibility mode and notifies the change. */
- void handleActivitySizeCompatModeIfNeeded(ActivityRecord r) {
- if (!r.isState(RESUMED) || r.getWindowingMode() != WINDOWING_MODE_FULLSCREEN) {
- // The callback is only interested in the foreground changes of fullscreen activity.
- return;
- }
- if (!r.inSizeCompatMode()) {
- if (mLastCompatModeActivity != null) {
- mAtmService.getTaskChangeNotificationController()
- .notifySizeCompatModeActivityChanged(mDisplayId, null /* activityToken */);
- }
- mLastCompatModeActivity = null;
- return;
- }
- if (mLastCompatModeActivity == r) {
- return;
- }
- mLastCompatModeActivity = r;
- mAtmService.getTaskChangeNotificationController()
- .notifySizeCompatModeActivityChanged(mDisplayId, r.appToken);
- }
-
- @Override
- public String toString() {
- return "ActivityDisplay={" + mDisplayId + " numStacks=" + getStackCount() + "}";
- }
-
- boolean isPrivate() {
- return (mDisplay.getFlags() & FLAG_PRIVATE) != 0;
- }
-
- boolean isUidPresent(int uid) {
- final PooledPredicate p = PooledLambda.obtainPredicate(
- ActivityRecord::isUid, PooledLambda.__(ActivityRecord.class), uid);
- final boolean isUidPresent = mDisplayContent.getActivity(p) != null;
- p.recycle();
- return isUidPresent;
- }
-
- /**
- * @see #mRemoved
- */
- boolean isRemoved() {
- return mRemoved;
- }
-
- /**
- * @see #mRemoving
- */
- boolean isRemoving() {
- return mRemoving;
- }
-
- void remove() {
- mRemoving = true;
- final boolean destroyContentOnRemoval = shouldDestroyContentOnRemove();
- ActivityStack lastReparentedStack = null;
- mPreferredTopFocusableStack = null;
-
- // Stacks could be reparented from the removed display to other display. While
- // reparenting the last stack of the removed display, the remove display is ready to be
- // released (no more ActivityStack). But, we cannot release it at that moment or the
- // related WindowContainer will also be removed. So, we set display as removed after
- // reparenting stack finished.
- final ActivityDisplay toDisplay = mRootActivityContainer.getDefaultDisplay();
- mRootActivityContainer.mStackSupervisor.beginDeferResume();
- try {
- int numStacks = getStackCount();
- // Keep the order from bottom to top.
- for (int stackNdx = 0; stackNdx < numStacks; stackNdx++) {
- final ActivityStack stack = getStackAt(stackNdx);
- // Always finish non-standard type stacks.
- if (destroyContentOnRemoval || !stack.isActivityTypeStandardOrUndefined()) {
- stack.finishAllActivitiesImmediately();
- } else {
- // If default display is in split-window mode, set windowing mode of the stack
- // to split-screen secondary. Otherwise, set the windowing mode to undefined by
- // default to let stack inherited the windowing mode from the new display.
- final int windowingMode = toDisplay.hasSplitScreenPrimaryStack()
- ? WINDOWING_MODE_SPLIT_SCREEN_SECONDARY
- : WINDOWING_MODE_UNDEFINED;
- stack.reparent(toDisplay, true /* onTop */);
- stack.setWindowingMode(windowingMode);
- lastReparentedStack = stack;
- }
- // Stacks may be removed from this display. Ensure each stack will be processed and
- // the loop will end.
- stackNdx -= numStacks - getStackCount();
- numStacks = getStackCount();
- }
- } finally {
- mRootActivityContainer.mStackSupervisor.endDeferResume();
- }
- mRemoved = true;
-
- // Only update focus/visibility for the last one because there may be many stacks are
- // reparented and the intermediate states are unnecessary.
- if (lastReparentedStack != null) {
- lastReparentedStack.postReparent();
- }
- releaseSelfIfNeeded();
-
- if (!mAllSleepTokens.isEmpty()) {
- mRootActivityContainer.mSleepTokens.removeAll(mAllSleepTokens);
- mAllSleepTokens.clear();
- mAtmService.updateSleepIfNeededLocked();
- }
- }
-
- private void releaseSelfIfNeeded() {
- if (!mRemoved) {
- return;
- }
-
- final ActivityStack stack = getStackCount() == 1 ? getStackAt(0) : null;
- if (stack != null && stack.isActivityTypeHome() && !stack.hasChild()) {
- // Release this display if an empty home stack is the only thing left.
- // Since it is the last stack, this display will be released along with the stack
- // removal.
- stack.removeIfPossible();
- } else if (getTopStack() == null) {
- removeIfPossible();
- mRootActivityContainer.removeChild(this);
- mRootActivityContainer.mStackSupervisor
- .getKeyguardController().onDisplayRemoved(mDisplayId);
- }
- }
-
- /** Update and get all UIDs that are present on the display and have access to it. */
- IntArray getPresentUIDs() {
- mDisplayAccessUIDs.clear();
- final PooledConsumer c = PooledLambda.obtainConsumer(ActivityDisplay::addActivityUid,
- PooledLambda.__(ActivityRecord.class), mDisplayAccessUIDs);
- mDisplayContent.forAllActivities(c);
- c.recycle();
- return mDisplayAccessUIDs;
- }
-
- private static void addActivityUid(ActivityRecord r, IntArray uids) {
- uids.add(r.getUid());
- }
-
- @VisibleForTesting
- boolean shouldDestroyContentOnRemove() {
- return mDisplay.getRemoveMode() == REMOVE_MODE_DESTROY_CONTENT;
- }
-
- boolean shouldSleep() {
- return (getStackCount() == 0 || !mAllSleepTokens.isEmpty())
- && (mAtmService.mRunningVoice == null);
- }
-
- void setFocusedApp(ActivityRecord r, boolean moveFocusNow) {
- final ActivityRecord newFocus;
- final IBinder token = r.appToken;
- if (token == null) {
- ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "Clearing focused app, displayId=%d",
- mDisplayId);
- newFocus = null;
- } else {
- newFocus = mWmService.mRoot.getActivityRecord(token);
- if (newFocus == null) {
- Slog.w(TAG_WM, "Attempted to set focus to non-existing app token: " + token
- + ", displayId=" + mDisplayId);
- }
- ProtoLog.v(WM_DEBUG_FOCUS_LIGHT,
- "Set focused app to: %s moveFocusNow=%b displayId=%d", newFocus,
- moveFocusNow, mDisplayId);
- }
-
- final boolean changed = setFocusedApp(newFocus);
- if (moveFocusNow && changed) {
- mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL,
- true /*updateInputWindows*/);
- }
- }
-
- /**
- * @return the stack currently above the {@param stack}. Can be null if the {@param stack} is
- * already top-most.
- */
- ActivityStack getStackAbove(ActivityStack stack) {
- final int stackIndex = getIndexOf(stack) + 1;
- return (stackIndex < getStackCount()) ? getStackAt(stackIndex) : null;
- }
-
- /**
- * Adjusts the {@param stack} behind the last visible stack in the display if necessary.
- * Generally used in conjunction with {@link #moveStackBehindStack}.
- */
- void moveStackBehindBottomMostVisibleStack(ActivityStack stack) {
- if (stack.shouldBeVisible(null)) {
- // Skip if the stack is already visible
- return;
- }
-
- // Move the stack to the bottom to not affect the following visibility checks
- positionStackAtBottom(stack);
-
- // Find the next position where the stack should be placed
- final int numStacks = getStackCount();
- for (int stackNdx = 0; stackNdx < numStacks; stackNdx++) {
- final ActivityStack s = getStackAt(stackNdx);
- if (s == stack) {
- continue;
- }
- final int winMode = s.getWindowingMode();
- final boolean isValidWindowingMode = winMode == WINDOWING_MODE_FULLSCREEN ||
- winMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
- if (s.shouldBeVisible(null) && isValidWindowingMode) {
- // Move the provided stack to behind this stack
- positionStackAt(stack, Math.max(0, stackNdx - 1));
- break;
- }
- }
- }
-
- /**
- * Moves the {@param stack} behind the given {@param behindStack} if possible. If
- * {@param behindStack} is not currently in the display, then then the stack is moved to the
- * back. Generally used in conjunction with {@link #moveStackBehindBottomMostVisibleStack}.
- */
- void moveStackBehindStack(ActivityStack stack, ActivityStack behindStack) {
- if (behindStack == null || behindStack == stack) {
- return;
- }
-
- // Note that positionChildAt will first remove the given stack before inserting into the
- // list, so we need to adjust the insertion index to account for the removed index
- // TODO: Remove this logic when WindowContainer.positionChildAt() is updated to adjust the
- // position internally
- final int stackIndex = getIndexOf(stack);
- final int behindStackIndex = getIndexOf(behindStack);
- final int insertIndex = stackIndex <= behindStackIndex
- ? behindStackIndex - 1 : behindStackIndex;
- positionStackAt(stack, Math.max(0, insertIndex));
- }
-
- void ensureActivitiesVisible(ActivityRecord starting, int configChanges,
- boolean preserveWindows, boolean notifyClients) {
- for (int stackNdx = getStackCount() - 1; stackNdx >= 0; --stackNdx) {
- final ActivityStack stack = getStackAt(stackNdx);
- stack.ensureActivitiesVisible(starting, configChanges, preserveWindows,
- notifyClients);
- }
- }
-
- void moveHomeStackToFront(String reason) {
- final ActivityStack homeStack = getHomeStack();
- if (homeStack != null) {
- homeStack.moveToFront(reason);
- }
- }
-
- /**
- * Moves the focusable home activity to top. If there is no such activity, the home stack will
- * still move to top.
- */
- void moveHomeActivityToTop(String reason) {
- final ActivityRecord top = getHomeActivity();
- if (top == null) {
- moveHomeStackToFront(reason);
- return;
- }
- top.moveFocusableActivityToTop(reason);
- }
-
- @Nullable
- ActivityRecord getHomeActivity() {
- return getHomeActivityForUser(mRootActivityContainer.mCurrentUser);
- }
-
- @Nullable
- ActivityRecord getHomeActivityForUser(int userId) {
- final ActivityStack homeStack = getHomeStack();
- if (homeStack == null) {
- return null;
- }
-
- final PooledPredicate p = PooledLambda.obtainPredicate(
- ActivityDisplay::isHomeActivityForUser, PooledLambda.__(ActivityRecord.class),
- userId);
- final ActivityRecord r = homeStack.getActivity(p);
- p.recycle();
- return r;
- }
-
- private static boolean isHomeActivityForUser(ActivityRecord r, int userId) {
- return r.isActivityTypeHome() && (userId == UserHandle.USER_ALL || r.mUserId == userId);
- }
-
- boolean isSleeping() {
- return mSleeping;
- }
-
- void setIsSleeping(boolean asleep) {
- mSleeping = asleep;
- }
-
- /**
- * Adds a listener to be notified whenever the stack order in the display changes. Currently
- * only used by the {@link RecentsAnimation} to determine whether to interrupt and cancel the
- * current animation when the system state changes.
- */
- void registerStackOrderChangedListener(OnStackOrderChangedListener listener) {
- if (!mStackOrderChangedCallbacks.contains(listener)) {
- mStackOrderChangedCallbacks.add(listener);
- }
- }
-
- /**
- * Removes a previously registered stack order change listener.
- */
- void unregisterStackOrderChangedListener(OnStackOrderChangedListener listener) {
- mStackOrderChangedCallbacks.remove(listener);
- }
-
- /**
- * Notifies of a stack order change
- * @param stack The stack which triggered the order change
- */
- private void onStackOrderChanged(ActivityStack stack) {
- for (int i = mStackOrderChangedCallbacks.size() - 1; i >= 0; i--) {
- mStackOrderChangedCallbacks.get(i).onStackOrderChanged(stack);
- }
- }
-
- void setDisplayToSingleTaskInstance() {
- final int childCount = getStackCount();
- if (childCount > 1) {
- throw new IllegalArgumentException("Display already has multiple stacks. display="
- + this);
- }
- if (childCount > 0) {
- final ActivityStack stack = getStackAt(0);
- if (stack.getChildCount() > 1) {
- throw new IllegalArgumentException("Display stack already has multiple tasks."
- + " display=" + this + " stack=" + stack);
- }
- }
-
- mSingleTaskInstance = true;
- }
-
- /** Returns true if the display can only contain one task */
- boolean isSingleTaskInstance() {
- return mSingleTaskInstance;
- }
-
- @VisibleForTesting
- void removeAllTasks() {
- mDisplayContent.forAllTasks((t) -> { t.getStack().removeChild(t, "removeAllTasks"); });
- }
-
- public void dump(PrintWriter pw, String prefix) {
- pw.println(prefix + "displayId=" + mDisplayId + " stacks=" + getStackCount()
- + (mSingleTaskInstance ? " mSingleTaskInstance" : ""));
- final String myPrefix = prefix + " ";
- ActivityStack stack = getHomeStack();
- if (stack != null) {
- pw.println(myPrefix + "mHomeStack=" + stack);
- }
- stack = getRecentsStack();
- if (stack != null) {
- pw.println(myPrefix + "mRecentsStack=" + stack);
- }
- stack = getPinnedStack();
- if (stack != null) {
- pw.println(myPrefix + "mPinnedStack=" + stack);
- }
- stack = getSplitScreenPrimaryStack();
- if (stack != null) {
- pw.println(myPrefix + "mSplitScreenPrimaryStack=" + stack);
- }
- if (mPreferredTopFocusableStack != null) {
- pw.println(myPrefix + "mPreferredTopFocusableStack=" + mPreferredTopFocusableStack);
- }
- if (mLastFocusedStack != null) {
- pw.println(myPrefix + "mLastFocusedStack=" + mLastFocusedStack);
- }
- }
-
- public void dumpStacks(PrintWriter pw) {
- for (int i = getStackCount() - 1; i >= 0; --i) {
- pw.print(getStackAt(i).mStackId);
- if (i > 0) {
- pw.print(",");
- }
- }
- }
-
- public void dumpDebug(ProtoOutputStream proto, long fieldId,
- @WindowTraceLogLevel int logLevel) {
- final long token = proto.start(fieldId);
- dumpDebugInner(proto, DISPLAY, logLevel);
- proto.write(ID, mDisplayId);
- proto.write(SINGLE_TASK_INSTANCE, mSingleTaskInstance);
- final ActivityStack focusedStack = getFocusedStack();
- if (focusedStack != null) {
- proto.write(FOCUSED_STACK_ID, focusedStack.mStackId);
- final ActivityRecord focusedActivity = focusedStack.getDisplay().getResumedActivity();
- if (focusedActivity != null) {
- focusedActivity.writeIdentifierToProto(proto, RESUMED_ACTIVITY);
- }
- } else {
- proto.write(FOCUSED_STACK_ID, INVALID_STACK_ID);
- }
- for (int stackNdx = getStackCount() - 1; stackNdx >= 0; --stackNdx) {
- final ActivityStack stack = getStackAt(stackNdx);
- stack.dumpDebug(proto, STACKS, logLevel);
- }
- proto.end(token);
- }
-
- /**
- * Callback for when the order of the stacks in the display changes.
- */
- interface OnStackOrderChangedListener {
- void onStackOrderChanged(ActivityStack stack);
- }
-}
diff --git a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java
index 20d1d1c..c8357e2 100644
--- a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java
+++ b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java
@@ -190,6 +190,8 @@
final int mTransitionType;
/** Whether the process was already running when the transition started. */
final boolean mProcessRunning;
+ /** whether the process of the launching activity didn't have any active activity. */
+ final boolean mProcessSwitch;
/** The activities that should be drawn. */
final LinkedList<ActivityRecord> mPendingDrawActivities = new LinkedList<>();
/** The latest activity to have been launched. */
@@ -218,7 +220,8 @@
/** @return Non-null if there will be a window drawn event for the launch. */
@Nullable
static TransitionInfo create(@NonNull ActivityRecord r,
- @NonNull LaunchingState launchingState, boolean processRunning, int startResult) {
+ @NonNull LaunchingState launchingState, boolean processRunning,
+ boolean processSwitch, int startResult) {
int transitionType = INVALID_TRANSITION_TYPE;
if (processRunning) {
if (startResult == START_SUCCESS) {
@@ -235,16 +238,18 @@
// That means the startResult is neither START_SUCCESS nor START_TASK_TO_FRONT.
return null;
}
- return new TransitionInfo(r, launchingState, transitionType, processRunning);
+ return new TransitionInfo(r, launchingState, transitionType, processRunning,
+ processSwitch);
}
/** Use {@link TransitionInfo#create} instead to ensure the transition type is valid. */
private TransitionInfo(ActivityRecord r, LaunchingState launchingState, int transitionType,
- boolean processRunning) {
+ boolean processRunning, boolean processSwitch) {
mLaunchingState = launchingState;
mTransitionStartTimeNs = launchingState.mCurrentTransitionStartTimeNs;
mTransitionType = transitionType;
mProcessRunning = processRunning;
+ mProcessSwitch = processSwitch;
mCurrentTransitionDeviceUptime =
(int) TimeUnit.MILLISECONDS.toSeconds(SystemClock.uptimeMillis());
setLatestLaunchedActivity(r);
@@ -282,6 +287,14 @@
return mPendingDrawActivities.isEmpty();
}
+ /**
+ * @return {@code true} if the transition info should be sent to MetricsLogger, StatsLog, or
+ * LaunchObserver.
+ */
+ boolean isInterestingToLoggerAndObserver() {
+ return mProcessSwitch;
+ }
+
int calculateCurrentDelay() {
return calculateDelay(SystemClock.elapsedRealtimeNanos());
}
@@ -540,13 +553,8 @@
return;
}
- if (!processSwitch) {
- abort(info, "not a process switch");
- return;
- }
-
final TransitionInfo newInfo = TransitionInfo.create(launchedActivity, launchingState,
- processRunning, resultCode);
+ processRunning, processSwitch, resultCode);
if (newInfo == null) {
abort(info, "unrecognized launch");
return;
@@ -557,7 +565,12 @@
mTransitionInfoList.add(newInfo);
mLastTransitionInfo.put(launchedActivity, newInfo);
startLaunchTrace(newInfo);
- launchObserverNotifyActivityLaunched(newInfo);
+ if (newInfo.isInterestingToLoggerAndObserver()) {
+ launchObserverNotifyActivityLaunched(newInfo);
+ } else {
+ // As abort for no process switch.
+ launchObserverNotifyIntentFailed();
+ }
}
/**
@@ -733,7 +746,9 @@
launchObserverNotifyActivityLaunchCancelled(info);
} else {
logAppTransitionFinished(info);
- launchObserverNotifyActivityLaunchFinished(info, timestampNs);
+ if (info.isInterestingToLoggerAndObserver()) {
+ launchObserverNotifyActivityLaunchFinished(info, timestampNs);
+ }
}
info.mPendingDrawActivities.clear();
mTransitionInfoList.remove(info);
@@ -768,8 +783,11 @@
// Take a snapshot of the transition info before sending it to the handler for logging.
// This will avoid any races with other operations that modify the ActivityRecord.
final TransitionInfoSnapshot infoSnapshot = new TransitionInfoSnapshot(info);
- BackgroundThread.getHandler().post(() -> logAppTransition(
- info.mCurrentTransitionDeviceUptime, info.mCurrentTransitionDelayMs, infoSnapshot));
+ if (info.isInterestingToLoggerAndObserver()) {
+ BackgroundThread.getHandler().post(() -> logAppTransition(
+ info.mCurrentTransitionDeviceUptime, info.mCurrentTransitionDelayMs,
+ infoSnapshot));
+ }
BackgroundThread.getHandler().post(() -> logAppDisplayed(infoSnapshot));
if (info.mPendingFullyDrawn != null) {
info.mPendingFullyDrawn.run();
@@ -905,6 +923,18 @@
return null;
}
+ final long currentTimestampNs = SystemClock.elapsedRealtimeNanos();
+ final long startupTimeMs = info.mPendingFullyDrawn != null
+ ? info.mWindowsDrawnDelayMs
+ : TimeUnit.NANOSECONDS.toMillis(currentTimestampNs - info.mTransitionStartTimeNs);
+ final TransitionInfoSnapshot infoSnapshot =
+ new TransitionInfoSnapshot(info, r, (int) startupTimeMs);
+ BackgroundThread.getHandler().post(() -> logAppFullyDrawn(infoSnapshot));
+
+ if (!info.isInterestingToLoggerAndObserver()) {
+ return infoSnapshot;
+ }
+
// Record the handling of the reportFullyDrawn callback in the trace system. This is not
// actually used to trace this function, but instead the logical task that this function
// fullfils (handling reportFullyDrawn() callbacks).
@@ -914,10 +944,6 @@
final LogMaker builder = new LogMaker(APP_TRANSITION_REPORTED_DRAWN);
builder.setPackageName(r.packageName);
builder.addTaggedData(FIELD_CLASS_NAME, r.info.name);
- final long currentTimestampNs = SystemClock.elapsedRealtimeNanos();
- final long startupTimeMs = info.mPendingFullyDrawn != null
- ? info.mWindowsDrawnDelayMs
- : TimeUnit.NANOSECONDS.toMillis(currentTimestampNs - info.mTransitionStartTimeNs);
builder.addTaggedData(APP_TRANSITION_REPORTED_DRAWN_MS, startupTimeMs);
builder.setType(restoredFromBundle
? TYPE_TRANSITION_REPORTED_DRAWN_WITH_BUNDLE
@@ -940,10 +966,6 @@
// the trace slice to have a noticable duration.
Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
- final TransitionInfoSnapshot infoSnapshot =
- new TransitionInfoSnapshot(info, r, (int) startupTimeMs);
- BackgroundThread.getHandler().post(() -> logAppFullyDrawn(infoSnapshot));
-
// Notify reportFullyDrawn event.
launchObserverNotifyReportFullyDrawn(r, currentTimestampNs);
@@ -1069,7 +1091,8 @@
return;
}
info.mLaunchTraceName = "launching: " + info.mLastLaunchedActivity.packageName;
- Trace.asyncTraceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, info.mLaunchTraceName, 0);
+ Trace.asyncTraceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, info.mLaunchTraceName,
+ (int) info.mTransitionStartTimeNs /* cookie */);
}
/** Stops trace for the launch is completed or cancelled. */
@@ -1078,7 +1101,8 @@
if (info.mLaunchTraceName == null) {
return;
}
- Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, info.mLaunchTraceName, 0);
+ Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, info.mLaunchTraceName,
+ (int) info.mTransitionStartTimeNs /* cookie */);
info.mLaunchTraceName = null;
}
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 4e39dae..6bfa1ae 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -1640,6 +1640,17 @@
allowTaskSnapshot, activityCreated, fromRecents, snapshot);
if (type == STARTING_WINDOW_TYPE_SNAPSHOT) {
+ if (isActivityTypeHome()) {
+ // The snapshot of home is only used once because it won't be updated while screen
+ // is on (see {@link TaskSnapshotController#screenTurningOff}).
+ mWmService.mTaskSnapshotController.removeSnapshotCache(task.mTaskId);
+ // TODO(b/9684093): Use more general condition to specify the case.
+ if (mDisplayContent.mAppTransition
+ .getAppTransition() != WindowManager.TRANSIT_KEYGUARD_GOING_AWAY) {
+ // Only use snapshot of home as starting window when unlocking.
+ return false;
+ }
+ }
return createSnapshot(snapshot);
}
@@ -1800,12 +1811,7 @@
} else if (newTask || !processRunning || (taskSwitch && !activityCreated)) {
return STARTING_WINDOW_TYPE_SPLASH_SCREEN;
} else if (taskSwitch && allowTaskSnapshot) {
- if (mWmService.mLowRamTaskSnapshotsAndRecents) {
- // For low RAM devices, we use the splash screen starting window instead of the
- // task snapshot starting window.
- return STARTING_WINDOW_TYPE_SPLASH_SCREEN;
- }
- return snapshot == null ? STARTING_WINDOW_TYPE_NONE
+ return snapshot == null ? STARTING_WINDOW_TYPE_SPLASH_SCREEN
: snapshotOrientationSameAsTask(snapshot) || fromRecents
? STARTING_WINDOW_TYPE_SNAPSHOT : STARTING_WINDOW_TYPE_SPLASH_SCREEN;
} else {
@@ -1996,7 +2002,7 @@
return getActivityStack() != null ? getActivityStack().mStackId : INVALID_STACK_ID;
}
- ActivityDisplay getDisplay() {
+ DisplayContent getDisplay() {
final ActivityStack stack = getActivityStack();
return stack != null ? stack.getDisplay() : null;
}
@@ -2153,7 +2159,7 @@
boolean isKeyguardLocked = mAtmService.isKeyguardLocked();
boolean isCurrentAppLocked =
mAtmService.getLockTaskModeState() != LOCK_TASK_MODE_NONE;
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
boolean hasPinnedStack = display != null && display.hasPinnedStack();
// Don't return early if !isNotLocked, since we want to throw an exception if the activity
// is in an incorrect state
@@ -2217,11 +2223,15 @@
return (info.flags & FLAG_ALWAYS_FOCUSABLE) != 0;
}
+ boolean windowsAreFocusable() {
+ return windowsAreFocusable(false /* fromUserTouch */);
+ }
+
// TODO: Does this really need to be different from isAlwaysFocusable()? For the activity side
// focusable means resumeable. I guess with that in mind maybe we should rename the other
// method to isResumeable() or something like that.
- boolean windowsAreFocusable() {
- if (mTargetSdk < Build.VERSION_CODES.Q) {
+ boolean windowsAreFocusable(boolean fromUserTouch) {
+ if (!fromUserTouch && mTargetSdk < Build.VERSION_CODES.Q) {
final int pid = getPid();
final ActivityRecord topFocusedAppOfMyProcess =
mWmService.mRoot.mTopFocusedAppByProcess.get(pid);
@@ -2235,7 +2245,12 @@
&& getDisplay() != null;
}
- /** Move activity with its stack to front and make the stack focused. */
+ /**
+ * Move activity with its stack to front and make the stack focused.
+ * @param reason the reason to move to top
+ * @return {@code true} if the stack is focusable and has been moved to top or the activity
+ * is not yet resumed while the stack is already on top, {@code false} otherwise.
+ */
boolean moveFocusableActivityToTop(String reason) {
if (!isFocusable()) {
if (DEBUG_FOCUS) {
@@ -2256,7 +2271,7 @@
if (DEBUG_FOCUS) {
Slog.d(TAG_FOCUS, "moveActivityStackToFront: already on top, activity=" + this);
}
- return false;
+ return !isState(RESUMED);
}
if (DEBUG_FOCUS) {
@@ -2413,7 +2428,7 @@
stack.adjustFocusToNextFocusableStack("finish-top");
} else {
// Only move the next stack to top in its display.
- final ActivityDisplay display = stack.getDisplay();
+ final DisplayContent display = stack.getDisplay();
next = display.topRunningActivity();
if (next != null) {
display.positionStackAtTop(next.getActivityStack(),
@@ -2587,9 +2602,9 @@
mStackSupervisor.mGoingToSleepActivities.remove(this);
final ActivityStack stack = getActivityStack();
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
// TODO(b/137329632): Exclude current activity when looking for the next one with
- // ActivityDisplay#topRunningActivity().
+ // DisplayContent#topRunningActivity().
final ActivityRecord next = display.topRunningActivity();
final boolean isLastStackOverEmptyHome =
next == null && stack.isFocusedStackOnDisplay() && display.getHomeStack() != null;
@@ -4656,7 +4671,7 @@
}
r.setSavedState(null /* savedState */);
- final ActivityDisplay display = r.getDisplay();
+ final DisplayContent display = r.getDisplay();
if (display != null) {
display.handleActivitySizeCompatModeIfNeeded(r);
}
@@ -6253,7 +6268,7 @@
}
// The role of CompatDisplayInsets is like the override bounds.
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
if (display != null) {
mCompatDisplayInsets = new CompatDisplayInsets(display.mDisplayContent,
getWindowConfiguration().getBounds(),
@@ -6523,7 +6538,7 @@
onMergedOverrideConfigurationChanged();
}
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
if (display == null) {
return;
}
@@ -7272,7 +7287,7 @@
* otherwise.
*/
boolean isResumedActivityOnDisplay() {
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
return display != null && this == display.getResumedActivity();
}
diff --git a/services/core/java/com/android/server/wm/ActivityStack.java b/services/core/java/com/android/server/wm/ActivityStack.java
index eb1f638..6f124ac 100644
--- a/services/core/java/com/android/server/wm/ActivityStack.java
+++ b/services/core/java/com/android/server/wm/ActivityStack.java
@@ -131,8 +131,6 @@
import android.app.IActivityController;
import android.app.RemoteAction;
import android.app.ResultInfo;
-import android.app.WindowConfiguration.ActivityType;
-import android.app.WindowConfiguration.WindowingMode;
import android.app.servertransaction.ActivityResultItem;
import android.app.servertransaction.ClientTransaction;
import android.app.servertransaction.NewIntentItem;
@@ -144,7 +142,6 @@
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.Rect;
-import android.graphics.Region;
import android.os.Binder;
import android.os.Debug;
import android.os.Handler;
@@ -154,9 +151,7 @@
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.Trace;
-import android.os.UserHandle;
import android.service.voice.IVoiceInteractionSession;
-import android.util.ArraySet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Slog;
@@ -732,7 +727,7 @@
}
}
- ActivityStack(ActivityDisplay display, int stackId, ActivityStackSupervisor supervisor,
+ ActivityStack(DisplayContent display, int stackId, ActivityStackSupervisor supervisor,
int windowingMode, int activityType, boolean onTop) {
super(supervisor.mService.mWindowManager);
mStackId = stackId;
@@ -816,7 +811,7 @@
}
}
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
if (display == null ) {
return;
}
@@ -946,7 +941,7 @@
boolean creating) {
final int currentMode = getWindowingMode();
final int currentOverrideMode = getRequestedOverrideWindowingMode();
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
final Task topTask = getTopMostTask();
final ActivityStack splitScreenStack = display.getSplitScreenPrimaryStack();
int windowingMode = preferredWindowingMode;
@@ -1116,8 +1111,8 @@
!PRESERVE_WINDOWS);
}
- ActivityDisplay getDisplay() {
- return mRootActivityContainer.getActivityDisplay(mDisplayId);
+ DisplayContent getDisplay() {
+ return getDisplayContent();
}
/**
@@ -1250,7 +1245,7 @@
/** @return true if the stack can only contain one task */
boolean isSingleTaskInstance() {
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
return display != null && display.isSingleTaskInstance();
}
@@ -1291,7 +1286,7 @@
return;
}
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
if (inSplitScreenSecondaryWindowingMode()) {
// If the stack is in split-screen seconardy mode, we need to make sure we move the
@@ -1358,7 +1353,7 @@
@Override
public boolean isAttached() {
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
return display != null && !display.isRemoved();
}
@@ -1777,7 +1772,7 @@
}
boolean isTopStackOnDisplay() {
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
return display != null && display.isTopStack(this);
}
@@ -1786,7 +1781,7 @@
* otherwise.
*/
boolean isFocusedStackOnDisplay() {
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
return display != null && this == display.getFocusedStack();
}
@@ -1815,7 +1810,7 @@
return STACK_VISIBILITY_INVISIBLE;
}
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
boolean gotSplitScreenStack = false;
boolean gotOpaqueSplitScreenPrimary = false;
boolean gotOpaqueSplitScreenSecondary = false;
@@ -2049,13 +2044,13 @@
* {@link Display#FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD} applied.
*/
boolean canShowWithInsecureKeyguard() {
- final ActivityDisplay activityDisplay = getDisplay();
- if (activityDisplay == null) {
+ final DisplayContent displayContent = getDisplay();
+ if (displayContent == null) {
throw new IllegalStateException("Stack is not attached to any display, stackId="
+ mStackId);
}
- final int flags = activityDisplay.mDisplay.getFlags();
+ final int flags = displayContent.mDisplay.getFlags();
return (flags & FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD) != 0;
}
@@ -2224,7 +2219,7 @@
}
next.delayedResume = false;
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
// If the top activity is the resumed one, nothing to do.
if (mResumedActivity == next && next.isState(RESUMED)
@@ -2966,7 +2961,7 @@
/** @return true if the stack behind this one is a standard activity type. */
private boolean inFrontOfStandardStack() {
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
if (display == null) {
return false;
}
@@ -3599,7 +3594,10 @@
pw.println(prefix + "* " + task);
task.dump(pw, prefix + " ");
final ArrayList<ActivityRecord> activities = new ArrayList<>();
- forAllActivities((Consumer<ActivityRecord>) activities::add);
+ // Add activities by traversing the hierarchy from bottom to top, since activities
+ // are dumped in reverse order in {@link ActivityStackSupervisor#dumpHistoryList()}.
+ forAllActivities((Consumer<ActivityRecord>) activities::add,
+ false /* traverseTopToBottom */);
dumpHistoryList(fd, pw, activities, prefix, "Hist", true, !dumpAll, dumpClient,
dumpPackage, false, null, task);
});
@@ -3665,7 +3663,7 @@
return;
}
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
final boolean topFocused = mRootActivityContainer.isTopDisplayFocusedStack(this);
if (DEBUG_TASK_MOVEMENT) Slog.d(TAG_WM, "removeChild: task=" + child);
@@ -3693,7 +3691,7 @@
}
void moveHomeStackToFrontIfNeeded(
- boolean wasTopFocusedStack, ActivityDisplay display, String reason) {
+ boolean wasTopFocusedStack, DisplayContent display, String reason) {
if (!hasChild() && wasTopFocusedStack) {
// We only need to adjust focused stack if this stack is in focus and we are not in the
// process of moving the task to the top of the stack that will be focused.
@@ -3790,11 +3788,11 @@
return;
}
super.setAlwaysOnTop(alwaysOnTop);
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
// positionChildAtTop() must be called even when always on top gets turned off because we
// need to make sure that the stack is moved from among always on top windows to below other
// always on top windows. Since the position the stack should be inserted into is calculated
- // properly in {@link ActivityDisplay#getTopInsertPosition()} in both cases, we can just
+ // properly in {@link DisplayContent#getTopInsertPosition()} in both cases, we can just
// request that the stack is put at top here.
display.positionStackAtTop(this, false /* includingParents */);
}
@@ -4352,11 +4350,10 @@
@Override
protected void onParentChanged(
ConfigurationContainer newParent, ConfigurationContainer oldParent) {
- // TODO(display-merge): Remove cast
- final ActivityDisplay display = newParent != null
- ? (ActivityDisplay) ((WindowContainer) newParent).getDisplayContent() : null;
- final ActivityDisplay oldDisplay = oldParent != null
- ? (ActivityDisplay) ((WindowContainer) oldParent).getDisplayContent() : null;
+ final DisplayContent display = newParent != null
+ ? ((WindowContainer) newParent).getDisplayContent() : null;
+ final DisplayContent oldDisplay = oldParent != null
+ ? ((WindowContainer) oldParent).getDisplayContent() : null;
mDisplayId = (display != null) ? display.mDisplayId : INVALID_DISPLAY;
mPrevDisplayId = (oldDisplay != null) ? oldDisplay.mDisplayId : INVALID_DISPLAY;
@@ -5408,7 +5405,7 @@
}
boolean shouldSleepActivities() {
- final ActivityDisplay display = getDisplay();
+ final DisplayContent display = getDisplay();
// Do not sleep activities in this stack if we're marked as focused and the keyguard
// is in the process of going away.
diff --git a/services/core/java/com/android/server/wm/ActivityStackSupervisor.java b/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
index 8c5fd8c..26d9dbc 100644
--- a/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
@@ -401,12 +401,12 @@
private final MoveTaskToFullscreenHelper mMoveTaskToFullscreenHelper =
new MoveTaskToFullscreenHelper();
private class MoveTaskToFullscreenHelper {
- private ActivityDisplay mToDisplay;
+ private DisplayContent mToDisplay;
private boolean mOnTop;
private Task mTopTask;
private boolean mSchedulePictureInPictureModeChange;
- void process(ActivityStack fromStack, ActivityDisplay toDisplay, boolean onTop,
+ void process(ActivityStack fromStack, DisplayContent toDisplay, boolean onTop,
boolean schedulePictureInPictureModeChange) {
mSchedulePictureInPictureModeChange = schedulePictureInPictureModeChange;
mToDisplay = toDisplay;
@@ -1122,9 +1122,9 @@
return true;
}
- final ActivityDisplay activityDisplay =
- mRootActivityContainer.getActivityDisplayOrCreate(launchDisplayId);
- if (activityDisplay == null || activityDisplay.isRemoved()) {
+ final DisplayContent displayContent =
+ mRootActivityContainer.getDisplayContentOrCreate(launchDisplayId);
+ if (displayContent == null || displayContent.isRemoved()) {
Slog.w(TAG, "Launch on display check: display not found");
return false;
}
@@ -1140,10 +1140,10 @@
}
// Check if caller is already present on display
- final boolean uidPresentOnDisplay = activityDisplay.isUidPresent(callingUid);
+ final boolean uidPresentOnDisplay = displayContent.isUidPresent(callingUid);
- final int displayOwnerUid = activityDisplay.mDisplay.getOwnerUid();
- if (activityDisplay.mDisplay.getType() == TYPE_VIRTUAL && displayOwnerUid != SYSTEM_UID
+ final int displayOwnerUid = displayContent.mDisplay.getOwnerUid();
+ if (displayContent.mDisplay.getType() == TYPE_VIRTUAL && displayOwnerUid != SYSTEM_UID
&& displayOwnerUid != aInfo.applicationInfo.uid) {
// Limit launching on virtual displays, because their contents can be read from Surface
// by apps that created them.
@@ -1161,7 +1161,7 @@
}
}
- if (!activityDisplay.isPrivate()) {
+ if (!displayContent.isPrivate()) {
// Anyone can launch on a public display.
if (DEBUG_TASKS) Slog.d(TAG, "Launch on display check:"
+ " allow launch on public display");
@@ -1482,7 +1482,7 @@
currentStack, forceNonResizeable);
}
- private void moveHomeStackToFrontIfNeeded(int flags, ActivityDisplay display, String reason) {
+ private void moveHomeStackToFrontIfNeeded(int flags, DisplayContent display, String reason) {
final ActivityStack focusedStack = display.getFocusedStack();
if ((display.getWindowingMode() == WINDOWING_MODE_FULLSCREEN
@@ -1542,8 +1542,8 @@
mService.deferWindowLayout();
try {
final int windowingMode = fromStack.getWindowingMode();
- final ActivityDisplay toDisplay =
- mRootActivityContainer.getActivityDisplay(toDisplayId);
+ final DisplayContent toDisplay =
+ mRootActivityContainer.getDisplayContent(toDisplayId);
if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) {
// We are moving all tasks from the docked stack to the fullscreen stack,
@@ -1668,7 +1668,7 @@
// static stacks need to be adjusted so they don't overlap with the docked stack.
// We get the bounds to use from window manager which has been adjusted for any
// screen controls and is also the same for all stacks.
- final ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
+ final DisplayContent display = mRootActivityContainer.getDefaultDisplay();
final Rect otherTaskRect = new Rect();
for (int i = display.getStackCount() - 1; i >= 0; --i) {
final ActivityStack current = display.getStackAt(i);
@@ -1934,7 +1934,7 @@
* Returns the reparent target stack, creating the stack if necessary. This call also enforces
* the various checks on tasks that are going to be reparented from one stack to another.
*/
- // TODO: Look into changing users to this method to ActivityDisplay.resolveWindowingMode()
+ // TODO: Look into changing users to this method to DisplayContent.resolveWindowingMode()
ActivityStack getReparentTargetStack(Task task, ActivityStack stack, boolean toTop) {
final ActivityStack prevStack = task.getStack();
final int stackId = stack.mStackId;
@@ -2426,8 +2426,8 @@
throw new IllegalStateException("Task resolved to incompatible display");
}
- final ActivityDisplay preferredDisplay =
- mRootActivityContainer.getActivityDisplay(preferredDisplayId);
+ final DisplayContent preferredDisplay =
+ mRootActivityContainer.getDisplayContent(preferredDisplayId);
final boolean singleTaskInstance = preferredDisplay != null
&& preferredDisplay.isSingleTaskInstance();
@@ -2527,8 +2527,8 @@
void scheduleUpdatePictureInPictureModeIfNeeded(Task task, ActivityStack prevStack) {
final ActivityStack stack = task.getStack();
- if (prevStack == null || prevStack == stack
- || (!prevStack.inPinnedWindowingMode() && !stack.inPinnedWindowingMode())) {
+ if ((prevStack == null || (prevStack != stack
+ && !prevStack.inPinnedWindowingMode() && !stack.inPinnedWindowingMode()))) {
return;
}
@@ -2818,7 +2818,7 @@
// call this at the end to make sure that tasks exists on the window manager side.
setResizingDuringAnimation(task);
- final ActivityDisplay display = task.getStack().getDisplay();
+ final DisplayContent display = task.getStack().getDisplay();
final ActivityStack topSecondaryStack =
display.getTopStackInWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_SECONDARY);
if (topSecondaryStack.isActivityTypeHome()) {
diff --git a/services/core/java/com/android/server/wm/ActivityStartController.java b/services/core/java/com/android/server/wm/ActivityStartController.java
index 695f58c..4c165df 100644
--- a/services/core/java/com/android/server/wm/ActivityStartController.java
+++ b/services/core/java/com/android/server/wm/ActivityStartController.java
@@ -43,6 +43,7 @@
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Slog;
+import android.util.SparseArray;
import android.util.proto.ProtoOutputStream;
import android.view.RemoteAnimationAdapter;
@@ -180,8 +181,8 @@
}
options.setLaunchDisplayId(displayId);
- final ActivityDisplay display =
- mService.mRootActivityContainer.getActivityDisplay(displayId);
+ final DisplayContent display =
+ mService.mRootActivityContainer.getDisplayContent(displayId);
// The home activity will be started later, defer resuming to avoid unneccerary operations
// (e.g. start home recursively) when creating home stack.
mSupervisor.beginDeferResume();
@@ -385,6 +386,7 @@
} else {
callingPid = callingUid = -1;
}
+ final SparseArray<String> startingUidPkgs = new SparseArray<>();
final long origId = Binder.clearCallingIdentity();
try {
intents = ArrayUtils.filterNotNull(intents, Intent[]::new);
@@ -411,9 +413,14 @@
callingUid, realCallingUid, UserHandle.USER_NULL));
aInfo = mService.mAmInternal.getActivityInfoForUser(aInfo, userId);
- if (aInfo != null && (aInfo.applicationInfo.privateFlags
- & ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0) {
- throw new IllegalArgumentException("FLAG_CANT_SAVE_STATE not supported here");
+ if (aInfo != null) {
+ if ((aInfo.applicationInfo.privateFlags
+ & ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0) {
+ throw new IllegalArgumentException(
+ "FLAG_CANT_SAVE_STATE not supported here");
+ }
+ startingUidPkgs.put(aInfo.applicationInfo.uid,
+ aInfo.applicationInfo.packageName);
}
final boolean top = i == intents.length - 1;
@@ -439,6 +446,16 @@
.setOriginatingPendingIntent(originatingPendingIntent)
.setAllowBackgroundActivityStart(allowBackgroundActivityStart);
}
+ // Log if the activities to be started have different uids.
+ if (startingUidPkgs.size() > 1) {
+ final StringBuilder sb = new StringBuilder("startActivities: different apps [");
+ final int size = startingUidPkgs.size();
+ for (int i = 0; i < size; i++) {
+ sb.append(startingUidPkgs.valueAt(i)).append(i == size - 1 ? "]" : ", ");
+ }
+ sb.append(" from ").append(callingPackage);
+ Slog.wtf(TAG, sb.toString());
+ }
final ActivityRecord[] outActivity = new ActivityRecord[1];
// Lock the loop to ensure the activities launched in a sequence.
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index 23083c9..674955e 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -98,6 +98,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.AuxiliaryResolveInfo;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManagerInternal;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.content.res.Configuration;
@@ -1309,9 +1310,11 @@
String resolvedType, int userId) {
if (auxiliaryResponse != null && auxiliaryResponse.needsPhaseTwo) {
// request phase two resolution
- mService.getPackageManagerInternalLocked().requestInstantAppResolutionPhaseTwo(
+ PackageManagerInternal packageManager = mService.getPackageManagerInternalLocked();
+ boolean isRequesterInstantApp = packageManager.isInstantApp(callingPackage, userId);
+ packageManager.requestInstantAppResolutionPhaseTwo(
auxiliaryResponse, originalIntent, resolvedType, callingPackage,
- verificationBundle, userId);
+ isRequesterInstantApp, verificationBundle, userId);
}
return InstantAppResolver.buildEphemeralInstallerIntent(
originalIntent,
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 46c4d87..f0bc412 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -2038,7 +2038,7 @@
}
@Override
- public int getActivityDisplayId(IBinder activityToken) throws RemoteException {
+ public int getDisplayId(IBinder activityToken) throws RemoteException {
synchronized (mGlobalLock) {
final ActivityStack stack = ActivityRecord.getStackLocked(activityToken);
if (stack != null && stack.mDisplayId != INVALID_DISPLAY) {
@@ -4572,6 +4572,17 @@
}
}
+ @Override
+ public void invalidateHomeTaskSnapshot(IBinder token) {
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null || !r.isActivityTypeHome()) {
+ return;
+ }
+ mWindowManager.mTaskSnapshotController.removeSnapshotCache(r.getTask().mTaskId);
+ }
+ }
+
/** Return the user id of the last resumed activity. */
@Override
public @UserIdInt
@@ -4691,7 +4702,7 @@
"registerRemoteAnimations");
definition.setCallingPidUid(Binder.getCallingPid(), Binder.getCallingUid());
synchronized (mGlobalLock) {
- final ActivityDisplay display = mRootActivityContainer.getActivityDisplay(displayId);
+ final DisplayContent display = mRootActivityContainer.getDisplayContent(displayId);
if (display == null) {
Slog.e(TAG, "Couldn't find display with id: " + displayId);
return;
@@ -4899,8 +4910,8 @@
"setDisplayToSingleTaskInstance");
final long origId = Binder.clearCallingIdentity();
try {
- final ActivityDisplay display =
- mRootActivityContainer.getActivityDisplayOrCreate(displayId);
+ final DisplayContent display =
+ mRootActivityContainer.getDisplayContentOrCreate(displayId);
if (display != null) {
display.setDisplayToSingleTaskInstance();
}
@@ -5198,8 +5209,8 @@
int updateGlobalConfigurationLocked(@NonNull Configuration values, boolean initLocale,
boolean persistent, int userId, boolean deferResume) {
- final ActivityDisplay defaultDisplay =
- mRootActivityContainer.getActivityDisplay(DEFAULT_DISPLAY);
+ final DisplayContent defaultDisplay =
+ mRootActivityContainer.getDisplayContent(DEFAULT_DISPLAY);
mTempConfig.setTo(getGlobalConfiguration());
final int changes = mTempConfig.updateFrom(values);
@@ -6205,12 +6216,12 @@
// We might change the visibilities here, so prepare an empty app transition which
// might be overridden later if we actually change visibilities.
- final ActivityDisplay activityDisplay =
- mRootActivityContainer.getActivityDisplay(displayId);
- if (activityDisplay == null) {
+ final DisplayContent displayContent =
+ mRootActivityContainer.getDisplayContent(displayId);
+ if (displayContent == null) {
return;
}
- final DisplayContent dc = activityDisplay.mDisplayContent;
+ final DisplayContent dc = displayContent.mDisplayContent;
final boolean wasTransitionSet =
dc.mAppTransition.getAppTransition() != TRANSIT_NONE;
if (!wasTransitionSet) {
@@ -6557,9 +6568,9 @@
return;
}
synchronized (mGlobalLock) {
- final ActivityDisplay activityDisplay =
- mRootActivityContainer.getActivityDisplay(displayId);
- if (activityDisplay == null) {
+ final DisplayContent displayContent =
+ mRootActivityContainer.getDisplayContent(displayId);
+ if (displayContent == null) {
// Call might come when display is not yet added or has been removed.
if (DEBUG_CONFIGURATION) {
Slog.w(TAG, "Trying to update display configuration for non-existing "
@@ -6576,7 +6587,7 @@
return;
}
process.mIsImeProcess = true;
- process.registerDisplayConfigurationListenerLocked(activityDisplay);
+ process.registerDisplayConfigurationListenerLocked(displayContent);
}
}
diff --git a/services/core/java/com/android/server/wm/ConfigurationContainer.java b/services/core/java/com/android/server/wm/ConfigurationContainer.java
index bd0ea3d..dd3365c 100644
--- a/services/core/java/com/android/server/wm/ConfigurationContainer.java
+++ b/services/core/java/com/android/server/wm/ConfigurationContainer.java
@@ -384,7 +384,6 @@
* When you call this function, make sure that the following functions are called as well to
* keep proper z-order.
* - {@Link DisplayContent#positionStackAt(POSITION_TOP, TaskStack)};
- * - {@Link ActivityDisplay#positionChildAtTop(ActivityStack)};
* */
public void setAlwaysOnTop(boolean alwaysOnTop) {
mRequestsTmpConfig.setTo(getRequestedOverrideConfiguration());
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index aa0e973..e3ea2c5 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -16,24 +16,33 @@
package com.android.server.wm;
+import static android.app.ActivityTaskManager.INVALID_STACK_ID;
import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
+import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
+import static android.app.WindowConfiguration.ROTATION_UNDEFINED;
+import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
+import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
+import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
+import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
+import static android.os.Build.VERSION_CODES.N;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.util.DisplayMetrics.DENSITY_DEFAULT;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.FLAG_PRIVATE;
import static android.view.Display.FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS;
import static android.view.Display.INVALID_DISPLAY;
+import static android.view.Display.REMOVE_MODE_DESTROY_CONTENT;
import static android.view.InsetsState.ITYPE_IME;
import static android.view.InsetsState.ITYPE_LEFT_GESTURES;
import static android.view.InsetsState.ITYPE_RIGHT_GESTURES;
@@ -75,10 +84,20 @@
import static android.view.WindowManager.TRANSIT_TASK_OPEN;
import static android.view.WindowManager.TRANSIT_TASK_TO_FRONT;
+import static com.android.server.am.ActivityDisplayProto.DISPLAY;
+import static com.android.server.am.ActivityDisplayProto.FOCUSED_STACK_ID;
+import static com.android.server.am.ActivityDisplayProto.RESUMED_ACTIVITY;
+import static com.android.server.am.ActivityDisplayProto.SINGLE_TASK_INSTANCE;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
+import static com.android.server.wm.ActivityStack.ActivityState.RESUMED;
+import static com.android.server.wm.ActivityStack.STACK_VISIBILITY_VISIBLE;
+import static com.android.server.wm.ActivityStackSupervisor.TAG_TASKS;
+import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_STATES;
+import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_TASKS;
+import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_STACK;
import static com.android.server.wm.DisplayContentProto.ABOVE_APP_WINDOWS;
import static com.android.server.wm.DisplayContentProto.APP_TRANSITION;
import static com.android.server.wm.DisplayContentProto.BELOW_APP_WINDOWS;
@@ -105,6 +124,7 @@
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_SCREEN_ON;
import static com.android.server.wm.ProtoLogGroup.WM_SHOW_TRANSACTIONS;
+import static com.android.server.wm.RootActivityContainer.TAG_STATES;
import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS;
import static com.android.server.wm.WindowContainer.AnimationFlags.TRANSITION;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DISPLAY;
@@ -124,6 +144,7 @@
import static com.android.server.wm.WindowManagerService.H.WINDOW_HIDE_TIMEOUT;
import static com.android.server.wm.WindowManagerService.LAYOUT_REPEAT_THRESHOLD;
import static com.android.server.wm.WindowManagerService.SEAMLESS_ROTATION_TIMEOUT_DURATION;
+import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_PLACING_SURFACES;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_REMOVING_FOCUS;
import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_ASSIGN_LAYERS;
@@ -141,6 +162,11 @@
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.app.ActivityManager;
+import android.app.ActivityManagerInternal;
+import android.app.ActivityOptions;
+import android.app.WindowConfiguration;
+import android.content.pm.ActivityInfo;
import android.content.pm.ActivityInfo.ScreenOrientation;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
@@ -158,15 +184,19 @@
import android.os.Debug;
import android.os.Handler;
import android.os.IBinder;
+import android.os.Message;
import android.os.Process;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.Trace;
import android.os.UserHandle;
+import android.provider.Settings;
import android.util.ArraySet;
import android.util.DisplayMetrics;
+import android.util.IntArray;
import android.util.Slog;
+import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.proto.ProtoOutputStream;
import android.view.Display;
@@ -174,6 +204,7 @@
import android.view.DisplayInfo;
import android.view.Gravity;
import android.view.ISystemGestureExclusionListener;
+import android.view.IWindow;
import android.view.InputChannel;
import android.view.InputDevice;
import android.view.InputWindowHandle;
@@ -196,6 +227,7 @@
import com.android.internal.util.function.pooled.PooledConsumer;
import com.android.internal.util.function.pooled.PooledFunction;
import com.android.internal.util.function.pooled.PooledLambda;
+import com.android.internal.util.function.pooled.PooledPredicate;
import com.android.server.AnimationThread;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.protolog.common.ProtoLog;
@@ -223,6 +255,7 @@
class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowContainer>
implements WindowManagerPolicy.DisplayContentInfo {
private static final String TAG = TAG_WITH_CLASS_NAME ? "DisplayContent" : TAG_WM;
+ private static final String TAG_STACK = TAG + POSTFIX_STACK;
/** The default scaling mode that scales content automatically. */
static final int FORCE_SCALING_MODE_AUTO = 0;
@@ -239,7 +272,7 @@
ActivityTaskManagerService mAtmService;
/** Unique identifier of this display. */
- private final int mDisplayId;
+ final int mDisplayId;
/**
* Most surfaces will be a child of this window. There are some special layers and windows
@@ -328,8 +361,8 @@
* @see WindowManagerService#setForcedDisplayScalingMode(int, int)
*/
boolean mDisplayScalingDisabled;
+ final Display mDisplay;
private final DisplayInfo mDisplayInfo = new DisplayInfo();
- private final Display mDisplay;
private final DisplayMetrics mDisplayMetrics = new DisplayMetrics();
private final DisplayPolicy mDisplayPolicy;
private final DisplayRotation mDisplayRotation;
@@ -563,6 +596,74 @@
/** Corner radius that windows should have in order to match the display. */
private final float mWindowCornerRadius;
+ private final SparseArray<ShellRoot> mShellRoots = new SparseArray<>();
+
+ /**
+ * Counter for next free stack ID to use for dynamic activity stacks. Unique across displays.
+ */
+ private static int sNextFreeStackId = 0;
+
+ private RootActivityContainer mRootActivityContainer;
+
+ /**
+ * All of the stacks on this display. Order matters, topmost stack is in front of all other
+ * stacks, bottommost behind. Accessed directly by ActivityManager package classes. Any calls
+ * changing the list should also call {@link #onStackOrderChanged()}.
+ */
+ private ArrayList<OnStackOrderChangedListener> mStackOrderChangedCallbacks = new ArrayList<>();
+
+ /** Array of all UIDs that are present on the display. */
+ private IntArray mDisplayAccessUIDs = new IntArray();
+
+ /** All tokens used to put activities on this stack to sleep (including mOffToken) */
+ final ArrayList<ActivityTaskManagerInternal.SleepToken> mAllSleepTokens = new ArrayList<>();
+ /** The token acquired by ActivityStackSupervisor to put stacks on the display to sleep */
+ ActivityTaskManagerInternal.SleepToken mOffToken;
+
+ private boolean mSleeping;
+
+ /** We started the process of removing the display from the system. */
+ private boolean mRemoving;
+
+ /**
+ * The display is removed from the system and we are just waiting for all activities on it to be
+ * finished before removing this object.
+ */
+ private boolean mRemoved;
+
+ /** The display can only contain one task. */
+ private boolean mSingleTaskInstance;
+
+ /**
+ * Non-null if the last size compatibility mode activity is using non-native screen
+ * configuration. The activity is not able to put in multi-window mode, so it exists only one
+ * per display.
+ */
+ private ActivityRecord mLastCompatModeActivity;
+
+ /**
+ * A focusable stack that is purposely to be positioned at the top. Although the stack may not
+ * have the topmost index, it is used as a preferred candidate to prevent being unable to resume
+ * target stack properly when there are other focusable always-on-top stacks.
+ */
+ private ActivityStack mPreferredTopFocusableStack;
+
+ /**
+ * If this is the same as {@link #getFocusedStack} then the activity on the top of the focused
+ * stack has been resumed. If stacks are changing position this will hold the old stack until
+ * the new stack becomes resumed after which it will be set to current focused stack.
+ */
+ private ActivityStack mLastFocusedStack;
+
+ // Used in updating the display size
+ private Point mTmpDisplaySize = new Point();
+
+ // Used in updating override configurations
+ private final Configuration mTempConfig = new Configuration();
+
+ private final RootActivityContainer.FindTaskResult
+ mTmpFindTaskResult = new RootActivityContainer.FindTaskResult();
+
private final Consumer<WindowState> mUpdateWindowsForAnimator = w -> {
WindowStateAnimator winAnimator = w.mWinAnimator;
final ActivityRecord activity = w.mActivityRecord;
@@ -842,17 +943,18 @@
* Create new {@link DisplayContent} instance, add itself to the root window container and
* initialize direct children.
* @param display May not be null.
- * @param service You know.
- * @param activityDisplay The ActivityDisplay for the display container.
+ * @param root {@link RootActivityContainer}
*/
- DisplayContent(Display display, WindowManagerService service) {
- super(service);
- if (service.mRoot.getDisplayContent(display.getDisplayId()) != null) {
+ DisplayContent(Display display, RootActivityContainer root) {
+ super(root.mWindowManager);
+ if (mWmService.mRoot.getDisplayContent(display.getDisplayId()) != null) {
throw new IllegalArgumentException("Display with ID=" + display.getDisplayId()
- + " already exists=" + service.mRoot.getDisplayContent(display.getDisplayId())
+ + " already exists="
+ + mWmService.mRoot.getDisplayContent(display.getDisplayId())
+ " new=" + display);
}
+ mRootActivityContainer = root;
mAtmService = mWmService.mAtmService;
mDisplay = display;
mDisplayId = display.getDisplayId();
@@ -866,13 +968,13 @@
calculateDisplayCutoutForRotation(mDisplayInfo.rotation));
initializeDisplayBaseInfo();
- mAppTransition = new AppTransition(service.mContext, service, this);
- mAppTransition.registerListenerLocked(service.mActivityManagerAppTransitionNotifier);
- mAppTransitionController = new AppTransitionController(service, this);
- mUnknownAppVisibilityController = new UnknownAppVisibilityController(service, this);
+ mAppTransition = new AppTransition(mWmService.mContext, mWmService, this);
+ mAppTransition.registerListenerLocked(mWmService.mActivityManagerAppTransitionNotifier);
+ mAppTransitionController = new AppTransitionController(mWmService, this);
+ mUnknownAppVisibilityController = new UnknownAppVisibilityController(mWmService, this);
AnimationHandler animationHandler = new AnimationHandler();
- mBoundsAnimationController = new BoundsAnimationController(service.mContext,
+ mBoundsAnimationController = new BoundsAnimationController(mWmService.mContext,
mAppTransition, AnimationThread.getHandler(), animationHandler);
final InputChannel inputChannel = mWmService.mInputManager.monitorInput(
@@ -890,9 +992,9 @@
mWmService.mAtmService.getRecentTasks().getInputListener());
}
- mDisplayPolicy = new DisplayPolicy(service, this);
- mDisplayRotation = new DisplayRotation(service, this);
- mCloseToSquareMaxAspectRatio = service.mContext.getResources().getFloat(
+ mDisplayPolicy = new DisplayPolicy(mWmService, this);
+ mDisplayRotation = new DisplayRotation(mWmService, this);
+ mCloseToSquareMaxAspectRatio = mWmService.mContext.getResources().getFloat(
com.android.internal.R.dimen.config_closeToSquareDisplayMaxAspectRatio);
if (isDefaultDisplay) {
// The policy may be invoked right after here, so it requires the necessary default
@@ -906,8 +1008,8 @@
mDisplayPolicy.systemReady();
}
mWindowCornerRadius = mDisplayPolicy.getWindowCornerRadius();
- mDividerControllerLocked = new DockedStackDividerController(service, this);
- mPinnedStackControllerLocked = new PinnedStackController(service, this);
+ mDividerControllerLocked = new DockedStackDividerController(mWmService, this);
+ mPinnedStackControllerLocked = new PinnedStackController(mWmService, this);
final SurfaceControl.Builder b = mWmService.makeSurfaceBuilder(mSession)
.setOpaque(true)
@@ -937,9 +1039,23 @@
mDisplayReady = true;
mWmService.mAnimator.addDisplayLocked(mDisplayId);
- mInputMonitor = new InputMonitor(service, mDisplayId);
+ mInputMonitor = new InputMonitor(mWmService, mDisplayId);
mInsetsStateController = new InsetsStateController(this);
mInsetsPolicy = new InsetsPolicy(mInsetsStateController, this);
+
+ if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Adding display=" + display);
+
+ mWmService.mDisplayWindowSettings.applySettingsToDisplayLocked(this);
+
+ if (mWmService.mDisplayManagerInternal != null) {
+ mWmService.mDisplayManagerInternal
+ .setDisplayInfoOverrideFromWindowManager(mDisplayId, getDisplayInfo());
+ configureDisplayPolicy();
+ }
+
+ reconfigureDisplayLocked();
+ onRequestedOverrideConfigurationChanged(getRequestedOverrideConfiguration());
+ mWmService.mDisplayNotificationController.dispatchDisplayAdded(this);
}
boolean isReady() {
@@ -1017,6 +1133,37 @@
return token;
}
+ SurfaceControl addShellRoot(@NonNull IWindow client, int windowType) {
+ ShellRoot root = mShellRoots.get(windowType);
+ if (root != null) {
+ if (root.getClient() == client) {
+ return root.getSurfaceControl();
+ }
+ root.clear();
+ mShellRoots.remove(windowType);
+ }
+ root = new ShellRoot(client, this, windowType);
+ SurfaceControl rootLeash = root.getSurfaceControl();
+ if (rootLeash == null) {
+ // Root didn't finish initializing, so don't add it.
+ root.clear();
+ return null;
+ }
+ mShellRoots.put(windowType, root);
+ SurfaceControl out = new SurfaceControl();
+ out.copyFrom(rootLeash);
+ return out;
+ }
+
+ void removeShellRoot(int windowType) {
+ ShellRoot root = mShellRoots.get(windowType);
+ if (root == null) {
+ return;
+ }
+ root.clear();
+ mShellRoots.remove(windowType);
+ }
+
/** Changes the display the input window token is housed on to this one. */
void reParentWindowToken(WindowToken token) {
final DisplayContent prevDc = token.getDisplayContent();
@@ -1154,9 +1301,7 @@
if (mDisplayRotation.isWaitingForRemoteRotation()) {
return;
}
- // TODO(display-merge): Remove cast
- final boolean configUpdated =
- ((ActivityDisplay) this).updateDisplayOverrideConfigurationLocked();
+ final boolean configUpdated = updateDisplayOverrideConfigurationLocked();
if (configUpdated) {
return;
}
@@ -1187,9 +1332,8 @@
if (handled && requestingContainer instanceof ActivityRecord) {
final ActivityRecord activityRecord = (ActivityRecord) requestingContainer;
- // TODO(display-merge): Remove cast
- final boolean kept = ((ActivityDisplay) this).updateDisplayOverrideConfigurationLocked(
- config, activityRecord, false /* deferResume */, null /* result */);
+ final boolean kept = updateDisplayOverrideConfigurationLocked(config, activityRecord,
+ false /* deferResume */, null /* result */);
activityRecord.frozenBeforeDestroy = true;
if (!kept) {
mWmService.mAtmService.mRootActivityContainer.resumeFocusedStacksTopActivities();
@@ -1197,9 +1341,8 @@
} else {
// We have a new configuration to push so we need to update ATMS for now.
// TODO: Clean up display configuration push between ATMS and WMS after unification.
- // TODO(display-merge): Remove cast
- ((ActivityDisplay) this.mDisplayContent).updateDisplayOverrideConfigurationLocked(
- config, null /* starting */, false /* deferResume */, null);
+ updateDisplayOverrideConfigurationLocked(config, null /* starting */,
+ false /* deferResume */, null);
}
return handled;
}
@@ -1880,15 +2023,9 @@
}
@Override
- public void onRequestedOverrideConfigurationChanged(Configuration overrideConfiguration) {
- mCurrentOverrideConfigurationChanges =
- getRequestedOverrideConfiguration().diff(overrideConfiguration);
- super.onRequestedOverrideConfigurationChanged(overrideConfiguration);
- mCurrentOverrideConfigurationChanges = 0;
- }
-
- @Override
public void onConfigurationChanged(Configuration newParentConfig) {
+ // update resources before cascade so that docked/pinned stacks use the correct info
+ preOnConfigurationChanged();
final int lastOrientation = getConfiguration().orientation;
super.onConfigurationChanged(newParentConfig);
if (mDisplayPolicy != null) {
@@ -1912,8 +2049,7 @@
/**
* Updates the resources used by docked/pinned controllers. This needs to be called at the
* beginning of a configuration update cascade since the metrics from these resources are used
- * for bounds calculations. Since ActivityDisplay initiates the configuration update, this
- * should be called from there instead of DisplayContent's onConfigurationChanged.
+ * for bounds calculations.
*/
void preOnConfigurationChanged() {
final DockedStackDividerController dividerController = getDockedDividerController();
@@ -2395,9 +2531,7 @@
setRotationAnimation(null);
mWmService.mAnimator.removeDisplayLocked(mDisplayId);
mInputMonitor.onDisplayRemoved();
- // TODO(display-merge): Remove cast
- mWmService.mDisplayNotificationController
- .dispatchDisplayRemoved((ActivityDisplay) this);
+ mWmService.mDisplayNotificationController.dispatchDisplayRemoved(this);
} finally {
mDisplayReady = false;
mRemovingDisplay = false;
@@ -2610,6 +2744,29 @@
}
}
+ public void dumpDebug(ProtoOutputStream proto, long fieldId,
+ @WindowTraceLogLevel int logLevel) {
+ final long token = proto.start(fieldId);
+ dumpDebugInner(proto, DISPLAY, logLevel);
+ proto.write(com.android.server.am.ActivityDisplayProto.ID, mDisplayId);
+ proto.write(SINGLE_TASK_INSTANCE, mSingleTaskInstance);
+ final ActivityStack focusedStack = getFocusedStack();
+ if (focusedStack != null) {
+ proto.write(FOCUSED_STACK_ID, focusedStack.mStackId);
+ final ActivityRecord focusedActivity = focusedStack.getDisplay().getResumedActivity();
+ if (focusedActivity != null) {
+ focusedActivity.writeIdentifierToProto(proto, RESUMED_ACTIVITY);
+ }
+ } else {
+ proto.write(FOCUSED_STACK_ID, INVALID_STACK_ID);
+ }
+ for (int stackNdx = getStackCount() - 1; stackNdx >= 0; --stackNdx) {
+ final ActivityStack stack = getStackAt(stackNdx);
+ stack.dumpDebug(proto, com.android.server.am.ActivityDisplayProto.STACKS, logLevel);
+ }
+ proto.end(token);
+ }
+
// TODO(proto-merge): Remove once protos for ActivityDisplay and DisplayContent are merged.
public void dumpDebugInner(ProtoOutputStream proto, long fieldId,
@WindowTraceLogLevel int logLevel) {
@@ -2670,7 +2827,9 @@
@Override
public void dump(PrintWriter pw, String prefix, boolean dumpAll) {
super.dump(pw, prefix, dumpAll);
- pw.print(prefix); pw.print("Display: mDisplayId="); pw.println(mDisplayId);
+ pw.print(prefix);
+ pw.println("Display: mDisplayId=" + mDisplayId + " stacks=" + getStackCount() + (
+ mSingleTaskInstance ? " mSingleTaskInstance" : ""));
final String subPrefix = " " + prefix;
pw.print(subPrefix); pw.print("init="); pw.print(mInitialDisplayWidth); pw.print("x");
pw.print(mInitialDisplayHeight); pw.print(" "); pw.print(mInitialDisplayDensity);
@@ -2706,6 +2865,12 @@
if (mLastFocus != mCurrentFocus) {
pw.print(" mLastFocus="); pw.println(mLastFocus);
}
+ if (mPreferredTopFocusableStack != null) {
+ pw.println(prefix + "mPreferredTopFocusableStack=" + mPreferredTopFocusableStack);
+ }
+ if (mLastFocusedStack != null) {
+ pw.println(prefix + "mLastFocusedStack=" + mLastFocusedStack);
+ }
if (mLosingFocus.size() > 0) {
pw.println();
pw.println(" Windows losing focus:");
@@ -2783,6 +2948,10 @@
if (splitScreenPrimaryStack != null) {
pw.println(prefix + "splitScreenPrimaryStack=" + splitScreenPrimaryStack.getName());
}
+ final ActivityStack recentsStack = getRecentsStack();
+ if (recentsStack != null) {
+ pw.println(prefix + "recentsStack=" + recentsStack.getName());
+ }
pw.println();
mDividerControllerLocked.dump(prefix, pw);
@@ -4068,8 +4237,7 @@
+ " already exist on display=" + this + " stack=" + stack);
}
mSplitScreenPrimaryStack = stack;
- // TODO(display-merge): Remove cast
- ((ActivityDisplay) this.mDisplayContent).onSplitScreenModeActivated();
+ mDisplayContent.onSplitScreenModeActivated();
mDividerControllerLocked.notifyDockedStackExistsChanged(true);
}
}
@@ -4083,8 +4251,7 @@
mPinnedStack = null;
} else if (stack == mSplitScreenPrimaryStack) {
mSplitScreenPrimaryStack = null;
- // TODO(display-merge): Remove cast
- ((ActivityDisplay) this.mDisplayContent).onSplitScreenModeDismissed();
+ mDisplayContent.onSplitScreenModeDismissed();
// Re-set the split-screen create mode whenever the split-screen stack is removed.
mWmService.setDockedStackCreateStateLocked(
SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT, null /* initialBounds */);
@@ -4109,8 +4276,7 @@
@Override
protected void removeChild(ActivityStack stack) {
super.removeChild(stack);
- // TODO(display-merge): Remove cast
- ((ActivityDisplay) this.mDisplayContent).onStackRemoved(stack);
+ mDisplayContent.onStackRemoved(stack);
removeStackReferenceIfNeeded(stack);
}
@@ -5342,4 +5508,1132 @@
}
return mMetricsLogger;
}
+
+ void onDisplayChanged() {
+ // The window policy is responsible for stopping activities on the default display.
+ final int displayId = mDisplay.getDisplayId();
+ if (displayId != DEFAULT_DISPLAY) {
+ final int displayState = mDisplay.getState();
+ if (displayState == Display.STATE_OFF && mOffToken == null) {
+ mOffToken = mAtmService.acquireSleepToken("Display-off", displayId);
+ } else if (displayState == Display.STATE_ON && mOffToken != null) {
+ mOffToken.release();
+ mOffToken = null;
+ }
+ }
+
+ mDisplay.getRealSize(mTmpDisplaySize);
+ setBounds(0, 0, mTmpDisplaySize.x, mTmpDisplaySize.y);
+ updateDisplayInfo();
+ mWmService.requestTraversal();
+ }
+
+ void addStack(ActivityStack stack, int position) {
+ setStackOnDisplay(stack, position);
+ positionStackAt(stack, position);
+ mAtmService.updateSleepIfNeededLocked();
+ }
+
+ void onStackRemoved(ActivityStack stack) {
+ if (ActivityTaskManagerDebugConfig.DEBUG_STACK) {
+ Slog.v(TAG_STACK, "removeStack: detaching " + stack + " from displayId=" + mDisplayId);
+ }
+ if (mPreferredTopFocusableStack == stack) {
+ mPreferredTopFocusableStack = null;
+ }
+ releaseSelfIfNeeded();
+ mAtmService.updateSleepIfNeededLocked();
+ onStackOrderChanged(stack);
+ }
+
+ void positionStackAtTop(ActivityStack stack, boolean includingParents) {
+ positionStackAtTop(stack, includingParents, null /* updateLastFocusedStackReason */);
+ }
+
+ void positionStackAtTop(ActivityStack stack, boolean includingParents,
+ String updateLastFocusedStackReason) {
+ positionStackAt(stack, getStackCount(), includingParents, updateLastFocusedStackReason);
+ }
+
+ void positionStackAtBottom(ActivityStack stack) {
+ positionStackAtBottom(stack, null /* updateLastFocusedStackReason */);
+ }
+
+ void positionStackAtBottom(ActivityStack stack, String updateLastFocusedStackReason) {
+ positionStackAt(stack, 0, false /* includingParents */, updateLastFocusedStackReason);
+ }
+
+ private void positionStackAt(ActivityStack stack, int position) {
+ positionStackAt(stack, position, false /* includingParents */,
+ null /* updateLastFocusedStackReason */);
+ }
+
+ private void positionStackAt(ActivityStack stack, int position, boolean includingParents,
+ String updateLastFocusedStackReason) {
+ // TODO: Keep in sync with WindowContainer.positionChildAt(), once we change that to adjust
+ // the position internally, also update the logic here
+ final ActivityStack prevFocusedStack = updateLastFocusedStackReason != null
+ ? getFocusedStack() : null;
+ final boolean wasContained = getIndexOf(stack) >= 0;
+ if (mSingleTaskInstance && getStackCount() == 1 && !wasContained) {
+ throw new IllegalStateException(
+ "positionStackAt: Can only have one task on display=" + this);
+ }
+
+ // Since positionChildAt() is called during the creation process of pinned stacks,
+ // ActivityStack#getStack() can be null.
+ positionStackAt(position, stack, includingParents);
+
+ // The insert position may be adjusted to non-top when there is always-on-top stack. Since
+ // the original position is preferred to be top, the stack should have higher priority when
+ // we are looking for top focusable stack. The condition {@code wasContained} restricts the
+ // preferred stack is set only when moving an existing stack to top instead of adding a new
+ // stack that may be too early (e.g. in the middle of launching or reparenting).
+ if (wasContained && position >= getStackCount() - 1 && stack.isFocusableAndVisible()) {
+ mPreferredTopFocusableStack = stack;
+ } else if (mPreferredTopFocusableStack == stack) {
+ mPreferredTopFocusableStack = null;
+ }
+
+ if (updateLastFocusedStackReason != null) {
+ final ActivityStack currentFocusedStack = getFocusedStack();
+ if (currentFocusedStack != prevFocusedStack) {
+ mLastFocusedStack = prevFocusedStack;
+ EventLogTags.writeWmFocusedStack(mRootActivityContainer.mCurrentUser, mDisplayId,
+ currentFocusedStack == null ? -1 : currentFocusedStack.getStackId(),
+ mLastFocusedStack == null ? -1 : mLastFocusedStack.getStackId(),
+ updateLastFocusedStackReason);
+ }
+ }
+
+ onStackOrderChanged(stack);
+ }
+
+ ActivityStack getStack(int stackId) {
+ for (int i = getStackCount() - 1; i >= 0; --i) {
+ final ActivityStack stack = getStackAt(i);
+ if (stack.mStackId == stackId) {
+ return stack;
+ }
+ }
+ return null;
+ }
+
+ boolean alwaysCreateStack(int windowingMode, int activityType) {
+ // Always create a stack for fullscreen, freeform, and split-screen-secondary windowing
+ // modes so that we can manage visual ordering and return types correctly.
+ return activityType == ACTIVITY_TYPE_STANDARD
+ && (windowingMode == WINDOWING_MODE_FULLSCREEN
+ || windowingMode == WINDOWING_MODE_FREEFORM
+ || windowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY);
+ }
+
+ /**
+ * Returns an existing stack compatible with the windowing mode and activity type or creates one
+ * if a compatible stack doesn't exist.
+ * @see #getStack(int, int)
+ * @see #createStack(int, int, boolean)
+ */
+ ActivityStack getOrCreateStack(int windowingMode, int activityType,
+ boolean onTop) {
+ if (!alwaysCreateStack(windowingMode, activityType)) {
+ ActivityStack stack = getStack(windowingMode, activityType);
+ if (stack != null) {
+ return stack;
+ }
+ }
+ return createStack(windowingMode, activityType, onTop);
+ }
+
+ /**
+ * Returns an existing stack compatible with the input params or creates one
+ * if a compatible stack doesn't exist.
+ * @see #getOrCreateStack(int, int, boolean)
+ */
+ ActivityStack getOrCreateStack(@Nullable ActivityRecord r,
+ @Nullable ActivityOptions options, @Nullable Task candidateTask, int activityType,
+ boolean onTop) {
+ // First preference is the windowing mode in the activity options if set.
+ int windowingMode = (options != null)
+ ? options.getLaunchWindowingMode() : WINDOWING_MODE_UNDEFINED;
+ // Validate that our desired windowingMode will work under the current conditions.
+ // UNDEFINED windowing mode is a valid result and means that the new stack will inherit
+ // it's display's windowing mode.
+ windowingMode = validateWindowingMode(windowingMode, r, candidateTask, activityType);
+ return getOrCreateStack(windowingMode, activityType, onTop);
+ }
+
+ @VisibleForTesting
+ int getNextStackId() {
+ return sNextFreeStackId++;
+ }
+
+ /**
+ * Creates a stack matching the input windowing mode and activity type on this display.
+ * @param windowingMode The windowing mode the stack should be created in. If
+ * {@link WindowConfiguration#WINDOWING_MODE_UNDEFINED} then the stack will
+ * inherit its parent's windowing mode.
+ * @param activityType The activityType the stack should be created in. If
+ * {@link WindowConfiguration#ACTIVITY_TYPE_UNDEFINED} then the stack will
+ * be created in {@link WindowConfiguration#ACTIVITY_TYPE_STANDARD}.
+ * @param onTop If true the stack will be created at the top of the display, else at the bottom.
+ * @return The newly created stack.
+ */
+ ActivityStack createStack(int windowingMode, int activityType, boolean onTop) {
+ if (mSingleTaskInstance && getStackCount() > 0) {
+ // Create stack on default display instead since this display can only contain 1 stack.
+ // TODO: Kinda a hack, but better that having the decision at each call point. Hoping
+ // this goes away once ActivityView is no longer using virtual displays.
+ return mRootActivityContainer.getDefaultDisplay().createStack(
+ windowingMode, activityType, onTop);
+ }
+
+ if (activityType == ACTIVITY_TYPE_UNDEFINED) {
+ // Can't have an undefined stack type yet...so re-map to standard. Anyone that wants
+ // anything else should be passing it in anyways...
+ activityType = ACTIVITY_TYPE_STANDARD;
+ }
+
+ if (activityType != ACTIVITY_TYPE_STANDARD) {
+ // For now there can be only one stack of a particular non-standard activity type on a
+ // display. So, get that ignoring whatever windowing mode it is currently in.
+ ActivityStack stack = getStack(WINDOWING_MODE_UNDEFINED, activityType);
+ if (stack != null) {
+ throw new IllegalArgumentException("Stack=" + stack + " of activityType="
+ + activityType + " already on display=" + this + ". Can't have multiple.");
+ }
+ }
+
+ if (!isWindowingModeSupported(windowingMode, mAtmService.mSupportsMultiWindow,
+ mAtmService.mSupportsSplitScreenMultiWindow,
+ mAtmService.mSupportsFreeformWindowManagement,
+ mAtmService.mSupportsPictureInPicture, activityType)) {
+ throw new IllegalArgumentException("Can't create stack for unsupported windowingMode="
+ + windowingMode);
+ }
+
+ final int stackId = getNextStackId();
+ return createStackUnchecked(windowingMode, activityType, stackId, onTop);
+ }
+
+ @VisibleForTesting
+ ActivityStack createStackUnchecked(int windowingMode, int activityType,
+ int stackId, boolean onTop) {
+ if (windowingMode == WINDOWING_MODE_PINNED && activityType != ACTIVITY_TYPE_STANDARD) {
+ throw new IllegalArgumentException("Stack with windowing mode cannot with non standard "
+ + "activity type.");
+ }
+ return new ActivityStack(this, stackId, mRootActivityContainer.mStackSupervisor,
+ windowingMode, activityType, onTop);
+ }
+
+ /**
+ * Get the preferred focusable stack in priority. If the preferred stack does not exist, find a
+ * focusable and visible stack from the top of stacks in this display.
+ */
+ ActivityStack getFocusedStack() {
+ if (mPreferredTopFocusableStack != null) {
+ return mPreferredTopFocusableStack;
+ }
+
+ for (int i = getStackCount() - 1; i >= 0; --i) {
+ final ActivityStack stack = getStackAt(i);
+ if (stack.isFocusableAndVisible()) {
+ return stack;
+ }
+ }
+
+ return null;
+ }
+
+ ActivityStack getNextFocusableStack(ActivityStack currentFocus, boolean ignoreCurrent) {
+ final int currentWindowingMode = currentFocus != null
+ ? currentFocus.getWindowingMode() : WINDOWING_MODE_UNDEFINED;
+
+ ActivityStack candidate = null;
+ for (int i = getStackCount() - 1; i >= 0; --i) {
+ final ActivityStack stack = getStackAt(i);
+ if (ignoreCurrent && stack == currentFocus) {
+ continue;
+ }
+ if (!stack.isFocusableAndVisible()) {
+ continue;
+ }
+
+ if (currentWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY
+ && candidate == null && stack.inSplitScreenPrimaryWindowingMode()) {
+ // If the currently focused stack is in split-screen secondary we save off the
+ // top primary split-screen stack as a candidate for focus because we might
+ // prefer focus to move to an other stack to avoid primary split-screen stack
+ // overlapping with a fullscreen stack when a fullscreen stack is higher in z
+ // than the next split-screen stack. Assistant stack, I am looking at you...
+ // We only move the focus to the primary-split screen stack if there isn't a
+ // better alternative.
+ candidate = stack;
+ continue;
+ }
+ if (candidate != null && stack.inSplitScreenSecondaryWindowingMode()) {
+ // Use the candidate stack since we are now at the secondary split-screen.
+ return candidate;
+ }
+ return stack;
+ }
+ return candidate;
+ }
+
+ ActivityRecord getResumedActivity() {
+ final ActivityStack focusedStack = getFocusedStack();
+ if (focusedStack == null) {
+ return null;
+ }
+ // TODO(b/111541062): Move this into ActivityStack#getResumedActivity()
+ // Check if the focused stack has the resumed activity
+ ActivityRecord resumedActivity = focusedStack.getResumedActivity();
+ if (resumedActivity == null || resumedActivity.app == null) {
+ // If there is no registered resumed activity in the stack or it is not running -
+ // try to use previously resumed one.
+ resumedActivity = focusedStack.mPausingActivity;
+ if (resumedActivity == null || resumedActivity.app == null) {
+ // If previously resumed activity doesn't work either - find the topmost running
+ // activity that can be focused.
+ resumedActivity = focusedStack.topRunningActivity(true /* focusableOnly */);
+ }
+ }
+ return resumedActivity;
+ }
+
+ ActivityStack getLastFocusedStack() {
+ return mLastFocusedStack;
+ }
+
+ boolean allResumedActivitiesComplete() {
+ for (int stackNdx = getStackCount() - 1; stackNdx >= 0; --stackNdx) {
+ final ActivityRecord r = getStackAt(stackNdx).getResumedActivity();
+ if (r != null && !r.isState(RESUMED)) {
+ return false;
+ }
+ }
+ final ActivityStack currentFocusedStack = getFocusedStack();
+ if (ActivityTaskManagerDebugConfig.DEBUG_STACK) {
+ Slog.d(TAG_STACK, "allResumedActivitiesComplete: mLastFocusedStack changing from="
+ + mLastFocusedStack + " to=" + currentFocusedStack);
+ }
+ mLastFocusedStack = currentFocusedStack;
+ return true;
+ }
+
+ /**
+ * Pause all activities in either all of the stacks or just the back stacks. This is done before
+ * resuming a new activity and to make sure that previously active activities are
+ * paused in stacks that are no longer visible or in pinned windowing mode. This does not
+ * pause activities in visible stacks, so if an activity is launched within the same stack/task,
+ * then we should explicitly pause that stack's top activity.
+ * @param userLeaving Passed to pauseActivity() to indicate whether to call onUserLeaving().
+ * @param resuming The resuming activity.
+ * @return {@code true} if any activity was paused as a result of this call.
+ */
+ boolean pauseBackStacks(boolean userLeaving, ActivityRecord resuming) {
+ boolean someActivityPaused = false;
+ for (int stackNdx = getStackCount() - 1; stackNdx >= 0; --stackNdx) {
+ final ActivityStack stack = getStackAt(stackNdx);
+ final ActivityRecord resumedActivity = stack.getResumedActivity();
+ if (resumedActivity != null
+ && (stack.getVisibility(resuming) != STACK_VISIBILITY_VISIBLE
+ || !stack.isFocusable())) {
+ if (DEBUG_STATES) Slog.d(TAG_STATES, "pauseBackStacks: stack=" + stack
+ + " mResumedActivity=" + resumedActivity);
+ someActivityPaused |= stack.startPausingLocked(userLeaving, false /* uiSleeping*/,
+ resuming);
+ }
+ }
+ return someActivityPaused;
+ }
+
+ /**
+ * Find task for putting the Activity in.
+ */
+ void findTaskLocked(final ActivityRecord r, final boolean isPreferredDisplay,
+ RootActivityContainer.FindTaskResult result) {
+ mTmpFindTaskResult.clear();
+ for (int stackNdx = getStackCount() - 1; stackNdx >= 0; --stackNdx) {
+ final ActivityStack stack = getStackAt(stackNdx);
+ if (!r.hasCompatibleActivityType(stack)) {
+ if (DEBUG_TASKS) {
+ Slog.d(TAG_TASKS, "Skipping stack: (mismatch activity/stack) " + stack);
+ }
+ continue;
+ }
+
+ mTmpFindTaskResult.process(r, stack);
+ // It is possible to have tasks in multiple stacks with the same root affinity, so
+ // we should keep looking after finding an affinity match to see if there is a
+ // better match in another stack. Also, task affinity isn't a good enough reason
+ // to target a display which isn't the source of the intent, so skip any affinity
+ // matches not on the specified display.
+ if (mTmpFindTaskResult.mRecord != null) {
+ if (mTmpFindTaskResult.mIdealMatch) {
+ result.setTo(mTmpFindTaskResult);
+ return;
+ } else if (isPreferredDisplay) {
+ // Note: since the traversing through the stacks is top down, the floating
+ // tasks should always have lower priority than any affinity-matching tasks
+ // in the fullscreen stacks
+ result.setTo(mTmpFindTaskResult);
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes stacks in the input windowing modes from the system if they are of activity type
+ * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
+ */
+ void removeStacksInWindowingModes(int... windowingModes) {
+ if (windowingModes == null || windowingModes.length == 0) {
+ return;
+ }
+
+ // Collect the stacks that are necessary to be removed instead of performing the removal
+ // by looping mStacks, so that we don't miss any stacks after the stack size changed or
+ // stacks reordered.
+ final ArrayList<ActivityStack> stacks = new ArrayList<>();
+ for (int j = windowingModes.length - 1; j >= 0; --j) {
+ final int windowingMode = windowingModes[j];
+ for (int i = getStackCount() - 1; i >= 0; --i) {
+ final ActivityStack stack = getStackAt(i);
+ if (!stack.isActivityTypeStandardOrUndefined()) {
+ continue;
+ }
+ if (stack.getWindowingMode() != windowingMode) {
+ continue;
+ }
+ stacks.add(stack);
+ }
+ }
+
+ for (int i = stacks.size() - 1; i >= 0; --i) {
+ mRootActivityContainer.mStackSupervisor.removeStack(stacks.get(i));
+ }
+ }
+
+ void removeStacksWithActivityTypes(int... activityTypes) {
+ if (activityTypes == null || activityTypes.length == 0) {
+ return;
+ }
+
+ // Collect the stacks that are necessary to be removed instead of performing the removal
+ // by looping mStacks, so that we don't miss any stacks after the stack size changed or
+ // stacks reordered.
+ final ArrayList<ActivityStack> stacks = new ArrayList<>();
+ for (int j = activityTypes.length - 1; j >= 0; --j) {
+ final int activityType = activityTypes[j];
+ for (int i = getStackCount() - 1; i >= 0; --i) {
+ final ActivityStack stack = getStackAt(i);
+ if (stack.getActivityType() == activityType) {
+ stacks.add(stack);
+ }
+ }
+ }
+
+ for (int i = stacks.size() - 1; i >= 0; --i) {
+ mRootActivityContainer.mStackSupervisor.removeStack(stacks.get(i));
+ }
+ }
+
+ void onSplitScreenModeDismissed() {
+ mAtmService.deferWindowLayout();
+ try {
+ // Adjust the windowing mode of any stack in secondary split-screen to fullscreen.
+ for (int i = getStackCount() - 1; i >= 0; --i) {
+ final ActivityStack otherStack = getStackAt(i);
+ if (!otherStack.inSplitScreenSecondaryWindowingMode()) {
+ continue;
+ }
+ otherStack.setWindowingMode(WINDOWING_MODE_UNDEFINED, false /* animate */,
+ false /* showRecents */, false /* enteringSplitScreenMode */,
+ true /* deferEnsuringVisibility */, false /* creating */);
+ }
+ } finally {
+ final ActivityStack topFullscreenStack =
+ getTopStackInWindowingMode(WINDOWING_MODE_FULLSCREEN);
+ final ActivityStack homeStack = getHomeStack();
+ if (topFullscreenStack != null && homeStack != null && !isTopStack(homeStack)) {
+ // Whenever split-screen is dismissed we want the home stack directly behind the
+ // current top fullscreen stack so it shows up when the top stack is finished.
+ // TODO: Would be better to use ActivityDisplay.positionChildAt() for this, however
+ // ActivityDisplay doesn't have a direct controller to WM side yet. We can switch
+ // once we have that.
+ homeStack.moveToFront("onSplitScreenModeDismissed");
+ topFullscreenStack.moveToFront("onSplitScreenModeDismissed");
+ }
+ mAtmService.continueWindowLayout();
+ }
+ }
+
+ void onSplitScreenModeActivated() {
+ mAtmService.deferWindowLayout();
+ try {
+ // Adjust the windowing mode of any affected by split-screen to split-screen secondary.
+ final ActivityStack splitScreenPrimaryStack = getSplitScreenPrimaryStack();
+ for (int i = getStackCount() - 1; i >= 0; --i) {
+ final ActivityStack otherStack = getStackAt(i);
+ if (otherStack == splitScreenPrimaryStack
+ || !otherStack.affectedBySplitScreenResize()) {
+ continue;
+ }
+ otherStack.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_SECONDARY,
+ false /* animate */, false /* showRecents */,
+ true /* enteringSplitScreenMode */, true /* deferEnsuringVisibility */,
+ false /* creating */);
+ }
+ } finally {
+ mAtmService.continueWindowLayout();
+ }
+ }
+
+ /**
+ * Returns true if the {@param windowingMode} is supported based on other parameters passed in.
+ * @param windowingMode The windowing mode we are checking support for.
+ * @param supportsMultiWindow If we should consider support for multi-window mode in general.
+ * @param supportsSplitScreen If we should consider support for split-screen multi-window.
+ * @param supportsFreeform If we should consider support for freeform multi-window.
+ * @param supportsPip If we should consider support for picture-in-picture mutli-window.
+ * @param activityType The activity type under consideration.
+ * @return true if the windowing mode is supported.
+ */
+ private boolean isWindowingModeSupported(int windowingMode, boolean supportsMultiWindow,
+ boolean supportsSplitScreen, boolean supportsFreeform, boolean supportsPip,
+ int activityType) {
+
+ if (windowingMode == WINDOWING_MODE_UNDEFINED
+ || windowingMode == WINDOWING_MODE_FULLSCREEN) {
+ return true;
+ }
+ if (!supportsMultiWindow) {
+ return false;
+ }
+
+ final int displayWindowingMode = getWindowingMode();
+ if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY
+ || windowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY) {
+ return supportsSplitScreen
+ && WindowConfiguration.supportSplitScreenWindowingMode(activityType)
+ // Freeform windows and split-screen windows don't mix well, so prevent
+ // split windowing modes on freeform displays.
+ && displayWindowingMode != WINDOWING_MODE_FREEFORM;
+ }
+
+ if (!supportsFreeform && windowingMode == WINDOWING_MODE_FREEFORM) {
+ return false;
+ }
+
+ if (!supportsPip && windowingMode == WINDOWING_MODE_PINNED) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Resolves the windowing mode that an {@link ActivityRecord} would be in if started on this
+ * display with the provided parameters.
+ *
+ * @param r The ActivityRecord in question.
+ * @param options Options to start with.
+ * @param task The task within-which the activity would start.
+ * @param activityType The type of activity to start.
+ * @return The resolved (not UNDEFINED) windowing-mode that the activity would be in.
+ */
+ int resolveWindowingMode(@Nullable ActivityRecord r, @Nullable ActivityOptions options,
+ @Nullable Task task, int activityType) {
+
+ // First preference if the windowing mode in the activity options if set.
+ int windowingMode = (options != null)
+ ? options.getLaunchWindowingMode() : WINDOWING_MODE_UNDEFINED;
+
+ // If windowing mode is unset, then next preference is the candidate task, then the
+ // activity record.
+ if (windowingMode == WINDOWING_MODE_UNDEFINED) {
+ if (task != null) {
+ windowingMode = task.getWindowingMode();
+ }
+ if (windowingMode == WINDOWING_MODE_UNDEFINED && r != null) {
+ windowingMode = r.getWindowingMode();
+ }
+ if (windowingMode == WINDOWING_MODE_UNDEFINED) {
+ // Use the display's windowing mode.
+ windowingMode = getWindowingMode();
+ }
+ }
+ windowingMode = validateWindowingMode(windowingMode, r, task, activityType);
+ return windowingMode != WINDOWING_MODE_UNDEFINED
+ ? windowingMode : WINDOWING_MODE_FULLSCREEN;
+ }
+
+ /**
+ * Check that the requested windowing-mode is appropriate for the specified task and/or activity
+ * on this display.
+ *
+ * @param windowingMode The windowing-mode to validate.
+ * @param r The {@link ActivityRecord} to check against.
+ * @param task The {@link Task} to check against.
+ * @param activityType An activity type.
+ * @return The provided windowingMode or the closest valid mode which is appropriate.
+ */
+ int validateWindowingMode(int windowingMode, @Nullable ActivityRecord r, @Nullable Task task,
+ int activityType) {
+ // Make sure the windowing mode we are trying to use makes sense for what is supported.
+ boolean supportsMultiWindow = mAtmService.mSupportsMultiWindow;
+ boolean supportsSplitScreen = mAtmService.mSupportsSplitScreenMultiWindow;
+ boolean supportsFreeform = mAtmService.mSupportsFreeformWindowManagement;
+ boolean supportsPip = mAtmService.mSupportsPictureInPicture;
+ if (supportsMultiWindow) {
+ if (task != null) {
+ supportsMultiWindow = task.isResizeable();
+ supportsSplitScreen = task.supportsSplitScreenWindowingMode();
+ // TODO: Do we need to check for freeform and Pip support here?
+ } else if (r != null) {
+ supportsMultiWindow = r.isResizeable();
+ supportsSplitScreen = r.supportsSplitScreenWindowingMode();
+ supportsFreeform = r.supportsFreeform();
+ supportsPip = r.supportsPictureInPicture();
+ }
+ }
+
+ final boolean inSplitScreenMode = hasSplitScreenPrimaryStack();
+ if (!inSplitScreenMode
+ && windowingMode == WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY) {
+ // Switch to the display's windowing mode if we are not in split-screen mode and we are
+ // trying to launch in split-screen secondary.
+ windowingMode = WINDOWING_MODE_UNDEFINED;
+ } else if (inSplitScreenMode && (windowingMode == WINDOWING_MODE_FULLSCREEN
+ || windowingMode == WINDOWING_MODE_UNDEFINED)
+ && supportsSplitScreen) {
+ windowingMode = WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
+ }
+
+ if (windowingMode != WINDOWING_MODE_UNDEFINED
+ && isWindowingModeSupported(windowingMode, supportsMultiWindow, supportsSplitScreen,
+ supportsFreeform, supportsPip, activityType)) {
+ return windowingMode;
+ }
+ return WINDOWING_MODE_UNDEFINED;
+ }
+
+ boolean isTopStack(ActivityStack stack) {
+ return stack == getTopStack();
+ }
+
+ boolean isTopNotPinnedStack(ActivityStack stack) {
+ for (int i = getStackCount() - 1; i >= 0; --i) {
+ final ActivityStack current = getStackAt(i);
+ if (!current.inPinnedWindowingMode()) {
+ return current == stack;
+ }
+ }
+ return false;
+ }
+
+ ActivityRecord topRunningActivity() {
+ return topRunningActivity(false /* considerKeyguardState */);
+ }
+
+ /**
+ * Returns the top running activity in the focused stack. In the case the focused stack has no
+ * such activity, the next focusable stack on this display is returned.
+ *
+ * @param considerKeyguardState Indicates whether the locked state should be considered. if
+ * {@code true} and the keyguard is locked, only activities that
+ * can be shown on top of the keyguard will be considered.
+ * @return The top running activity. {@code null} if none is available.
+ */
+ ActivityRecord topRunningActivity(boolean considerKeyguardState) {
+ ActivityRecord topRunning = null;
+ final ActivityStack focusedStack = getFocusedStack();
+ if (focusedStack != null) {
+ topRunning = focusedStack.topRunningActivity();
+ }
+
+ // Look in other focusable stacks.
+ if (topRunning == null) {
+ for (int i = getStackCount() - 1; i >= 0; --i) {
+ final ActivityStack stack = getStackAt(i);
+ // Only consider focusable stacks other than the current focused one.
+ if (stack == focusedStack || !stack.isFocusable()) {
+ continue;
+ }
+ topRunning = stack.topRunningActivity();
+ if (topRunning != null) {
+ break;
+ }
+ }
+ }
+
+ // This activity can be considered the top running activity if we are not considering
+ // the locked state, the keyguard isn't locked, or we can show when locked.
+ if (topRunning != null && considerKeyguardState
+ && mRootActivityContainer.mStackSupervisor.getKeyguardController()
+ .isKeyguardLocked()
+ && !topRunning.canShowWhenLocked()) {
+ return null;
+ }
+
+ return topRunning;
+ }
+
+ boolean updateDisplayOverrideConfigurationLocked() {
+ Configuration values = new Configuration();
+ computeScreenConfiguration(values);
+
+ mAtmService.mH.sendMessage(PooledLambda.obtainMessage(
+ ActivityManagerInternal::updateOomLevelsForDisplay, mAtmService.mAmInternal,
+ mDisplayId));
+
+ Settings.System.clearConfiguration(values);
+ updateDisplayOverrideConfigurationLocked(values, null /* starting */,
+ false /* deferResume */, mAtmService.mTmpUpdateConfigurationResult);
+ return mAtmService.mTmpUpdateConfigurationResult.changes != 0;
+ }
+
+ /**
+ * Updates override configuration specific for the selected display. If no config is provided,
+ * new one will be computed in WM based on current display info.
+ */
+ boolean updateDisplayOverrideConfigurationLocked(Configuration values,
+ ActivityRecord starting, boolean deferResume,
+ ActivityTaskManagerService.UpdateConfigurationResult result) {
+
+ int changes = 0;
+ boolean kept = true;
+
+ mAtmService.deferWindowLayout();
+ try {
+ if (values != null) {
+ if (mDisplayId == DEFAULT_DISPLAY) {
+ // Override configuration of the default display duplicates global config, so
+ // we're calling global config update instead for default display. It will also
+ // apply the correct override config.
+ changes = mAtmService.updateGlobalConfigurationLocked(values,
+ false /* initLocale */, false /* persistent */,
+ UserHandle.USER_NULL /* userId */, deferResume);
+ } else {
+ changes = performDisplayOverrideConfigUpdate(values, deferResume);
+ }
+ }
+
+ kept = mAtmService.ensureConfigAndVisibilityAfterUpdate(starting, changes);
+ } finally {
+ mAtmService.continueWindowLayout();
+ }
+
+ if (result != null) {
+ result.changes = changes;
+ result.activityRelaunched = !kept;
+ }
+ return kept;
+ }
+
+ int performDisplayOverrideConfigUpdate(Configuration values, boolean deferResume) {
+ mTempConfig.setTo(getRequestedOverrideConfiguration());
+ final int changes = mTempConfig.updateFrom(values);
+ if (changes != 0) {
+ Slog.i(TAG, "Override config changes=" + Integer.toHexString(changes) + " "
+ + mTempConfig + " for displayId=" + mDisplayId);
+ onRequestedOverrideConfigurationChanged(mTempConfig);
+
+ final boolean isDensityChange = (changes & ActivityInfo.CONFIG_DENSITY) != 0;
+ if (isDensityChange && mDisplayId == DEFAULT_DISPLAY) {
+ mAtmService.mAppWarnings.onDensityChanged();
+
+ // Post message to start process to avoid possible deadlock of calling into AMS with
+ // the ATMS lock held.
+ final Message msg = PooledLambda.obtainMessage(
+ ActivityManagerInternal::killAllBackgroundProcessesExcept,
+ mAtmService.mAmInternal, N,
+ ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND);
+ mAtmService.mH.sendMessage(msg);
+ }
+ mWmService.mDisplayNotificationController.dispatchDisplayChanged(
+ this, getConfiguration());
+ }
+ return changes;
+ }
+
+ @Override
+ public void onRequestedOverrideConfigurationChanged(Configuration overrideConfiguration) {
+ final int currRotation =
+ getRequestedOverrideConfiguration().windowConfiguration.getRotation();
+ if (currRotation != ROTATION_UNDEFINED
+ && currRotation != overrideConfiguration.windowConfiguration.getRotation()) {
+ applyRotationLocked(currRotation,
+ overrideConfiguration.windowConfiguration.getRotation());
+ }
+ mCurrentOverrideConfigurationChanges =
+ getRequestedOverrideConfiguration().diff(overrideConfiguration);
+ super.onRequestedOverrideConfigurationChanged(overrideConfiguration);
+ mCurrentOverrideConfigurationChanges = 0;
+ mWmService.setNewDisplayOverrideConfiguration(overrideConfiguration, this);
+ mAtmService.addWindowLayoutReasons(
+ ActivityTaskManagerService.LAYOUT_REASON_CONFIG_CHANGED);
+ }
+
+ /** Checks whether the given activity is in size compatibility mode and notifies the change. */
+ void handleActivitySizeCompatModeIfNeeded(ActivityRecord r) {
+ if (!r.isState(RESUMED) || r.getWindowingMode() != WINDOWING_MODE_FULLSCREEN) {
+ // The callback is only interested in the foreground changes of fullscreen activity.
+ return;
+ }
+ if (!r.inSizeCompatMode()) {
+ if (mLastCompatModeActivity != null) {
+ mAtmService.getTaskChangeNotificationController()
+ .notifySizeCompatModeActivityChanged(mDisplayId, null /* activityToken */);
+ }
+ mLastCompatModeActivity = null;
+ return;
+ }
+ if (mLastCompatModeActivity == r) {
+ return;
+ }
+ mLastCompatModeActivity = r;
+ mAtmService.getTaskChangeNotificationController()
+ .notifySizeCompatModeActivityChanged(mDisplayId, r.appToken);
+ }
+
+ boolean isUidPresent(int uid) {
+ final PooledPredicate p = PooledLambda.obtainPredicate(
+ ActivityRecord::isUid, PooledLambda.__(ActivityRecord.class), uid);
+ final boolean isUidPresent = mDisplayContent.getActivity(p) != null;
+ p.recycle();
+ return isUidPresent;
+ }
+
+ /**
+ * @see #mRemoved
+ */
+ boolean isRemoved() {
+ return mRemoved;
+ }
+
+ /**
+ * @see #mRemoving
+ */
+ boolean isRemoving() {
+ return mRemoving;
+ }
+
+ void remove() {
+ mRemoving = true;
+ final boolean destroyContentOnRemoval = shouldDestroyContentOnRemove();
+ ActivityStack lastReparentedStack = null;
+ mPreferredTopFocusableStack = null;
+
+ // Stacks could be reparented from the removed display to other display. While
+ // reparenting the last stack of the removed display, the remove display is ready to be
+ // released (no more ActivityStack). But, we cannot release it at that moment or the
+ // related WindowContainer will also be removed. So, we set display as removed after
+ // reparenting stack finished.
+ final DisplayContent toDisplay = mRootActivityContainer.getDefaultDisplay();
+ mRootActivityContainer.mStackSupervisor.beginDeferResume();
+ try {
+ int numStacks = getStackCount();
+ // Keep the order from bottom to top.
+ for (int stackNdx = 0; stackNdx < numStacks; stackNdx++) {
+ final ActivityStack stack = getStackAt(stackNdx);
+ // Always finish non-standard type stacks.
+ if (destroyContentOnRemoval || !stack.isActivityTypeStandardOrUndefined()) {
+ stack.finishAllActivitiesImmediately();
+ } else {
+ // If default display is in split-window mode, set windowing mode of the stack
+ // to split-screen secondary. Otherwise, set the windowing mode to undefined by
+ // default to let stack inherited the windowing mode from the new display.
+ final int windowingMode = toDisplay.hasSplitScreenPrimaryStack()
+ ? WINDOWING_MODE_SPLIT_SCREEN_SECONDARY
+ : WINDOWING_MODE_UNDEFINED;
+ stack.reparent(toDisplay, true /* onTop */);
+ stack.setWindowingMode(windowingMode);
+ lastReparentedStack = stack;
+ }
+ // Stacks may be removed from this display. Ensure each stack will be processed and
+ // the loop will end.
+ stackNdx -= numStacks - getStackCount();
+ numStacks = getStackCount();
+ }
+ } finally {
+ mRootActivityContainer.mStackSupervisor.endDeferResume();
+ }
+ mRemoved = true;
+
+ // Only update focus/visibility for the last one because there may be many stacks are
+ // reparented and the intermediate states are unnecessary.
+ if (lastReparentedStack != null) {
+ lastReparentedStack.postReparent();
+ }
+ releaseSelfIfNeeded();
+
+ if (!mAllSleepTokens.isEmpty()) {
+ mRootActivityContainer.mSleepTokens.removeAll(mAllSleepTokens);
+ mAllSleepTokens.clear();
+ mAtmService.updateSleepIfNeededLocked();
+ }
+ }
+
+ private void releaseSelfIfNeeded() {
+ if (!mRemoved) {
+ return;
+ }
+
+ final ActivityStack stack = getStackCount() == 1 ? getStackAt(0) : null;
+ if (stack != null && stack.isActivityTypeHome() && !stack.hasChild()) {
+ // Release this display if an empty home stack is the only thing left.
+ // Since it is the last stack, this display will be released along with the stack
+ // removal.
+ stack.removeIfPossible();
+ } else if (getTopStack() == null) {
+ removeIfPossible();
+ mRootActivityContainer.removeChild(this);
+ mRootActivityContainer.mStackSupervisor
+ .getKeyguardController().onDisplayRemoved(mDisplayId);
+ }
+ }
+
+ /** Update and get all UIDs that are present on the display and have access to it. */
+ IntArray getPresentUIDs() {
+ mDisplayAccessUIDs.clear();
+ final PooledConsumer c = PooledLambda.obtainConsumer(DisplayContent::addActivityUid,
+ PooledLambda.__(ActivityRecord.class), mDisplayAccessUIDs);
+ mDisplayContent.forAllActivities(c);
+ c.recycle();
+ return mDisplayAccessUIDs;
+ }
+
+ private static void addActivityUid(ActivityRecord r, IntArray uids) {
+ uids.add(r.getUid());
+ }
+
+ @VisibleForTesting
+ boolean shouldDestroyContentOnRemove() {
+ return mDisplay.getRemoveMode() == REMOVE_MODE_DESTROY_CONTENT;
+ }
+
+ boolean shouldSleep() {
+ return (getStackCount() == 0 || !mAllSleepTokens.isEmpty())
+ && (mAtmService.mRunningVoice == null);
+ }
+
+ void setFocusedApp(ActivityRecord r, boolean moveFocusNow) {
+ final ActivityRecord newFocus;
+ final IBinder token = r.appToken;
+ if (token == null) {
+ ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "Clearing focused app, displayId=%d",
+ mDisplayId);
+ newFocus = null;
+ } else {
+ newFocus = mWmService.mRoot.getActivityRecord(token);
+ if (newFocus == null) {
+ Slog.w(TAG_WM, "Attempted to set focus to non-existing app token: " + token
+ + ", displayId=" + mDisplayId);
+ }
+ ProtoLog.v(WM_DEBUG_FOCUS_LIGHT,
+ "Set focused app to: %s moveFocusNow=%b displayId=%d", newFocus,
+ moveFocusNow, mDisplayId);
+ }
+
+ final boolean changed = setFocusedApp(newFocus);
+ if (moveFocusNow && changed) {
+ mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL,
+ true /*updateInputWindows*/);
+ }
+ }
+
+ /**
+ * @return the stack currently above the {@param stack}. Can be null if the {@param stack} is
+ * already top-most.
+ */
+ ActivityStack getStackAbove(ActivityStack stack) {
+ final int stackIndex = getIndexOf(stack) + 1;
+ return (stackIndex < getStackCount()) ? getStackAt(stackIndex) : null;
+ }
+
+ /**
+ * Adjusts the {@param stack} behind the last visible stack in the display if necessary.
+ * Generally used in conjunction with {@link #moveStackBehindStack}.
+ */
+ void moveStackBehindBottomMostVisibleStack(ActivityStack stack) {
+ if (stack.shouldBeVisible(null)) {
+ // Skip if the stack is already visible
+ return;
+ }
+
+ // Move the stack to the bottom to not affect the following visibility checks
+ positionStackAtBottom(stack);
+
+ // Find the next position where the stack should be placed
+ final int numStacks = getStackCount();
+ for (int stackNdx = 0; stackNdx < numStacks; stackNdx++) {
+ final ActivityStack s = getStackAt(stackNdx);
+ if (s == stack) {
+ continue;
+ }
+ final int winMode = s.getWindowingMode();
+ final boolean isValidWindowingMode = winMode == WINDOWING_MODE_FULLSCREEN
+ || winMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
+ if (s.shouldBeVisible(null) && isValidWindowingMode) {
+ // Move the provided stack to behind this stack
+ positionStackAt(stack, Math.max(0, stackNdx - 1));
+ break;
+ }
+ }
+ }
+
+ /**
+ * Moves the {@param stack} behind the given {@param behindStack} if possible. If
+ * {@param behindStack} is not currently in the display, then then the stack is moved to the
+ * back. Generally used in conjunction with {@link #moveStackBehindBottomMostVisibleStack}.
+ */
+ void moveStackBehindStack(ActivityStack stack, ActivityStack behindStack) {
+ if (behindStack == null || behindStack == stack) {
+ return;
+ }
+
+ // Note that positionChildAt will first remove the given stack before inserting into the
+ // list, so we need to adjust the insertion index to account for the removed index
+ // TODO: Remove this logic when WindowContainer.positionChildAt() is updated to adjust the
+ // position internally
+ final int stackIndex = getIndexOf(stack);
+ final int behindStackIndex = getIndexOf(behindStack);
+ final int insertIndex = stackIndex <= behindStackIndex
+ ? behindStackIndex - 1 : behindStackIndex;
+ positionStackAt(stack, Math.max(0, insertIndex));
+ }
+
+ void ensureActivitiesVisible(ActivityRecord starting, int configChanges,
+ boolean preserveWindows, boolean notifyClients) {
+ for (int stackNdx = getStackCount() - 1; stackNdx >= 0; --stackNdx) {
+ final ActivityStack stack = getStackAt(stackNdx);
+ stack.ensureActivitiesVisible(starting, configChanges, preserveWindows,
+ notifyClients);
+ }
+ }
+
+ void moveHomeStackToFront(String reason) {
+ final ActivityStack homeStack = getHomeStack();
+ if (homeStack != null) {
+ homeStack.moveToFront(reason);
+ }
+ }
+
+ /**
+ * Moves the focusable home activity to top. If there is no such activity, the home stack will
+ * still move to top.
+ */
+ void moveHomeActivityToTop(String reason) {
+ final ActivityRecord top = getHomeActivity();
+ if (top == null) {
+ moveHomeStackToFront(reason);
+ return;
+ }
+ top.moveFocusableActivityToTop(reason);
+ }
+
+ @Nullable
+ ActivityRecord getHomeActivity() {
+ return getHomeActivityForUser(mRootActivityContainer.mCurrentUser);
+ }
+
+ @Nullable
+ ActivityRecord getHomeActivityForUser(int userId) {
+ final ActivityStack homeStack = getHomeStack();
+ if (homeStack == null) {
+ return null;
+ }
+
+ final PooledPredicate p = PooledLambda.obtainPredicate(
+ DisplayContent::isHomeActivityForUser, PooledLambda.__(ActivityRecord.class),
+ userId);
+ final ActivityRecord r = homeStack.getActivity(p);
+ p.recycle();
+ return r;
+ }
+
+ private static boolean isHomeActivityForUser(ActivityRecord r, int userId) {
+ return r.isActivityTypeHome() && (userId == UserHandle.USER_ALL || r.mUserId == userId);
+ }
+
+ boolean isSleeping() {
+ return mSleeping;
+ }
+
+ void setIsSleeping(boolean asleep) {
+ mSleeping = asleep;
+ }
+
+ /**
+ * Adds a listener to be notified whenever the stack order in the display changes. Currently
+ * only used by the {@link RecentsAnimation} to determine whether to interrupt and cancel the
+ * current animation when the system state changes.
+ */
+ void registerStackOrderChangedListener(OnStackOrderChangedListener listener) {
+ if (!mStackOrderChangedCallbacks.contains(listener)) {
+ mStackOrderChangedCallbacks.add(listener);
+ }
+ }
+
+ /**
+ * Removes a previously registered stack order change listener.
+ */
+ void unregisterStackOrderChangedListener(OnStackOrderChangedListener listener) {
+ mStackOrderChangedCallbacks.remove(listener);
+ }
+
+ /**
+ * Notifies of a stack order change
+ * @param stack The stack which triggered the order change
+ */
+ private void onStackOrderChanged(ActivityStack stack) {
+ for (int i = mStackOrderChangedCallbacks.size() - 1; i >= 0; i--) {
+ mStackOrderChangedCallbacks.get(i).onStackOrderChanged(stack);
+ }
+ }
+
+ void setDisplayToSingleTaskInstance() {
+ final int childCount = getStackCount();
+ if (childCount > 1) {
+ throw new IllegalArgumentException("Display already has multiple stacks. display="
+ + this);
+ }
+ if (childCount > 0) {
+ final ActivityStack stack = getStackAt(0);
+ if (stack.getChildCount() > 1) {
+ throw new IllegalArgumentException("Display stack already has multiple tasks."
+ + " display=" + this + " stack=" + stack);
+ }
+ }
+
+ mSingleTaskInstance = true;
+ }
+
+ /** Returns true if the display can only contain one task */
+ boolean isSingleTaskInstance() {
+ return mSingleTaskInstance;
+ }
+
+ @VisibleForTesting
+ void removeAllTasks() {
+ forAllTasks((t) -> { t.getStack().removeChild(t, "removeAllTasks"); });
+ }
+
+ /**
+ * Callback for when the order of the stacks in the display changes.
+ */
+ interface OnStackOrderChangedListener {
+ void onStackOrderChanged(ActivityStack stack);
+ }
+
+ public void dumpStacks(PrintWriter pw) {
+ for (int i = getStackCount() - 1; i >= 0; --i) {
+ pw.print(getStackAt(i).mStackId);
+ if (i > 0) {
+ pw.print(",");
+ }
+ }
+ }
}
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index 2283041..667e713 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -33,6 +33,7 @@
import static android.view.InsetsState.ITYPE_STATUS_BAR;
import static android.view.InsetsState.ITYPE_TOP_GESTURES;
import static android.view.InsetsState.ITYPE_TOP_TAPPABLE_ELEMENT;
+import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
@@ -49,7 +50,6 @@
import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_ATTACHED_IN_DECOR;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
-import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
@@ -63,6 +63,7 @@
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
+import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_ONLY_DRAW_BOTTOM_BAR_BACKGROUND;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
@@ -149,13 +150,17 @@
import android.view.InputEvent;
import android.view.InputEventReceiver;
import android.view.InsetsFlags;
+import android.view.InsetsState;
import android.view.InsetsState.InternalInsetsType;
import android.view.MotionEvent;
import android.view.PointerIcon;
import android.view.Surface;
import android.view.View;
import android.view.ViewRootImpl;
-import android.view.WindowInsets;
+import android.view.WindowInsets.Side;
+import android.view.WindowInsets.Side.InsetsSide;
+import android.view.WindowInsets.Type;
+import android.view.WindowInsets.Type.InsetsType;
import android.view.WindowInsetsController.Appearance;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
@@ -337,6 +342,7 @@
private int mLastAppearance;
private int mLastFullscreenAppearance;
private int mLastDockedAppearance;
+ private int mLastBehavior;
private final Rect mNonDockedStackBounds = new Rect();
private final Rect mDockedStackBounds = new Rect();
private final Rect mLastNonDockedStackBounds = new Rect();
@@ -353,6 +359,7 @@
private static final Rect sTmpRect = new Rect();
private static final Rect sTmpNavFrame = new Rect();
private static final Rect sTmpLastParentFrame = new Rect();
+ private static final int[] sTmpTypesAndSides = new int[2];
private WindowState mTopFullscreenOpaqueWindowState;
private WindowState mTopFullscreenOpaqueOrDimmingWindowState;
@@ -1228,7 +1235,8 @@
final boolean screenDecor = (pfl & PRIVATE_FLAG_IS_SCREEN_DECOR) != 0;
if (layoutInScreenAndInsetDecor && !screenDecor) {
- if ((sysUiVis & SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0) {
+ if ((sysUiVis & SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0
+ || (attrs.getFitWindowInsetsTypes() & Type.navigationBars()) == 0) {
outFrame.set(displayFrames.mUnrestricted);
} else {
outFrame.set(displayFrames.mRestricted);
@@ -1281,11 +1289,27 @@
}
}
+ private static void getImpliedTypesAndSidesToFit(LayoutParams attrs, int[] typesAndSides) {
+ typesAndSides[0] = attrs.getFitWindowInsetsTypes();
+ typesAndSides[1] = attrs.getFitWindowInsetsSides();
+ final boolean forceDrawsBarBackgrounds =
+ (attrs.privateFlags & PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS) != 0
+ && attrs.height == MATCH_PARENT && attrs.width == MATCH_PARENT;
+ if ((attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0 || forceDrawsBarBackgrounds) {
+ if ((attrs.privateFlags & PRIVATE_FLAG_ONLY_DRAW_BOTTOM_BAR_BACKGROUND) != 0) {
+ typesAndSides[1] &= ~Side.BOTTOM;
+ } else {
+ typesAndSides[0] &= ~Type.systemBars();
+ }
+ }
+ }
+
+ // TODO(b/118118435): remove after migration
private static int getImpliedSysUiFlagsForLayout(LayoutParams attrs) {
int impliedFlags = 0;
final boolean forceWindowDrawsBarBackgrounds =
(attrs.privateFlags & PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS) != 0
- && attrs.height == MATCH_PARENT && attrs.width == MATCH_PARENT;
+ && attrs.height == MATCH_PARENT && attrs.width == MATCH_PARENT;
if ((attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0
|| forceWindowDrawsBarBackgrounds) {
impliedFlags |= SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
@@ -1300,6 +1324,13 @@
synchronized (mLock) {
mForceClearedSystemUiFlags &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
mDisplayContent.reevaluateStatusBarVisibility();
+ if (ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_FULL && mNavigationBar != null) {
+ final InsetsControlTarget target =
+ mNavigationBar.getControllableInsetProvider().getControlTarget();
+ if (target != null) {
+ target.showInsets(Type.navigationBars(), false /* fromIme */);
+ }
+ }
}
}
};
@@ -1376,11 +1407,18 @@
// For purposes of putting out fake window up to steal focus, we will
// drive nav being hidden only by whether it is requested.
final int sysui = mLastSystemUiFlags;
- boolean navVisible = (sysui & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
+ final int behavior = mLastBehavior;
+ boolean navVisible = ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL
+ ? (sysui & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0
+ : mNavigationBar != null && mNavigationBar.getControllableInsetProvider() != null
+ && mNavigationBar.getControllableInsetProvider().isClientVisible()
+ && !mDisplayContent.getInsetsPolicy().isTransient(ITYPE_NAVIGATION_BAR);
boolean navTranslucent = (sysui
& (View.NAVIGATION_BAR_TRANSLUCENT | View.NAVIGATION_BAR_TRANSPARENT)) != 0;
- boolean immersive = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0;
- boolean immersiveSticky = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0;
+ boolean immersive = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0
+ || (behavior & BEHAVIOR_SHOW_BARS_BY_SWIPE) != 0;
+ boolean immersiveSticky = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0
+ || (behavior & BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE) != 0;
boolean navAllowedHidden = immersive || immersiveSticky;
navTranslucent &= !immersiveSticky; // transient trumps translucent
boolean isKeyguardShowing = isStatusBarKeyguard()
@@ -1464,6 +1502,9 @@
displayFrames.mUnrestricted /* stableFrame */);
w.getWindowFrames().setDisplayCutout(displayFrames.mDisplayCutout);
w.computeFrameLw();
+ if (w.getControllableInsetProvider() != null) {
+ w.getControllableInsetProvider().updateSourceFrame();
+ }
final Rect frame = w.getFrameLw();
if (frame.left <= 0 && frame.top <= 0) {
@@ -1526,6 +1567,11 @@
// Let the status bar determine its size.
mStatusBar.computeFrameLw();
+ // Update the source frame to provide insets to other windows during layout.
+ if (mStatusBar.getControllableInsetProvider() != null) {
+ mStatusBar.getControllableInsetProvider().updateSourceFrame();
+ }
+
// For layout, the status bar is always at the top with our fixed height.
displayFrames.mStable.top = displayFrames.mUnrestricted.top
+ mStatusBarHeightForRotation[displayFrames.mRotation];
@@ -1540,7 +1586,8 @@
sTmpRect.bottom = displayFrames.mStable.top; // Use collapsed status bar size
mStatusBarController.setContentFrame(sTmpRect);
- boolean statusBarTransient = (sysui & View.STATUS_BAR_TRANSIENT) != 0;
+ boolean statusBarTransient = (sysui & View.STATUS_BAR_TRANSIENT) != 0
+ || mDisplayContent.getInsetsPolicy().isTransient(ITYPE_STATUS_BAR);
boolean statusBarTranslucent = (sysui
& (View.STATUS_BAR_TRANSLUCENT | View.STATUS_BAR_TRANSPARENT)) != 0;
@@ -1676,6 +1723,9 @@
navigationFrame /* stableFrame */);
mNavigationBar.getWindowFrames().setDisplayCutout(displayFrames.mDisplayCutout);
mNavigationBar.computeFrameLw();
+ if (mNavigationBar.getControllableInsetProvider() != null) {
+ mNavigationBar.getControllableInsetProvider().updateSourceFrame();
+ }
mNavigationBarController.setContentFrame(mNavigationBar.getContentFrameLw());
if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + navigationFrame);
@@ -1811,19 +1861,44 @@
final int adjust = sim & SOFT_INPUT_MASK_ADJUST;
- final boolean requestedFullscreen = (fl & FLAG_FULLSCREEN) != 0
- || (requestedSysUiFl & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0;
-
final boolean layoutInScreen = (fl & FLAG_LAYOUT_IN_SCREEN) == FLAG_LAYOUT_IN_SCREEN;
final boolean layoutInsetDecor = (fl & FLAG_LAYOUT_INSET_DECOR) == FLAG_LAYOUT_INSET_DECOR;
sf.set(displayFrames.mStable);
- if (type == TYPE_INPUT_METHOD) {
+ if (ViewRootImpl.sNewInsetsMode == NEW_INSETS_MODE_FULL) {
+ getImpliedTypesAndSidesToFit(attrs, sTmpTypesAndSides);
+ final @InsetsType int typesToFit = sTmpTypesAndSides[0];
+ final @InsetsSide int sidesToFit = sTmpTypesAndSides[1];
+ final ArraySet<Integer> types = InsetsState.toInternalType(typesToFit);
+ final Rect dfu = displayFrames.mUnrestricted;
+ Insets insets = Insets.of(0, 0, 0, 0);
+ for (int i = types.size() - 1; i >= 0; i--) {
+ insets = Insets.max(insets, mDisplayContent.getInsetsStateController()
+ .getInsetsForDispatch(win).getSource(types.valueAt(i))
+ .calculateInsets(dfu, attrs.getFitIgnoreVisibility()));
+ }
+ final int left = (sidesToFit & Side.LEFT) != 0 ? insets.left : 0;
+ final int top = (sidesToFit & Side.TOP) != 0 ? insets.top : 0;
+ final int right = (sidesToFit & Side.RIGHT) != 0 ? insets.right : 0;
+ final int bottom = (sidesToFit & Side.BOTTOM) != 0 ? insets.bottom : 0;
+ df.set(left, top, dfu.right - right, dfu.bottom - bottom);
+ if (attached == null) {
+ pf.set(df);
+ vf.set(adjust != SOFT_INPUT_ADJUST_NOTHING
+ ? displayFrames.mCurrent : displayFrames.mDock);
+ } else {
+ pf.set((fl & FLAG_LAYOUT_IN_SCREEN) == 0 ? attached.getFrameLw() : df);
+ vf.set(attached.getVisibleFrameLw());
+ }
+ cf.set(adjust != SOFT_INPUT_ADJUST_RESIZE
+ ? displayFrames.mDock : displayFrames.mContent);
+ dcf.set(displayFrames.mSystem);
+ } else if (type == TYPE_INPUT_METHOD) {
vf.set(displayFrames.mDock);
cf.set(displayFrames.mDock);
df.set(displayFrames.mDock);
- windowFrames.mParentFrame.set(displayFrames.mDock);
+ pf.set(displayFrames.mDock);
// IM dock windows layout below the nav bar...
pf.bottom = df.bottom = displayFrames.mUnrestricted.bottom;
// ...with content insets above the nav bar
@@ -1989,7 +2064,7 @@
}
}
} else if (layoutInScreen || (sysUiFl
- & (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ & (SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)) != 0) {
if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle()
+ "): IN_SCREEN");
@@ -2039,7 +2114,7 @@
cf.set(displayFrames.mUnrestricted);
df.set(displayFrames.mUnrestricted);
pf.set(displayFrames.mUnrestricted);
- } else if ((sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) != 0) {
+ } else if ((sysUiFl & SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) != 0) {
df.set(displayFrames.mRestricted);
pf.set(displayFrames.mRestricted);
@@ -2111,8 +2186,12 @@
final int cutoutMode = attrs.layoutInDisplayCutoutMode;
final boolean attachedInParent = attached != null && !layoutInScreen;
+ final boolean requestedFullscreen = (fl & FLAG_FULLSCREEN) != 0
+ || (requestedSysUiFl & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0
+ || !win.getClientInsetsState().getSource(ITYPE_STATUS_BAR).isVisible();
final boolean requestedHideNavigation =
- (requestedSysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0;
+ (requestedSysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0
+ || !win.getClientInsetsState().getSource(ITYPE_NAVIGATION_BAR).isVisible();
// TYPE_BASE_APPLICATION windows are never considered floating here because they don't get
// cropped / shifted to the displayFrame in WindowState.
@@ -2195,6 +2274,9 @@
}
win.computeFrameLw();
+ if (win.getControllableInsetProvider() != null) {
+ win.getControllableInsetProvider().updateSourceFrame();
+ }
// Dock windows carve out the bottom of the screen, so normal windows
// can't appear underneath them.
if (type == TYPE_INPUT_METHOD && win.isVisibleLw()
@@ -2985,7 +3067,7 @@
mDisplayContent.getInsetsPolicy().showTransient(IntArray.wrap(
new int[]{ITYPE_STATUS_BAR, ITYPE_NAVIGATION_BAR}));
} else {
- controlTarget.showInsets(WindowInsets.Type.systemBars(), false);
+ controlTarget.showInsets(Type.systemBars(), false);
}
} else {
boolean sb = mStatusBarController.checkShowTransientBarLw();
@@ -3109,6 +3191,7 @@
&& mLastAppearance == appearance
&& mLastFullscreenAppearance == fullscreenAppearance
&& mLastDockedAppearance == dockedAppearance
+ && mLastBehavior == behavior
&& mLastFocusIsFullscreen == isFullscreen
&& mLastFocusIsImmersive == isImmersive
&& mFocusedApp == win.getAppToken()
@@ -3125,6 +3208,7 @@
mLastAppearance = appearance;
mLastFullscreenAppearance = fullscreenAppearance;
mLastDockedAppearance = dockedAppearance;
+ mLastBehavior = behavior;
mLastFocusIsFullscreen = isFullscreen;
mLastFocusIsImmersive = isImmersive;
mFocusedApp = win.getAppToken();
diff --git a/services/core/java/com/android/server/wm/DisplayWindowListenerController.java b/services/core/java/com/android/server/wm/DisplayWindowListenerController.java
index 78fea74..bb31d45 100644
--- a/services/core/java/com/android/server/wm/DisplayWindowListenerController.java
+++ b/services/core/java/com/android/server/wm/DisplayWindowListenerController.java
@@ -41,7 +41,7 @@
try {
for (int i = 0; i < mService.mAtmService.mRootActivityContainer.getChildCount();
++i) {
- ActivityDisplay d = mService.mAtmService.mRootActivityContainer.getChildAt(i);
+ DisplayContent d = mService.mAtmService.mRootActivityContainer.getChildAt(i);
listener.onDisplayAdded(d.mDisplayId);
}
} catch (RemoteException e) { }
@@ -52,7 +52,7 @@
mDisplayListeners.unregister(listener);
}
- void dispatchDisplayAdded(ActivityDisplay display) {
+ void dispatchDisplayAdded(DisplayContent display) {
int count = mDisplayListeners.beginBroadcast();
for (int i = 0; i < count; ++i) {
try {
@@ -85,7 +85,7 @@
mDisplayListeners.finishBroadcast();
}
- void dispatchDisplayRemoved(ActivityDisplay display) {
+ void dispatchDisplayRemoved(DisplayContent display) {
int count = mDisplayListeners.beginBroadcast();
for (int i = 0; i < count; ++i) {
try {
diff --git a/services/core/java/com/android/server/wm/ImmersiveModeConfirmation.java b/services/core/java/com/android/server/wm/ImmersiveModeConfirmation.java
index 82ac6b8..bef1442 100644
--- a/services/core/java/com/android/server/wm/ImmersiveModeConfirmation.java
+++ b/services/core/java/com/android/server/wm/ImmersiveModeConfirmation.java
@@ -46,6 +46,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
+import android.view.WindowInsets.Type;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
@@ -189,6 +190,7 @@
| WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
PixelFormat.TRANSLUCENT);
+ lp.setFitWindowInsetsTypes(lp.getFitWindowInsetsTypes() & ~Type.statusBars());
lp.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS;
lp.setTitle("ImmersiveModeConfirmation");
lp.windowAnimations = com.android.internal.R.style.Animation_ImmersiveModeConfirmation;
diff --git a/services/core/java/com/android/server/wm/InsetsPolicy.java b/services/core/java/com/android/server/wm/InsetsPolicy.java
index d50bcc4..af84836 100644
--- a/services/core/java/com/android/server/wm/InsetsPolicy.java
+++ b/services/core/java/com/android/server/wm/InsetsPolicy.java
@@ -45,7 +45,7 @@
private final IntArray mShowingTransientTypes = new IntArray();
private WindowState mFocusedWin;
- private BarWindow mTopBar = new BarWindow(StatusBarManager.WINDOW_STATUS_BAR);
+ private BarWindow mStatusBar = new BarWindow(StatusBarManager.WINDOW_STATUS_BAR);
private BarWindow mNavBar = new BarWindow(StatusBarManager.WINDOW_NAVIGATION_BAR);
InsetsPolicy(InsetsStateController stateController, DisplayContent displayContent) {
@@ -57,15 +57,15 @@
/** Updates the target which can control system bars. */
void updateBarControlTarget(@Nullable WindowState focusedWin) {
mFocusedWin = focusedWin;
- mStateController.onBarControlTargetChanged(getTopControlTarget(focusedWin),
- getFakeTopControlTarget(focusedWin),
+ mStateController.onBarControlTargetChanged(getStatusControlTarget(focusedWin),
+ getFakeStatusControlTarget(focusedWin),
getNavControlTarget(focusedWin),
getFakeNavControlTarget(focusedWin));
if (ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL) {
return;
}
- mTopBar.setVisible(focusedWin == null
- || focusedWin != getTopControlTarget(focusedWin)
+ mStatusBar.setVisible(focusedWin == null
+ || focusedWin != getStatusControlTarget(focusedWin)
|| focusedWin.getClientInsetsState().getSource(ITYPE_STATUS_BAR).isVisible());
mNavBar.setVisible(focusedWin == null
|| focusedWin != getNavControlTarget(focusedWin)
@@ -110,6 +110,10 @@
mStateController.notifyInsetsChanged();
}
+ boolean isTransient(@InternalInsetsType int type) {
+ return mShowingTransientTypes.indexOf(type) != -1;
+ }
+
/**
* @see InsetsStateController#getInsetsForDispatch
*/
@@ -130,8 +134,8 @@
if (ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL) {
return;
}
- if (windowState == getTopControlTarget(mFocusedWin)) {
- mTopBar.setVisible(state.getSource(ITYPE_STATUS_BAR).isVisible());
+ if (windowState == getStatusControlTarget(mFocusedWin)) {
+ mStatusBar.setVisible(state.getSource(ITYPE_STATUS_BAR).isVisible());
}
if (windowState == getNavControlTarget(mFocusedWin)) {
mNavBar.setVisible(state.getSource(ITYPE_NAVIGATION_BAR).isVisible());
@@ -164,7 +168,8 @@
}
}
- private @Nullable InsetsControlTarget getFakeTopControlTarget(@Nullable WindowState focused) {
+ private @Nullable InsetsControlTarget getFakeStatusControlTarget(
+ @Nullable WindowState focused) {
if (mShowingTransientTypes.indexOf(ITYPE_STATUS_BAR) != -1) {
return focused;
}
@@ -178,7 +183,7 @@
return null;
}
- private @Nullable InsetsControlTarget getTopControlTarget(@Nullable WindowState focusedWin) {
+ private @Nullable InsetsControlTarget getStatusControlTarget(@Nullable WindowState focusedWin) {
if (mShowingTransientTypes.indexOf(ITYPE_STATUS_BAR) != -1) {
return mTransientControlTarget;
}
diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java
index 69e8fdc..0821873 100644
--- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java
+++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java
@@ -141,9 +141,10 @@
}
/**
- * Called when a layout pass has occurred.
+ * The source frame can affect the layout of other windows, so this should be called once the
+ * window gets laid out.
*/
- void onPostLayout() {
+ void updateSourceFrame() {
if (mWin == null) {
return;
}
@@ -155,6 +156,17 @@
mTmpRect.inset(mWin.mGivenContentInsets);
}
mSource.setFrame(mTmpRect);
+ }
+
+ /**
+ * Called when a layout pass has occurred.
+ */
+ void onPostLayout() {
+ if (mWin == null) {
+ return;
+ }
+
+ updateSourceFrame();
if (mControl != null) {
final Rect frame = mWin.getWindowFrames().mFrame;
if (mControl.setSurfacePosition(frame.left, frame.top)) {
diff --git a/services/core/java/com/android/server/wm/KeyguardController.java b/services/core/java/com/android/server/wm/KeyguardController.java
index 3a0696f..6f81957 100644
--- a/services/core/java/com/android/server/wm/KeyguardController.java
+++ b/services/core/java/com/android/server/wm/KeyguardController.java
@@ -296,7 +296,7 @@
boolean requestDismissKeyguard = false;
for (int displayNdx = mRootActivityContainer.getChildCount() - 1;
displayNdx >= 0; displayNdx--) {
- final ActivityDisplay display = mRootActivityContainer.getChildAt(displayNdx);
+ final DisplayContent display = mRootActivityContainer.getChildAt(displayNdx);
final KeyguardDisplayState state = getDisplay(display.mDisplayId);
state.visibilitiesUpdated(this, display);
requestDismissKeyguard |= state.mRequestDismissKeyguard;
@@ -420,7 +420,7 @@
private void updateKeyguardSleepToken() {
for (int displayNdx = mRootActivityContainer.getChildCount() - 1;
displayNdx >= 0; displayNdx--) {
- final ActivityDisplay display = mRootActivityContainer.getChildAt(displayNdx);
+ final DisplayContent display = mRootActivityContainer.getChildAt(displayNdx);
updateKeyguardSleepToken(display.mDisplayId);
}
}
@@ -483,7 +483,7 @@
}
}
- void visibilitiesUpdated(KeyguardController controller, ActivityDisplay display) {
+ void visibilitiesUpdated(KeyguardController controller, DisplayContent display) {
final boolean lastOccluded = mOccluded;
final ActivityRecord lastDismissActivity = mDismissingKeyguardActivity;
mRequestDismissKeyguard = false;
@@ -530,7 +530,7 @@
* Only the top non-pinned activity of the focusable stack on each display can control its
* occlusion state.
*/
- private ActivityStack getStackForControllingOccluding(ActivityDisplay display) {
+ private ActivityStack getStackForControllingOccluding(DisplayContent display) {
for (int stackNdx = display.getStackCount() - 1; stackNdx >= 0; --stackNdx) {
final ActivityStack stack = display.getStackAt(stackNdx);
if (stack != null && stack.isFocusableAndVisible()
diff --git a/services/core/java/com/android/server/wm/LaunchParamsPersister.java b/services/core/java/com/android/server/wm/LaunchParamsPersister.java
index c3bcc74..8cf3dc8 100644
--- a/services/core/java/com/android/server/wm/LaunchParamsPersister.java
+++ b/services/core/java/com/android/server/wm/LaunchParamsPersister.java
@@ -223,8 +223,8 @@
private boolean saveTaskToLaunchParam(Task task, PersistableLaunchParams params) {
final ActivityStack stack = task.getStack();
final int displayId = stack.mDisplayId;
- final ActivityDisplay display =
- mSupervisor.mRootActivityContainer.getActivityDisplay(displayId);
+ final DisplayContent display =
+ mSupervisor.mRootActivityContainer.getDisplayContent(displayId);
final DisplayInfo info = new DisplayInfo();
display.mDisplay.getDisplayInfo(info);
@@ -260,7 +260,7 @@
return;
}
- final ActivityDisplay display = mSupervisor.mRootActivityContainer.getActivityDisplay(
+ final DisplayContent display = mSupervisor.mRootActivityContainer.getDisplayContent(
persistableParams.mDisplayUniqueId);
if (display != null) {
outParams.mPreferredDisplayId = display.mDisplayId;
diff --git a/services/core/java/com/android/server/wm/RecentTasks.java b/services/core/java/com/android/server/wm/RecentTasks.java
index c54fbd6..71bbb70 100644
--- a/services/core/java/com/android/server/wm/RecentTasks.java
+++ b/services/core/java/com/android/server/wm/RecentTasks.java
@@ -208,7 +208,7 @@
synchronized (mService.mGlobalLock) {
// Unfreeze the task list once we touch down in a task
final RootActivityContainer rac = mService.mRootActivityContainer;
- final DisplayContent dc = rac.getActivityDisplay(displayId).mDisplayContent;
+ final DisplayContent dc = rac.getDisplayContent(displayId).mDisplayContent;
if (dc.pointWithinAppWindow(x, y)) {
final ActivityStack stack = mService.getTopDisplayFocusedStack();
final Task topTask = stack != null ? stack.getTopMostTask() : null;
@@ -1144,6 +1144,7 @@
// Trim the set of tasks to the active set
trimInactiveRecentTasks();
+ notifyTaskPersisterLocked(task, false /* flush */);
}
/**
@@ -1316,7 +1317,7 @@
// TODO(b/126185105): Find a different signal to use besides isSingleTaskInstance
final ActivityStack stack = task.getStack();
if (stack != null) {
- ActivityDisplay display = stack.getDisplay();
+ DisplayContent display = stack.getDisplay();
if (display != null && display.isSingleTaskInstance()) {
return false;
}
@@ -1386,7 +1387,7 @@
}
// Trim tasks that are in stacks that are behind the home stack
- final ActivityDisplay display = stack.getDisplay();
+ final DisplayContent display = stack.getDisplay();
return display.getIndexOf(stack) < display.getIndexOf(display.getHomeStack());
}
diff --git a/services/core/java/com/android/server/wm/RecentsAnimation.java b/services/core/java/com/android/server/wm/RecentsAnimation.java
index b398626..0a8e747 100644
--- a/services/core/java/com/android/server/wm/RecentsAnimation.java
+++ b/services/core/java/com/android/server/wm/RecentsAnimation.java
@@ -53,14 +53,14 @@
* cleanup. See {@link com.android.server.wm.RecentsAnimationController}.
*/
class RecentsAnimation implements RecentsAnimationCallbacks,
- ActivityDisplay.OnStackOrderChangedListener {
+ DisplayContent.OnStackOrderChangedListener {
private static final String TAG = RecentsAnimation.class.getSimpleName();
private final ActivityTaskManagerService mService;
private final ActivityStackSupervisor mStackSupervisor;
private final ActivityStartController mActivityStartController;
private final WindowManagerService mWindowManager;
- private final ActivityDisplay mDefaultDisplay;
+ private final DisplayContent mDefaultDisplay;
private final Intent mTargetIntent;
private final ComponentName mRecentsComponent;
private final int mRecentsUid;
@@ -180,7 +180,7 @@
ActivityRecord targetActivity = getTargetActivity(targetStack);
final boolean hasExistingActivity = targetActivity != null;
if (hasExistingActivity) {
- final ActivityDisplay display = targetActivity.getDisplay();
+ final DisplayContent display = targetActivity.getDisplay();
mRestoreTargetBehindStack = display.getStackAbove(targetStack);
if (mRestoreTargetBehindStack == null) {
notifyAnimationCancelBeforeStart(recentsAnimationRunner);
@@ -250,7 +250,7 @@
mWindowManager.cancelRecentsAnimation(REORDER_MOVE_TO_ORIGINAL_POSITION,
"startRecentsActivity");
mWindowManager.initializeRecentsAnimation(mTargetActivityType, recentsAnimationRunner,
- this, mDefaultDisplay.mDisplayId,
+ this, mDefaultDisplay.getDisplayId(),
mStackSupervisor.mRecentTasks.getRecentTaskIds(), targetActivity);
// If we updated the launch-behind state, update the visibility of the activities after
@@ -351,7 +351,7 @@
}
} else if (reorderMode == REORDER_MOVE_TO_ORIGINAL_POSITION){
// Restore the target stack to its previous position
- final ActivityDisplay display = targetActivity.getDisplay();
+ final DisplayContent display = targetActivity.getDisplay();
display.moveStackBehindStack(targetStack, mRestoreTargetBehindStack);
if (WM_DEBUG_RECENTS_ANIMATIONS.isLogToAny()) {
final ActivityStack aboveTargetStack =
diff --git a/services/core/java/com/android/server/wm/ResetTargetTaskHelper.java b/services/core/java/com/android/server/wm/ResetTargetTaskHelper.java
index 3aa91d5..d787cbc 100644
--- a/services/core/java/com/android/server/wm/ResetTargetTaskHelper.java
+++ b/services/core/java/com/android/server/wm/ResetTargetTaskHelper.java
@@ -258,7 +258,7 @@
private void processCreatedTasks() {
if (mCreatedTasks.isEmpty()) return;
- ActivityDisplay display = mParent.getDisplay();
+ DisplayContent display = mParent.getDisplay();
final boolean singleTaskInstanceDisplay = display.isSingleTaskInstance();
if (singleTaskInstanceDisplay) {
display = mParent.mRootActivityContainer.getDefaultDisplay();
diff --git a/services/core/java/com/android/server/wm/RootActivityContainer.java b/services/core/java/com/android/server/wm/RootActivityContainer.java
index 704a4b7..7dd9790 100644
--- a/services/core/java/com/android/server/wm/RootActivityContainer.java
+++ b/services/core/java/com/android/server/wm/RootActivityContainer.java
@@ -109,7 +109,6 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.ResolverActivity;
-import com.android.internal.util.ToBooleanFunction;
import com.android.internal.util.function.pooled.PooledConsumer;
import com.android.internal.util.function.pooled.PooledFunction;
import com.android.internal.util.function.pooled.PooledLambda;
@@ -176,10 +175,10 @@
* List of displays which contain activities, sorted by z-order.
* The last entry in the list is the topmost.
*/
- private final ArrayList<ActivityDisplay> mActivityDisplays = new ArrayList<>();
+ private final ArrayList<DisplayContent> mDisplayContents = new ArrayList<>();
/** Reference to default display so we can quickly look it up. */
- private ActivityDisplay mDefaultDisplay;
+ private DisplayContent mDefaultDisplay;
private final SparseArray<IntArray> mDisplayAccessUIDs = new SparseArray<>();
/** The current user */
@@ -355,35 +354,35 @@
final Display[] displays = mDisplayManager.getDisplays();
for (int displayNdx = 0; displayNdx < displays.length; ++displayNdx) {
final Display display = displays[displayNdx];
- final ActivityDisplay activityDisplay = new ActivityDisplay(this, display);
- if (activityDisplay.mDisplayId == DEFAULT_DISPLAY) {
- mDefaultDisplay = activityDisplay;
+ final DisplayContent displayContent = new DisplayContent(display, this);
+ if (displayContent.mDisplayId == DEFAULT_DISPLAY) {
+ mDefaultDisplay = displayContent;
}
- addChild(activityDisplay, ActivityDisplay.POSITION_TOP);
+ addChild(displayContent, DisplayContent.POSITION_TOP);
}
calculateDefaultMinimalSizeOfResizeableTasks();
- final ActivityDisplay defaultDisplay = getDefaultDisplay();
+ final DisplayContent defaultDisplay = getDefaultDisplay();
defaultDisplay.getOrCreateStack(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, ON_TOP);
- positionChildAt(defaultDisplay, ActivityDisplay.POSITION_TOP);
+ positionChildAt(defaultDisplay, DisplayContent.POSITION_TOP);
}
// TODO(multi-display): Look at all callpoints to make sure they make sense in multi-display.
- ActivityDisplay getDefaultDisplay() {
+ DisplayContent getDefaultDisplay() {
return mDefaultDisplay;
}
/**
- * Get an existing instance of {@link ActivityDisplay} that has the given uniqueId. Unique ID is
+ * Get an existing instance of {@link DisplayContent} that has the given uniqueId. Unique ID is
* defined in {@link DisplayInfo#uniqueId}.
*
* @param uniqueId the unique ID of the display
- * @return the {@link ActivityDisplay} or {@code null} if nothing is found.
+ * @return the {@link DisplayContent} or {@code null} if nothing is found.
*/
- ActivityDisplay getActivityDisplay(String uniqueId) {
- for (int i = mActivityDisplays.size() - 1; i >= 0; --i) {
- final ActivityDisplay display = mActivityDisplays.get(i);
+ DisplayContent getDisplayContent(String uniqueId) {
+ for (int i = mDisplayContents.size() - 1; i >= 0; --i) {
+ final DisplayContent display = mDisplayContents.get(i);
final boolean isValid = display.mDisplay.isValid();
if (isValid && display.mDisplay.getUniqueId().equals(uniqueId)) {
return display;
@@ -393,26 +392,26 @@
return null;
}
- // TODO: Look into consolidating with getActivityDisplayOrCreate()
- ActivityDisplay getActivityDisplay(int displayId) {
- for (int i = mActivityDisplays.size() - 1; i >= 0; --i) {
- final ActivityDisplay activityDisplay = mActivityDisplays.get(i);
- if (activityDisplay.mDisplayId == displayId) {
- return activityDisplay;
+ // TODO: Look into consolidating with getDisplayContentOrCreate()
+ DisplayContent getDisplayContent(int displayId) {
+ for (int i = mDisplayContents.size() - 1; i >= 0; --i) {
+ final DisplayContent displayContent = mDisplayContents.get(i);
+ if (displayContent.mDisplayId == displayId) {
+ return displayContent;
}
}
return null;
}
/**
- * Get an existing instance of {@link ActivityDisplay} or create new if there is a
+ * Get an existing instance of {@link DisplayContent} or create new if there is a
* corresponding record in display manager.
*/
- // TODO: Look into consolidating with getActivityDisplay()
- @Nullable ActivityDisplay getActivityDisplayOrCreate(int displayId) {
- ActivityDisplay activityDisplay = getActivityDisplay(displayId);
- if (activityDisplay != null) {
- return activityDisplay;
+ // TODO: Look into consolidating with getDisplayContent()
+ @Nullable DisplayContent getDisplayContentOrCreate(int displayId) {
+ DisplayContent displayContent = getDisplayContent(displayId);
+ if (displayContent != null) {
+ return displayContent;
}
if (mDisplayManager == null) {
// The system isn't fully initialized yet.
@@ -424,9 +423,9 @@
return null;
}
// The display hasn't been added to ActivityManager yet, create a new record now.
- activityDisplay = new ActivityDisplay(this, display);
- addChild(activityDisplay, ActivityDisplay.POSITION_BOTTOM);
- return activityDisplay;
+ displayContent = new DisplayContent(display, this);
+ addChild(displayContent, DisplayContent.POSITION_BOTTOM);
+ return displayContent;
}
ActivityRecord getDefaultDisplayHomeActivity() {
@@ -434,21 +433,21 @@
}
ActivityRecord getDefaultDisplayHomeActivityForUser(int userId) {
- return getActivityDisplay(DEFAULT_DISPLAY).getHomeActivityForUser(userId);
+ return getDisplayContent(DEFAULT_DISPLAY).getHomeActivityForUser(userId);
}
boolean startHomeOnAllDisplays(int userId, String reason) {
boolean homeStarted = false;
- for (int i = mActivityDisplays.size() - 1; i >= 0; i--) {
- final int displayId = mActivityDisplays.get(i).mDisplayId;
+ for (int i = mDisplayContents.size() - 1; i >= 0; i--) {
+ final int displayId = mDisplayContents.get(i).mDisplayId;
homeStarted |= startHomeOnDisplay(userId, reason, displayId);
}
return homeStarted;
}
void startHomeOnEmptyDisplays(String reason) {
- for (int i = mActivityDisplays.size() - 1; i >= 0; i--) {
- final ActivityDisplay display = mActivityDisplays.get(i);
+ for (int i = mDisplayContents.size() - 1; i >= 0; i--) {
+ final DisplayContent display = mDisplayContents.get(i);
if (display.topRunningActivity() == null) {
startHomeOnDisplay(mCurrentUser, reason, display.mDisplayId);
}
@@ -630,7 +629,7 @@
displayId = DEFAULT_DISPLAY;
}
- final ActivityRecord r = getActivityDisplay(displayId).getHomeActivity();
+ final ActivityRecord r = getDisplayContent(displayId).getHomeActivity();
final String myReason = reason + " resumeHomeActivity";
// Only resume home activity if isn't finishing.
@@ -672,7 +671,7 @@
return false;
}
- final ActivityDisplay display = getActivityDisplay(displayId);
+ final DisplayContent display = getDisplayContent(displayId);
if (display == null || display.isRemoved() || !display.supportsSystemDecorations()) {
// Can't launch home on display that doesn't support system decorations.
return false;
@@ -772,10 +771,8 @@
if (displayContent != null) {
// Update the configuration of the activities on the display.
- // TODO(display-merge): Remove cast
- return ((ActivityDisplay) displayContent)
- .updateDisplayOverrideConfigurationLocked(config, starting, deferResume,
- null /* result */);
+ return displayContent.updateDisplayOverrideConfigurationLocked(config, starting,
+ deferResume, null /* result */);
} else {
return true;
}
@@ -789,8 +786,8 @@
final ArrayList<IBinder> topActivityTokens = new ArrayList<>();
final ActivityStack topFocusedStack = getTopDisplayFocusedStack();
// Traverse all displays.
- for (int i = mActivityDisplays.size() - 1; i >= 0; i--) {
- final ActivityDisplay display = mActivityDisplays.get(i);
+ for (int i = mDisplayContents.size() - 1; i >= 0; i--) {
+ final DisplayContent display = mDisplayContents.get(i);
// Traverse all stacks on a display.
for (int j = display.getStackCount() - 1; j >= 0; --j) {
final ActivityStack stack = display.getStackAt(j);
@@ -811,8 +808,8 @@
}
ActivityStack getTopDisplayFocusedStack() {
- for (int i = mActivityDisplays.size() - 1; i >= 0; --i) {
- final ActivityStack focusedStack = mActivityDisplays.get(i).getFocusedStack();
+ for (int i = mDisplayContents.size() - 1; i >= 0; --i) {
+ final ActivityStack focusedStack = mDisplayContents.get(i).getFocusedStack();
if (focusedStack != null) {
return focusedStack;
}
@@ -831,8 +828,8 @@
}
// The top focused stack might not have a resumed activity yet - look on all displays in
// focus order.
- for (int i = mActivityDisplays.size() - 1; i >= 0; --i) {
- final ActivityDisplay display = mActivityDisplays.get(i);
+ for (int i = mDisplayContents.size() - 1; i >= 0; --i) {
+ final DisplayContent display = mDisplayContents.get(i);
final ActivityRecord resumedActivityOnDisplay = display.getResumedActivity();
if (resumedActivityOnDisplay != null) {
return resumedActivityOnDisplay;
@@ -861,8 +858,8 @@
// previous app if this activity is being hosted by the process that is actually still the
// foreground.
WindowProcessController fgApp = null;
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
for (int stackNdx = display.getStackCount() - 1; stackNdx >= 0; --stackNdx) {
final ActivityStack stack = display.getStackAt(stackNdx);
if (isTopDisplayFocusedStack(stack)) {
@@ -889,8 +886,8 @@
boolean attachApplication(WindowProcessController app) throws RemoteException {
final String processName = app.mName;
boolean didSomething = false;
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
final ActivityStack stack = display.getFocusedStack();
if (stack == null) {
continue;
@@ -958,8 +955,8 @@
try {
mStackSupervisor.getKeyguardController().beginActivityVisibilityUpdate();
// First the front stacks. In case any are not fullscreen and are in front of home.
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
display.ensureActivitiesVisible(starting, configChanges, preserveWindows,
notifyClients);
}
@@ -988,8 +985,8 @@
mCurrentUser = userId;
mStackSupervisor.mStartingUsers.add(uss);
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
for (int stackNdx = display.getStackCount() - 1; stackNdx >= 0; --stackNdx) {
final ActivityStack stack = display.getStackAt(stackNdx);
stack.switchUser(userId);
@@ -1036,8 +1033,8 @@
* @param onTop Indicates whether container should be place on top or on bottom.
*/
void moveStackToDisplay(int stackId, int displayId, boolean onTop) {
- final ActivityDisplay activityDisplay = getActivityDisplayOrCreate(displayId);
- if (activityDisplay == null) {
+ final DisplayContent displayContent = getDisplayContentOrCreate(displayId);
+ if (displayContent == null) {
throw new IllegalArgumentException("moveStackToDisplay: Unknown displayId="
+ displayId);
}
@@ -1047,7 +1044,7 @@
+ stackId);
}
- final ActivityDisplay currentDisplay = stack.getDisplay();
+ final DisplayContent currentDisplay = stack.getDisplay();
if (currentDisplay == null) {
throw new IllegalStateException("moveStackToDisplay: Stack with stack=" + stack
+ " is not attached to any display.");
@@ -1058,14 +1055,14 @@
+ " to its current displayId=" + displayId);
}
- if (activityDisplay.isSingleTaskInstance() && activityDisplay.getStackCount() > 0) {
+ if (displayContent.isSingleTaskInstance() && displayContent.getStackCount() > 0) {
// We don't allow moving stacks to single instance display that already has a child.
Slog.e(TAG, "Can not move stack=" + stack
- + " to single task instance display=" + activityDisplay);
+ + " to single task instance display=" + displayContent);
return;
}
- stack.reparent(activityDisplay.mDisplayContent, onTop);
+ stack.reparent(displayContent.mDisplayContent, onTop);
// TODO(multi-display): resize stacks properly if moved from split-screen.
}
@@ -1098,7 +1095,7 @@
String reason) {
mService.deferWindowLayout();
- final ActivityDisplay display = r.getActivityStack().getDisplay();
+ final DisplayContent display = r.getActivityStack().getDisplay();
try {
final Task task = r.getTask();
@@ -1168,8 +1165,8 @@
}
void executeAppTransitionForAllDisplay() {
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
display.mDisplayContent.executeAppTransition();
}
}
@@ -1194,7 +1191,7 @@
mTmpFindTaskResult.clear();
// Looking up task on preferred display first
- final ActivityDisplay preferredDisplay = getActivityDisplay(preferredDisplayId);
+ final DisplayContent preferredDisplay = getDisplayContent(preferredDisplayId);
if (preferredDisplay != null) {
preferredDisplay.findTaskLocked(r, true /* isPreferredDisplay */, mTmpFindTaskResult);
if (mTmpFindTaskResult.mIdealMatch) {
@@ -1202,8 +1199,8 @@
}
}
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
if (display.mDisplayId == preferredDisplayId) {
continue;
}
@@ -1227,8 +1224,8 @@
int finishTopCrashedActivities(WindowProcessController app, String reason) {
Task finishedTask = null;
ActivityStack focusedStack = getTopDisplayFocusedStack();
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
// It is possible that request to finish activity might also remove its task and stack,
// so we need to be careful with indexes in the loop and check child count every time.
for (int stackNdx = 0; stackNdx < display.getStackCount(); ++stackNdx) {
@@ -1259,9 +1256,9 @@
result = targetStack.resumeTopActivityUncheckedLocked(target, targetOptions);
}
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
boolean resumedOnDisplay = false;
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ final DisplayContent display = mDisplayContents.get(displayNdx);
for (int stackNdx = display.getStackCount() - 1; stackNdx >= 0; --stackNdx) {
final ActivityStack stack = display.getStackAt(stackNdx);
final ActivityRecord topRunningActivity = stack.topRunningActivity();
@@ -1291,7 +1288,7 @@
final ActivityStack focusedStack = display.getFocusedStack();
if (focusedStack != null) {
result |= focusedStack.resumeTopActivityUncheckedLocked(target, targetOptions);
- } else if (targetStack == null && !display.hasChild()) {
+ } else if (targetStack == null && display.getStackCount() == 0) {
result |= resumeHomeActivity(null /* prev */, "empty-display",
display.mDisplayId);
}
@@ -1302,9 +1299,9 @@
}
void applySleepTokens(boolean applyToStacks) {
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
// Set the sleeping state of the display.
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ final DisplayContent display = mDisplayContents.get(displayNdx);
final boolean displayShouldSleep = display.shouldSleep();
if (displayShouldSleep == display.isSleeping()) {
continue;
@@ -1358,8 +1355,8 @@
}
protected ActivityStack getStack(int stackId) {
- for (int i = mActivityDisplays.size() - 1; i >= 0; --i) {
- final ActivityStack stack = mActivityDisplays.get(i).getStack(stackId);
+ for (int i = mDisplayContents.size() - 1; i >= 0; --i) {
+ final ActivityStack stack = mDisplayContents.get(i).getStack(stackId);
if (stack != null) {
return stack;
}
@@ -1367,11 +1364,11 @@
return null;
}
- /** @see ActivityDisplay#getStack(int, int) */
+ /** @see DisplayContent#getStack(int, int) */
ActivityStack getStack(int windowingMode, int activityType) {
- for (int i = mActivityDisplays.size() - 1; i >= 0; --i) {
+ for (int i = mDisplayContents.size() - 1; i >= 0; --i) {
final ActivityStack stack =
- mActivityDisplays.get(i).getStack(windowingMode, activityType);
+ mDisplayContents.get(i).getStack(windowingMode, activityType);
if (stack != null) {
return stack;
}
@@ -1381,7 +1378,7 @@
private ActivityStack getStack(int windowingMode, int activityType,
int displayId) {
- ActivityDisplay display = getActivityDisplay(displayId);
+ DisplayContent display = getDisplayContent(displayId);
if (display == null) {
return null;
}
@@ -1390,7 +1387,7 @@
private ActivityManager.StackInfo getStackInfo(ActivityStack stack) {
final int displayId = stack.mDisplayId;
- final ActivityDisplay display = getActivityDisplay(displayId);
+ final DisplayContent display = getDisplayContent(displayId);
ActivityManager.StackInfo info = new ActivityManager.StackInfo();
stack.getBounds(info.bounds);
info.displayId = displayId;
@@ -1455,8 +1452,8 @@
ArrayList<ActivityManager.StackInfo> getAllStackInfos(int displayId) {
ArrayList<ActivityManager.StackInfo> list = new ArrayList<>();
if (displayId == INVALID_DISPLAY) {
- for (int displayNdx = 0; displayNdx < mActivityDisplays.size(); ++displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = 0; displayNdx < mDisplayContents.size(); ++displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
for (int stackNdx = display.getStackCount() - 1; stackNdx >= 0; --stackNdx) {
final ActivityStack stack = display.getStackAt(stackNdx);
list.add(getStackInfo(stack));
@@ -1464,7 +1461,7 @@
}
return list;
}
- final ActivityDisplay display = getActivityDisplay(displayId);
+ final DisplayContent display = getDisplayContent(displayId);
if (display == null) {
return list;
}
@@ -1493,7 +1490,7 @@
public void onDisplayAdded(int displayId) {
if (DEBUG_STACK) Slog.v(TAG, "Display added displayId=" + displayId);
synchronized (mService.mGlobalLock) {
- final ActivityDisplay display = getActivityDisplayOrCreate(displayId);
+ final DisplayContent display = getDisplayContentOrCreate(displayId);
if (display == null) {
return;
}
@@ -1519,12 +1516,12 @@
}
synchronized (mService.mGlobalLock) {
- final ActivityDisplay activityDisplay = getActivityDisplay(displayId);
- if (activityDisplay == null) {
+ final DisplayContent displayContent = getDisplayContent(displayId);
+ if (displayContent == null) {
return;
}
- activityDisplay.remove();
+ displayContent.remove();
}
}
@@ -1532,9 +1529,9 @@
public void onDisplayChanged(int displayId) {
if (DEBUG_STACK) Slog.v(TAG, "Display changed displayId=" + displayId);
synchronized (mService.mGlobalLock) {
- final ActivityDisplay activityDisplay = getActivityDisplay(displayId);
- if (activityDisplay != null) {
- activityDisplay.onDisplayChanged();
+ final DisplayContent displayContent = getDisplayContent(displayId);
+ if (displayContent != null) {
+ displayContent.onDisplayChanged();
}
}
}
@@ -1542,12 +1539,12 @@
/** Update lists of UIDs that are present on displays and have access to them. */
void updateUIDsPresentOnDisplay() {
mDisplayAccessUIDs.clear();
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay activityDisplay = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent displayContent = mDisplayContents.get(displayNdx);
// Only bother calculating the whitelist for private displays
- if (activityDisplay.isPrivate()) {
+ if (displayContent.isPrivate()) {
mDisplayAccessUIDs.append(
- activityDisplay.mDisplayId, activityDisplay.getPresentUIDs());
+ displayContent.mDisplayId, displayContent.getPresentUIDs());
}
}
// Store updated lists in DisplayManager. Callers from outside of AM should get them there.
@@ -1555,7 +1552,7 @@
}
ActivityStack findStackBehind(ActivityStack stack) {
- final ActivityDisplay display = getActivityDisplay(stack.mDisplayId);
+ final DisplayContent display = getDisplayContent(stack.mDisplayId);
if (display != null) {
for (int i = display.getStackCount() - 1; i >= 0; i--) {
if (display.getStackAt(i) == stack && i > 0) {
@@ -1569,12 +1566,12 @@
@Override
protected int getChildCount() {
- return mActivityDisplays.size();
+ return mDisplayContents.size();
}
@Override
- protected ActivityDisplay getChildAt(int index) {
- return mActivityDisplays.get(index);
+ protected DisplayContent getChildAt(int index) {
+ return mDisplayContents.get(index);
}
@Override
@@ -1592,61 +1589,59 @@
/** Change the z-order of the given display. */
private void positionChildAt(DisplayContent display, int position) {
- if (position >= mActivityDisplays.size()) {
- position = mActivityDisplays.size() - 1;
+ if (position >= mDisplayContents.size()) {
+ position = mDisplayContents.size() - 1;
} else if (position < 0) {
position = 0;
}
- // TODO(display-merge): Remove cast
- final ActivityDisplay activityDisplay = (ActivityDisplay) display;
- if (mActivityDisplays.isEmpty()) {
- mActivityDisplays.add(activityDisplay);
- } else if (mActivityDisplays.get(position) != display) {
- mActivityDisplays.remove(display);
- mActivityDisplays.add(position, activityDisplay);
+ if (mDisplayContents.isEmpty()) {
+ mDisplayContents.add(display);
+ } else if (mDisplayContents.get(position) != display) {
+ mDisplayContents.remove(display);
+ mDisplayContents.add(position, display);
}
mStackSupervisor.updateTopResumedActivityIfNeeded();
}
@VisibleForTesting
- void addChild(ActivityDisplay activityDisplay, int position) {
- positionChildAt(activityDisplay, position);
- mRootWindowContainer.positionChildAt(position, activityDisplay.mDisplayContent);
+ void addChild(DisplayContent displayContent, int position) {
+ positionChildAt(displayContent, position);
+ mRootWindowContainer.positionChildAt(position, displayContent);
}
- void removeChild(ActivityDisplay activityDisplay) {
- // The caller must tell the controller of {@link ActivityDisplay} to release its container
- // {@link DisplayContent}. That is done in {@link ActivityDisplay#releaseSelfIfNeeded}).
- mActivityDisplays.remove(activityDisplay);
+ void removeChild(DisplayContent displayContent) {
+ // The caller must tell the controller of {@link DisplayContent} to release its container
+ // {@link DisplayContent}. That is done in {@link DisplayContent#releaseSelfIfNeeded}).
+ mDisplayContents.remove(displayContent);
}
Configuration getDisplayOverrideConfiguration(int displayId) {
- final ActivityDisplay activityDisplay = getActivityDisplayOrCreate(displayId);
- if (activityDisplay == null) {
+ final DisplayContent displayContent = getDisplayContentOrCreate(displayId);
+ if (displayContent == null) {
throw new IllegalArgumentException("No display found with id: " + displayId);
}
- return activityDisplay.getRequestedOverrideConfiguration();
+ return displayContent.getRequestedOverrideConfiguration();
}
void setDisplayOverrideConfiguration(Configuration overrideConfiguration, int displayId) {
- final ActivityDisplay activityDisplay = getActivityDisplayOrCreate(displayId);
- if (activityDisplay == null) {
+ final DisplayContent displayContent = getDisplayContentOrCreate(displayId);
+ if (displayContent == null) {
throw new IllegalArgumentException("No display found with id: " + displayId);
}
- activityDisplay.onRequestedOverrideConfigurationChanged(overrideConfiguration);
+ displayContent.onRequestedOverrideConfigurationChanged(overrideConfiguration);
}
void prepareForShutdown() {
- for (int i = 0; i < mActivityDisplays.size(); i++) {
- createSleepToken("shutdown", mActivityDisplays.get(i).mDisplayId);
+ for (int i = 0; i < mDisplayContents.size(); i++) {
+ createSleepToken("shutdown", mDisplayContents.get(i).mDisplayId);
}
}
ActivityTaskManagerInternal.SleepToken createSleepToken(String tag, int displayId) {
- final ActivityDisplay display = getActivityDisplay(displayId);
+ final DisplayContent display = getDisplayContent(displayId);
if (display == null) {
throw new IllegalArgumentException("Invalid display: " + displayId);
}
@@ -1660,7 +1655,7 @@
private void removeSleepToken(SleepTokenImpl token) {
mSleepTokens.remove(token);
- final ActivityDisplay display = getActivityDisplay(token.mDisplayId);
+ final DisplayContent display = getDisplayContent(token.mDisplayId);
if (display != null) {
display.mAllSleepTokens.remove(token);
if (display.mAllSleepTokens.isEmpty()) {
@@ -1717,8 +1712,8 @@
}
void scheduleDestroyAllActivities(WindowProcessController app, String reason) {
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
for (int stackNdx = display.getStackCount() - 1; stackNdx >= 0; --stackNdx) {
final ActivityStack stack = display.getStackAt(stackNdx);
stack.scheduleDestroyActivities(app, reason);
@@ -1730,8 +1725,8 @@
// successfully put to sleep.
boolean putStacksToSleep(boolean allowDelay, boolean shuttingDown) {
boolean allSleep = true;
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
for (int stackNdx = display.getStackCount() - 1; stackNdx >= 0; --stackNdx) {
// Stacks and activities could be removed while putting activities to sleep if
// the app process was gone. This prevents us getting exception by accessing an
@@ -1801,8 +1796,8 @@
}
boolean hasAwakeDisplay() {
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
if (!display.shouldSleep()) {
return true;
}
@@ -1878,7 +1873,7 @@
return stack;
}
}
- final ActivityDisplay display = getActivityDisplayOrCreate(displayId);
+ final DisplayContent display = getDisplayContentOrCreate(displayId);
if (display != null) {
stack = display.getOrCreateStack(r, options, candidateTask, activityType, onTop);
if (stack != null) {
@@ -1890,7 +1885,7 @@
// Give preference to the stack and display of the input task and activity if they match the
// mode we want to launch into.
stack = null;
- ActivityDisplay display = null;
+ DisplayContent display = null;
if (candidateTask != null) {
stack = candidateTask.getStack();
}
@@ -1948,8 +1943,8 @@
private ActivityStack getValidLaunchStackOnDisplay(int displayId, @NonNull ActivityRecord r,
@Nullable Task candidateTask, @Nullable ActivityOptions options,
@Nullable LaunchParamsController.LaunchParams launchParams) {
- final ActivityDisplay activityDisplay = getActivityDisplayOrCreate(displayId);
- if (activityDisplay == null) {
+ final DisplayContent displayContent = getDisplayContentOrCreate(displayId);
+ if (displayContent == null) {
throw new IllegalArgumentException(
"Display with displayId=" + displayId + " not found.");
}
@@ -1978,12 +1973,12 @@
windowingMode = options != null ? options.getLaunchWindowingMode()
: r.getWindowingMode();
}
- windowingMode = activityDisplay.validateWindowingMode(windowingMode, r, candidateTask,
+ windowingMode = displayContent.validateWindowingMode(windowingMode, r, candidateTask,
r.getActivityType());
// Return the topmost valid stack on the display.
- for (int i = activityDisplay.getStackCount() - 1; i >= 0; --i) {
- final ActivityStack stack = activityDisplay.getStackAt(i);
+ for (int i = displayContent.getStackCount() - 1; i >= 0; --i) {
+ final ActivityStack stack = displayContent.getStackAt(i);
if (isValidLaunchStack(stack, r, windowingMode)) {
return stack;
}
@@ -1994,7 +1989,7 @@
final int activityType =
options != null && options.getLaunchActivityType() != ACTIVITY_TYPE_UNDEFINED
? options.getLaunchActivityType() : r.getActivityType();
- return activityDisplay.createStack(windowingMode, activityType, true /*onTop*/);
+ return displayContent.createStack(windowingMode, activityType, true /*onTop*/);
}
return null;
@@ -2056,11 +2051,11 @@
ActivityStack getNextFocusableStack(@NonNull ActivityStack currentFocus,
boolean ignoreCurrent) {
// First look for next focusable stack on the same display
- ActivityDisplay preferredDisplay = currentFocus.getDisplay();
+ DisplayContent preferredDisplay = currentFocus.getDisplay();
if (preferredDisplay == null) {
// Stack is currently detached because it is being removed. Use the previous display it
// was on.
- preferredDisplay = getActivityDisplay(currentFocus.mPrevDisplayId);
+ preferredDisplay = getDisplayContent(currentFocus.mPrevDisplayId);
}
final ActivityStack preferredFocusableStack = preferredDisplay.getNextFocusableStack(
currentFocus, ignoreCurrent);
@@ -2075,8 +2070,8 @@
}
// Now look through all displays
- for (int i = mActivityDisplays.size() - 1; i >= 0; --i) {
- final ActivityDisplay display = mActivityDisplays.get(i);
+ for (int i = mDisplayContents.size() - 1; i >= 0; --i) {
+ final DisplayContent display = mDisplayContents.get(i);
if (display == preferredDisplay) {
// We've already checked this one
continue;
@@ -2102,8 +2097,8 @@
* @return Next valid {@link ActivityStack}, null if not found.
*/
ActivityStack getNextValidLaunchStack(@NonNull ActivityRecord r, int currentFocus) {
- for (int i = mActivityDisplays.size() - 1; i >= 0; --i) {
- final ActivityDisplay display = mActivityDisplays.get(i);
+ for (int i = mDisplayContents.size() - 1; i >= 0; --i) {
+ final DisplayContent display = mDisplayContents.get(i);
if (display.mDisplayId == currentFocus) {
continue;
}
@@ -2118,8 +2113,8 @@
boolean handleAppDied(WindowProcessController app) {
boolean hasVisibleActivities = false;
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
for (int stackNdx = display.getStackCount() - 1; stackNdx >= 0; --stackNdx) {
final ActivityStack stack = display.getStackAt(stackNdx);
hasVisibleActivities |= stack.handleAppDiedLocked(app);
@@ -2231,8 +2226,8 @@
}
void finishVoiceTask(IVoiceInteractionSession session) {
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
final int numStacks = display.getStackCount();
for (int stackNdx = 0; stackNdx < numStacks; ++stackNdx) {
final ActivityStack stack = display.getStackAt(stackNdx);
@@ -2246,20 +2241,20 @@
* ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
*/
void removeStacksInWindowingModes(int... windowingModes) {
- for (int i = mActivityDisplays.size() - 1; i >= 0; --i) {
- mActivityDisplays.get(i).removeStacksInWindowingModes(windowingModes);
+ for (int i = mDisplayContents.size() - 1; i >= 0; --i) {
+ mDisplayContents.get(i).removeStacksInWindowingModes(windowingModes);
}
}
void removeStacksWithActivityTypes(int... activityTypes) {
- for (int i = mActivityDisplays.size() - 1; i >= 0; --i) {
- mActivityDisplays.get(i).removeStacksWithActivityTypes(activityTypes);
+ for (int i = mDisplayContents.size() - 1; i >= 0; --i) {
+ mDisplayContents.get(i).removeStacksWithActivityTypes(activityTypes);
}
}
ActivityRecord topRunningActivity() {
- for (int i = mActivityDisplays.size() - 1; i >= 0; --i) {
- final ActivityRecord topActivity = mActivityDisplays.get(i).topRunningActivity();
+ for (int i = mDisplayContents.size() - 1; i >= 0; --i) {
+ final ActivityRecord topActivity = mDisplayContents.get(i).topRunningActivity();
if (topActivity != null) {
return topActivity;
}
@@ -2268,9 +2263,9 @@
}
boolean allResumedActivitiesIdle() {
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
// TODO(b/117135575): Check resumed activities on all visible stacks.
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ final DisplayContent display = mDisplayContents.get(displayNdx);
if (display.isSleeping()) {
// No resumed activities while display is sleeping.
continue;
@@ -2298,8 +2293,8 @@
boolean allResumedActivitiesVisible() {
boolean foundResumed = false;
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
for (int stackNdx = display.getStackCount() - 1; stackNdx >= 0; --stackNdx) {
final ActivityStack stack = display.getStackAt(stackNdx);
final ActivityRecord r = stack.getResumedActivity();
@@ -2316,8 +2311,8 @@
boolean allPausedActivitiesComplete() {
boolean pausing = true;
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
for (int stackNdx = display.getStackCount() - 1; stackNdx >= 0; --stackNdx) {
final ActivityStack stack = display.getStackAt(stackNdx);
final ActivityRecord r = stack.mPausingActivity;
@@ -2381,8 +2376,8 @@
}
void cancelInitializingActivities() {
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ final DisplayContent display = mDisplayContents.get(displayNdx);
for (int stackNdx = display.getStackCount() - 1; stackNdx >= 0; --stackNdx) {
final ActivityStack stack = display.getStackAt(stackNdx);
stack.cancelInitializingActivities();
@@ -2467,9 +2462,9 @@
}
ActivityRecord isInAnyStack(IBinder token) {
- int numDisplays = mActivityDisplays.size();
+ int numDisplays = mDisplayContents.size();
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ final DisplayContent display = mDisplayContents.get(displayNdx);
for (int stackNdx = display.getStackCount() - 1; stackNdx >= 0; --stackNdx) {
final ActivityStack stack = display.getStackAt(stackNdx);
final ActivityRecord r = stack.isInStackLocked(token);
@@ -2503,9 +2498,9 @@
// activity on all displays, or if there are no resumed activities in the system.
boolean noResumedActivities = true;
boolean allFocusedProcessesDiffer = true;
- for (int displayNdx = 0; displayNdx < mActivityDisplays.size(); ++displayNdx) {
- final ActivityDisplay activityDisplay = mActivityDisplays.get(displayNdx);
- final ActivityRecord resumedActivity = activityDisplay.getResumedActivity();
+ for (int displayNdx = 0; displayNdx < mDisplayContents.size(); ++displayNdx) {
+ final DisplayContent displayContent = mDisplayContents.get(displayNdx);
+ final ActivityRecord resumedActivity = displayContent.getResumedActivity();
final WindowProcessController resumedActivityProcess =
resumedActivity == null ? null : resumedActivity.app;
@@ -2550,9 +2545,9 @@
return getTopDisplayFocusedStack().getDumpActivitiesLocked(name);
} else {
ArrayList<ActivityRecord> activities = new ArrayList<>();
- int numDisplays = mActivityDisplays.size();
+ int numDisplays = mDisplayContents.size();
for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ final DisplayContent display = mDisplayContents.get(displayNdx);
for (int stackNdx = display.getStackCount() - 1; stackNdx >= 0; --stackNdx) {
final ActivityStack stack = display.getStackAt(stackNdx);
if (!dumpVisibleStacksOnly || stack.shouldBeVisible(null)) {
@@ -2567,9 +2562,9 @@
public void dump(PrintWriter pw, String prefix) {
pw.print(prefix);
pw.println("topDisplayFocusedStack=" + getTopDisplayFocusedStack());
- for (int i = mActivityDisplays.size() - 1; i >= 0; --i) {
- final ActivityDisplay display = mActivityDisplays.get(i);
- display.dump(pw, prefix);
+ for (int i = mDisplayContents.size() - 1; i >= 0; --i) {
+ final DisplayContent display = mDisplayContents.get(i);
+ display.dump(pw, prefix, true /* dumpAll */);
}
}
@@ -2579,17 +2574,17 @@
*/
void dumpDisplayConfigs(PrintWriter pw, String prefix) {
pw.print(prefix); pw.println("Display override configurations:");
- final int displayCount = mActivityDisplays.size();
+ final int displayCount = mDisplayContents.size();
for (int i = 0; i < displayCount; i++) {
- final ActivityDisplay activityDisplay = mActivityDisplays.get(i);
- pw.print(prefix); pw.print(" "); pw.print(activityDisplay.mDisplayId); pw.print(": ");
- pw.println(activityDisplay.getRequestedOverrideConfiguration());
+ final DisplayContent displayContent = mDisplayContents.get(i);
+ pw.print(prefix); pw.print(" "); pw.print(displayContent.mDisplayId); pw.print(": ");
+ pw.println(displayContent.getRequestedOverrideConfiguration());
}
}
public void dumpDisplays(PrintWriter pw) {
- for (int i = mActivityDisplays.size() - 1; i >= 0; --i) {
- final ActivityDisplay display = mActivityDisplays.get(i);
+ for (int i = mDisplayContents.size() - 1; i >= 0; --i) {
+ final DisplayContent display = mDisplayContents.get(i);
pw.print("[id:" + display.mDisplayId + " stacks:");
display.dumpStacks(pw);
pw.print("]");
@@ -2600,18 +2595,18 @@
String dumpPackage) {
boolean printed = false;
boolean needSep = false;
- for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
- ActivityDisplay activityDisplay = mActivityDisplays.get(displayNdx);
- pw.print("Display #"); pw.print(activityDisplay.mDisplayId);
+ for (int displayNdx = mDisplayContents.size() - 1; displayNdx >= 0; --displayNdx) {
+ DisplayContent displayContent = mDisplayContents.get(displayNdx);
+ pw.print("Display #"); pw.print(displayContent.mDisplayId);
pw.println(" (activities from top to bottom):");
- final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+ final DisplayContent display = mDisplayContents.get(displayNdx);
for (int stackNdx = display.getStackCount() - 1; stackNdx >= 0; --stackNdx) {
final ActivityStack stack = display.getStackAt(stackNdx);
pw.println();
printed = stack.dump(fd, pw, dumpAll, dumpClient, dumpPackage, needSep);
needSep = printed;
}
- printThisActivity(pw, activityDisplay.getResumedActivity(), dumpPackage, needSep,
+ printThisActivity(pw, displayContent.getResumedActivity(), dumpPackage, needSep,
" ResumedActivity:");
}
@@ -2632,9 +2627,9 @@
@WindowTraceLogLevel int logLevel) {
final long token = proto.start(fieldId);
super.dumpDebug(proto, CONFIGURATION_CONTAINER, logLevel);
- for (int displayNdx = 0; displayNdx < mActivityDisplays.size(); ++displayNdx) {
- final ActivityDisplay activityDisplay = mActivityDisplays.get(displayNdx);
- activityDisplay.dumpDebug(proto, DISPLAYS, logLevel);
+ for (int displayNdx = 0; displayNdx < mDisplayContents.size(); ++displayNdx) {
+ final DisplayContent displayContent = mDisplayContents.get(displayNdx);
+ displayContent.dumpDebug(proto, DISPLAYS, logLevel);
}
mStackSupervisor.getKeyguardController().dumpDebug(proto, KEYGUARD_CONTROLLER);
// TODO(b/111541062): Update tests to look for resumed activities on all displays
diff --git a/services/core/java/com/android/server/wm/ShellRoot.java b/services/core/java/com/android/server/wm/ShellRoot.java
new file mode 100644
index 0000000..9732637
--- /dev/null
+++ b/services/core/java/com/android/server/wm/ShellRoot.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2019 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 com.android.server.wm;
+
+import android.annotation.NonNull;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.util.Slog;
+import android.view.IWindow;
+import android.view.SurfaceControl;
+
+/**
+ * Represents a piece of the hierarchy under which a client Shell can manage sub-windows.
+ */
+public class ShellRoot {
+ private static final String TAG = "ShellRoot";
+ private final DisplayContent mDisplayContent;
+ private IWindow mClient;
+ private WindowToken mToken;
+ private final IBinder.DeathRecipient mDeathRecipient;
+ private SurfaceControl mSurfaceControl = null;
+
+ ShellRoot(@NonNull IWindow client, @NonNull DisplayContent dc, final int windowType) {
+ mDisplayContent = dc;
+ mDeathRecipient = () -> mDisplayContent.removeShellRoot(windowType);
+ try {
+ client.asBinder().linkToDeath(mDeathRecipient, 0);
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Unable to add shell root for layer " + windowType + " on display "
+ + dc.getDisplayId(), e);
+ return;
+ }
+ mClient = client;
+ mToken = new WindowToken(
+ dc.mWmService, client.asBinder(), windowType, true, dc, true, false);
+ mSurfaceControl = mToken.makeChildSurface(null)
+ .setContainerLayer().setName("Shell Root Leash " + dc.getDisplayId()).build();
+ mToken.getPendingTransaction().show(mSurfaceControl);
+ }
+
+ void clear() {
+ if (mClient != null) {
+ mClient.asBinder().unlinkToDeath(mDeathRecipient, 0);
+ mClient = null;
+ }
+ if (mToken != null) {
+ mToken.removeImmediately();
+ mToken = null;
+ }
+ }
+
+ SurfaceControl getSurfaceControl() {
+ return mSurfaceControl;
+ }
+
+ IWindow getClient() {
+ return mClient;
+ }
+}
+
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 0e07e52..1b2274a 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -135,7 +135,6 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.IVoiceInteractor;
-import com.android.internal.util.ToBooleanFunction;
import com.android.internal.util.XmlUtils;
import com.android.internal.util.function.pooled.PooledConsumer;
import com.android.internal.util.function.pooled.PooledFunction;
@@ -1583,8 +1582,8 @@
if (!inPinnedWindowingMode() && mStack != null) {
final int defaultMinSizeDp =
mAtmService.mRootActivityContainer.mDefaultMinSizeOfResizeableTaskDp;
- final ActivityDisplay display =
- mAtmService.mRootActivityContainer.getActivityDisplay(mStack.mDisplayId);
+ final DisplayContent display =
+ mAtmService.mRootActivityContainer.getDisplayContent(mStack.mDisplayId);
final float density =
(float) display.getConfiguration().densityDpi / DisplayMetrics.DENSITY_DEFAULT;
final int defaultMinSize = (int) (defaultMinSizeDp * density);
@@ -1995,7 +1994,7 @@
((float) newParentConfig.densityDpi) / DisplayMetrics.DENSITY_DEFAULT;
final Rect parentBounds =
new Rect(newParentConfig.windowConfiguration.getBounds());
- final ActivityDisplay display = mStack.getDisplay();
+ final DisplayContent display = mStack.getDisplay();
if (display != null && display.mDisplayContent != null) {
// If a freeform window moves below system bar, there is no way to move it again
// by touch. Because its caption is covered by system bar. So we exclude them
@@ -2188,7 +2187,7 @@
final ActivityStack prevStack = getTaskStack();
final boolean wasTopFocusedStack =
mAtmService.mRootActivityContainer.isTopDisplayFocusedStack(prevStack);
- final ActivityDisplay prevStackDisplay = prevStack.getDisplay();
+ final DisplayContent prevStackDisplay = prevStack.getDisplay();
position = stack.findPositionForTask(this, position, showForAllUsers());
diff --git a/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java b/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java
index 9d19cfe..4de61f0 100644
--- a/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java
+++ b/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java
@@ -137,7 +137,7 @@
// STEP 1: Determine the display to launch the activity/task.
final int displayId = getPreferredLaunchDisplay(task, options, source, currentParams);
outParams.mPreferredDisplayId = displayId;
- ActivityDisplay display = mSupervisor.mRootActivityContainer.getActivityDisplay(displayId);
+ DisplayContent display = mSupervisor.mRootActivityContainer.getDisplayContent(displayId);
if (DEBUG) {
appendLog("display-id=" + outParams.mPreferredDisplayId + " display-windowing-mode="
+ display.getWindowingMode());
@@ -282,7 +282,7 @@
if (source != null && source.inFreeformWindowingMode()
&& resolvedMode == WINDOWING_MODE_FREEFORM
&& outParams.mBounds.isEmpty()
- && source.getDisplayId() == display.mDisplayId) {
+ && source.getDisplayId() == display.getDisplayId()) {
// Set bounds to be not very far from source activity.
cascadeBounds(source.getConfiguration().windowConfiguration.getBounds(),
display, outParams.mBounds);
@@ -333,17 +333,17 @@
}
if (displayId != INVALID_DISPLAY
- && mSupervisor.mRootActivityContainer.getActivityDisplay(displayId) == null) {
+ && mSupervisor.mRootActivityContainer.getDisplayContent(displayId) == null) {
displayId = currentParams.mPreferredDisplayId;
}
displayId = (displayId == INVALID_DISPLAY) ? currentParams.mPreferredDisplayId : displayId;
return (displayId != INVALID_DISPLAY
- && mSupervisor.mRootActivityContainer.getActivityDisplay(displayId) != null)
+ && mSupervisor.mRootActivityContainer.getDisplayContent(displayId) != null)
? displayId : DEFAULT_DISPLAY;
}
- private boolean canInheritWindowingModeFromSource(@NonNull ActivityDisplay display,
+ private boolean canInheritWindowingModeFromSource(@NonNull DisplayContent display,
@Nullable ActivityRecord source) {
if (source == null) {
return false;
@@ -365,10 +365,10 @@
// Only inherit windowing mode if both source and target activities are on the same display.
// Otherwise we may have unintended freeform windows showing up if an activity in freeform
// window launches an activity on a fullscreen display by specifying display ID.
- return display.mDisplayId == source.getDisplayId();
+ return display.getDisplayId() == source.getDisplayId();
}
- private boolean canApplyFreeformWindowPolicy(@NonNull ActivityDisplay display, int launchMode) {
+ private boolean canApplyFreeformWindowPolicy(@NonNull DisplayContent display, int launchMode) {
return mSupervisor.mService.mSupportsFreeformWindowManagement
&& (display.inFreeformWindowingMode() || launchMode == WINDOWING_MODE_FREEFORM);
}
@@ -378,7 +378,7 @@
&& launchMode == WINDOWING_MODE_PINNED;
}
- private void getLayoutBounds(@NonNull ActivityDisplay display, @NonNull ActivityRecord root,
+ private void getLayoutBounds(@NonNull DisplayContent display, @NonNull ActivityRecord root,
@NonNull ActivityInfo.WindowLayout windowLayout, @NonNull Rect outBounds) {
final int verticalGravity = windowLayout.gravity & Gravity.VERTICAL_GRAVITY_MASK;
final int horizontalGravity = windowLayout.gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
@@ -488,7 +488,7 @@
return orientation;
}
- private void cascadeBounds(@NonNull Rect srcBounds, @NonNull ActivityDisplay display,
+ private void cascadeBounds(@NonNull Rect srcBounds, @NonNull DisplayContent display,
@NonNull Rect outBounds) {
outBounds.set(srcBounds);
float density = (float) display.getConfiguration().densityDpi / DENSITY_DEFAULT;
@@ -500,7 +500,7 @@
outBounds.offset(dx, dy);
}
- private void getTaskBounds(@NonNull ActivityRecord root, @NonNull ActivityDisplay display,
+ private void getTaskBounds(@NonNull ActivityRecord root, @NonNull DisplayContent display,
@NonNull ActivityInfo.WindowLayout layout, int resolvedMode, boolean hasInitialBounds,
@NonNull Rect inOutBounds) {
if (resolvedMode == WINDOWING_MODE_FULLSCREEN) {
@@ -567,7 +567,7 @@
}
}
- private int resolveOrientation(@NonNull ActivityRecord root, @NonNull ActivityDisplay display,
+ private int resolveOrientation(@NonNull ActivityRecord root, @NonNull DisplayContent display,
@NonNull Rect bounds) {
int orientation = resolveOrientation(root);
@@ -593,7 +593,7 @@
return orientation;
}
- private void getDefaultFreeformSize(@NonNull ActivityDisplay display,
+ private void getDefaultFreeformSize(@NonNull DisplayContent display,
@NonNull ActivityInfo.WindowLayout layout, int orientation, @NonNull Rect bounds) {
// Default size, which is letterboxing/pillarboxing in display. That's to say the large
// dimension of default size is the small dimension of display size, and the small dimension
@@ -637,7 +637,7 @@
* Gets centered bounds of width x height. If inOutBounds is not empty, the result bounds
* centers at its center or display's app bounds center if inOutBounds is empty.
*/
- private void centerBounds(@NonNull ActivityDisplay display, int width, int height,
+ private void centerBounds(@NonNull DisplayContent display, int width, int height,
@NonNull Rect inOutBounds) {
if (inOutBounds.isEmpty()) {
inOutBounds.set(display.mDisplayContent.mDisplayFrames.mStable);
@@ -647,7 +647,7 @@
inOutBounds.set(left, top, left + width, top + height);
}
- private void adjustBoundsToFitInDisplay(@NonNull ActivityDisplay display,
+ private void adjustBoundsToFitInDisplay(@NonNull DisplayContent display,
@NonNull Rect inOutBounds) {
final Rect displayStableBounds = display.mDisplayContent.mDisplayFrames.mStable;
@@ -702,7 +702,7 @@
* @param display the display which tasks are to check
* @param inOutBounds the bounds used to input initial bounds and output result bounds
*/
- private void adjustBoundsToAvoidConflictInDisplay(@NonNull ActivityDisplay display,
+ private void adjustBoundsToAvoidConflictInDisplay(@NonNull DisplayContent display,
@NonNull Rect inOutBounds) {
final List<Rect> taskBoundsToCheck = new ArrayList<>();
for (int i = 0; i < display.getStackCount(); ++i) {
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotCache.java b/services/core/java/com/android/server/wm/TaskSnapshotCache.java
index 5cbab5d..7b0d841 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotCache.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotCache.java
@@ -109,7 +109,7 @@
removeRunningEntry(taskId);
}
- private void removeRunningEntry(int taskId) {
+ void removeRunningEntry(int taskId) {
final CacheEntry entry = mRunningCache.get(taskId);
if (entry != null) {
mAppTaskMap.remove(entry.topApp);
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotController.java b/services/core/java/com/android/server/wm/TaskSnapshotController.java
index c1a36c4..dee9e9f 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotController.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotController.java
@@ -171,22 +171,30 @@
}
void snapshotTasks(ArraySet<Task> tasks) {
+ snapshotTasks(mTmpTasks, false /* allowSnapshotHome */);
+ }
+
+ private void snapshotTasks(ArraySet<Task> tasks, boolean allowSnapshotHome) {
for (int i = tasks.size() - 1; i >= 0; i--) {
final Task task = tasks.valueAt(i);
- final int mode = getSnapshotMode(task);
final TaskSnapshot snapshot;
- switch (mode) {
- case SNAPSHOT_MODE_NONE:
- continue;
- case SNAPSHOT_MODE_APP_THEME:
- snapshot = drawAppThemeSnapshot(task);
- break;
- case SNAPSHOT_MODE_REAL:
- snapshot = snapshotTask(task);
- break;
- default:
- snapshot = null;
- break;
+ final boolean snapshotHome = allowSnapshotHome && task.isActivityTypeHome();
+ if (snapshotHome) {
+ snapshot = snapshotTask(task);
+ } else {
+ switch (getSnapshotMode(task)) {
+ case SNAPSHOT_MODE_NONE:
+ continue;
+ case SNAPSHOT_MODE_APP_THEME:
+ snapshot = drawAppThemeSnapshot(task);
+ break;
+ case SNAPSHOT_MODE_REAL:
+ snapshot = snapshotTask(task);
+ break;
+ default:
+ snapshot = null;
+ break;
+ }
}
if (snapshot != null) {
final GraphicBuffer buffer = snapshot.getSnapshot();
@@ -196,8 +204,11 @@
+ buffer.getHeight());
} else {
mCache.putSnapshot(task, snapshot);
- mPersister.persistSnapshot(task.mTaskId, task.mUserId, snapshot);
- task.onSnapshotChanged(snapshot);
+ // Don't persist or notify the change for the temporal snapshot.
+ if (!snapshotHome) {
+ mPersister.persistSnapshot(task.mTaskId, task.mUserId, snapshot);
+ task.onSnapshotChanged(snapshot);
+ }
}
}
}
@@ -403,7 +414,7 @@
final LayoutParams attrs = mainWindow.getAttrs();
final SystemBarBackgroundPainter decorPainter = new SystemBarBackgroundPainter(attrs.flags,
attrs.privateFlags, attrs.systemUiVisibility, task.getTaskDescription(),
- mFullSnapshotScale);
+ mFullSnapshotScale, mainWindow.getClientInsetsState());
final int width = (int) (task.getBounds().width() * mFullSnapshotScale);
final int height = (int) (task.getBounds().height() * mFullSnapshotScale);
@@ -450,6 +461,10 @@
mPersister.onTaskRemovedFromRecents(taskId, userId);
}
+ void removeSnapshotCache(int taskId) {
+ mCache.removeRunningEntry(taskId);
+ }
+
/**
* See {@link TaskSnapshotPersister#removeObsoleteFiles}
*/
@@ -485,7 +500,9 @@
mTmpTasks.add(task);
}
});
- snapshotTasks(mTmpTasks);
+ // Allow taking snapshot of home when turning screen off to reduce the delay of
+ // unlocking/waking to home.
+ snapshotTasks(mTmpTasks, true /* allowSnapshotHome */);
}
} finally {
listener.onScreenOff();
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotPersister.java b/services/core/java/com/android/server/wm/TaskSnapshotPersister.java
index 5915590..10f2996 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotPersister.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotPersister.java
@@ -54,7 +54,6 @@
private static final String REDUCED_POSTFIX = "_reduced";
private static final float REDUCED_SCALE = .5f;
private static final float LOW_RAM_REDUCED_SCALE = .6f;
- private static final float LOW_RAM_RECENTS_REDUCED_SCALE = .1f;
static final boolean DISABLE_FULL_SIZED_BITMAPS = ActivityManager.isLowRamDeviceStatic();
private static final long DELAY_MS = 100;
private static final int QUALITY = 95;
@@ -85,14 +84,8 @@
TaskSnapshotPersister(WindowManagerService service, DirectoryResolver resolver) {
mDirectoryResolver = resolver;
- if (service.mLowRamTaskSnapshotsAndRecents) {
- // Use very low res snapshots if we are using Go version of recents.
- mReducedScale = LOW_RAM_RECENTS_REDUCED_SCALE;
- } else {
- // TODO(122671846) Replace the low RAM value scale with the above when it is fully built
- mReducedScale = ActivityManager.isLowRamDeviceStatic()
- ? LOW_RAM_REDUCED_SCALE : REDUCED_SCALE;
- }
+ mReducedScale = ActivityManager.isLowRamDeviceStatic()
+ ? LOW_RAM_REDUCED_SCALE : REDUCED_SCALE;
mUse16BitFormat = service.mContext.getResources().getBoolean(
com.android.internal.R.bool.config_use16BitTaskSnapshotPixelFormat);
}
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
index b3750e9..1484d6a 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java
@@ -71,6 +71,7 @@
import android.view.SurfaceSession;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
+import android.view.ViewRootImpl;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
@@ -154,6 +155,7 @@
final MergedConfiguration tmpMergedConfiguration = new MergedConfiguration();
final TaskDescription taskDescription = new TaskDescription();
taskDescription.setBackgroundColor(WHITE);
+ final WindowState topFullscreenWindow;
final int sysUiVis;
final int windowFlags;
final int windowPrivateFlags;
@@ -173,7 +175,7 @@
+ task);
return null;
}
- final WindowState topFullscreenWindow = topFullscreenActivity.getTopFullscreenWindow();
+ topFullscreenWindow = topFullscreenActivity.getTopFullscreenWindow();
if (mainWindow == null || topFullscreenWindow == null) {
Slog.w(TAG, "TaskSnapshotSurface.create: Failed to find main window for activity="
+ activity);
@@ -220,7 +222,7 @@
final TaskSnapshotSurface snapshotSurface = new TaskSnapshotSurface(service, window,
surfaceControl, snapshot, layoutParams.getTitle(), taskDescription, sysUiVis,
windowFlags, windowPrivateFlags, taskBounds,
- currentOrientation);
+ currentOrientation, topFullscreenWindow.getClientInsetsState());
window.setOuter(snapshotSurface);
try {
session.relayout(window, window.mSeq, layoutParams, -1, -1, View.VISIBLE, 0, -1,
@@ -238,7 +240,7 @@
TaskSnapshotSurface(WindowManagerService service, Window window, SurfaceControl surfaceControl,
TaskSnapshot snapshot, CharSequence title, TaskDescription taskDescription,
int sysUiVis, int windowFlags, int windowPrivateFlags, Rect taskBounds,
- int currentOrientation) {
+ int currentOrientation, InsetsState insetsState) {
mService = service;
mSurface = service.mSurfaceFactory.get();
mHandler = new Handler(mService.mH.getLooper());
@@ -251,7 +253,7 @@
mBackgroundPaint.setColor(backgroundColor != 0 ? backgroundColor : WHITE);
mTaskBounds = taskBounds;
mSystemBarBackgroundPainter = new SystemBarBackgroundPainter(windowFlags,
- windowPrivateFlags, sysUiVis, taskDescription, 1f);
+ windowPrivateFlags, sysUiVis, taskDescription, 1f, insetsState);
mStatusBarColor = taskDescription.getStatusBarColor();
mOrientationOnCreation = currentOrientation;
mTransaction = mService.mTransactionFactory.get();
@@ -502,9 +504,10 @@
private final int mWindowPrivateFlags;
private final int mSysUiVis;
private final float mScale;
+ private final InsetsState mInsetsState;
SystemBarBackgroundPainter(int windowFlags, int windowPrivateFlags, int sysUiVis,
- TaskDescription taskDescription, float scale) {
+ TaskDescription taskDescription, float scale, InsetsState insetsState) {
mWindowFlags = windowFlags;
mWindowPrivateFlags = windowPrivateFlags;
mSysUiVis = sysUiVis;
@@ -524,6 +527,7 @@
&& context.getResources().getBoolean(R.bool.config_navBarNeedsScrim));
mStatusBarPaint.setColor(mStatusBarColor);
mNavigationBarPaint.setColor(mNavigationBarColor);
+ mInsetsState = insetsState;
}
void setInsets(Rect contentInsets, Rect stableInsets) {
@@ -534,8 +538,11 @@
int getStatusBarColorViewHeight() {
final boolean forceBarBackground =
(mWindowPrivateFlags & PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS) != 0;
- if (STATUS_BAR_COLOR_VIEW_ATTRIBUTES.isVisible(
- mSysUiVis, mStatusBarColor, mWindowFlags, forceBarBackground)) {
+ if (ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL
+ ? STATUS_BAR_COLOR_VIEW_ATTRIBUTES.isVisible(
+ mSysUiVis, mStatusBarColor, mWindowFlags, forceBarBackground)
+ : STATUS_BAR_COLOR_VIEW_ATTRIBUTES.isVisible(
+ mInsetsState, mStatusBarColor, mWindowFlags, forceBarBackground)) {
return (int) (getColorViewTopInset(mStableInsets.top, mContentInsets.top) * mScale);
} else {
return 0;
@@ -545,8 +552,11 @@
private boolean isNavigationBarColorViewVisible() {
final boolean forceBarBackground =
(mWindowPrivateFlags & PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS) != 0;
- return NAVIGATION_BAR_COLOR_VIEW_ATTRIBUTES.isVisible(
- mSysUiVis, mNavigationBarColor, mWindowFlags, forceBarBackground);
+ return ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL
+ ? NAVIGATION_BAR_COLOR_VIEW_ATTRIBUTES.isVisible(
+ mSysUiVis, mNavigationBarColor, mWindowFlags, forceBarBackground)
+ : NAVIGATION_BAR_COLOR_VIEW_ATTRIBUTES.isVisible(
+ mInsetsState, mNavigationBarColor, mWindowFlags, forceBarBackground);
}
void drawDecors(Canvas c, @Nullable Rect alreadyDrawnFrame) {
diff --git a/services/core/java/com/android/server/wm/WindowFrames.java b/services/core/java/com/android/server/wm/WindowFrames.java
index 0490bac..97186b4 100644
--- a/services/core/java/com/android/server/wm/WindowFrames.java
+++ b/services/core/java/com/android/server/wm/WindowFrames.java
@@ -207,6 +207,7 @@
return (mLastFrame.width() != mFrame.width()) || (mLastFrame.height() != mFrame.height());
}
+ // TODO(b/118118435): Remove after migration.
/**
* Calculate the insets for the type
* {@link android.view.WindowManager.LayoutParams#TYPE_DOCK_DIVIDER}
diff --git a/services/core/java/com/android/server/wm/WindowManagerConstants.java b/services/core/java/com/android/server/wm/WindowManagerConstants.java
index 10c8ef0..74d5c04 100644
--- a/services/core/java/com/android/server/wm/WindowManagerConstants.java
+++ b/services/core/java/com/android/server/wm/WindowManagerConstants.java
@@ -19,6 +19,8 @@
import static android.provider.AndroidDeviceConfig.KEY_SYSTEM_GESTURES_EXCLUDED_BY_PRE_Q_STICKY_IMMERSIVE;
import static android.provider.AndroidDeviceConfig.KEY_SYSTEM_GESTURE_EXCLUSION_LIMIT_DP;
+import static com.android.internal.util.Preconditions.checkNotNull;
+
import android.provider.AndroidDeviceConfig;
import android.provider.DeviceConfig;
@@ -72,8 +74,8 @@
WindowManagerConstants(WindowManagerGlobalLock globalLock,
Runnable updateSystemGestureExclusionCallback,
DeviceConfigInterface deviceConfig) {
- mGlobalLock = globalLock;
- mUpdateSystemGestureExclusionCallback = updateSystemGestureExclusionCallback;
+ mGlobalLock = checkNotNull(globalLock);
+ mUpdateSystemGestureExclusionCallback = checkNotNull(updateSystemGestureExclusionCallback);
mDeviceConfig = deviceConfig;
mListenerAndroid = this::onAndroidPropertiesChanged;
mListenerWindowManager = this::onWindowPropertiesChanged;
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index f45eb50..acaaed9 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -79,7 +79,6 @@
import static com.android.server.LockGuard.INDEX_WINDOW;
import static com.android.server.LockGuard.installLock;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
-import static com.android.server.wm.ActivityStackSupervisor.PRESERVE_WINDOWS;
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_BOOT;
import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_FOCUS;
@@ -406,8 +405,7 @@
private static final int ANIMATION_COMPLETED_TIMEOUT_MS = 5000;
- final WindowManagerConstants mConstants = new WindowManagerConstants(this,
- DeviceConfigInterface.REAL);
+ final WindowManagerConstants mConstants;
final WindowTracing mWindowTracing;
@@ -491,13 +489,6 @@
final long mDrawLockTimeoutMillis;
final boolean mAllowAnimationsInLowPowerMode;
- // TODO(b/122671846) Remove the flag below in favor of isLowRam once feature is stable
- /**
- * Use very low resolution task snapshots. Replaces task snapshot starting windows with
- * splashscreen starting windows. Used on low RAM devices to save memory.
- */
- final boolean mLowRamTaskSnapshotsAndRecents;
-
final boolean mAllowBootMessages;
final boolean mLimitedAlphaCompositing;
@@ -1114,8 +1105,6 @@
com.android.internal.R.bool.config_disableTransitionAnimation);
mPerDisplayFocusEnabled = context.getResources().getBoolean(
com.android.internal.R.bool.config_perDisplayFocusEnabled);
- mLowRamTaskSnapshotsAndRecents = context.getResources().getBoolean(
- com.android.internal.R.bool.config_lowRamTaskSnapshotsAndRecents);
mInputManager = inputManager; // Must be before createDisplayContentLocked.
mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
@@ -1242,6 +1231,7 @@
mHighRefreshRateBlacklist = HighRefreshRateBlacklist.create(context.getResources());
+ mConstants = new WindowManagerConstants(this, DeviceConfigInterface.REAL);
mConstants.start(new HandlerExecutor(mH));
LocalServices.addService(WindowManagerInternal.class, new LocalService());
@@ -1731,7 +1721,7 @@
}
}
- return mAtmService.mRootActivityContainer.getActivityDisplayOrCreate(displayId);
+ return mAtmService.mRootActivityContainer.getDisplayContentOrCreate(displayId);
}
private boolean doesAddToastWindowRequireToken(String packageName, int callingUid,
@@ -3721,6 +3711,26 @@
}
@Override
+ public SurfaceControl addShellRoot(int displayId, IWindow client, int windowType) {
+ if (mContext.checkCallingOrSelfPermission(MANAGE_APP_TOKENS)
+ != PackageManager.PERMISSION_GRANTED) {
+ throw new SecurityException("Must hold permission " + MANAGE_APP_TOKENS);
+ }
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ final DisplayContent dc = mRoot.getDisplayContent(displayId);
+ if (dc == null) {
+ return null;
+ }
+ return dc.addShellRoot(client, windowType);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+
+ @Override
public int watchRotation(IRotationWatcher watcher, int displayId) {
final DisplayContent displayContent;
synchronized (mGlobalLock) {
@@ -7639,7 +7649,11 @@
return;
}
- handleDisplayFocusChange(touchedWindow);
+ final DisplayContent displayContent = touchedWindow.getDisplayContent();
+ if (!displayContent.isOnTop()) {
+ displayContent.getParent().positionChildAt(WindowContainer.POSITION_TOP, displayContent,
+ true /* includingParents */);
+ }
handleTaskFocusChange(touchedWindow.getTask());
}
@@ -7662,29 +7676,6 @@
}
}
- private void handleDisplayFocusChange(WindowState window) {
- final DisplayContent displayContent = window.getDisplayContent();
- if (displayContent == null) {
- return;
- }
-
- final WindowContainer parent = displayContent.getParent();
- if (parent != null && parent.getTopChild() != displayContent) {
- parent.positionChildAt(WindowContainer.POSITION_TOP, displayContent,
- true /* includingParents */);
- // For compatibility, only the topmost activity is allowed to be resumed for pre-Q
- // app. Ensure the topmost activities are resumed whenever a display is moved to top.
- // TODO(b/123761773): Investigate whether we can move this into
- // RootActivityContainer#updateTopResumedActivityIfNeeded(). Currently, it is risky
- // to do so because it seems possible to resume activities as part of a larger
- // transaction and it's too early to resume based on current order when performing
- // updateTopResumedActivityIfNeeded().
- // TODO(display-merge): Remove cast
- ((ActivityDisplay) displayContent).ensureActivitiesVisible(null /* starting */,
- 0 /* configChanges */, !PRESERVE_WINDOWS, true /* notifyClients */);
- }
- }
-
/**
* Assigns an InputChannel to a SurfaceControl and configures it to receive
* touch input according to it's on-screen geometry.
diff --git a/services/core/java/com/android/server/wm/WindowProcessController.java b/services/core/java/com/android/server/wm/WindowProcessController.java
index ddf8e9b..1a41006 100644
--- a/services/core/java/com/android/server/wm/WindowProcessController.java
+++ b/services/core/java/com/android/server/wm/WindowProcessController.java
@@ -575,14 +575,14 @@
return true;
}
- final ActivityDisplay display = activity.getDisplay();
+ final DisplayContent display = activity.getDisplay();
if (display == null) {
// No need to update if the activity hasn't attach to any display.
return false;
}
boolean canUpdate = false;
- final ActivityDisplay topDisplay =
+ final DisplayContent topDisplay =
mPreQTopResumedActivity != null ? mPreQTopResumedActivity.getDisplay() : null;
// Update the topmost activity if current top activity is
// - not on any display OR
@@ -938,15 +938,15 @@
mAtm.mH.sendMessage(m);
}
- void registerDisplayConfigurationListenerLocked(ActivityDisplay activityDisplay) {
- if (activityDisplay == null) {
+ void registerDisplayConfigurationListenerLocked(DisplayContent displayContent) {
+ if (displayContent == null) {
return;
}
// A process can only register to one display to listener to the override configuration
// change. Unregister existing listener if it has one before register the new one.
unregisterDisplayConfigurationListenerLocked();
- mDisplayId = activityDisplay.mDisplayId;
- activityDisplay.registerConfigurationChangeListener(this);
+ mDisplayId = displayContent.mDisplayId;
+ displayContent.registerConfigurationChangeListener(this);
}
@VisibleForTesting
@@ -954,10 +954,10 @@
if (mDisplayId == INVALID_DISPLAY) {
return;
}
- final ActivityDisplay activityDisplay =
- mAtm.mRootActivityContainer.getActivityDisplay(mDisplayId);
- if (activityDisplay != null) {
- activityDisplay.unregisterConfigurationChangeListener(this);
+ final DisplayContent displayContent =
+ mAtm.mRootActivityContainer.getDisplayContent(mDisplayId);
+ if (displayContent != null) {
+ displayContent.unregisterConfigurationChangeListener(this);
}
mDisplayId = INVALID_DISPLAY;
}
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 5b7f36d..6918c96 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -2149,13 +2149,27 @@
return false;
}
- final int fl = mAttrs.flags & (FLAG_NOT_FOCUSABLE | FLAG_ALT_FOCUSABLE_IM);
- final int type = mAttrs.type;
+ if (PixelFormat.formatHasAlpha(mAttrs.format)) {
+ // Support legacy use cases where transparent windows can still be ime target with
+ // FLAG_NOT_FOCUSABLE and ALT_FOCUSABLE_IM set.
+ // Certain apps listen for IME insets using transparent windows and ADJUST_NOTHING to
+ // manually synchronize app content to IME animation b/144619551.
+ // TODO(b/145812508): remove this once new focus management is complete b/141738570
+ final int fl = mAttrs.flags & (FLAG_NOT_FOCUSABLE | FLAG_ALT_FOCUSABLE_IM);
+ final int type = mAttrs.type;
- // Can only be an IME target if both FLAG_NOT_FOCUSABLE and FLAG_ALT_FOCUSABLE_IM are set or
- // both are cleared...and not a starting window.
- if (fl != 0 && fl != (FLAG_NOT_FOCUSABLE | FLAG_ALT_FOCUSABLE_IM)
- && type != TYPE_APPLICATION_STARTING) {
+ // Can only be an IME target if both FLAG_NOT_FOCUSABLE and FLAG_ALT_FOCUSABLE_IM are
+ // set or both are cleared...and not a starting window.
+ if (fl != 0 && fl != (FLAG_NOT_FOCUSABLE | FLAG_ALT_FOCUSABLE_IM)
+ && type != TYPE_APPLICATION_STARTING) {
+ return false;
+ }
+ } else if (!WindowManager.LayoutParams.mayUseInputMethod(mAttrs.flags)
+ || mAttrs.type == TYPE_APPLICATION_STARTING) {
+ // Can be an IME target only if:
+ // 1. FLAG_NOT_FOCUSABLE is not set
+ // 2. FLAG_ALT_FOCUSABLE_IM is not set
+ // 3. not a starting window.
return false;
}
@@ -2611,7 +2625,7 @@
final boolean canReceiveKeys = isVisibleOrAdding()
&& (mViewVisibility == View.VISIBLE) && !mRemoveOnExit
&& ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0)
- && (mActivityRecord == null || mActivityRecord.windowsAreFocusable())
+ && (mActivityRecord == null || mActivityRecord.windowsAreFocusable(fromUserTouch))
&& !cantReceiveTouchInput();
if (!canReceiveKeys) {
return false;
diff --git a/services/core/jni/com_android_server_security_VerityUtils.cpp b/services/core/jni/com_android_server_security_VerityUtils.cpp
index 906b568..be11b86 100644
--- a/services/core/jni/com_android_server_security_VerityUtils.cpp
+++ b/services/core/jni/com_android_server_security_VerityUtils.cpp
@@ -24,6 +24,7 @@
#include <errno.h>
#include <fcntl.h>
+#include <linux/fsverity.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
@@ -33,40 +34,6 @@
#include <android-base/unique_fd.h>
-// TODO(112037636): Always include once fsverity.h is upstreamed.
-#if __has_include(<linux/fsverity.h>)
-#include <linux/fsverity.h>
-#else
-
-#include <linux/limits.h>
-#include <linux/ioctl.h>
-#include <linux/types.h>
-
-#define FS_VERITY_HASH_ALG_SHA256 1
-
-struct fsverity_enable_arg {
- __u32 version;
- __u32 hash_algorithm;
- __u32 block_size;
- __u32 salt_size;
- __u64 salt_ptr;
- __u32 sig_size;
- __u32 __reserved1;
- __u64 sig_ptr;
- __u64 __reserved2[11];
-};
-
-struct fsverity_digest {
- __u16 digest_algorithm;
- __u16 digest_size; /* input/output */
- __u8 digest[];
-};
-
-#define FS_IOC_ENABLE_VERITY _IOW('f', 133, struct fsverity_enable_arg)
-#define FS_IOC_MEASURE_VERITY _IOWR('f', 134, struct fsverity_digest)
-
-#endif
-
const int kSha256Bytes = 32;
namespace android {
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index ee0449d..d91ec42 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -990,6 +990,7 @@
"cross-profile-calendar-packages";
private static final String TAG_CROSS_PROFILE_CALENDAR_PACKAGES_NULL =
"cross-profile-calendar-packages-null";
+ private static final String TAG_CROSS_PROFILE_PACKAGES = "cross-profile-packages";
DeviceAdminInfo info;
@@ -1104,6 +1105,11 @@
// is whitelisted.
List<String> mCrossProfileCalendarPackages = Collections.emptyList();
+ // The whitelist of packages that the admin has enabled to be able to request consent from
+ // the user to communicate cross-profile. By default, no packages are whitelisted, which is
+ // represented as an empty list.
+ List<String> mCrossProfilePackages = Collections.emptyList();
+
ActiveAdmin(DeviceAdminInfo _info, boolean parent) {
info = _info;
isParent = parent;
@@ -1329,6 +1335,7 @@
writePackageListToXml(out, TAG_CROSS_PROFILE_CALENDAR_PACKAGES,
mCrossProfileCalendarPackages);
}
+ writePackageListToXml(out, TAG_CROSS_PROFILE_PACKAGES, mCrossProfilePackages);
}
void writeTextToXml(XmlSerializer out, String tag, String text) throws IOException {
@@ -1560,6 +1567,8 @@
mCrossProfileCalendarPackages = readPackageList(parser, tag);
} else if (TAG_CROSS_PROFILE_CALENDAR_PACKAGES_NULL.equals(tag)) {
mCrossProfileCalendarPackages = null;
+ } else if (TAG_CROSS_PROFILE_PACKAGES.equals(tag)) {
+ mCrossProfilePackages = readPackageList(parser, tag);
} else {
Slog.w(LOG_TAG, "Unknown admin tag: " + tag);
XmlUtils.skipCurrentTag(parser);
@@ -1783,6 +1792,8 @@
pw.print("mCrossProfileCalendarPackages=");
pw.println(mCrossProfileCalendarPackages);
}
+ pw.print("mCrossProfilePackages=");
+ pw.println(mCrossProfilePackages);
}
}
@@ -2436,7 +2447,7 @@
Settings.Secure.UNKNOWN_SOURCES_DEFAULT_REVERSED, 0, userId) != 0) {
profileOwner.ensureUserRestrictions().putBoolean(
UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES, true);
- saveUserRestrictionsLocked(userId);
+ saveUserRestrictionsLocked(userId, /* parent = */ false);
mInjector.settingsSecurePutIntForUser(
Settings.Secure.UNKNOWN_SOURCES_DEFAULT_REVERSED, 0, userId);
}
@@ -2467,7 +2478,7 @@
}
admin.defaultEnabledRestrictionsAlreadySet.addAll(restrictionsToSet);
Slog.i(LOG_TAG, "Enabled the following restrictions by default: " + restrictionsToSet);
- saveUserRestrictionsLocked(userId);
+ saveUserRestrictionsLocked(userId, /* parent = */ false);
}
}
@@ -7429,7 +7440,7 @@
}
/**
- * Returns whether or auto time is used on the device or not.
+ * Returns whether auto time is used on the device or not.
*/
@Override
public boolean getAutoTime(ComponentName who) {
@@ -7442,6 +7453,42 @@
return mInjector.settingsGlobalGetInt(Global.AUTO_TIME, 0) > 0;
}
+ /**
+ * Set whether auto time zone is enabled on the device.
+ */
+ @Override
+ public void setAutoTimeZone(ComponentName who, boolean enabled) {
+ if (!mHasFeature) {
+ return;
+ }
+ Preconditions.checkNotNull(who, "ComponentName is null");
+ // TODO (b/145286957) Refactor security checks
+ enforceDeviceOwnerOrProfileOwnerOnUser0OrProfileOwnerOrganizationOwned();
+
+ mInjector.binderWithCleanCallingIdentity(() ->
+ mInjector.settingsGlobalPutInt(Global.AUTO_TIME_ZONE, enabled ? 1 : 0));
+
+ DevicePolicyEventLogger
+ .createEvent(DevicePolicyEnums.SET_AUTO_TIME_ZONE)
+ .setAdmin(who)
+ .setBoolean(enabled)
+ .write();
+ }
+
+ /**
+ * Returns whether auto time zone is used on the device or not.
+ */
+ @Override
+ public boolean getAutoTimeZone(ComponentName who) {
+ if (!mHasFeature) {
+ return false;
+ }
+ Preconditions.checkNotNull(who, "ComponentName is null");
+ enforceDeviceOwnerOrProfileOwnerOnUser0OrProfileOwnerOrganizationOwned();
+
+ return mInjector.settingsGlobalGetInt(Global.AUTO_TIME_ZONE, 0) > 0;
+ }
+
@Override
public void setForceEphemeralUsers(ComponentName who, boolean forceEphemeralUsers) {
if (!mHasFeature) {
@@ -7992,7 +8039,7 @@
activeAdmin.defaultEnabledRestrictionsAlreadySet.addAll(restrictions);
Slog.i(LOG_TAG, "Enabled the following restrictions by default: " + restrictions);
- saveUserRestrictionsLocked(userId);
+ saveUserRestrictionsLocked(userId, /* parent = */ false);
}
long ident = mInjector.binderClearCallingIdentity();
@@ -10263,24 +10310,33 @@
}
@Override
- public void setUserRestriction(ComponentName who, String key, boolean enabledFromThisOwner) {
+ public void setUserRestriction(ComponentName who, String key, boolean enabledFromThisOwner,
+ boolean parent) {
Preconditions.checkNotNull(who, "ComponentName is null");
if (!UserRestrictionsUtils.isValidRestriction(key)) {
return;
}
- final int userHandle = mInjector.userHandleGetCallingUserId();
+ int userHandle = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) {
final ActiveAdmin activeAdmin =
getActiveAdminForCallerLocked(who,
- DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
+ DeviceAdminInfo.USES_POLICY_PROFILE_OWNER, parent);
final boolean isDeviceOwner = isDeviceOwner(who, userHandle);
+
if (isDeviceOwner) {
if (!UserRestrictionsUtils.canDeviceOwnerChange(key)) {
throw new SecurityException("Device owner cannot set user restriction " + key);
}
- } else { // profile owner
- if (!UserRestrictionsUtils.canProfileOwnerChange(key, userHandle)) {
+ if (parent) {
+ throw new IllegalArgumentException(
+ "Cannot use the parent instance in Device Owner mode");
+ }
+ } else {
+ if (!(UserRestrictionsUtils.canProfileOwnerChange(key, userHandle) || (
+ isProfileOwnerOfOrganizationOwnedDevice(activeAdmin) && parent
+ && UserRestrictionsUtils.canProfileOwnerOfOrganizationOwnedDeviceChange(
+ key)))) {
throw new SecurityException("Profile owner cannot set user restriction " + key);
}
}
@@ -10292,7 +10348,7 @@
} else {
restrictions.remove(key);
}
- saveUserRestrictionsLocked(userHandle);
+ saveUserRestrictionsLocked(userHandle, parent);
}
final int eventId = enabledFromThisOwner
? DevicePolicyEnums.ADD_USER_RESTRICTION
@@ -10310,9 +10366,9 @@
}
}
- private void saveUserRestrictionsLocked(int userId) {
+ private void saveUserRestrictionsLocked(int userId, boolean parent) {
saveSettingsLocked(userId);
- pushUserRestrictions(userId);
+ pushUserRestrictions(parent ? getProfileParentId(userId) : userId);
sendChangedNotification(userId);
}
@@ -10321,6 +10377,7 @@
final boolean isDeviceOwner = mOwners.isDeviceOwnerUserId(userId);
Bundle userRestrictions = null;
final int restrictionOwnerType;
+ final int originatingUserId;
if (isDeviceOwner) {
final ActiveAdmin deviceOwner = getDeviceOwnerAdminLocked();
@@ -10330,6 +10387,7 @@
userRestrictions = deviceOwner.userRestrictions;
addOrRemoveDisableCameraRestriction(userRestrictions, deviceOwner);
restrictionOwnerType = UserManagerInternal.OWNER_TYPE_DEVICE_OWNER;
+ originatingUserId = deviceOwner.getUserHandle().getIdentifier();
} else {
final ActiveAdmin profileOwnerOfOrganizationOwnedDevice =
getProfileOwnerOfOrganizationOwnedDeviceLocked(userId);
@@ -10344,21 +10402,25 @@
userRestrictions = parent.userRestrictions;
userRestrictions = addOrRemoveDisableCameraRestriction(userRestrictions,
parent);
+ originatingUserId =
+ profileOwnerOfOrganizationOwnedDevice.getUserHandle().getIdentifier();
} else {
final ActiveAdmin profileOwner = getProfileOwnerAdminLocked(userId);
if (profileOwner != null) {
userRestrictions = profileOwner.userRestrictions;
restrictionOwnerType = UserManagerInternal.OWNER_TYPE_PROFILE_OWNER;
+ originatingUserId = profileOwner.getUserHandle().getIdentifier();
} else {
restrictionOwnerType = UserManagerInternal.OWNER_TYPE_NO_OWNER;
+ originatingUserId = userId;
}
userRestrictions = addOrRemoveDisableCameraRestriction(
userRestrictions, userId);
}
}
- mUserManagerInternal.setDevicePolicyUserRestrictions(userId, userRestrictions,
- restrictionOwnerType);
+ mUserManagerInternal.setDevicePolicyUserRestrictions(originatingUserId,
+ userRestrictions, restrictionOwnerType);
}
}
@@ -10388,14 +10450,18 @@
}
@Override
- public Bundle getUserRestrictions(ComponentName who) {
+ public Bundle getUserRestrictions(ComponentName who, boolean parent) {
if (!mHasFeature) {
return null;
}
Preconditions.checkNotNull(who, "ComponentName is null");
+
synchronized (getLockObject()) {
final ActiveAdmin activeAdmin = getActiveAdminForCallerLocked(who,
- DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
+ DeviceAdminInfo.USES_POLICY_PROFILE_OWNER, parent);
+ if (parent) {
+ enforceProfileOwnerOfOrganizationOwnedDevice(activeAdmin);
+ }
return activeAdmin.userRestrictions;
}
}
@@ -11194,7 +11260,7 @@
} else {
try {
setUserRestriction(who, UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES,
- (Integer.parseInt(value) == 0) ? true : false);
+ (Integer.parseInt(value) == 0) ? true : false, /* parent */ false);
DevicePolicyEventLogger
.createEvent(DevicePolicyEnums.SET_SECURE_SETTING)
.setAdmin(who)
@@ -11239,7 +11305,7 @@
Preconditions.checkNotNull(who, "ComponentName is null");
synchronized (getLockObject()) {
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
- setUserRestriction(who, UserManager.DISALLOW_UNMUTE_DEVICE, on);
+ setUserRestriction(who, UserManager.DISALLOW_UNMUTE_DEVICE, on, /* parent */ false);
DevicePolicyEventLogger
.createEvent(DevicePolicyEnums.SET_MASTER_VOLUME_MUTED)
.setAdmin(who)
@@ -13726,8 +13792,9 @@
} else {
deviceOwner.lastNetworkLoggingNotificationTimeMs = now;
}
+ final PackageManagerInternal pm = mInjector.getPackageManagerInternal();
final Intent intent = new Intent(DevicePolicyManager.ACTION_SHOW_DEVICE_MONITORING_DIALOG);
- intent.setPackage("com.android.systemui");
+ intent.setPackage(pm.getSystemUiServiceComponent().getPackageName());
final PendingIntent pendingIntent = PendingIntent.getBroadcastAsUser(mContext, 0, intent, 0,
UserHandle.CURRENT);
Notification notification =
@@ -14645,6 +14712,35 @@
}
@Override
+ public void setCrossProfilePackages(ComponentName who, List<String> packageNames) {
+ if (!mHasFeature) {
+ return;
+ }
+ Preconditions.checkNotNull(who, "ComponentName is null");
+ Preconditions.checkNotNull(packageNames, "Package names is null");
+ synchronized (getLockObject()) {
+ final ActiveAdmin admin =
+ getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
+ admin.mCrossProfilePackages = packageNames;
+ saveSettingsLocked(mInjector.userHandleGetCallingUserId());
+ }
+ }
+
+ @Override
+ public List<String> getCrossProfilePackages(ComponentName who) {
+ if (!mHasFeature) {
+ return Collections.emptyList();
+ }
+ Preconditions.checkNotNull(who, "ComponentName is null");
+
+ synchronized (getLockObject()) {
+ final ActiveAdmin admin = getActiveAdminForCallerLocked(
+ who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
+ return admin.mCrossProfilePackages;
+ }
+ }
+
+ @Override
public boolean isManagedKiosk() {
if (!mHasFeature) {
return false;
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index b6e501a..f3ac7d6 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -30,12 +30,12 @@
import android.app.AppCompatCallbacks;
import android.app.INotificationManager;
import android.app.usage.UsageStatsManagerInternal;
-import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManagerInternal;
import android.content.res.Configuration;
import android.content.res.Resources.Theme;
import android.database.sqlite.SQLiteCompatibilityWalFlags;
@@ -126,6 +126,7 @@
import com.android.server.os.SchedulingPolicyService;
import com.android.server.pm.BackgroundDexOptService;
import com.android.server.pm.CrossProfileAppsService;
+import com.android.server.pm.DataLoaderManagerService;
import com.android.server.pm.DynamicCodeLoggingService;
import com.android.server.pm.Installer;
import com.android.server.pm.LauncherAppsService;
@@ -321,6 +322,7 @@
private PackageManager mPackageManager;
private ContentResolver mContentResolver;
private EntropyMixer mEntropyMixer;
+ private DataLoaderManagerService mDataLoaderManagerService;
private boolean mOnlyCore;
private boolean mFirstBoot;
@@ -493,6 +495,9 @@
// Initialize the system context.
createSystemContext();
+ // Call per-process mainline module initialization.
+ ActivityThread.initializeMainlineModules();
+
// Create the system service manager.
mSystemServiceManager = new SystemServiceManager(mSystemContext);
mSystemServiceManager.setStartInfo(mRuntimeRestart,
@@ -694,6 +699,12 @@
mWindowManagerGlobalLock = atm.getGlobalLock();
t.traceEnd();
+ // Data loader manager service needs to be started before package manager
+ t.traceBegin("StartDataLoaderManagerService");
+ mDataLoaderManagerService = mSystemServiceManager.startService(
+ DataLoaderManagerService.class);
+ t.traceEnd();
+
// Power manager needs to be started early because other services need it.
// Native daemons may be watching for it to be registered so it must be ready
// to handle incoming binder calls immediately (including being able to verify
@@ -2384,9 +2395,9 @@
}
private static void startSystemUi(Context context, WindowManagerService windowManager) {
+ PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class);
Intent intent = new Intent();
- intent.setComponent(new ComponentName("com.android.systemui",
- "com.android.systemui.SystemUIService"));
+ intent.setComponent(pm.getSystemUiServiceComponent());
intent.addFlags(Intent.FLAG_DEBUG_TRIAGED_MISSING);
//Slog.d(TAG, "Starting service: " + intent);
context.startServiceAsUser(intent, UserHandle.SYSTEM);
diff --git a/services/net/java/android/net/TcpKeepalivePacketData.java b/services/net/java/android/net/TcpKeepalivePacketData.java
index 7f2f499..aad75ae 100644
--- a/services/net/java/android/net/TcpKeepalivePacketData.java
+++ b/services/net/java/android/net/TcpKeepalivePacketData.java
@@ -19,7 +19,6 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.net.SocketKeepalive.InvalidPacketException;
import android.net.util.IpUtils;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/services/tests/servicestests/Android.bp b/services/tests/servicestests/Android.bp
index cf7919b..3910993 100644
--- a/services/tests/servicestests/Android.bp
+++ b/services/tests/servicestests/Android.bp
@@ -40,7 +40,6 @@
"platformprotosnano",
"hamcrest-library",
"servicestests-utils",
- "xml-writer-device-lib",
"service-appsearch",
"service-jobscheduler",
],
diff --git a/services/tests/servicestests/res/xml/usertypes_test_eraseArray.xml b/services/tests/servicestests/res/xml/usertypes_test_eraseArray.xml
new file mode 100644
index 0000000..02ac48e
--- /dev/null
+++ b/services/tests/servicestests/res/xml/usertypes_test_eraseArray.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 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.
+-->
+<user-types>
+ <profile-type
+ name='android.test'
+ max-allowed-per-parent='2' >
+ <badge-colors>
+ </badge-colors>
+ <default-restrictions />
+ </profile-type>
+</user-types>
\ No newline at end of file
diff --git a/services/tests/servicestests/res/xml/usertypes_test_full.xml b/services/tests/servicestests/res/xml/usertypes_test_full.xml
new file mode 100644
index 0000000..a281dca
--- /dev/null
+++ b/services/tests/servicestests/res/xml/usertypes_test_full.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 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.
+-->
+<user-types>
+ <full-type
+ name='android.test.1'
+ max-allowed-per-parent='12' >
+ <default-restrictions no_remove_user='true' no_bluetooth='true' />
+ <badge-colors>
+ <item res='@*android:color/profile_badge_1' />
+ </badge-colors>
+ </full-type>
+</user-types>
diff --git a/services/tests/servicestests/res/xml/usertypes_test_illegalOemName.xml b/services/tests/servicestests/res/xml/usertypes_test_illegalOemName.xml
new file mode 100644
index 0000000..f91df1f
--- /dev/null
+++ b/services/tests/servicestests/res/xml/usertypes_test_illegalOemName.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 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.
+-->
+<user-types>
+ <profile-type name='android.aosp.legal' max-allowed-per-parent='12' />
+ <profile-type name='android.oem.illegal.name' max-allowed-per-parent='14' />
+</user-types>
diff --git a/services/tests/servicestests/res/xml/usertypes_test_illegalUserBaseType.xml b/services/tests/servicestests/res/xml/usertypes_test_illegalUserBaseType.xml
new file mode 100644
index 0000000..0785655
--- /dev/null
+++ b/services/tests/servicestests/res/xml/usertypes_test_illegalUserBaseType.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 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.
+-->
+<user-types>
+ <profile-type name='android.test' max-allowed-per-parent='12' />
+</user-types>
diff --git a/services/tests/servicestests/res/xml/usertypes_test_profile.xml b/services/tests/servicestests/res/xml/usertypes_test_profile.xml
new file mode 100644
index 0000000..b6c8fbd
--- /dev/null
+++ b/services/tests/servicestests/res/xml/usertypes_test_profile.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 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.
+-->
+<user-types>
+ <profile-type
+ name='android.test.2'
+ max-allowed-per-parent='12'
+ icon-badge='@*android:drawable/ic_corp_icon_badge_case'
+ badge-plain='garbage'
+ badge-no-background='@*android:drawable/ic_corp_badge_no_background'
+ >
+ <badge-labels>
+ <item res='@*android:string/managed_profile_label_badge' />
+ <item res='@*android:string/managed_profile_label_badge_2' />
+ </badge-labels>
+ <badge-colors>
+ <item res='@*android:color/profile_badge_1' />
+ <item res='@*android:color/profile_badge_2' />
+ </badge-colors>
+ <default-restrictions no_remove_user='true' no_bluetooth='true' />
+ </profile-type>
+ <profile-type name='custom.test.1' max-allowed-per-parent='14' />
+</user-types>
diff --git a/services/tests/servicestests/src/com/android/server/GnssManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/GnssManagerServiceTest.java
index 9692c25..8b5444c 100644
--- a/services/tests/servicestests/src/com/android/server/GnssManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/GnssManagerServiceTest.java
@@ -61,6 +61,7 @@
import com.android.server.location.GnssNavigationMessageProvider;
import com.android.server.location.GnssNavigationMessageProvider.GnssNavigationMessageProviderNative;
import com.android.server.location.GnssStatusListenerHelper;
+import com.android.server.location.LocationUsageLogger;
import org.junit.Before;
import org.junit.Test;
diff --git a/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityWindowManagerTest.java b/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityWindowManagerTest.java
index b5e5deb..67075ed 100644
--- a/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityWindowManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityWindowManagerTest.java
@@ -705,6 +705,26 @@
assertTrue(displayList.equals(mExpectedDisplayList));
}
+ @Test
+ public void setAccessibilityWindowIdToSurfaceMetadata()
+ throws RemoteException {
+ final IWindow token = addAccessibilityInteractionConnection(Display.DEFAULT_DISPLAY,
+ true, USER_SYSTEM_ID);
+ int windowId = -1;
+ for (int i = 0; i < mA11yWindowTokens.size(); i++) {
+ if (mA11yWindowTokens.valueAt(i).equals(token)) {
+ windowId = mA11yWindowTokens.keyAt(i);
+ }
+ }
+ assertNotEquals("Returned token is not found in mA11yWindowTokens", -1, windowId);
+ verify(mMockWindowManagerInternal, times(1)).setAccessibilityIdToSurfaceMetadata(
+ token.asBinder(), windowId);
+
+ mA11yWindowManager.removeAccessibilityInteractionConnection(token);
+ verify(mMockWindowManagerInternal, times(1)).setAccessibilityIdToSurfaceMetadata(
+ token.asBinder(), -1);
+ }
+
private void startTrackingPerDisplay(int displayId) throws RemoteException {
ArrayList<WindowInfo> windowInfosForDisplay = new ArrayList<>();
// Adds RemoteAccessibilityConnection into AccessibilityWindowManager, and copy
diff --git a/services/tests/servicestests/src/com/android/server/accessibility/gestures/AccessibilityGestureDetectorTest.java b/services/tests/servicestests/src/com/android/server/accessibility/gestures/GestureManifoldTest.java
similarity index 83%
rename from services/tests/servicestests/src/com/android/server/accessibility/gestures/AccessibilityGestureDetectorTest.java
rename to services/tests/servicestests/src/com/android/server/accessibility/gestures/GestureManifoldTest.java
index b707912..538e2d5 100644
--- a/services/tests/servicestests/src/com/android/server/accessibility/gestures/AccessibilityGestureDetectorTest.java
+++ b/services/tests/servicestests/src/com/android/server/accessibility/gestures/GestureManifoldTest.java
@@ -24,22 +24,21 @@
import android.accessibilityservice.AccessibilityService;
import android.content.Context;
-import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.PointF;
-import android.util.DisplayMetrics;
-import android.view.GestureDetector;
import android.view.MotionEvent;
+import androidx.test.InstrumentationRegistry;
+
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
/**
- * Tests for AccessibilityGestureDetector
+ * Tests for GestureManifold
*/
-public class AccessibilityGestureDetectorTest {
+public class GestureManifoldTest {
// Constants for testRecognizeGesturePath()
private static final PointF PATH_START = new PointF(300f, 300f);
@@ -47,24 +46,21 @@
private static final long PATH_STEP_MILLISEC = 100;
// Data used by all tests
- private AccessibilityGestureDetector mDetector;
- private AccessibilityGestureDetector.Listener mResultListener;
+ private GestureManifold mManifold;
+ private TouchState mState;
+ private GestureManifold.Listener mResultListener;
@Before
public void setUp() {
- // Construct a mock Context.
- DisplayMetrics displayMetricsMock = mock(DisplayMetrics.class);
- displayMetricsMock.xdpi = 500;
- displayMetricsMock.ydpi = 500;
- Resources mockResources = mock(Resources.class);
- when(mockResources.getDisplayMetrics()).thenReturn(displayMetricsMock);
- Context contextMock = mock(Context.class);
- when(contextMock.getResources()).thenReturn(mockResources);
+ Context context = InstrumentationRegistry.getContext();
+ // Construct a testable GestureManifold.
+ mResultListener = mock(GestureManifold.Listener.class);
+ mState = new TouchState();
+ mManifold = new GestureManifold(context, mResultListener, mState);
+ // Play the role of touch explorer in updating the shared state.
+ when(mResultListener.onGestureStarted()).thenReturn(onGestureStarted());
- // Construct a testable AccessibilityGestureDetector.
- mResultListener = mock(AccessibilityGestureDetector.Listener.class);
- GestureDetector doubleTapDetectorMock = mock(GestureDetector.class);
- mDetector = new AccessibilityGestureDetector(contextMock, mResultListener, doubleTapDetectorMock);
+
}
@@ -141,8 +137,8 @@
// For each path step from start (non-inclusive) to end ... add a motion point.
for (int step = 1; step < numSteps; ++step) {
path.add(new PointF(
- (start.x + (stepX * (float) step)),
- (start.y + (stepY * (float) step))));
+ (start.x + (stepX * (float) step)),
+ (start.y + (stepY * (float) step))));
}
}
@@ -170,12 +166,22 @@
point.x, point.y, 0);
// Send event.
- mDetector.onMotionEvent(event, event, policyFlags);
+ mState.onReceivedMotionEvent(event);
+ mManifold.onMotionEvent(event, event, policyFlags);
eventTimeMs += PATH_STEP_MILLISEC;
+ if (mState.isClear()) {
+ mState.startTouchInteracting();
+ }
}
+ mState.clear();
// Check that correct gesture was recognized.
verify(mResultListener).onGestureCompleted(
argThat(gestureEvent -> gestureEvent.getGestureId() == gestureId));
}
+
+ private boolean onGestureStarted() {
+ mState.startGestureDetecting();
+ return false;
+ }
}
diff --git a/services/tests/servicestests/src/com/android/server/accessibility/gestures/TouchExplorerTest.java b/services/tests/servicestests/src/com/android/server/accessibility/gestures/TouchExplorerTest.java
index 4b1ec6f..a4ceadb 100644
--- a/services/tests/servicestests/src/com/android/server/accessibility/gestures/TouchExplorerTest.java
+++ b/services/tests/servicestests/src/com/android/server/accessibility/gestures/TouchExplorerTest.java
@@ -74,7 +74,7 @@
private TouchExplorer mTouchExplorer;
private long mLastDownTime = Integer.MIN_VALUE;
- // mock package-private AccessibilityGestureDetector class
+ // mock package-private GestureManifold class
@Rule
public final DexmakerShareClassLoaderRule mDexmakerShareClassLoaderRule =
new DexmakerShareClassLoaderRule();
@@ -108,7 +108,7 @@
public void setUp() {
Context context = InstrumentationRegistry.getContext();
AccessibilityManagerService ams = new AccessibilityManagerService(context);
- AccessibilityGestureDetector detector = mock(AccessibilityGestureDetector.class);
+ GestureManifold detector = mock(GestureManifold.class);
mCaptor = new EventCaptor();
mTouchExplorer = new TouchExplorer(context, ams, detector);
mTouchExplorer.setNext(mCaptor);
diff --git a/services/tests/servicestests/src/com/android/server/attention/AttentionManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/attention/AttentionManagerServiceTest.java
index a47a567..e90cb46 100644
--- a/services/tests/servicestests/src/com/android/server/attention/AttentionManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/attention/AttentionManagerServiceTest.java
@@ -16,7 +16,11 @@
package com.android.server.attention;
+import static android.provider.DeviceConfig.NAMESPACE_ATTENTION_MANAGER_SERVICE;
+
import static com.android.server.attention.AttentionManagerService.ATTENTION_CACHE_BUFFER_SIZE;
+import static com.android.server.attention.AttentionManagerService.DEFAULT_STALE_AFTER_MILLIS;
+import static com.android.server.attention.AttentionManagerService.KEY_STALE_AFTER_MILLIS;
import static com.google.common.truth.Truth.assertThat;
@@ -35,6 +39,7 @@
import android.os.IPowerManager;
import android.os.PowerManager;
import android.os.RemoteException;
+import android.provider.DeviceConfig;
import android.service.attention.IAttentionCallback;
import android.service.attention.IAttentionService;
@@ -180,6 +185,45 @@
assertThat(buffer.get(0)).isEqualTo(cache);
}
+ @Test
+ public void testGetStaleAfterMillis_handlesGoodFlagValue() {
+ DeviceConfig.setProperty(NAMESPACE_ATTENTION_MANAGER_SERVICE,
+ KEY_STALE_AFTER_MILLIS, "123", false);
+ assertThat(mSpyAttentionManager.getStaleAfterMillis()).isEqualTo(123);
+ }
+
+ @Test
+ public void testGetStaleAfterMillis_handlesBadFlagValue_1() {
+ DeviceConfig.setProperty(NAMESPACE_ATTENTION_MANAGER_SERVICE,
+ KEY_STALE_AFTER_MILLIS, "-123", false);
+ assertThat(mSpyAttentionManager.getStaleAfterMillis()).isEqualTo(
+ DEFAULT_STALE_AFTER_MILLIS);
+ }
+
+ @Test
+ public void testGetStaleAfterMillis_handlesBadFlagValue_2() {
+ DeviceConfig.setProperty(NAMESPACE_ATTENTION_MANAGER_SERVICE,
+ KEY_STALE_AFTER_MILLIS, "15000", false);
+ assertThat(mSpyAttentionManager.getStaleAfterMillis()).isEqualTo(
+ DEFAULT_STALE_AFTER_MILLIS);
+ }
+
+ @Test
+ public void testGetStaleAfterMillis_handlesBadFlagValue_3() {
+ DeviceConfig.setProperty(NAMESPACE_ATTENTION_MANAGER_SERVICE,
+ KEY_STALE_AFTER_MILLIS, "abracadabra", false);
+ assertThat(mSpyAttentionManager.getStaleAfterMillis()).isEqualTo(
+ DEFAULT_STALE_AFTER_MILLIS);
+ }
+
+ @Test
+ public void testGetStaleAfterMillis_handlesBadFlagValue_4() {
+ DeviceConfig.setProperty(NAMESPACE_ATTENTION_MANAGER_SERVICE,
+ KEY_STALE_AFTER_MILLIS, "15_000L", false);
+ assertThat(mSpyAttentionManager.getStaleAfterMillis()).isEqualTo(
+ DEFAULT_STALE_AFTER_MILLIS);
+ }
+
private class MockIAttentionService implements IAttentionService {
public void checkAttention(IAttentionCallback callback) throws RemoteException {
callback.onSuccess(0, 0);
diff --git a/services/tests/servicestests/src/com/android/server/biometrics/AuthServiceTest.java b/services/tests/servicestests/src/com/android/server/biometrics/AuthServiceTest.java
index 106a723..d38c80c 100644
--- a/services/tests/servicestests/src/com/android/server/biometrics/AuthServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/biometrics/AuthServiceTest.java
@@ -20,6 +20,7 @@
import static junit.framework.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -65,8 +66,16 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
+ // Dummy test config
+ final String[] config = {
+ "0:2:15", // ID0:Fingerprint:Strong
+ "1:4:15", // ID1:Iris:Strong
+ "2:8:15", // ID2:Face:Strong
+ };
+
when(mContext.getPackageManager()).thenReturn(mPackageManager);
when(mInjector.getBiometricService()).thenReturn(mBiometricService);
+ when(mInjector.getConfiguration(any())).thenReturn(config);
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
.thenReturn(true);
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_IRIS)).thenReturn(true);
@@ -76,8 +85,7 @@
// TODO(b/141025588): Check that an exception is thrown when the userId != callingUserId
@Test
- public void testAuthenticate_callsBiometricServiceAuthenticate() throws
- Exception {
+ public void testAuthenticate_callsBiometricServiceAuthenticate() throws Exception {
mAuthService = new AuthService(mContext, mInjector);
mAuthService.onStart();
@@ -104,22 +112,25 @@
}
@Test
- public void testCanAuthenticate_callsBiometricServiceCanAuthenticate() throws
- Exception {
+ public void testCanAuthenticate_callsBiometricServiceCanAuthenticate() throws Exception {
mAuthService = new AuthService(mContext, mInjector);
mAuthService.onStart();
final int userId = 0;
final int expectedResult = BIOMETRIC_SUCCESS;
- when(mBiometricService.canAuthenticate(anyString(), anyInt())).thenReturn(expectedResult);
+ final int authenticators = 0;
+ when(mBiometricService.canAuthenticate(anyString(), anyInt(), anyInt()))
+ .thenReturn(expectedResult);
- final int result = mAuthService.mImpl.canAuthenticate(TEST_OP_PACKAGE_NAME, userId);
+ final int result = mAuthService.mImpl
+ .canAuthenticate(TEST_OP_PACKAGE_NAME, userId, authenticators);
assertEquals(expectedResult, result);
waitForIdle();
verify(mBiometricService).canAuthenticate(
eq(TEST_OP_PACKAGE_NAME),
- eq(userId));
+ eq(userId),
+ eq(authenticators));
}
diff --git a/services/tests/servicestests/src/com/android/server/biometrics/BiometricServiceTest.java b/services/tests/servicestests/src/com/android/server/biometrics/BiometricServiceTest.java
index 4ced421..211fc4d 100644
--- a/services/tests/servicestests/src/com/android/server/biometrics/BiometricServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/biometrics/BiometricServiceTest.java
@@ -16,12 +16,14 @@
package com.android.server.biometrics;
+import static android.hardware.biometrics.BiometricManager.Authenticators;
+
import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
import static junit.framework.TestCase.assertNotNull;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -34,12 +36,13 @@
import static org.mockito.Mockito.when;
import android.app.IActivityManager;
+import android.app.trust.ITrustManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
-import android.hardware.biometrics.Authenticator;
import android.hardware.biometrics.BiometricAuthenticator;
import android.hardware.biometrics.BiometricConstants;
+import android.hardware.biometrics.BiometricManager;
import android.hardware.biometrics.BiometricPrompt;
import android.hardware.biometrics.IBiometricAuthenticator;
import android.hardware.biometrics.IBiometricService;
@@ -81,8 +84,6 @@
private static final String FINGERPRINT_ACQUIRED_SENSOR_DIRTY = "sensor_dirty";
- private static final int STRENGTH_STRONG = 1;
-
private BiometricService mBiometricService;
@Mock
@@ -101,6 +102,8 @@
IBiometricAuthenticator mFingerprintAuthenticator;
@Mock
IBiometricAuthenticator mFaceAuthenticator;
+ @Mock
+ ITrustManager mTrustManager;
@Before
public void setUp() {
@@ -111,10 +114,13 @@
when(mInjector.getActivityManagerService()).thenReturn(mock(IActivityManager.class));
when(mInjector.getStatusBarService()).thenReturn(mock(IStatusBarService.class));
- when(mInjector.getSettingObserver(any(), any(), any())).thenReturn(
- mock(BiometricService.SettingObserver.class));
+ when(mInjector.getSettingObserver(any(), any(), any()))
+ .thenReturn(mock(BiometricService.SettingObserver.class));
when(mInjector.getKeyStore()).thenReturn(mock(KeyStore.class));
when(mInjector.isDebugEnabled(any(), anyInt())).thenReturn(false);
+ when(mInjector.getBiometricStrengthController(any()))
+ .thenReturn(mock(BiometricStrengthController.class));
+ when(mInjector.getTrustManager()).thenReturn(mTrustManager);
when(mResources.getString(R.string.biometric_error_hw_unavailable))
.thenReturn(ERROR_HW_UNAVAILABLE);
@@ -122,6 +128,56 @@
.thenReturn(ERROR_NOT_RECOGNIZED);
when(mResources.getString(R.string.biometric_error_user_canceled))
.thenReturn(ERROR_USER_CANCELED);
+
+ final String[] config = {
+ "0:2:15", // ID0:Fingerprint:Strong
+ "1:8:15", // ID1:Face:Strong
+ "2:4:255", // ID2:Iris:Weak
+ };
+
+ when(mInjector.getConfiguration(any())).thenReturn(config);
+ }
+
+ @Test
+ public void testAuthenticate_credentialAllowedButNotSetup_returnsNoDeviceCredential()
+ throws Exception {
+ when(mTrustManager.isDeviceSecure(anyInt())).thenReturn(false);
+
+ mBiometricService = new BiometricService(mContext, mInjector);
+ mBiometricService.onStart();
+
+ invokeAuthenticate(mBiometricService.mImpl, mReceiver1, false /* requireConfirmation */,
+ Authenticators.DEVICE_CREDENTIAL);
+ waitForIdle();
+ verify(mReceiver1).onError(
+ eq(BiometricAuthenticator.TYPE_NONE),
+ eq(BiometricConstants.BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL),
+ eq(0 /* vendorCode */));
+ }
+
+ @Test
+ public void testAuthenticate_credentialAllowedAndSetup_callsSystemUI() throws Exception {
+ // When no biometrics are enrolled, but credentials are set up, status bar should be
+ // invoked right away with showAuthenticationDialog
+
+ when(mTrustManager.isDeviceSecure(anyInt())).thenReturn(true);
+
+ mBiometricService = new BiometricService(mContext, mInjector);
+ mBiometricService.onStart();
+
+ invokeAuthenticate(mBiometricService.mImpl, mReceiver1, false /* requireConfirmation */,
+ Authenticators.DEVICE_CREDENTIAL);
+ waitForIdle();
+
+ assertNull(mBiometricService.mPendingAuthSession);
+ // StatusBar showBiometricDialog invoked
+ verify(mBiometricService.mStatusBarService).showAuthenticationDialog(
+ eq(mBiometricService.mCurrentAuthSession.mBundle),
+ any(IBiometricServiceReceiverInternal.class),
+ eq(0),
+ anyBoolean() /* requireConfirmation */,
+ anyInt() /* userId */,
+ eq(TEST_PACKAGE_NAME));
}
@Test
@@ -131,7 +187,7 @@
mBiometricService.onStart();
invokeAuthenticate(mBiometricService.mImpl, mReceiver1, false /* requireConfirmation */,
- false /* allowDeviceCredential */);
+ null /* authenticators */);
waitForIdle();
verify(mReceiver1).onError(
eq(BiometricAuthenticator.TYPE_NONE),
@@ -145,12 +201,12 @@
mBiometricService = new BiometricService(mContext, mInjector);
mBiometricService.onStart();
- mBiometricService.mImpl.registerAuthenticator(0 /* id */, STRENGTH_STRONG,
- BiometricAuthenticator.TYPE_FINGERPRINT, mFingerprintAuthenticator);
-
+ mBiometricService.mImpl.registerAuthenticator(0 /* id */,
+ BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG,
+ mFingerprintAuthenticator);
invokeAuthenticate(mBiometricService.mImpl, mReceiver1, false /* requireConfirmation */,
- false /* allowDeviceCredential */);
+ null /* authenticators */);
waitForIdle();
verify(mReceiver1).onError(
eq(BiometricAuthenticator.TYPE_FINGERPRINT),
@@ -159,6 +215,54 @@
}
@Test
+ public void testAuthenticate_notStrongEnough_returnsHardwareNotPresent() throws Exception {
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_WEAK);
+
+ invokeAuthenticate(mBiometricService.mImpl, mReceiver1, false /* requireConfirmation */,
+ Authenticators.BIOMETRIC_STRONG);
+ waitForIdle();
+ verify(mReceiver1).onError(
+ eq(BiometricAuthenticator.TYPE_NONE),
+ eq(BiometricConstants.BIOMETRIC_ERROR_HW_NOT_PRESENT),
+ eq(0 /* vendorCode */));
+ }
+
+ @Test
+ public void testAuthenticate_picksStrongIfAvailable() throws Exception {
+ // If both strong and weak are available, and the caller requires STRONG, authentication
+ // is able to proceed.
+
+ final int[] modalities = new int[] {
+ BiometricAuthenticator.TYPE_FINGERPRINT,
+ BiometricAuthenticator.TYPE_FACE,
+ };
+
+ final int[] strengths = new int[] {
+ Authenticators.BIOMETRIC_WEAK,
+ Authenticators.BIOMETRIC_STRONG,
+ };
+
+ setupAuthForMultiple(modalities, strengths);
+
+ invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
+ false /* requireConfirmation */, Authenticators.BIOMETRIC_STRONG);
+ waitForIdle();
+ verify(mReceiver1, never()).onError(
+ anyInt(),
+ anyInt(),
+ anyInt() /* vendorCode */);
+
+ // StatusBar showBiometricDialog invoked with face, which was set up to be STRONG
+ verify(mBiometricService.mStatusBarService).showAuthenticationDialog(
+ eq(mBiometricService.mCurrentAuthSession.mBundle),
+ any(IBiometricServiceReceiverInternal.class),
+ eq(BiometricAuthenticator.TYPE_FACE),
+ eq(false) /* requireConfirmation */,
+ anyInt() /* userId */,
+ eq(TEST_PACKAGE_NAME));
+ }
+
+ @Test
public void testAuthenticate_whenHalIsDead_returnsErrorHardwareUnavailable() throws
Exception {
when(mFingerprintAuthenticator.hasEnrolledTemplates(anyInt(), any())).thenReturn(true);
@@ -166,11 +270,12 @@
mBiometricService = new BiometricService(mContext, mInjector);
mBiometricService.onStart();
- mBiometricService.mImpl.registerAuthenticator(0 /* id */, STRENGTH_STRONG,
- BiometricAuthenticator.TYPE_FINGERPRINT, mFingerprintAuthenticator);
+ mBiometricService.mImpl.registerAuthenticator(0 /* id */,
+ BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG,
+ mFingerprintAuthenticator);
invokeAuthenticate(mBiometricService.mImpl, mReceiver1, false /* requireConfirmation */,
- false /* allowDeviceCredential */);
+ null /* authenticators */);
waitForIdle();
verify(mReceiver1).onError(
eq(BiometricAuthenticator.TYPE_NONE),
@@ -181,18 +286,12 @@
@Test
public void testAuthenticateFace_respectsUserSetting()
throws Exception {
- when(mFaceAuthenticator.hasEnrolledTemplates(anyInt(), any())).thenReturn(true);
- when(mFaceAuthenticator.isHardwareDetected(any())).thenReturn(true);
-
- mBiometricService = new BiometricService(mContext, mInjector);
- mBiometricService.onStart();
- mBiometricService.mImpl.registerAuthenticator(0 /* id */, STRENGTH_STRONG,
- BiometricAuthenticator.TYPE_FACE, mFaceAuthenticator);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FACE, Authenticators.BIOMETRIC_STRONG);
// Disabled in user settings receives onError
when(mBiometricService.mSettingObserver.getFaceEnabledForApps(anyInt())).thenReturn(false);
invokeAuthenticate(mBiometricService.mImpl, mReceiver1, false /* requireConfirmation */,
- false /* allowDeviceCredential */);
+ null /* authenticators */);
waitForIdle();
verify(mReceiver1).onError(
eq(BiometricAuthenticator.TYPE_NONE),
@@ -205,7 +304,7 @@
when(mBiometricService.mSettingObserver.getFaceAlwaysRequireConfirmation(anyInt()))
.thenReturn(true);
invokeAuthenticate(mBiometricService.mImpl, mReceiver1, false /* requireConfirmation */,
- false /* allowDeviceCredential */);
+ null /* authenticators */);
waitForIdle();
verify(mReceiver1, never()).onError(anyInt(), anyInt(), anyInt());
verify(mBiometricService.mAuthenticators.get(0).impl).prepareForAuthentication(
@@ -225,7 +324,7 @@
when(mBiometricService.mSettingObserver.getFaceAlwaysRequireConfirmation(anyInt()))
.thenReturn(false);
invokeAuthenticate(mBiometricService.mImpl, mReceiver1, false /* requireConfirmation */,
- false /* allowDeviceCredential */);
+ null /* authenticators */);
waitForIdle();
verify(mBiometricService.mAuthenticators.get(0).impl).prepareForAuthentication(
eq(false) /* requireConfirmation */,
@@ -242,11 +341,11 @@
@Test
public void testAuthenticate_happyPathWithoutConfirmation() throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG);
// Start testing the happy path
invokeAuthenticate(mBiometricService.mImpl, mReceiver1, false /* requireConfirmation */,
- false /* allowDeviceCredential */);
+ null /* authenticators */);
waitForIdle();
// Creates a pending auth session with the correct initial states
@@ -314,15 +413,16 @@
@Test
public void testAuthenticate_noBiometrics_credentialAllowed() throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FACE);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FACE, Authenticators.BIOMETRIC_STRONG);
when(mFaceAuthenticator.hasEnrolledTemplates(anyInt(), any())).thenReturn(false);
invokeAuthenticate(mBiometricService.mImpl, mReceiver1,
- true /* requireConfirmation */, true /* allowDeviceCredential */);
+ true /* requireConfirmation */,
+ Authenticators.DEVICE_CREDENTIAL | Authenticators.BIOMETRIC_WEAK);
waitForIdle();
assertEquals(BiometricService.STATE_SHOWING_DEVICE_CREDENTIAL,
mBiometricService.mCurrentAuthSession.mState);
- assertEquals(Authenticator.TYPE_CREDENTIAL,
+ assertEquals(Authenticators.DEVICE_CREDENTIAL,
mBiometricService.mCurrentAuthSession.mBundle
.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED));
verify(mBiometricService.mStatusBarService).showAuthenticationDialog(
@@ -336,9 +436,9 @@
@Test
public void testAuthenticate_happyPathWithConfirmation() throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FACE);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FACE, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
- true /* requireConfirmation */, false /* allowDeviceCredential */);
+ true /* requireConfirmation */, null /* authenticators */);
// Test authentication succeeded goes to PENDING_CONFIRMATION and that the HAT is not
// sent to KeyStore yet
@@ -362,9 +462,9 @@
@Test
public void testRejectFace_whenAuthenticating_notifiesSystemUIAndClient_thenPaused()
throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FACE);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FACE, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
- false /* requireConfirmation */, false /* allowDeviceCredential */);
+ false /* requireConfirmation */, null /* authenticators */);
mBiometricService.mInternalReceiver.onAuthenticationFailed();
waitForIdle();
@@ -381,9 +481,9 @@
@Test
public void testRejectFingerprint_whenAuthenticating_notifiesAndKeepsAuthenticating()
throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
- false /* requireConfirmation */, false /* allowDeviceCredential */);
+ false /* requireConfirmation */, null /* authenticators */);
mBiometricService.mInternalReceiver.onAuthenticationFailed();
waitForIdle();
@@ -398,53 +498,10 @@
}
@Test
- public void testErrorCanceled_whenAuthenticating_notifiesSystemUIAndClient() throws
- Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT);
- invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
- false /* requireConfirmation */, false /* allowDeviceCredential */);
-
- // Create a new pending auth session but don't start it yet. HAL contract is that previous
- // one must get ERROR_CANCELED. Simulate that here by creating the pending auth session,
- // sending ERROR_CANCELED to the current auth session, and then having the second one
- // onReadyForAuthentication.
- invokeAuthenticate(mBiometricService.mImpl, mReceiver2, false /* requireConfirmation */,
- false /* allowDeviceCredential */);
- waitForIdle();
-
- assertEquals(mBiometricService.mCurrentAuthSession.mState,
- BiometricService.STATE_AUTH_STARTED);
- mBiometricService.mInternalReceiver.onError(
- getCookieForCurrentSession(mBiometricService.mCurrentAuthSession),
- BiometricAuthenticator.TYPE_FINGERPRINT,
- BiometricConstants.BIOMETRIC_ERROR_CANCELED, 0 /* vendorCode */);
- waitForIdle();
-
- // Auth session doesn't become null until SystemUI responds that the animation is completed
- assertNotNull(mBiometricService.mCurrentAuthSession);
- // ERROR_CANCELED is not sent until SystemUI responded that animation is completed
- verify(mReceiver1, never()).onError(anyInt(), anyInt(), anyInt());
- verify(mReceiver2, never()).onError(anyInt(), anyInt(), anyInt());
-
- // SystemUI dialog closed
- verify(mBiometricService.mStatusBarService).hideAuthenticationDialog();
-
- // After SystemUI notifies that the animation has completed
- mBiometricService.mInternalReceiver
- .onDialogDismissed(BiometricPrompt.DISMISSED_REASON_SERVER_REQUESTED);
- waitForIdle();
- verify(mReceiver1).onError(
- eq(BiometricAuthenticator.TYPE_FINGERPRINT),
- eq(BiometricConstants.BIOMETRIC_ERROR_CANCELED),
- eq(0 /* vendorCode */));
- assertNull(mBiometricService.mCurrentAuthSession);
- }
-
- @Test
public void testErrorHalTimeout_whenAuthenticating_entersPausedState() throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FACE);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FACE, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
- false /* requireConfirmation */, false /* allowDeviceCredential */);
+ false /* requireConfirmation */, null /* authenticators */);
mBiometricService.mInternalReceiver.onError(
getCookieForCurrentSession(mBiometricService.mCurrentAuthSession),
@@ -491,9 +548,9 @@
@Test
public void testErrorFromHal_whenPaused_notifiesSystemUIAndClient() throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FACE);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FACE, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
- false /* requireConfirmation */, false /* allowDeviceCredential */);
+ false /* requireConfirmation */, null /* authenticators */);
mBiometricService.mInternalReceiver.onError(
getCookieForCurrentSession(mBiometricService.mCurrentAuthSession),
@@ -524,9 +581,9 @@
// For errors that show in SystemUI, BiometricService stays in STATE_ERROR_PENDING_SYSUI
// until SystemUI notifies us that the dialog is dismissed at which point the current
// session is done.
- setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
- false /* requireConfirmation */, false /* allowDeviceCredential */);
+ false /* requireConfirmation */, null /* authenticators */);
mBiometricService.mInternalReceiver.onError(
getCookieForCurrentSession(mBiometricService.mCurrentAuthSession),
@@ -558,9 +615,10 @@
@Test
public void testErrorFromHal_whilePreparingAuthentication_credentialAllowed() throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticate(mBiometricService.mImpl, mReceiver1,
- false /* requireConfirmation */, true /* allowDeviceCredential */);
+ false /* requireConfirmation */,
+ Authenticators.DEVICE_CREDENTIAL | Authenticators.BIOMETRIC_WEAK);
waitForIdle();
mBiometricService.mInternalReceiver.onError(
@@ -576,7 +634,7 @@
assertNotNull(mBiometricService.mCurrentAuthSession);
assertEquals(BiometricService.STATE_SHOWING_DEVICE_CREDENTIAL,
mBiometricService.mCurrentAuthSession.mState);
- assertEquals(Authenticator.TYPE_CREDENTIAL,
+ assertEquals(Authenticators.DEVICE_CREDENTIAL,
mBiometricService.mCurrentAuthSession.mBundle.getInt(
BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED));
verify(mBiometricService.mStatusBarService).showAuthenticationDialog(
@@ -591,9 +649,9 @@
@Test
public void testErrorFromHal_whilePreparingAuthentication_credentialNotAllowed()
throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticate(mBiometricService.mImpl, mReceiver1,
- false /* requireConfirmation */, false /* allowDeviceCredential */);
+ false /* requireConfirmation */, null /* authenticators */);
waitForIdle();
mBiometricService.mInternalReceiver.onError(
@@ -609,58 +667,64 @@
}
@Test
- public void testCombineAuthenticatorBundle_keyAllowDeviceCredentialAlwaysRemoved() {
- Bundle bundle;
- int authenticators;
+ public void testCombineAuthenticatorBundles_withKeyDeviceCredential_andKeyAuthenticators() {
+ final boolean allowDeviceCredential = false;
+ final @Authenticators.Types int authenticators =
+ Authenticators.DEVICE_CREDENTIAL | Authenticators.BIOMETRIC_WEAK;
+ final Bundle bundle = new Bundle();
- // In:
- // KEY_ALLOW_DEVICE_CREDENTIAL = true
- // KEY_AUTHENTICATORS_ALLOWED = TYPE_BIOMETRIC | TYPE_CREDENTIAL
- // Out:
- // KEY_ALLOW_DEVICE_CREDENTIAL = null
- // KEY_AUTHENTICATORS_ALLOWED = TYPE_BIOMETRIC | TYPE_CREDENTIAL
- bundle = new Bundle();
- bundle.putBoolean(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL, true);
- authenticators = Authenticator.TYPE_CREDENTIAL | Authenticator.TYPE_BIOMETRIC;
+ bundle.putBoolean(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL, allowDeviceCredential);
bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, authenticators);
Utils.combineAuthenticatorBundles(bundle);
- assertNull(bundle.get(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL));
- assertEquals(authenticators, bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED));
- // In:
- // KEY_ALLOW_DEVICE_CREDENTIAL = true
- // KEY_AUTHENTICATORS_ALLOWED = TYPE_BIOMETRIC
- // Out:
- // KEY_ALLOW_DEVICE_CREDENTIAL = null
- // KEY_AUTHENTICATORS_ALLOWED = TYPE_BIOMETRIC | TYPE_CREDENTIAL
- bundle = new Bundle();
- bundle.putBoolean(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL, true);
- authenticators = Authenticator.TYPE_BIOMETRIC;
+ assertNull(bundle.get(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL));
+ assertEquals(bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED), authenticators);
+ }
+
+ @Test
+ public void testCombineAuthenticatorBundles_withNoKeyDeviceCredential_andKeyAuthenticators() {
+ final @Authenticators.Types int authenticators =
+ Authenticators.DEVICE_CREDENTIAL | Authenticators.BIOMETRIC_WEAK;
+ final Bundle bundle = new Bundle();
+
bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, authenticators);
Utils.combineAuthenticatorBundles(bundle);
- assertNull(bundle.get(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL));
- assertEquals(authenticators, bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED));
- // In:
- // KEY_ALLOW_DEVICE_CREDENTIAL = null
- // KEY_AUTHENTICATORS_ALLOWED = TYPE_BIOMETRIC | TYPE_CREDENTIAL
- // Out:
- // KEY_ALLOW_DEVICE_CREDENTIAL = null
- // KEY_AUTHENTICATORS_ALLOWED = TYPE_BIOMETRIC | TYPE_CREDENTIAL
- bundle = new Bundle();
- authenticators = Authenticator.TYPE_BIOMETRIC | Authenticator.TYPE_CREDENTIAL;
- bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, authenticators);
- Utils.combineAuthenticatorBundles(bundle);
assertNull(bundle.get(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL));
- assertEquals(authenticators, bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED));
+ assertEquals(bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED), authenticators);
+ }
+
+ @Test
+ public void testCombineAuthenticatorBundles_withKeyDeviceCredential_andNoKeyAuthenticators() {
+ final boolean allowDeviceCredential = true;
+ final Bundle bundle = new Bundle();
+
+ bundle.putBoolean(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL, allowDeviceCredential);
+ Utils.combineAuthenticatorBundles(bundle);
+
+ assertNull(bundle.get(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL));
+ assertEquals(bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED),
+ Authenticators.DEVICE_CREDENTIAL | Authenticators.BIOMETRIC_WEAK);
+ }
+
+ @Test
+ public void testCombineAuthenticatorBundles_withNoKeyDeviceCredential_andNoKeyAuthenticators() {
+ final Bundle bundle = new Bundle();
+
+ Utils.combineAuthenticatorBundles(bundle);
+
+ assertNull(bundle.get(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL));
+ assertEquals(bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED),
+ Authenticators.BIOMETRIC_WEAK);
}
@Test
public void testErrorFromHal_whileShowingDeviceCredential_doesntNotifySystemUI()
throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
- false /* requireConfirmation */, true /* allowDeviceCredential */);
+ false /* requireConfirmation */,
+ Authenticators.DEVICE_CREDENTIAL | Authenticators.BIOMETRIC_WEAK);
mBiometricService.mInternalReceiver.onDeviceCredentialPressed();
waitForIdle();
@@ -683,9 +747,10 @@
@Test
public void testLockout_whileAuthenticating_credentialAllowed() throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
- false /* requireConfirmation */, true /* allowDeviceCredential */);
+ false /* requireConfirmation */,
+ Authenticators.DEVICE_CREDENTIAL | Authenticators.BIOMETRIC_WEAK);
assertEquals(BiometricService.STATE_AUTH_STARTED,
mBiometricService.mCurrentAuthSession.mState);
@@ -707,9 +772,9 @@
@Test
public void testLockout_whenAuthenticating_credentialNotAllowed() throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
- false /* requireConfirmation */, false /* allowDeviceCredential */);
+ false /* requireConfirmation */, null /* authenticators */);
assertEquals(BiometricService.STATE_AUTH_STARTED,
mBiometricService.mCurrentAuthSession.mState);
@@ -732,9 +797,9 @@
@Test
public void testDismissedReasonUserCancel_whileAuthenticating_cancelsHalAuthentication()
throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
- false /* requireConfirmation */, false /* allowDeviceCredential */);
+ false /* requireConfirmation */, null /* authenticators */);
mBiometricService.mInternalReceiver
.onDialogDismissed(BiometricPrompt.DISMISSED_REASON_USER_CANCEL);
@@ -755,9 +820,9 @@
@Test
public void testDismissedReasonNegative_whilePaused_doesntInvokeHalCancel() throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FACE);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FACE, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
- false /* requireConfirmation */, false /* allowDeviceCredential */);
+ false /* requireConfirmation */, null /* authenticators */);
mBiometricService.mInternalReceiver.onError(
getCookieForCurrentSession(mBiometricService.mCurrentAuthSession),
@@ -781,9 +846,9 @@
@Test
public void testDismissedReasonUserCancel_whilePaused_doesntInvokeHalCancel() throws
Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FACE);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FACE, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
- false /* requireConfirmation */, false /* allowDeviceCredential */);
+ false /* requireConfirmation */, null /* authenticators */);
mBiometricService.mInternalReceiver.onError(
getCookieForCurrentSession(mBiometricService.mCurrentAuthSession),
@@ -806,9 +871,9 @@
@Test
public void testDismissedReasonUserCancel_whenPendingConfirmation() throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FACE);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FACE, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
- true /* requireConfirmation */, false /* allowDeviceCredential */);
+ true /* requireConfirmation */, null /* authenticators */);
mBiometricService.mInternalReceiver.onAuthenticationSucceeded(
true /* requireConfirmation */,
@@ -835,9 +900,9 @@
@Test
public void testAcquire_whenAuthenticating_sentToSystemUI() throws Exception {
- setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG);
invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
- false /* requireConfirmation */, false /* allowDeviceCredential */);
+ false /* requireConfirmation */, null /* authenticators */);
mBiometricService.mInternalReceiver.onAcquired(
FingerprintManager.FINGERPRINT_ACQUIRED_IMAGER_DIRTY,
@@ -851,26 +916,354 @@
BiometricService.STATE_AUTH_STARTED);
}
+ @Test
+ public void testCancel_whenAuthenticating() throws Exception {
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG);
+ invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
+ false /* requireConfirmation */, null /* authenticators */);
+
+ mBiometricService.mImpl.cancelAuthentication(mBiometricService.mCurrentAuthSession.mToken,
+ TEST_PACKAGE_NAME);
+ waitForIdle();
+
+ // Pretend that the HAL has responded to cancel with ERROR_CANCELED
+ mBiometricService.mInternalReceiver.onError(getCookieForCurrentSession(
+ mBiometricService.mCurrentAuthSession), BiometricAuthenticator.TYPE_FINGERPRINT,
+ BiometricConstants.BIOMETRIC_ERROR_CANCELED, 0 /* vendorCode */);
+ waitForIdle();
+
+ // Hides system dialog and invokes the onError callback
+ verify(mReceiver1).onError(eq(BiometricAuthenticator.TYPE_FINGERPRINT),
+ eq(BiometricConstants.BIOMETRIC_ERROR_CANCELED),
+ eq(0 /* vendorCode */));
+ verify(mBiometricService.mStatusBarService).hideAuthenticationDialog();
+ }
+
+ @Test
+ public void testCanAuthenticate_whenDeviceHasRequestedBiometricStrength() throws Exception {
+ // When only biometric is requested, and sensor is strong enough
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG);
+
+ assertEquals(BiometricManager.BIOMETRIC_SUCCESS,
+ invokeCanAuthenticate(mBiometricService, Authenticators.BIOMETRIC_STRONG));
+ }
+
+ @Test
+ public void testCanAuthenticate_whenDeviceDoesNotHaveRequestedBiometricStrength()
+ throws Exception {
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_WEAK);
+
+ // When only biometric is requested, and sensor is not strong enough
+ when(mTrustManager.isDeviceSecure(anyInt())).thenReturn(false);
+ int authenticators = Authenticators.BIOMETRIC_STRONG;
+ assertEquals(BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE,
+ invokeCanAuthenticate(mBiometricService, authenticators));
+
+ // When credential and biometric are requested, and sensor is not strong enough
+ when(mTrustManager.isDeviceSecure(anyInt())).thenReturn(true);
+ authenticators = Authenticators.BIOMETRIC_STRONG | Authenticators.DEVICE_CREDENTIAL;
+ assertEquals(BiometricManager.BIOMETRIC_SUCCESS,
+ invokeCanAuthenticate(mBiometricService, authenticators));
+ }
+
+ @Test
+ public void testCanAuthenticate_onlyCredentialRequested() throws Exception {
+ mBiometricService = new BiometricService(mContext, mInjector);
+ mBiometricService.onStart();
+
+ // Credential requested but not set up
+ when(mTrustManager.isDeviceSecure(anyInt())).thenReturn(false);
+ assertEquals(BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED,
+ invokeCanAuthenticate(mBiometricService, Authenticators.DEVICE_CREDENTIAL));
+
+ // Credential requested and set up
+ when(mTrustManager.isDeviceSecure(anyInt())).thenReturn(true);
+ assertEquals(BiometricManager.BIOMETRIC_SUCCESS,
+ invokeCanAuthenticate(mBiometricService, Authenticators.DEVICE_CREDENTIAL));
+ }
+
+ @Test
+ public void testCanAuthenticate_whenNoBiometricsEnrolled() throws Exception {
+ // With credential set up, test the following.
+ when(mTrustManager.isDeviceSecure(anyInt())).thenReturn(true);
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG,
+ false /* enrolled */);
+
+ // When only biometric is requested
+ int authenticators = Authenticators.BIOMETRIC_STRONG;
+ assertEquals(BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED,
+ invokeCanAuthenticate(mBiometricService, authenticators));
+
+ // When credential and biometric are requested
+ authenticators = Authenticators.BIOMETRIC_STRONG | Authenticators.DEVICE_CREDENTIAL;
+ assertEquals(BiometricManager.BIOMETRIC_SUCCESS,
+ invokeCanAuthenticate(mBiometricService, authenticators));
+ }
+
+ @Test
+ public void testCanAuthenticate_whenBiometricsNotEnabledForApps() throws Exception {
+ setupAuthForOnly(BiometricAuthenticator.TYPE_FACE, Authenticators.BIOMETRIC_STRONG);
+ when(mBiometricService.mSettingObserver.getFaceEnabledForApps(anyInt())).thenReturn(false);
+ when(mTrustManager.isDeviceSecure(anyInt())).thenReturn(true);
+
+ // When only biometric is requested
+ int authenticators = Authenticators.BIOMETRIC_STRONG;
+ assertEquals(BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE,
+ invokeCanAuthenticate(mBiometricService, authenticators));
+
+ // When credential and biometric are requested
+ authenticators = Authenticators.BIOMETRIC_STRONG | Authenticators.DEVICE_CREDENTIAL;
+ assertEquals(BiometricManager.BIOMETRIC_SUCCESS,
+ invokeCanAuthenticate(mBiometricService, authenticators));
+ }
+
+ @Test
+ public void testCanAuthenticate_whenNoBiometricSensor() throws Exception {
+ mBiometricService = new BiometricService(mContext, mInjector);
+ mBiometricService.onStart();
+
+ // When only biometric is requested
+ int authenticators = Authenticators.BIOMETRIC_STRONG;
+ assertEquals(BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE,
+ invokeCanAuthenticate(mBiometricService, authenticators));
+
+ // When credential and biometric are requested, and credential is not set up
+ authenticators = Authenticators.BIOMETRIC_STRONG | Authenticators.DEVICE_CREDENTIAL;
+ assertEquals(BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED,
+ invokeCanAuthenticate(mBiometricService, authenticators));
+
+ // When credential and biometric are requested, and credential is set up
+ when(mTrustManager.isDeviceSecure(anyInt())).thenReturn(true);
+ assertEquals(BiometricManager.BIOMETRIC_SUCCESS,
+ invokeCanAuthenticate(mBiometricService, authenticators));
+ }
+
+ @Test
+ public void testAuthenticatorActualStrength() {
+ // Tuple of OEM config, updatedStrength, and expectedStrength
+ final int[][] testCases = {
+ // Downgrades to the specified strength
+ {Authenticators.BIOMETRIC_STRONG, Authenticators.BIOMETRIC_WEAK,
+ Authenticators.BIOMETRIC_WEAK},
+
+ // Cannot be upgraded
+ {Authenticators.BIOMETRIC_WEAK, Authenticators.BIOMETRIC_STRONG,
+ Authenticators.BIOMETRIC_WEAK},
+
+ // Downgrades to convenience
+ {Authenticators.BIOMETRIC_WEAK, Authenticators.BIOMETRIC_CONVENIENCE,
+ Authenticators.BIOMETRIC_CONVENIENCE},
+
+ // EMPTY_SET does not modify specified strength
+ {Authenticators.BIOMETRIC_WEAK, Authenticators.EMPTY_SET,
+ Authenticators.BIOMETRIC_WEAK},
+ };
+
+ for (int i = 0; i < testCases.length; i++) {
+ final BiometricService.AuthenticatorWrapper authenticator =
+ new BiometricService.AuthenticatorWrapper(0 /* id */,
+ BiometricAuthenticator.TYPE_FINGERPRINT,
+ testCases[i][0],
+ null /* impl */);
+ authenticator.updateStrength(testCases[i][1]);
+ assertEquals(testCases[i][2], authenticator.getActualStrength());
+ }
+ }
+
+ @Test
+ public void testWithDowngradedAuthenticator() throws Exception {
+ mBiometricService = new BiometricService(mContext, mInjector);
+ mBiometricService.onStart();
+
+ final int testId = 0;
+
+ when(mFingerprintAuthenticator.hasEnrolledTemplates(anyInt(), any()))
+ .thenReturn(true);
+ when(mFingerprintAuthenticator.isHardwareDetected(any())).thenReturn(true);
+ mBiometricService.mImpl.registerAuthenticator(testId /* id */,
+ BiometricAuthenticator.TYPE_FINGERPRINT, Authenticators.BIOMETRIC_STRONG,
+ mFingerprintAuthenticator);
+
+ // Downgrade the authenticator
+ for (BiometricService.AuthenticatorWrapper wrapper : mBiometricService.mAuthenticators) {
+ if (wrapper.id == testId) {
+ wrapper.updateStrength(Authenticators.BIOMETRIC_WEAK);
+ }
+ }
+
+ // STRONG-only auth is not available
+ int authenticators = Authenticators.BIOMETRIC_STRONG;
+ assertEquals(BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE,
+ invokeCanAuthenticate(mBiometricService, authenticators));
+ invokeAuthenticate(mBiometricService.mImpl, mReceiver1, false /* requireConfirmation */,
+ authenticators);
+ waitForIdle();
+ verify(mReceiver1).onError(
+ eq(BiometricAuthenticator.TYPE_NONE),
+ eq(BiometricPrompt.BIOMETRIC_ERROR_HW_NOT_PRESENT),
+ eq(0) /* vendorCode */);
+
+ // Request for weak auth works
+ resetReceiver();
+ authenticators = Authenticators.BIOMETRIC_WEAK;
+ assertEquals(BiometricManager.BIOMETRIC_SUCCESS,
+ invokeCanAuthenticate(mBiometricService, authenticators));
+ invokeAuthenticateAndStart(mBiometricService.mImpl, mReceiver1,
+ false /* requireConfirmation */,
+ authenticators);
+ waitForIdle();
+ verify(mBiometricService.mStatusBarService).showAuthenticationDialog(
+ eq(mBiometricService.mCurrentAuthSession.mBundle),
+ any(IBiometricServiceReceiverInternal.class),
+ eq(BiometricAuthenticator.TYPE_FINGERPRINT /* biometricModality */),
+ anyBoolean() /* requireConfirmation */,
+ anyInt() /* userId */,
+ eq(TEST_PACKAGE_NAME));
+
+ // Requesting strong and credential, when credential is setup
+ resetReceiver();
+ authenticators = Authenticators.BIOMETRIC_STRONG | Authenticators.DEVICE_CREDENTIAL;
+ when(mTrustManager.isDeviceSecure(anyInt())).thenReturn(true);
+ assertEquals(BiometricManager.BIOMETRIC_SUCCESS,
+ invokeCanAuthenticate(mBiometricService, authenticators));
+ invokeAuthenticate(mBiometricService.mImpl, mReceiver1,
+ false /* requireConfirmation */,
+ authenticators);
+ waitForIdle();
+ assertTrue(Utils.isDeviceCredentialAllowed(mBiometricService.mCurrentAuthSession.mBundle));
+ verify(mBiometricService.mStatusBarService).showAuthenticationDialog(
+ eq(mBiometricService.mCurrentAuthSession.mBundle),
+ any(IBiometricServiceReceiverInternal.class),
+ eq(BiometricAuthenticator.TYPE_NONE /* biometricModality */),
+ anyBoolean() /* requireConfirmation */,
+ anyInt() /* userId */,
+ eq(TEST_PACKAGE_NAME));
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testRegistrationWithDuplicateId_throwsIllegalStateException() throws Exception {
+ mBiometricService = new BiometricService(mContext, mInjector);
+ mBiometricService.onStart();
+
+ mBiometricService.mImpl.registerAuthenticator(
+ 0 /* id */, 2 /* modality */, 15 /* strength */,
+ mFingerprintAuthenticator);
+ mBiometricService.mImpl.registerAuthenticator(
+ 0 /* id */, 2 /* modality */, 15 /* strength */,
+ mFingerprintAuthenticator);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testRegistrationWithUnknownId_throwsIllegalStateException() throws Exception {
+ mBiometricService = new BiometricService(mContext, mInjector);
+ mBiometricService.onStart();
+
+ mBiometricService.mImpl.registerAuthenticator(
+ 100 /* id */, 2 /* modality */, 15 /* strength */,
+ mFingerprintAuthenticator);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testRegistrationWithUnsupportedStrength_throwsIllegalStateException()
+ throws Exception {
+ mBiometricService = new BiometricService(mContext, mInjector);
+ mBiometricService.onStart();
+
+ // Only STRONG and WEAK are supported. Let's enforce that CONVENIENCE cannot be
+ // registered. If there is a compelling reason, we can remove this constraint.
+ mBiometricService.mImpl.registerAuthenticator(
+ 0 /* id */, 2 /* modality */,
+ Authenticators.BIOMETRIC_CONVENIENCE /* strength */,
+ mFingerprintAuthenticator);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testRegistrationWithNullAuthenticator_throwsIllegalArgumentException()
+ throws Exception {
+ mBiometricService = new BiometricService(mContext, mInjector);
+ mBiometricService.onStart();
+
+ mBiometricService.mImpl.registerAuthenticator(
+ 0 /* id */, 2 /* modality */,
+ Authenticators.BIOMETRIC_STRONG /* strength */,
+ null /* authenticator */);
+ }
+
+ @Test
+ public void testRegistrationHappyPath_isOk() throws Exception {
+ // This is being tested in many of the other cases, but here's the base case.
+ mBiometricService = new BiometricService(mContext, mInjector);
+ mBiometricService.onStart();
+
+ for (String s : mInjector.getConfiguration(null)) {
+ SensorConfig config = new SensorConfig(s);
+ mBiometricService.mImpl.registerAuthenticator(config.mId, config.mModality,
+ config.mStrength, mFingerprintAuthenticator);
+ }
+ }
+
// Helper methods
- private void setupAuthForOnly(int modality) throws RemoteException {
+ private int invokeCanAuthenticate(BiometricService service, int authenticators)
+ throws Exception {
+ return service.mImpl.canAuthenticate(TEST_PACKAGE_NAME, 0 /* userId */, authenticators);
+ }
+
+ private void setupAuthForOnly(int modality, int strength) throws Exception {
+ setupAuthForOnly(modality, strength, true /* enrolled */);
+ }
+
+ // TODO: Reconcile the registration strength with the injector
+ private void setupAuthForOnly(int modality, int strength, boolean enrolled) throws Exception {
mBiometricService = new BiometricService(mContext, mInjector);
mBiometricService.onStart();
when(mBiometricService.mSettingObserver.getFaceEnabledForApps(anyInt())).thenReturn(true);
- if (modality == BiometricAuthenticator.TYPE_FINGERPRINT) {
- when(mFingerprintAuthenticator.hasEnrolledTemplates(anyInt(), any())).thenReturn(true);
+ if ((modality & BiometricAuthenticator.TYPE_FINGERPRINT) != 0) {
+ when(mFingerprintAuthenticator.hasEnrolledTemplates(anyInt(), any()))
+ .thenReturn(enrolled);
when(mFingerprintAuthenticator.isHardwareDetected(any())).thenReturn(true);
- mBiometricService.mImpl.registerAuthenticator(0 /* id */, STRENGTH_STRONG, modality,
+ mBiometricService.mImpl.registerAuthenticator(0 /* id */, modality, strength,
mFingerprintAuthenticator);
- } else if (modality == BiometricAuthenticator.TYPE_FACE) {
- when(mFaceAuthenticator.hasEnrolledTemplates(anyInt(), any())).thenReturn(true);
+ }
+
+ if ((modality & BiometricAuthenticator.TYPE_FACE) != 0) {
+ when(mFaceAuthenticator.hasEnrolledTemplates(anyInt(), any())).thenReturn(enrolled);
when(mFaceAuthenticator.isHardwareDetected(any())).thenReturn(true);
- mBiometricService.mImpl.registerAuthenticator(0 /* id */, STRENGTH_STRONG, modality,
+ mBiometricService.mImpl.registerAuthenticator(1 /* id */, modality, strength,
mFaceAuthenticator);
- } else {
- fail("Unknown modality: " + modality);
+ }
+ }
+
+ // TODO: Reduce duplicated code, currently we cannot start the BiometricService in setUp() for
+ // all tests.
+ private void setupAuthForMultiple(int[] modalities, int[] strengths) throws RemoteException {
+ mBiometricService = new BiometricService(mContext, mInjector);
+ mBiometricService.onStart();
+
+ when(mBiometricService.mSettingObserver.getFaceEnabledForApps(anyInt())).thenReturn(true);
+
+ assertEquals(modalities.length, strengths.length);
+
+ for (int i = 0; i < modalities.length; i++) {
+ final int modality = modalities[i];
+ final int strength = strengths[i];
+
+ if ((modality & BiometricAuthenticator.TYPE_FINGERPRINT) != 0) {
+ when(mFingerprintAuthenticator.hasEnrolledTemplates(anyInt(), any()))
+ .thenReturn(true);
+ when(mFingerprintAuthenticator.isHardwareDetected(any())).thenReturn(true);
+ mBiometricService.mImpl.registerAuthenticator(0 /* id */, modality, strength,
+ mFingerprintAuthenticator);
+ }
+
+ if ((modality & BiometricAuthenticator.TYPE_FACE) != 0) {
+ when(mFaceAuthenticator.hasEnrolledTemplates(anyInt(), any())).thenReturn(true);
+ when(mFaceAuthenticator.isHardwareDetected(any())).thenReturn(true);
+ mBiometricService.mImpl.registerAuthenticator(1 /* id */, modality, strength,
+ mFaceAuthenticator);
+ }
}
}
@@ -885,9 +1278,9 @@
private void invokeAuthenticateAndStart(IBiometricService.Stub service,
IBiometricServiceReceiver receiver, boolean requireConfirmation,
- boolean allowDeviceCredential) throws Exception {
+ Integer authenticators) throws Exception {
// Request auth, creates a pending session
- invokeAuthenticate(service, receiver, requireConfirmation, allowDeviceCredential);
+ invokeAuthenticate(service, receiver, requireConfirmation, authenticators);
waitForIdle();
startPendingAuthSession(mBiometricService);
@@ -908,23 +1301,24 @@
private static void invokeAuthenticate(IBiometricService.Stub service,
IBiometricServiceReceiver receiver, boolean requireConfirmation,
- boolean allowDeviceCredential) throws Exception {
+ Integer authenticators) throws Exception {
service.authenticate(
new Binder() /* token */,
0 /* sessionId */,
0 /* userId */,
receiver,
TEST_PACKAGE_NAME /* packageName */,
- createTestBiometricPromptBundle(requireConfirmation, allowDeviceCredential));
+ createTestBiometricPromptBundle(requireConfirmation, authenticators));
}
- private static Bundle createTestBiometricPromptBundle(boolean requireConfirmation,
- boolean allowDeviceCredential) {
+ private static Bundle createTestBiometricPromptBundle(
+ boolean requireConfirmation,
+ Integer authenticators) {
final Bundle bundle = new Bundle();
bundle.putBoolean(BiometricPrompt.KEY_REQUIRE_CONFIRMATION, requireConfirmation);
- if (allowDeviceCredential) {
- bundle.putBoolean(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL, true);
+ if (authenticators != null) {
+ bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, authenticators);
}
return bundle;
}
diff --git a/services/tests/servicestests/src/com/android/server/biometrics/OWNERS b/services/tests/servicestests/src/com/android/server/biometrics/OWNERS
new file mode 100644
index 0000000..8765c9a
--- /dev/null
+++ b/services/tests/servicestests/src/com/android/server/biometrics/OWNERS
@@ -0,0 +1,7 @@
+set noparent
+
+kchyn@google.com
+jaggies@google.com
+curtislb@google.com
+ilyamaty@google.com
+joshmccloskey@google.com
diff --git a/services/tests/servicestests/src/com/android/server/biometrics/UtilsTest.java b/services/tests/servicestests/src/com/android/server/biometrics/UtilsTest.java
new file mode 100644
index 0000000..abe39f0
--- /dev/null
+++ b/services/tests/servicestests/src/com/android/server/biometrics/UtilsTest.java
@@ -0,0 +1,226 @@
+/*
+ * Copyright (C) 2019 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 com.android.server.biometrics;
+
+import static android.hardware.biometrics.BiometricManager.Authenticators;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+
+import static org.junit.Assert.assertNull;
+
+import android.hardware.biometrics.BiometricConstants;
+import android.hardware.biometrics.BiometricManager;
+import android.hardware.biometrics.BiometricPrompt;
+import android.os.Bundle;
+
+import androidx.test.filters.SmallTest;
+
+import org.junit.Test;
+
+@SmallTest
+public class UtilsTest {
+
+ @Test
+ public void testCombineAuthenticatorBundles_withKeyDeviceCredential_andKeyAuthenticators() {
+ final boolean allowDeviceCredential = false;
+ final @Authenticators.Types int authenticators =
+ Authenticators.DEVICE_CREDENTIAL | Authenticators.BIOMETRIC_WEAK;
+ final Bundle bundle = new Bundle();
+
+ bundle.putBoolean(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL, allowDeviceCredential);
+ bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, authenticators);
+ Utils.combineAuthenticatorBundles(bundle);
+
+ assertNull(bundle.get(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL));
+ assertEquals(bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED), authenticators);
+ }
+
+ @Test
+ public void testCombineAuthenticatorBundles_withNoKeyDeviceCredential_andKeyAuthenticators() {
+ final @Authenticators.Types int authenticators =
+ Authenticators.DEVICE_CREDENTIAL | Authenticators.BIOMETRIC_WEAK;
+ final Bundle bundle = new Bundle();
+
+ bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, authenticators);
+ Utils.combineAuthenticatorBundles(bundle);
+
+ assertNull(bundle.get(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL));
+ assertEquals(bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED), authenticators);
+ }
+
+ @Test
+ public void testCombineAuthenticatorBundles_withKeyDeviceCredential_andNoKeyAuthenticators() {
+ final boolean allowDeviceCredential = true;
+ final Bundle bundle = new Bundle();
+
+ bundle.putBoolean(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL, allowDeviceCredential);
+ Utils.combineAuthenticatorBundles(bundle);
+
+ assertNull(bundle.get(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL));
+ assertEquals(bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED),
+ Authenticators.DEVICE_CREDENTIAL | Authenticators.BIOMETRIC_WEAK);
+ }
+
+ @Test
+ public void testCombineAuthenticatorBundles_withNoKeyDeviceCredential_andNoKeyAuthenticators() {
+ final Bundle bundle = new Bundle();
+
+ Utils.combineAuthenticatorBundles(bundle);
+
+ assertNull(bundle.get(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL));
+ assertEquals(bundle.getInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED),
+ Authenticators.BIOMETRIC_WEAK);
+ }
+
+ @Test
+ public void testIsDeviceCredentialAllowed_withIntegerFlags() {
+ int authenticators = 0;
+ assertFalse(Utils.isDeviceCredentialAllowed(authenticators));
+
+ authenticators |= Authenticators.DEVICE_CREDENTIAL;
+ assertTrue(Utils.isDeviceCredentialAllowed(authenticators));
+
+ authenticators |= Authenticators.BIOMETRIC_WEAK;
+ assertTrue(Utils.isDeviceCredentialAllowed(authenticators));
+ }
+
+ @Test
+ public void testIsDeviceCredentialAllowed_withBundle() {
+ Bundle bundle = new Bundle();
+ assertFalse(Utils.isDeviceCredentialAllowed(bundle));
+
+ int authenticators = 0;
+ bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, authenticators);
+ assertFalse(Utils.isDeviceCredentialAllowed(bundle));
+
+ authenticators |= Authenticators.DEVICE_CREDENTIAL;
+ bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, authenticators);
+ assertTrue(Utils.isDeviceCredentialAllowed(bundle));
+
+ authenticators |= Authenticators.BIOMETRIC_WEAK;
+ bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, authenticators);
+ assertTrue(Utils.isDeviceCredentialAllowed(bundle));
+ }
+
+ @Test
+ public void testGetBiometricStrength_removeUnrelatedBits() {
+ // BIOMETRIC_MIN_STRENGTH uses all of the allowed bits for biometric strength, so any other
+ // bits aside from these should be clipped off.
+
+ int authenticators = Integer.MAX_VALUE;
+ assertEquals(Authenticators.BIOMETRIC_WEAK,
+ Utils.getPublicBiometricStrength(authenticators));
+
+ Bundle bundle = new Bundle();
+ bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, authenticators);
+ assertEquals(Authenticators.BIOMETRIC_WEAK, Utils.getPublicBiometricStrength(bundle));
+ }
+
+ @Test
+ public void testIsBiometricAllowed() {
+ // Only the lowest 8 bits (BIOMETRIC_WEAK mask) are allowed to integrate with the
+ // Biometric APIs
+ Bundle bundle = new Bundle();
+ for (int i = 0; i <= 7; i++) {
+ int authenticators = 1 << i;
+ bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, authenticators);
+ assertTrue(Utils.isBiometricAllowed(bundle));
+ }
+
+ // The rest of the bits are not allowed to integrate with the public APIs
+ for (int i = 8; i < 32; i++) {
+ int authenticators = 1 << i;
+ bundle.putInt(BiometricPrompt.KEY_AUTHENTICATORS_ALLOWED, authenticators);
+ assertFalse(Utils.isBiometricAllowed(bundle));
+ }
+ }
+
+ @Test
+ public void testIsValidAuthenticatorConfig() {
+ assertTrue(Utils.isValidAuthenticatorConfig(Authenticators.EMPTY_SET));
+
+ assertTrue(Utils.isValidAuthenticatorConfig(Authenticators.BIOMETRIC_STRONG));
+
+ assertTrue(Utils.isValidAuthenticatorConfig(Authenticators.BIOMETRIC_WEAK));
+
+ assertTrue(Utils.isValidAuthenticatorConfig(Authenticators.DEVICE_CREDENTIAL));
+
+ assertTrue(Utils.isValidAuthenticatorConfig(Authenticators.DEVICE_CREDENTIAL
+ | Authenticators.BIOMETRIC_STRONG));
+
+ assertTrue(Utils.isValidAuthenticatorConfig(Authenticators.DEVICE_CREDENTIAL
+ | Authenticators.BIOMETRIC_WEAK));
+
+ assertFalse(Utils.isValidAuthenticatorConfig(Authenticators.BIOMETRIC_CONVENIENCE));
+
+ assertFalse(Utils.isValidAuthenticatorConfig(Authenticators.BIOMETRIC_CONVENIENCE
+ | Authenticators.DEVICE_CREDENTIAL));
+
+ assertFalse(Utils.isValidAuthenticatorConfig(Authenticators.BIOMETRIC_MAX_STRENGTH));
+
+ assertFalse(Utils.isValidAuthenticatorConfig(Authenticators.BIOMETRIC_MIN_STRENGTH));
+
+ // The rest of the bits are not allowed to integrate with the public APIs
+ for (int i = 8; i < 32; i++) {
+ final int authenticator = 1 << i;
+ if (authenticator == Authenticators.DEVICE_CREDENTIAL) {
+ continue;
+ }
+ assertFalse(Utils.isValidAuthenticatorConfig(1 << i));
+ }
+ }
+
+ @Test
+ public void testIsAtLeastStrength() {
+ int sensorStrength = Authenticators.BIOMETRIC_STRONG;
+ int requestedStrength = Authenticators.BIOMETRIC_WEAK;
+ assertTrue(Utils.isAtLeastStrength(sensorStrength, requestedStrength));
+
+ requestedStrength = Authenticators.BIOMETRIC_STRONG;
+ assertTrue(Utils.isAtLeastStrength(sensorStrength, requestedStrength));
+
+ sensorStrength = Authenticators.BIOMETRIC_WEAK;
+ requestedStrength = Authenticators.BIOMETRIC_STRONG;
+ assertFalse(Utils.isAtLeastStrength(sensorStrength, requestedStrength));
+
+ requestedStrength = Authenticators.BIOMETRIC_WEAK;
+ assertTrue(Utils.isAtLeastStrength(sensorStrength, requestedStrength));
+ }
+
+ @Test
+ public void testBiometricConstantsConversion() {
+ final int[][] testCases = {
+ {BiometricConstants.BIOMETRIC_SUCCESS,
+ BiometricManager.BIOMETRIC_SUCCESS},
+ {BiometricConstants.BIOMETRIC_ERROR_NO_BIOMETRICS,
+ BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED},
+ {BiometricConstants.BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL,
+ BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED},
+ {BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE,
+ BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE},
+ {BiometricConstants.BIOMETRIC_ERROR_HW_NOT_PRESENT,
+ BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE}
+ };
+
+ for (int i = 0; i < testCases.length; i++) {
+ assertEquals(testCases[i][1],
+ Utils.biometricConstantsToBiometricManager(testCases[i][0]));
+ }
+ }
+}
diff --git a/services/tests/servicestests/src/com/android/server/compat/CompatConfigTest.java b/services/tests/servicestests/src/com/android/server/compat/CompatConfigTest.java
index 7267976..cb99c11 100644
--- a/services/tests/servicestests/src/com/android/server/compat/CompatConfigTest.java
+++ b/services/tests/servicestests/src/com/android/server/compat/CompatConfigTest.java
@@ -22,15 +22,13 @@
import androidx.test.runner.AndroidJUnit4;
-import com.android.compat.annotation.Change;
-import com.android.compat.annotation.XmlWriter;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.util.UUID;
@RunWith(AndroidJUnit4.class)
@@ -50,18 +48,10 @@
return dir;
}
- private void writeChangesToFile(Change[] changes, File f) {
- XmlWriter writer = new XmlWriter();
- for (Change change: changes) {
- writer.addChange(change);
- }
- try {
- f.createNewFile();
- writer.write(new FileOutputStream(f));
- } catch (IOException e) {
- throw new RuntimeException(
- "Encountered an error while writing compat config file", e);
- }
+ private void writeToFile(File dir, String filename, String content) throws IOException {
+ OutputStream os = new FileOutputStream(new File(dir, filename));
+ os.write(content.getBytes());
+ os.close();
}
@Test
@@ -173,13 +163,15 @@
}
@Test
- public void testReadConfig() {
- Change[] changes = {new Change(1234L, "MY_CHANGE1", false, 2, null), new Change(1235L,
- "MY_CHANGE2", true, null, "description"), new Change(1236L, "MY_CHANGE3", false,
- null, "")};
+ public void testReadConfig() throws IOException {
+ String configXml = "<config>"
+ + "<compat-change id=\"1234\" name=\"MY_CHANGE1\" enableAfterTargetSdk=\"2\" />"
+ + "<compat-change id=\"1235\" name=\"MY_CHANGE2\" disabled=\"true\" />"
+ + "<compat-change id=\"1236\" name=\"MY_CHANGE3\" />"
+ + "</config>";
File dir = createTempDir();
- writeChangesToFile(changes, new File(dir.getPath() + "/platform_compat_config.xml"));
+ writeToFile(dir, "platform_compat_config.xml", configXml);
CompatConfig pc = new CompatConfig();
pc.initConfigFromLib(dir);
@@ -191,17 +183,18 @@
}
@Test
- public void testReadConfigMultipleFiles() {
- Change[] changes1 = {new Change(1234L, "MY_CHANGE1", false, 2, null)};
- Change[] changes2 = {new Change(1235L, "MY_CHANGE2", true, null, ""), new Change(1236L,
- "MY_CHANGE3", false, null, null)};
+ public void testReadConfigMultipleFiles() throws IOException {
+ String configXml1 = "<config>"
+ + "<compat-change id=\"1234\" name=\"MY_CHANGE1\" enableAfterTargetSdk=\"2\" />"
+ + "</config>";
+ String configXml2 = "<config>"
+ + "<compat-change id=\"1235\" name=\"MY_CHANGE2\" disabled=\"true\" />"
+ + "<compat-change id=\"1236\" name=\"MY_CHANGE3\" />"
+ + "</config>";
File dir = createTempDir();
- writeChangesToFile(changes1,
- new File(dir.getPath() + "/libcore_platform_compat_config.xml"));
- writeChangesToFile(changes2,
- new File(dir.getPath() + "/frameworks_platform_compat_config.xml"));
-
+ writeToFile(dir, "libcore_platform_compat_config.xml", configXml1);
+ writeToFile(dir, "frameworks_platform_compat_config.xml", configXml2);
CompatConfig pc = new CompatConfig();
pc.initConfigFromLib(dir);
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
index 43d8f92..f97c887 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
@@ -1162,7 +1162,8 @@
MockUtils.checkUserHandle(UserHandle.USER_SYSTEM));
verify(getServices().userManagerInternal).setDevicePolicyUserRestrictions(
- eq(UserHandle.USER_SYSTEM), eq(null),
+ eq(UserHandle.USER_SYSTEM),
+ eq(null),
eq(UserManagerInternal.OWNER_TYPE_DEVICE_OWNER));
verify(getServices().usageStatsManagerInternal).setActiveAdminApps(
@@ -1966,7 +1967,6 @@
// TODO Make sure restrictions are written to the file.
}
- // TODO: (b/138709470) test addUserRestriction as PO of an organization-owned device
public void testSetUserRestriction_asPoOfOrgOwnedDevice() throws Exception {
final int MANAGED_PROFILE_USER_ID = DpmMockContext.CALLER_USER_HANDLE;
final int MANAGED_PROFILE_ADMIN_UID =
@@ -1979,16 +1979,26 @@
when(getServices().userManager.getProfileParent(MANAGED_PROFILE_USER_ID))
.thenReturn(new UserInfo(UserHandle.USER_SYSTEM, "user system", 0));
+ parentDpm.addUserRestriction(admin1, UserManager.DISALLOW_CONFIG_DATE_TIME);
+ verify(getServices().userManagerInternal).setDevicePolicyUserRestrictions(
+ eq(MANAGED_PROFILE_USER_ID),
+ MockUtils.checkUserRestrictions(UserManager.DISALLOW_CONFIG_DATE_TIME),
+ eq(UserManagerInternal.OWNER_TYPE_PROFILE_OWNER_OF_ORGANIZATION_OWNED_DEVICE));
+ reset(getServices().userManagerInternal);
+
+ parentDpm.clearUserRestriction(admin1, UserManager.DISALLOW_CONFIG_DATE_TIME);
+ reset(getServices().userManagerInternal);
+
parentDpm.setCameraDisabled(admin1, true);
verify(getServices().userManagerInternal).setDevicePolicyUserRestrictions(
- eq(UserHandle.USER_SYSTEM),
+ eq(MANAGED_PROFILE_USER_ID),
MockUtils.checkUserRestrictions(UserManager.DISALLOW_CAMERA),
eq(UserManagerInternal.OWNER_TYPE_PROFILE_OWNER_OF_ORGANIZATION_OWNED_DEVICE));
reset(getServices().userManagerInternal);
parentDpm.setCameraDisabled(admin1, false);
verify(getServices().userManagerInternal).setDevicePolicyUserRestrictions(
- eq(UserHandle.USER_SYSTEM),
+ eq(MANAGED_PROFILE_USER_ID),
MockUtils.checkUserRestrictions(),
eq(UserManagerInternal.OWNER_TYPE_PROFILE_OWNER_OF_ORGANIZATION_OWNED_DEVICE));
reset(getServices().userManagerInternal);
@@ -3673,6 +3683,45 @@
verify(getServices().settings).settingsGlobalPutInt(Settings.Global.AUTO_TIME, 0);
}
+ public void testSetAutoTimeZoneModifiesSetting() throws Exception {
+ mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
+ setupDeviceOwner();
+ dpm.setAutoTimeZone(admin1, true);
+ verify(getServices().settings).settingsGlobalPutInt(Settings.Global.AUTO_TIME_ZONE, 1);
+
+ dpm.setAutoTimeZone(admin1, false);
+ verify(getServices().settings).settingsGlobalPutInt(Settings.Global.AUTO_TIME_ZONE, 0);
+ }
+
+ public void testSetAutoTimeZoneWithPOOnUser0() throws Exception {
+ mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
+ setupProfileOwnerOnUser0();
+ dpm.setAutoTimeZone(admin1, true);
+ verify(getServices().settings).settingsGlobalPutInt(Settings.Global.AUTO_TIME_ZONE, 1);
+
+ dpm.setAutoTimeZone(admin1, false);
+ verify(getServices().settings).settingsGlobalPutInt(Settings.Global.AUTO_TIME_ZONE, 0);
+ }
+
+ public void testSetAutoTimeZoneFailWithPONotOnUser0() throws Exception {
+ setupProfileOwner();
+ assertExpectException(SecurityException.class, null,
+ () -> dpm.setAutoTimeZone(admin1, false));
+ verify(getServices().settings, never()).settingsGlobalPutInt(Settings.Global.AUTO_TIME_ZONE,
+ 0);
+ }
+
+ public void testSetAutoTimeZoneWithPOOfOrganizationOwnedDevice() throws Exception {
+ setupProfileOwner();
+ configureProfileOwnerOfOrgOwnedDevice(admin1, DpmMockContext.CALLER_USER_HANDLE);
+
+ dpm.setAutoTimeZone(admin1, true);
+ verify(getServices().settings).settingsGlobalPutInt(Settings.Global.AUTO_TIME_ZONE, 1);
+
+ dpm.setAutoTimeZone(admin1, false);
+ verify(getServices().settings).settingsGlobalPutInt(Settings.Global.AUTO_TIME_ZONE, 0);
+ }
+
public void testSetTime() throws Exception {
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
setupDeviceOwner();
@@ -5548,6 +5597,38 @@
mServiceContext.binder.restoreCallingIdentity(ident);
}
+ public void testGetCrossProfilePackages_notSet_returnsEmpty() {
+ setAsProfileOwner(admin1);
+ assertTrue(dpm.getCrossProfilePackages(admin1).isEmpty());
+ }
+
+ public void testGetCrossProfilePackages_notSet_dpmsReinitialized_returnsEmpty() {
+ setAsProfileOwner(admin1);
+
+ initializeDpms();
+
+ assertTrue(dpm.getCrossProfilePackages(admin1).isEmpty());
+ }
+
+ public void testGetCrossProfilePackages_whenSet_returnsEqual() {
+ setAsProfileOwner(admin1);
+ Set<String> packages = Collections.singleton("TEST_PACKAGE");
+
+ dpm.setCrossProfilePackages(admin1, packages);
+
+ assertEquals(packages, dpm.getCrossProfilePackages(admin1));
+ }
+
+ public void testGetCrossProfilePackages_whenSet_dpmsReinitialized_returnsEqual() {
+ setAsProfileOwner(admin1);
+ Set<String> packages = Collections.singleton("TEST_PACKAGE");
+
+ dpm.setCrossProfilePackages(admin1, packages);
+ initializeDpms();
+
+ assertEquals(packages, dpm.getCrossProfilePackages(admin1));
+ }
+
// admin1 is the outgoing DPC, adminAnotherPakcage is the incoming one.
private void assertDeviceOwnershipRevertedWithFakeTransferMetadata() throws Exception {
writeFakeTransferMetadataFile(UserHandle.USER_SYSTEM,
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java b/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java
index 7a2350e..919a3f6 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java
@@ -35,6 +35,7 @@
import android.app.timezonedetector.TimeZoneDetector;
import android.app.usage.UsageStatsManagerInternal;
import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
@@ -162,6 +163,8 @@
// Package manager is huge, so we use a partial mock instead.
packageManager = spy(realContext.getPackageManager());
+ when(packageManagerInternal.getSystemUiServiceComponent()).thenReturn(
+ new ComponentName("com.android.systemui", ".Service"));
contentResolver = new MockContentResolver();
contentResolver.addProvider("telephony", new MockContentProvider(realContext) {
diff --git a/services/tests/servicestests/src/com/android/server/om/MockitoUtils.kt b/services/tests/servicestests/src/com/android/server/om/MockitoUtils.kt
new file mode 100644
index 0000000..0f915db
--- /dev/null
+++ b/services/tests/servicestests/src/com/android/server/om/MockitoUtils.kt
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2019 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 com.android.server.om
+
+import org.mockito.Answers
+import org.mockito.Mockito
+import org.mockito.invocation.InvocationOnMock
+import org.mockito.stubbing.Answer
+import org.mockito.stubbing.Stubber
+
+// TODO(chiuwinson): Move this entire file to a shared utility module
+// TODO(b/135203078): De-dupe utils added for overlays vs package refactor
+object MockitoUtils {
+ val ANSWER_THROWS = Answer<Any?> {
+ when (val name = it.method.name) {
+ "toString" -> return@Answer Answers.CALLS_REAL_METHODS.answer(it)
+ else -> {
+ val arguments = it.arguments
+ ?.takeUnless { it.isEmpty() }
+ ?.joinToString()
+ ?.let {
+ "with $it"
+ }
+ .orEmpty()
+
+ throw UnsupportedOperationException("${it.mock::class.java.simpleName}#$name " +
+ "$arguments should not be called")
+ }
+ }
+ }
+}
+
+inline fun <reified T> mock(block: T.() -> Unit = {}) = Mockito.mock(T::class.java).apply(block)
+
+fun <Type> Stubber.whenever(mock: Type) = Mockito.`when`(mock)
+fun <Type : Any?> whenever(mock: Type) = Mockito.`when`(mock)
+
+@Suppress("UNCHECKED_CAST")
+fun <Type : Any?> whenever(mock: Type, block: InvocationOnMock.() -> Any?) =
+ Mockito.`when`(mock).thenAnswer { block(it) }
+
+fun whenever(mock: Unit) = Mockito.`when`(mock).thenAnswer { }
+
+inline fun <reified T> mockThrowOnUnmocked(block: T.() -> Unit): T {
+ val swappingAnswer = object : Answer<Any?> {
+ var delegate: Answer<*> = Answers.RETURNS_DEFAULTS
+
+ override fun answer(invocation: InvocationOnMock?): Any? {
+ return delegate.answer(invocation)
+ }
+ }
+
+ return Mockito.mock(T::class.java, swappingAnswer).apply(block)
+ .also {
+ // To allow when() usage inside block, only swap to throwing afterwards
+ swappingAnswer.delegate = MockitoUtils.ANSWER_THROWS
+ }
+}
diff --git a/services/tests/servicestests/src/com/android/server/om/OverlayReferenceMapperTests.kt b/services/tests/servicestests/src/com/android/server/om/OverlayReferenceMapperTests.kt
new file mode 100644
index 0000000..ef12948
--- /dev/null
+++ b/services/tests/servicestests/src/com/android/server/om/OverlayReferenceMapperTests.kt
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2019 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 com.android.server.om
+
+import android.content.pm.parsing.AndroidPackage
+import android.net.Uri
+import com.google.common.truth.Truth.assertThat
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
+import org.testng.Assert.assertThrows
+
+@RunWith(Parameterized::class)
+class OverlayReferenceMapperTests {
+
+ companion object {
+ private const val TARGET_PACKAGE_NAME = "com.test.target"
+ private const val OVERLAY_PACKAGE_NAME = "com.test.overlay"
+ private const val ACTOR_PACKAGE_NAME = "com.test.actor"
+ private const val ACTOR_NAME = "overlay://test/actorName"
+
+ @JvmStatic
+ @Parameterized.Parameters(name = "deferRebuild {0}")
+ fun parameters() = arrayOf(true, false)
+ }
+
+ private lateinit var mapper: OverlayReferenceMapper
+
+ @JvmField
+ @Parameterized.Parameter(0)
+ var deferRebuild = false
+
+ @Before
+ fun initMapper() {
+ mapper = mapper()
+ }
+
+ @Test
+ fun targetWithOverlay() {
+ val target = mockTarget()
+ val overlay = mockOverlay()
+ val existing = mapper.addInOrder(overlay)
+ assertEmpty()
+ mapper.addInOrder(target, existing = existing)
+ assertMapping(ACTOR_PACKAGE_NAME to setOf(target, overlay))
+ mapper.remove(target)
+ assertEmpty()
+ }
+
+ @Test
+ fun targetWithMultipleOverlays() {
+ val target = mockTarget()
+ val overlay0 = mockOverlay(0)
+ val overlay1 = mockOverlay(1)
+ mapper = mapper(
+ overlayToTargetToOverlayables = mapOf(
+ overlay0.packageName to mapOf(
+ target.packageName to target.overlayables.keys
+ ),
+ overlay1.packageName to mapOf(
+ target.packageName to target.overlayables.keys
+ )
+ )
+ )
+ val existing = mapper.addInOrder(overlay0, overlay1)
+ assertEmpty()
+ mapper.addInOrder(target, existing = existing)
+ assertMapping(ACTOR_PACKAGE_NAME to setOf(target, overlay0, overlay1))
+ mapper.remove(overlay0)
+ assertMapping(ACTOR_PACKAGE_NAME to setOf(target, overlay1))
+ mapper.remove(target)
+ assertEmpty()
+ }
+
+ @Test
+ fun targetWithoutOverlay() {
+ val target = mockTarget()
+ mapper.addInOrder(target)
+ assertMapping(ACTOR_PACKAGE_NAME to setOf(target))
+ mapper.remove(target)
+ assertEmpty()
+ }
+
+ @Test
+ fun overlayWithTarget() {
+ val target = mockTarget()
+ val overlay = mockOverlay()
+ val existing = mapper.addInOrder(target)
+ assertMapping(ACTOR_PACKAGE_NAME to setOf(target))
+ mapper.addInOrder(overlay, existing = existing)
+ assertMapping(ACTOR_PACKAGE_NAME to setOf(target, overlay))
+ mapper.remove(overlay)
+ assertMapping(ACTOR_PACKAGE_NAME to setOf(target))
+ }
+
+ @Test
+ fun overlayWithMultipleTargets() {
+ val target0 = mockTarget(0)
+ val target1 = mockTarget(1)
+ val overlay = mockOverlay()
+ mapper = mapper(
+ overlayToTargetToOverlayables = mapOf(
+ overlay.packageName to mapOf(
+ target0.packageName to target0.overlayables.keys,
+ target1.packageName to target1.overlayables.keys
+ )
+ )
+ )
+ mapper.addInOrder(target0, target1, overlay)
+ assertMapping(ACTOR_PACKAGE_NAME to setOf(target0, target1, overlay))
+ mapper.remove(target0)
+ assertMapping(ACTOR_PACKAGE_NAME to setOf(target1, overlay))
+ mapper.remove(target1)
+ assertEmpty()
+ }
+
+ @Test
+ fun overlayWithoutTarget() {
+ val overlay = mockOverlay()
+ mapper.addInOrder(overlay)
+ // An overlay can only have visibility exposed through its target
+ assertEmpty()
+ mapper.remove(overlay)
+ assertEmpty()
+ }
+
+ private fun OverlayReferenceMapper.addInOrder(
+ vararg pkgs: AndroidPackage,
+ existing: MutableMap<String, AndroidPackage> = mutableMapOf()
+ ) = pkgs.fold(existing) { map, pkg ->
+ addPkg(pkg, map)
+ map[pkg.packageName] = pkg
+ return@fold map
+ }
+
+ private fun OverlayReferenceMapper.remove(pkg: AndroidPackage) = removePkg(pkg.packageName)
+
+ private fun assertMapping(vararg pairs: Pair<String, Set<AndroidPackage>>) {
+ val expected = pairs.associate { it }
+ .mapValues { pair -> pair.value.map { it.packageName }.toSet() }
+
+ // This validates the API exposed for querying the relationships
+ expected.forEach { (actorPkgName, expectedPkgNames) ->
+ expectedPkgNames.forEach { expectedPkgName ->
+ if (deferRebuild) {
+ assertThrows(IllegalStateException::class.java) {
+ mapper.isValidActor(expectedPkgName, actorPkgName)
+ }
+ mapper.rebuildIfDeferred()
+ deferRebuild = false
+ }
+
+ assertThat(mapper.isValidActor(expectedPkgName, actorPkgName)).isTrue()
+ }
+ }
+
+ // This asserts no other relationships are defined besides those tested above
+ assertThat(mapper.actorPkgToPkgs).containsExactlyEntriesIn(expected)
+ }
+
+ private fun assertEmpty() = assertMapping()
+
+ private fun mapper(
+ namedActors: Map<String, Map<String, String>> = Uri.parse(ACTOR_NAME).run {
+ mapOf(authority!! to mapOf(pathSegments.first() to ACTOR_PACKAGE_NAME))
+ },
+ overlayToTargetToOverlayables: Map<String, Map<String, Set<String>>> = mapOf(
+ mockOverlay().packageName to mapOf(
+ mockTarget().run { packageName to overlayables.keys }
+ )
+ )
+ ) = OverlayReferenceMapper(deferRebuild, object : OverlayReferenceMapper.Provider {
+ override fun getActorPkg(actor: String?) =
+ OverlayActorEnforcer.getPackageNameForActor(actor, namedActors).first
+
+ override fun getTargetToOverlayables(pkg: AndroidPackage) =
+ overlayToTargetToOverlayables[pkg.packageName] ?: emptyMap()
+ })
+
+ private fun mockTarget(increment: Int = 0) = mockThrowOnUnmocked<AndroidPackage> {
+ whenever(packageName) { "$TARGET_PACKAGE_NAME$increment" }
+ whenever(overlayables) { mapOf("overlayableName$increment" to ACTOR_NAME) }
+ whenever(toString()) { "Package{$packageName}" }
+ }
+
+ private fun mockOverlay(increment: Int = 0) = mockThrowOnUnmocked<AndroidPackage> {
+ whenever(packageName) { "$OVERLAY_PACKAGE_NAME$increment" }
+ whenever(overlayables) { emptyMap<String, String>() }
+ whenever(toString()) { "Package{$packageName}" }
+ }
+}
diff --git a/services/tests/servicestests/src/com/android/server/pm/ApexManagerTest.java b/services/tests/servicestests/src/com/android/server/pm/ApexManagerTest.java
index fb9c68a..40ada2a 100644
--- a/services/tests/servicestests/src/com/android/server/pm/ApexManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/ApexManagerTest.java
@@ -30,6 +30,7 @@
import android.apex.ApexInfo;
import android.apex.ApexSessionInfo;
+import android.apex.ApexSessionParams;
import android.apex.IApexService;
import android.content.Context;
import android.content.pm.PackageInfo;
@@ -183,19 +184,18 @@
public void testSubmitStagedSession_throwPackageManagerException() throws RemoteException {
doAnswer(invocation -> {
throw new Exception();
- }).when(mApexService).submitStagedSession(anyInt(), any(), any());
+ }).when(mApexService).submitStagedSession(any(), any());
assertThrows(PackageManagerException.class,
- () -> mApexManager.submitStagedSession(TEST_SESSION_ID, TEST_CHILD_SESSION_ID));
+ () -> mApexManager.submitStagedSession(testParamsWithChildren()));
}
@Test
public void testSubmitStagedSession_throwRunTimeException() throws RemoteException {
- doThrow(RemoteException.class).when(mApexService).submitStagedSession(anyInt(), any(),
- any());
+ doThrow(RemoteException.class).when(mApexService).submitStagedSession(any(), any());
assertThrows(RuntimeException.class,
- () -> mApexManager.submitStagedSession(TEST_SESSION_ID, TEST_CHILD_SESSION_ID));
+ () -> mApexManager.submitStagedSession(testParamsWithChildren()));
}
@Test
@@ -272,6 +272,13 @@
return stagedSessionInfo;
}
+ private static ApexSessionParams testParamsWithChildren() {
+ ApexSessionParams params = new ApexSessionParams();
+ params.sessionId = TEST_SESSION_ID;
+ params.childSessionIds = TEST_CHILD_SESSION_ID;
+ return params;
+ }
+
/**
* Copies a specified {@code resourceId} to a temp file. Returns a non-null file if the copy
* succeeded
diff --git a/services/tests/servicestests/src/com/android/server/pm/AppsFilterTest.java b/services/tests/servicestests/src/com/android/server/pm/AppsFilterTest.java
index 4fc625a..82bbdcb 100644
--- a/services/tests/servicestests/src/com/android/server/pm/AppsFilterTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/AppsFilterTest.java
@@ -35,6 +35,11 @@
import android.os.Build;
import android.os.Process;
import android.util.ArrayMap;
+import android.util.ArraySet;
+
+import androidx.annotation.NonNull;
+
+import com.android.server.om.OverlayReferenceMapper;
import org.junit.Before;
import org.junit.Test;
@@ -43,11 +48,18 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
@RunWith(JUnit4.class)
public class AppsFilterTest {
private static final int DUMMY_CALLING_UID = 10345;
private static final int DUMMY_TARGET_UID = 10556;
+ private static final int DUMMY_ACTOR_UID = 10656;
+ private static final int DUMMY_OVERLAY_UID = 10756;
+ private static final int DUMMY_ACTOR_TWO_UID = 10856;
@Mock
AppsFilter.FeatureConfig mFeatureConfigMock;
@@ -117,7 +129,7 @@
@Test
public void testSystemReadyPropogates() throws Exception {
final AppsFilter appsFilter =
- new AppsFilter(mFeatureConfigMock, new String[]{}, false);
+ new AppsFilter(mFeatureConfigMock, new String[]{}, false, null);
appsFilter.onSystemReady();
verify(mFeatureConfigMock).onSystemReady();
}
@@ -125,7 +137,8 @@
@Test
public void testQueriesAction_FilterMatches() {
final AppsFilter appsFilter =
- new AppsFilter(mFeatureConfigMock, new String[]{}, false);
+ new AppsFilter(mFeatureConfigMock, new String[]{}, false, null);
+ appsFilter.onSystemReady();
PackageSetting target = simulateAddPackage(appsFilter,
pkg("com.some.package", new IntentFilter("TEST_ACTION")), DUMMY_TARGET_UID);
@@ -138,7 +151,8 @@
@Test
public void testQueriesAction_NoMatchingAction_Filters() {
final AppsFilter appsFilter =
- new AppsFilter(mFeatureConfigMock, new String[]{}, false);
+ new AppsFilter(mFeatureConfigMock, new String[]{}, false, null);
+ appsFilter.onSystemReady();
PackageSetting target = simulateAddPackage(appsFilter,
pkg("com.some.package"), DUMMY_TARGET_UID);
@@ -151,7 +165,8 @@
@Test
public void testQueriesAction_NoMatchingActionFilterLowSdk_DoesntFilter() {
final AppsFilter appsFilter =
- new AppsFilter(mFeatureConfigMock, new String[]{}, false);
+ new AppsFilter(mFeatureConfigMock, new String[]{}, false, null);
+ appsFilter.onSystemReady();
PackageSetting target = simulateAddPackage(appsFilter,
pkg("com.some.package"), DUMMY_TARGET_UID);
@@ -169,7 +184,8 @@
@Test
public void testNoQueries_Filters() {
final AppsFilter appsFilter =
- new AppsFilter(mFeatureConfigMock, new String[]{}, false);
+ new AppsFilter(mFeatureConfigMock, new String[]{}, false, null);
+ appsFilter.onSystemReady();
PackageSetting target = simulateAddPackage(appsFilter,
pkg("com.some.package"), DUMMY_TARGET_UID);
@@ -182,7 +198,8 @@
@Test
public void testForceQueryable_DoesntFilter() {
final AppsFilter appsFilter =
- new AppsFilter(mFeatureConfigMock, new String[]{}, false);
+ new AppsFilter(mFeatureConfigMock, new String[]{}, false, null);
+ appsFilter.onSystemReady();
PackageSetting target = simulateAddPackage(appsFilter,
pkg("com.some.package").setForceQueryable(true), DUMMY_TARGET_UID);
@@ -195,7 +212,8 @@
@Test
public void testForceQueryableByDevice_SystemCaller_DoesntFilter() {
final AppsFilter appsFilter =
- new AppsFilter(mFeatureConfigMock, new String[]{"com.some.package"}, false);
+ new AppsFilter(mFeatureConfigMock, new String[]{"com.some.package"}, false, null);
+ appsFilter.onSystemReady();
PackageSetting target = simulateAddPackage(appsFilter,
pkg("com.some.package"), DUMMY_TARGET_UID,
@@ -209,7 +227,8 @@
@Test
public void testForceQueryableByDevice_NonSystemCaller_Filters() {
final AppsFilter appsFilter =
- new AppsFilter(mFeatureConfigMock, new String[]{"com.some.package"}, false);
+ new AppsFilter(mFeatureConfigMock, new String[]{"com.some.package"}, false, null);
+ appsFilter.onSystemReady();
PackageSetting target = simulateAddPackage(appsFilter,
pkg("com.some.package"), DUMMY_TARGET_UID);
@@ -224,7 +243,8 @@
public void testSystemQueryable_DoesntFilter() {
final AppsFilter appsFilter =
new AppsFilter(mFeatureConfigMock, new String[]{},
- true /* system force queryable */);
+ true /* system force queryable */, null);
+ appsFilter.onSystemReady();
PackageSetting target = simulateAddPackage(appsFilter,
pkg("com.some.package"), DUMMY_TARGET_UID,
@@ -238,7 +258,8 @@
@Test
public void testQueriesPackage_DoesntFilter() {
final AppsFilter appsFilter =
- new AppsFilter(mFeatureConfigMock, new String[]{}, false);
+ new AppsFilter(mFeatureConfigMock, new String[]{}, false, null);
+ appsFilter.onSystemReady();
PackageSetting target = simulateAddPackage(appsFilter,
pkg("com.some.package"), DUMMY_TARGET_UID);
@@ -253,7 +274,8 @@
when(mFeatureConfigMock.packageIsEnabled(any(AndroidPackage.class)))
.thenReturn(false);
final AppsFilter appsFilter =
- new AppsFilter(mFeatureConfigMock, new String[]{}, false);
+ new AppsFilter(mFeatureConfigMock, new String[]{}, false, null);
+ appsFilter.onSystemReady();
PackageSetting target = simulateAddPackage(
appsFilter, pkg("com.some.package"), DUMMY_TARGET_UID);
@@ -266,20 +288,22 @@
@Test
public void testSystemUid_DoesntFilter() {
final AppsFilter appsFilter =
- new AppsFilter(mFeatureConfigMock, new String[]{}, false);
+ new AppsFilter(mFeatureConfigMock, new String[]{}, false, null);
+ appsFilter.onSystemReady();
PackageSetting target = simulateAddPackage(appsFilter,
pkg("com.some.package"), DUMMY_TARGET_UID);
assertFalse(appsFilter.shouldFilterApplication(0, null, target, 0));
- assertFalse(appsFilter.shouldFilterApplication(
- Process.FIRST_APPLICATION_UID - 1, null, target, 0));
+ assertFalse(appsFilter.shouldFilterApplication(Process.FIRST_APPLICATION_UID - 1,
+ null, target, 0));
}
@Test
public void testNonSystemUid_NoCallingSetting_Filters() {
final AppsFilter appsFilter =
- new AppsFilter(mFeatureConfigMock, new String[]{}, false);
+ new AppsFilter(mFeatureConfigMock, new String[]{}, false, null);
+ appsFilter.onSystemReady();
PackageSetting target = simulateAddPackage(appsFilter,
pkg("com.some.package"), DUMMY_TARGET_UID);
@@ -290,7 +314,8 @@
@Test
public void testNoTargetPackage_filters() {
final AppsFilter appsFilter =
- new AppsFilter(mFeatureConfigMock, new String[]{}, false);
+ new AppsFilter(mFeatureConfigMock, new String[]{}, false, null);
+ appsFilter.onSystemReady();
PackageSetting target = new PackageSettingBuilder()
.setName("com.some.package")
@@ -304,6 +329,127 @@
assertTrue(appsFilter.shouldFilterApplication(DUMMY_CALLING_UID, calling, target, 0));
}
+ @Test
+ public void testActsOnTargetOfOverlay() {
+ final String actorName = "overlay://test/actorName";
+
+ ParsingPackage target = pkg("com.some.package.target")
+ .addOverlayable("overlayableName", actorName);
+ ParsingPackage overlay = pkg("com.some.package.overlay")
+ .setIsOverlay(true)
+ .setOverlayTarget(target.getPackageName())
+ .setOverlayTargetName("overlayableName");
+ ParsingPackage actor = pkg("com.some.package.actor");
+
+ final AppsFilter appsFilter = new AppsFilter(mFeatureConfigMock, new String[]{}, false,
+ new OverlayReferenceMapper.Provider() {
+ @Nullable
+ @Override
+ public String getActorPkg(String actorString) {
+ if (actorName.equals(actorString)) {
+ return actor.getPackageName();
+ }
+ return null;
+ }
+
+ @NonNull
+ @Override
+ public Map<String, Set<String>> getTargetToOverlayables(
+ @NonNull AndroidPackage pkg) {
+ if (overlay.getPackageName().equals(pkg.getPackageName())) {
+ Map<String, Set<String>> map = new ArrayMap<>();
+ Set<String> set = new ArraySet<>();
+ set.add(overlay.getOverlayTargetName());
+ map.put(overlay.getOverlayTarget(), set);
+ return map;
+ }
+ return Collections.emptyMap();
+ }
+ });
+ appsFilter.onSystemReady();
+
+ PackageSetting targetSetting = simulateAddPackage(appsFilter, target, DUMMY_TARGET_UID);
+ PackageSetting overlaySetting = simulateAddPackage(appsFilter, overlay, DUMMY_OVERLAY_UID);
+ PackageSetting actorSetting = simulateAddPackage(appsFilter, actor, DUMMY_ACTOR_UID);
+
+ // Actor can see both target and overlay
+ assertFalse(appsFilter.shouldFilterApplication(DUMMY_ACTOR_UID, actorSetting,
+ targetSetting, 0));
+ assertFalse(appsFilter.shouldFilterApplication(DUMMY_ACTOR_UID, actorSetting,
+ overlaySetting, 0));
+
+ // But target/overlay can't see each other
+ assertTrue(appsFilter.shouldFilterApplication(DUMMY_TARGET_UID, targetSetting,
+ overlaySetting, 0));
+ assertTrue(appsFilter.shouldFilterApplication(DUMMY_OVERLAY_UID, overlaySetting,
+ targetSetting, 0));
+
+ // And can't see the actor
+ assertTrue(appsFilter.shouldFilterApplication(DUMMY_TARGET_UID, targetSetting,
+ actorSetting, 0));
+ assertTrue(appsFilter.shouldFilterApplication(DUMMY_OVERLAY_UID, overlaySetting,
+ actorSetting, 0));
+ }
+
+ @Test
+ public void testActsOnTargetOfOverlayThroughSharedUser() {
+ final String actorName = "overlay://test/actorName";
+
+ ParsingPackage target = pkg("com.some.package.target")
+ .addOverlayable("overlayableName", actorName);
+ ParsingPackage overlay = pkg("com.some.package.overlay")
+ .setIsOverlay(true)
+ .setOverlayTarget(target.getPackageName())
+ .setOverlayTargetName("overlayableName");
+ ParsingPackage actorOne = pkg("com.some.package.actor.one");
+ ParsingPackage actorTwo = pkg("com.some.package.actor.two");
+
+ final AppsFilter appsFilter = new AppsFilter(mFeatureConfigMock, new String[]{}, false,
+ new OverlayReferenceMapper.Provider() {
+ @Nullable
+ @Override
+ public String getActorPkg(String actorString) {
+ // Only actorOne is mapped as a valid actor
+ if (actorName.equals(actorString)) {
+ return actorOne.getPackageName();
+ }
+ return null;
+ }
+
+ @NonNull
+ @Override
+ public Map<String, Set<String>> getTargetToOverlayables(
+ @NonNull AndroidPackage pkg) {
+ if (overlay.getPackageName().equals(pkg.getPackageName())) {
+ Map<String, Set<String>> map = new ArrayMap<>();
+ Set<String> set = new ArraySet<>();
+ set.add(overlay.getOverlayTargetName());
+ map.put(overlay.getOverlayTarget(), set);
+ return map;
+ }
+ return Collections.emptyMap();
+ }
+ });
+ appsFilter.onSystemReady();
+
+ PackageSetting targetSetting = simulateAddPackage(appsFilter, target, DUMMY_TARGET_UID);
+ PackageSetting overlaySetting = simulateAddPackage(appsFilter, overlay, DUMMY_OVERLAY_UID);
+ PackageSetting actorOneSetting = simulateAddPackage(appsFilter, actorOne, DUMMY_ACTOR_UID);
+ PackageSetting actorTwoSetting = simulateAddPackage(appsFilter, actorTwo,
+ DUMMY_ACTOR_TWO_UID);
+
+ SharedUserSetting actorSharedSetting = new SharedUserSetting("actorSharedUser",
+ actorOneSetting.pkgFlags, actorOneSetting.pkgPrivateFlags);
+ actorSharedSetting.addPackage(actorOneSetting);
+ actorSharedSetting.addPackage(actorTwoSetting);
+
+ // actorTwo can see both target and overlay
+ assertFalse(appsFilter.shouldFilterApplication(DUMMY_ACTOR_TWO_UID, actorSharedSetting,
+ targetSetting, 0));
+ assertFalse(appsFilter.shouldFilterApplication(DUMMY_ACTOR_TWO_UID, actorSharedSetting,
+ overlaySetting, 0));
+ }
+
private interface WithSettingBuilder {
PackageSettingBuilder withBuilder(PackageSettingBuilder builder);
}
diff --git a/services/tests/servicestests/src/com/android/server/pm/PackageInstallerSessionTest.java b/services/tests/servicestests/src/com/android/server/pm/PackageInstallerSessionTest.java
index b751308..c478ec4 100644
--- a/services/tests/servicestests/src/com/android/server/pm/PackageInstallerSessionTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/PackageInstallerSessionTest.java
@@ -173,6 +173,7 @@
/* createdMillis */ 0L,
/* stageDir */ mTmpDir,
/* stageCid */ null,
+ /* files */ null,
/* prepared */ true,
/* committed */ true,
/* sealed */ false, // Setting to true would trigger some PM logic.
diff --git a/services/tests/servicestests/src/com/android/server/pm/PackageSettingBuilder.java b/services/tests/servicestests/src/com/android/server/pm/PackageSettingBuilder.java
index 5baeede..2473997 100644
--- a/services/tests/servicestests/src/com/android/server/pm/PackageSettingBuilder.java
+++ b/services/tests/servicestests/src/com/android/server/pm/PackageSettingBuilder.java
@@ -22,7 +22,7 @@
import java.io.File;
-class PackageSettingBuilder {
+public class PackageSettingBuilder {
private String mName;
private String mRealName;
private String mCodePath;
diff --git a/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserTypeTest.java b/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserTypeTest.java
index 7aadd87..8e74c90 100644
--- a/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserTypeTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserTypeTest.java
@@ -25,24 +25,32 @@
import static android.content.pm.UserInfo.FLAG_RESTRICTED;
import static android.content.pm.UserInfo.FLAG_SYSTEM;
+import static com.android.server.pm.UserTypeDetails.UNLIMITED_NUMBER_OF_USERS;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.testng.Assert.assertThrows;
import android.content.pm.UserInfo;
import android.content.res.Resources;
+import android.content.res.XmlResourceParser;
+import android.os.Bundle;
import android.os.UserManager;
+import android.util.ArrayMap;
+import androidx.test.InstrumentationRegistry;
import androidx.test.filters.MediumTest;
import androidx.test.runner.AndroidJUnit4;
+import com.android.frameworks.servicestests.R;
+
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import java.util.ArrayList;
-import java.util.Arrays;
-
/**
* Tests for {@link UserTypeDetails} and {@link UserTypeFactory}.
*
@@ -52,9 +60,17 @@
@MediumTest
public class UserManagerServiceUserTypeTest {
+ private Resources mResources;
+
+ @Before
+ public void setup() {
+ mResources = InstrumentationRegistry.getTargetContext().getResources();
+ }
+
@Test
public void testUserTypeBuilder_createUserType() {
- UserTypeDetails type = new UserTypeDetails.Builder()
+ final Bundle restrictions = makeRestrictionsBundle("r1", "r2");
+ final UserTypeDetails type = new UserTypeDetails.Builder()
.setName("a.name")
.setEnabled(true)
.setMaxAllowed(21)
@@ -67,7 +83,7 @@
.setBadgeNoBackground(30)
.setLabel(31)
.setMaxAllowedPerParent(32)
- .setDefaultRestrictions(new ArrayList<>(Arrays.asList("r1", "r2")))
+ .setDefaultRestrictions(restrictions)
.createUserTypeDetails();
assertEquals("a.name", type.getName());
@@ -79,7 +95,8 @@
assertEquals(30, type.getBadgeNoBackground());
assertEquals(31, type.getLabel());
assertEquals(32, type.getMaxAllowedPerParent());
- assertEquals(new ArrayList<>(Arrays.asList("r1", "r2")), type.getDefaultRestrictions());
+ assertTrue(UserRestrictionsUtils.areEqual(restrictions, type.getDefaultRestrictions()));
+ assertNotSame(restrictions, type.getDefaultRestrictions());
assertEquals(23, type.getBadgeLabel(0));
@@ -106,8 +123,8 @@
.createUserTypeDetails();
assertTrue(type.isEnabled());
- assertEquals(UserTypeDetails.UNLIMITED_NUMBER_OF_USERS, type.getMaxAllowed());
- assertEquals(UserTypeDetails.UNLIMITED_NUMBER_OF_USERS, type.getMaxAllowedPerParent());
+ assertEquals(UNLIMITED_NUMBER_OF_USERS, type.getMaxAllowed());
+ assertEquals(UNLIMITED_NUMBER_OF_USERS, type.getMaxAllowedPerParent());
assertEquals(FLAG_FULL, type.getDefaultUserInfoFlags());
assertEquals(Resources.ID_NULL, type.getIconBadge());
assertEquals(Resources.ID_NULL, type.getBadgePlain());
@@ -185,8 +202,173 @@
UserInfo.getDefaultUserType(FLAG_EPHEMERAL));
}
+ /** Tests {@link UserTypeFactory#customizeBuilders} for a reasonable xml file. */
+ @Test
+ public void testUserTypeFactoryCustomize_profile() throws Exception {
+ final String userTypeAosp1 = "android.test.1"; // Profile user that is not customized
+ final String userTypeAosp2 = "android.test.2"; // Profile user that is customized
+ final String userTypeOem1 = "custom.test.1"; // Custom-defined profile
+
+ // Mock some "AOSP defaults".
+ final Bundle restrictions = makeRestrictionsBundle("no_config_vpn", "no_config_tethering");
+ final ArrayMap<String, UserTypeDetails.Builder> builders = new ArrayMap<>();
+ builders.put(userTypeAosp1, new UserTypeDetails.Builder()
+ .setName(userTypeAosp1)
+ .setBaseType(FLAG_PROFILE)
+ .setMaxAllowedPerParent(31)
+ .setDefaultRestrictions(restrictions));
+ builders.put(userTypeAosp2, new UserTypeDetails.Builder()
+ .setName(userTypeAosp1)
+ .setBaseType(FLAG_PROFILE)
+ .setMaxAllowedPerParent(32)
+ .setIconBadge(401)
+ .setBadgeColors(402, 403, 404)
+ .setDefaultRestrictions(restrictions));
+
+ final XmlResourceParser parser = mResources.getXml(R.xml.usertypes_test_profile);
+ UserTypeFactory.customizeBuilders(builders, parser);
+
+ // userTypeAosp1 should not be modified.
+ UserTypeDetails aospType = builders.get(userTypeAosp1).createUserTypeDetails();
+ assertEquals(31, aospType.getMaxAllowedPerParent());
+ assertEquals(Resources.ID_NULL, aospType.getIconBadge());
+ assertTrue(UserRestrictionsUtils.areEqual(restrictions, aospType.getDefaultRestrictions()));
+
+ // userTypeAosp2 should be modified.
+ aospType = builders.get(userTypeAosp2).createUserTypeDetails();
+ assertEquals(12, aospType.getMaxAllowedPerParent());
+ assertEquals(com.android.internal.R.drawable.ic_corp_icon_badge_case,
+ aospType.getIconBadge());
+ assertEquals(Resources.ID_NULL, aospType.getBadgePlain()); // No resId for 'garbage'
+ assertEquals(com.android.internal.R.drawable.ic_corp_badge_no_background,
+ aospType.getBadgeNoBackground());
+ assertEquals(com.android.internal.R.string.managed_profile_label_badge,
+ aospType.getBadgeLabel(0));
+ assertEquals(com.android.internal.R.string.managed_profile_label_badge_2,
+ aospType.getBadgeLabel(1));
+ assertEquals(com.android.internal.R.string.managed_profile_label_badge_2,
+ aospType.getBadgeLabel(2));
+ assertEquals(com.android.internal.R.string.managed_profile_label_badge_2,
+ aospType.getBadgeLabel(3));
+ assertEquals(com.android.internal.R.color.profile_badge_1,
+ aospType.getBadgeColor(0));
+ assertEquals(com.android.internal.R.color.profile_badge_2,
+ aospType.getBadgeColor(1));
+ assertEquals(com.android.internal.R.color.profile_badge_2,
+ aospType.getBadgeColor(2));
+ assertEquals(com.android.internal.R.color.profile_badge_2,
+ aospType.getBadgeColor(3));
+ assertTrue(UserRestrictionsUtils.areEqual(
+ makeRestrictionsBundle("no_remove_user", "no_bluetooth"),
+ aospType.getDefaultRestrictions()));
+
+ // userTypeOem1 should be created.
+ UserTypeDetails.Builder customType = builders.get(userTypeOem1);
+ assertNotNull(customType);
+ assertEquals(14, customType.createUserTypeDetails().getMaxAllowedPerParent());
+ }
+
+ /** Tests {@link UserTypeFactory#customizeBuilders} for customizing a FULL user. */
+ @Test
+ public void testUserTypeFactoryCustomize_full() throws Exception {
+ final String userTypeFull = "android.test.1";
+
+ // Mock "AOSP default".
+ final Bundle restrictions = makeRestrictionsBundle("no_config_vpn", "no_config_tethering");
+ final ArrayMap<String, UserTypeDetails.Builder> builders = new ArrayMap<>();
+ builders.put(userTypeFull, new UserTypeDetails.Builder()
+ .setName(userTypeFull)
+ .setBaseType(FLAG_FULL)
+ .setDefaultRestrictions(restrictions));
+
+ final XmlResourceParser parser = mResources.getXml(R.xml.usertypes_test_full);
+ UserTypeFactory.customizeBuilders(builders, parser);
+
+ UserTypeDetails details = builders.get(userTypeFull).createUserTypeDetails();
+ assertEquals(UNLIMITED_NUMBER_OF_USERS, details.getMaxAllowedPerParent());
+ assertTrue(UserRestrictionsUtils.areEqual(
+ makeRestrictionsBundle("no_remove_user", "no_bluetooth"),
+ details.getDefaultRestrictions()));
+ assertEquals(Resources.ID_NULL, details.getBadgeColor(0));
+ }
+
+ /**
+ * Tests {@link UserTypeFactory#customizeBuilders} when custom user type deletes the
+ * badge-colors and restrictions.
+ */
+ @Test
+ public void testUserTypeFactoryCustomize_eraseArray() throws Exception {
+ final String typeName = "android.test";
+
+ final ArrayMap<String, UserTypeDetails.Builder> builders = new ArrayMap<>();
+ builders.put(typeName, new UserTypeDetails.Builder()
+ .setName(typeName)
+ .setBaseType(FLAG_PROFILE)
+ .setMaxAllowedPerParent(1)
+ .setBadgeColors(501, 502)
+ .setDefaultRestrictions(makeRestrictionsBundle("r1")));
+
+ final XmlResourceParser parser = mResources.getXml(R.xml.usertypes_test_eraseArray);
+ UserTypeFactory.customizeBuilders(builders, parser);
+
+ UserTypeDetails typeDetails = builders.get(typeName).createUserTypeDetails();
+ assertEquals(2, typeDetails.getMaxAllowedPerParent());
+ assertEquals(Resources.ID_NULL, typeDetails.getBadgeColor(0));
+ assertEquals(Resources.ID_NULL, typeDetails.getBadgeColor(1));
+ assertTrue(typeDetails.getDefaultRestrictions().isEmpty());
+ }
+
+ /** Tests {@link UserTypeFactory#customizeBuilders} when custom user type has illegal name. */
+ @Test
+ public void testUserTypeFactoryCustomize_illegalOemName() throws Exception {
+ final String userTypeAosp = "android.aosp.legal";
+ final String userTypeOem = "android.oem.illegal.name"; // Custom-defined profile
+
+ final ArrayMap<String, UserTypeDetails.Builder> builders = new ArrayMap<>();
+ builders.put(userTypeAosp, new UserTypeDetails.Builder()
+ .setName(userTypeAosp)
+ .setBaseType(FLAG_PROFILE)
+ .setMaxAllowedPerParent(21));
+
+ final XmlResourceParser parser = mResources.getXml(R.xml.usertypes_test_illegalOemName);
+
+ // parser is illegal because non-AOSP user types cannot be prefixed with "android.".
+ assertThrows(IllegalArgumentException.class,
+ () -> UserTypeFactory.customizeBuilders(builders, parser));
+ }
+
+ /**
+ * Tests {@link UserTypeFactory#customizeBuilders} when illegally customizing a non-profile as
+ * a profile.
+ */
+ @Test
+ public void testUserTypeFactoryCustomize_illegalUserBaseType() throws Exception {
+ final String userTypeFull = "android.test";
+
+ final ArrayMap<String, UserTypeDetails.Builder> builders = new ArrayMap<>();
+ builders.put(userTypeFull, new UserTypeDetails.Builder()
+ .setName(userTypeFull)
+ .setBaseType(FLAG_FULL)
+ .setMaxAllowedPerParent(21));
+
+ XmlResourceParser parser = mResources.getXml(R.xml.usertypes_test_illegalUserBaseType);
+
+ // parser is illegal because userTypeFull is FULL but the tag is for profile-type.
+ assertThrows(IllegalArgumentException.class,
+ () -> UserTypeFactory.customizeBuilders(builders, parser));
+ }
+
/** Returns a minimal {@link UserTypeDetails.Builder} that can legitimately be created. */
private UserTypeDetails.Builder getMinimalBuilder() {
return new UserTypeDetails.Builder().setName("name").setBaseType(FLAG_FULL);
}
+
+ /** Creates a Bundle of the given String restrictions, each set to true. */
+ private Bundle makeRestrictionsBundle(String ... restrictions) {
+ final Bundle bundle = new Bundle();
+ for (String restriction : restrictions) {
+ bundle.putBoolean(restriction, true);
+ }
+ return bundle;
+ }
}
diff --git a/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java b/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java
index dee79bb..b3f1bcd6 100644
--- a/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java
@@ -278,26 +278,12 @@
@MediumTest
public void testSetUserAdmin() throws Exception {
UserInfo userInfo = createUser("SecondaryUser", /*flags=*/ 0);
-
- // Assert user is not admin and has SMS and calls restrictions.
assertFalse(userInfo.isAdmin());
- assertTrue(mUserManager.hasUserRestriction(UserManager.DISALLOW_SMS,
- userInfo.getUserHandle()));
- assertTrue(mUserManager.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS,
- userInfo.getUserHandle()));
- // Assign admin privileges.
mUserManager.setUserAdmin(userInfo.id);
- // Refresh.
userInfo = mUserManager.getUserInfo(userInfo.id);
-
- // Verify user became admin and SMS and call restrictions are lifted.
assertTrue(userInfo.isAdmin());
- assertFalse(mUserManager.hasUserRestriction(UserManager.DISALLOW_SMS,
- userInfo.getUserHandle()));
- assertFalse(mUserManager.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS,
- userInfo.getUserHandle()));
}
@MediumTest
@@ -631,6 +617,21 @@
}
@MediumTest
+ public void testDefaultRestrictionsApplied() throws Exception {
+ final UserInfo userInfo = createUser("Useroid", UserManager.USER_TYPE_FULL_SECONDARY, 0);
+ final UserTypeDetails userTypeDetails =
+ UserTypeFactory.getUserTypes().get(UserManager.USER_TYPE_FULL_SECONDARY);
+ final Bundle expectedRestrictions = userTypeDetails.getDefaultRestrictions();
+ // Note this can fail if DO unset those restrictions.
+ for (String restriction : expectedRestrictions.keySet()) {
+ if (expectedRestrictions.getBoolean(restriction)) {
+ assertTrue(
+ mUserManager.hasUserRestriction(restriction, UserHandle.of(userInfo.id)));
+ }
+ }
+ }
+
+ @MediumTest
public void testSetDefaultGuestRestrictions() {
final Bundle origGuestRestrictions = mUserManager.getDefaultGuestRestrictions();
Bundle restrictions = new Bundle();
diff --git a/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorStrategyTest.java b/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorStrategyTest.java
index cb49fef..2429cfc 100644
--- a/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorStrategyTest.java
+++ b/services/tests/servicestests/src/com/android/server/timezonedetector/TimeZoneDetectorStrategyTest.java
@@ -453,7 +453,7 @@
@Override
public boolean isDeviceTimeZoneInitialized() {
- return mTimeZoneId != null;
+ return mTimeZoneId.getLatest() != null;
}
@Override
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationComparatorTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationComparatorTest.java
index 0b4760d..a328568 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationComparatorTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationComparatorTest.java
@@ -23,6 +23,7 @@
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.spy;
import android.app.Notification;
import android.app.NotificationChannel;
@@ -271,6 +272,18 @@
}
@Test
+ public void testRankingScoreOverrides() {
+ NotificationComparator comp = new NotificationComparator(mContext);
+ NotificationRecord recordMinCallNonInterruptive = spy(mRecordMinCallNonInterruptive);
+ assertTrue(comp.compare(mRecordMinCall, recordMinCallNonInterruptive) < 0);
+
+ when(recordMinCallNonInterruptive.getRankingScore()).thenReturn(1f);
+ assertTrue(comp.compare(mRecordMinCall, recordMinCallNonInterruptive) > 0);
+ assertTrue(comp.compare(mRecordCheater, recordMinCallNonInterruptive) > 0);
+ assertTrue(comp.compare(mRecordColorizedCall, recordMinCallNonInterruptive) < 0);
+ }
+
+ @Test
public void testMessaging() {
NotificationComparator comp = new NotificationComparator(mContext);
assertTrue(comp.isImportantMessaging(mRecordInlineReply));
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java
index 7c22350..fab6b7f 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java
@@ -52,11 +52,13 @@
import android.media.AudioAttributes;
import android.metrics.LogMaker;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;
import android.service.notification.Adjustment;
import android.service.notification.StatusBarNotification;
+import android.widget.RemoteViews;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
@@ -114,7 +116,9 @@
when(mMockContext.getResources()).thenReturn(getContext().getResources());
when(mMockContext.getPackageManager()).thenReturn(mPm);
- when(mMockContext.getApplicationInfo()).thenReturn(new ApplicationInfo());
+ ApplicationInfo appInfo = new ApplicationInfo();
+ appInfo.targetSdkVersion = Build.VERSION_CODES.O;
+ when(mMockContext.getApplicationInfo()).thenReturn(appInfo);
}
private StatusBarNotification getNotification(String pkg, boolean noisy, boolean defaultSound,
@@ -168,6 +172,28 @@
return new StatusBarNotification(pkg, pkg, id1, tag1, uid, uid, n, mUser, null, uid);
}
+ private StatusBarNotification getStyledNotification(boolean customContent, boolean customBig,
+ boolean customHeadsUp, Notification.Style style) {
+ final Builder builder = new Builder(mMockContext)
+ .setContentTitle("foo")
+ .setSmallIcon(android.R.drawable.sym_def_app_icon);
+ if (style != null) {
+ builder.setStyle(style);
+ }
+ if (customContent) {
+ builder.setCustomContentView(mock(RemoteViews.class));
+ }
+ if (customBig) {
+ builder.setCustomBigContentView(mock(RemoteViews.class));
+ }
+ if (customHeadsUp) {
+ builder.setCustomHeadsUpContentView(mock(RemoteViews.class));
+ }
+
+ Notification n = builder.build();
+ return new StatusBarNotification(pkg, pkg, id1, tag1, uid, uid, n, mUser, null, uid);
+ }
+
//
// Tests
//
@@ -999,4 +1025,74 @@
assertEquals(IMPORTANCE_LOW, record.getImportance());
}
+
+ @Test
+ public void testHasUndecoratedRemoteViews_NoRemoteViews() {
+ StatusBarNotification sbn = getStyledNotification(false, false, false, null);
+ NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel);
+
+ assertFalse("false positive detection", record.hasUndecoratedRemoteView());
+ }
+
+ @Test
+ public void testHasUndecoratedRemoteViews_NoRemoteViewsWithStyle() {
+ StatusBarNotification sbn = getStyledNotification(false, false, false,
+ new Notification.BigPictureStyle());
+ NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel);
+
+ assertFalse("false positive detection", record.hasUndecoratedRemoteView());
+ }
+
+ @Test
+ public void testHasUndecoratedRemoteViews_UndecoratedContent() {
+ StatusBarNotification sbn = getStyledNotification(true, false, false, null);
+ NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel);
+
+ assertTrue("false negative detection", record.hasUndecoratedRemoteView());
+ }
+
+
+ @Test
+ public void testHasUndecoratedRemoteViews_UndecoratedBig() {
+ StatusBarNotification sbn = getStyledNotification(false, true, false, null);
+ NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel);
+
+ assertTrue("false negative detection", record.hasUndecoratedRemoteView());
+ }
+
+
+ @Test
+ public void testHasUndecoratedRemoteViews_UndecoratedHeadsup() {
+ StatusBarNotification sbn = getStyledNotification(false, false, true, null);
+ NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel);
+
+ assertTrue("false negative detection", record.hasUndecoratedRemoteView());
+ }
+
+ @Test
+ public void testHasUndecoratedRemoteViews_DecoratedRemoteViews() {
+ StatusBarNotification sbn = getStyledNotification(true, true, true,
+ new Notification.DecoratedCustomViewStyle());
+ NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel);
+
+ assertFalse("false positive detection", record.hasUndecoratedRemoteView());
+ }
+
+ @Test
+ public void testHasUndecoratedRemoteViews_DecoratedMediaRemoteViews() {
+ StatusBarNotification sbn = getStyledNotification(true, true, true,
+ new Notification.DecoratedMediaCustomViewStyle());
+ NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel);
+
+ assertFalse("false positive detection", record.hasUndecoratedRemoteView());
+ }
+
+ @Test
+ public void testHasUndecoratedRemoteViews_UndecoratedWrongStyle() {
+ StatusBarNotification sbn = getStyledNotification(true, true, true,
+ new Notification.BigPictureStyle());
+ NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel);
+
+ assertTrue("false negative detection", record.hasUndecoratedRemoteView());
+ }
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityDisplayTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityDisplayTests.java
index 5928641..9c17de9 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityDisplayTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityDisplayTests.java
@@ -47,7 +47,7 @@
import org.junit.runner.RunWith;
/**
- * Tests for the {@link ActivityDisplay} class.
+ * Tests for the {@link DisplayContent} class.
*
* Build/Install/Run:
* atest WmTests:ActivityDisplayTests
@@ -55,12 +55,13 @@
@SmallTest
@Presubmit
@RunWith(WindowTestRunner.class)
+// TODO(b/144248496): Merge to DisplayContentTests
public class ActivityDisplayTests extends ActivityTestsBase {
@Test
public void testLastFocusedStackIsUpdatedWhenMovingStack() {
// Create a stack at bottom.
- final ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
+ final DisplayContent display = mRootActivityContainer.getDefaultDisplay();
final ActivityStack stack =
new StackBuilder(mRootActivityContainer).setOnTop(!ON_TOP).build();
final ActivityStack prevFocusedStack = display.getFocusedStack();
@@ -103,13 +104,13 @@
}
/**
- * Test {@link ActivityDisplay#mPreferredTopFocusableStack} will be cleared when the stack is
+ * Test {@link DisplayContent#mPreferredTopFocusableStack} will be cleared when the stack is
* removed or moved to back, and the focused stack will be according to z-order.
*/
@Test
public void testStackShouldNotBeFocusedAfterMovingToBackOrRemoving() {
// Create a display which only contains 2 stacks.
- final ActivityDisplay display = addNewActivityDisplayAt(ActivityDisplay.POSITION_TOP);
+ final DisplayContent display = addNewDisplayContentAt(DisplayContent.POSITION_TOP);
final ActivityStack stack1 = createFullscreenStackWithSimpleActivityAt(display);
final ActivityStack stack2 = createFullscreenStackWithSimpleActivityAt(display);
@@ -128,13 +129,13 @@
}
/**
- * Verifies {@link ActivityDisplay#remove} should not resume home stack on the removing display.
+ * Verifies {@link DisplayContent#remove} should not resume home stack on the removing display.
*/
@Test
public void testNotResumeHomeStackOnRemovingDisplay() {
// Create a display which supports system decoration and allows reparenting stacks to
// another display when the display is removed.
- final ActivityDisplay display = new TestActivityDisplay.Builder(
+ final DisplayContent display = new TestDisplayContent.Builder(
mService, 1000, 1500).setSystemDecorations(true).build();
doReturn(false).when(display).shouldDestroyContentOnRemove();
@@ -154,7 +155,7 @@
verify(homeStack, never()).resumeTopActivityUncheckedLocked(any(), any());
}
- private ActivityStack createFullscreenStackWithSimpleActivityAt(ActivityDisplay display) {
+ private ActivityStack createFullscreenStackWithSimpleActivityAt(DisplayContent display) {
final ActivityStack fullscreenStack = display.createStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, ON_TOP);
final Task fullscreenTask = new TaskBuilder(mService.mStackSupervisor)
@@ -168,7 +169,7 @@
*/
@Test
public void testTopRunningActivity() {
- final ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
+ final DisplayContent display = mRootActivityContainer.getDefaultDisplay();
final KeyguardController keyguard = mSupervisor.getKeyguardController();
final ActivityStack stack = new StackBuilder(mRootActivityContainer).build();
final ActivityRecord activity = stack.getTopNonFinishingActivity();
@@ -208,7 +209,7 @@
assertTopRunningActivity(showWhenLockedActivity, display);
}
- private static void assertTopRunningActivity(ActivityRecord top, ActivityDisplay display) {
+ private static void assertTopRunningActivity(ActivityRecord top, DisplayContent display) {
assertEquals(top, display.topRunningActivity());
assertEquals(top, display.topRunningActivity(true /* considerKeyguardState */));
}
@@ -218,7 +219,7 @@
*/
@Test
public void testAlwaysOnTopStackLocation() {
- final ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
+ final DisplayContent display = mRootActivityContainer.getDefaultDisplay();
final ActivityStack alwaysOnTopStack = display.createStack(WINDOWING_MODE_FREEFORM,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
final ActivityRecord activity = new ActivityBuilder(mService).setCreateTask(true)
@@ -283,7 +284,7 @@
}
private void removeStackTests(Runnable runnable) {
- final ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
+ final DisplayContent display = mRootActivityContainer.getDefaultDisplay();
final ActivityStack stack1 = display.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, ON_TOP);
final ActivityStack stack2 = display.createStack(WINDOWING_MODE_FULLSCREEN,
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
index 7a449b3..89723d1 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -635,8 +635,8 @@
final ActivityStack stack1 = new StackBuilder(mRootActivityContainer).build();
mStack.moveToFront("test");
// The stack2 is needed here for moving back to simulate the
- // {@link ActivityDisplay#mPreferredTopFocusableStack} is cleared, so
- // {@link ActivityDisplay#getFocusedStack} will rely on the order of focusable-and-visible
+ // {@link DisplayContent#mPreferredTopFocusableStack} is cleared, so
+ // {@link DisplayContent#getFocusedStack} will rely on the order of focusable-and-visible
// stacks. Then when mActivity is finishing, its stack will be invisible (no running
// activities in the stack) that is the key condition to verify.
final ActivityStack stack2 = new StackBuilder(mRootActivityContainer).build();
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStackSupervisorTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStackSupervisorTests.java
index 0219539..530adb5 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStackSupervisorTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStackSupervisorTests.java
@@ -112,7 +112,7 @@
@Test
public void testHandleNonResizableTaskOnSecondaryDisplay() {
// Create an unresizable task on secondary display.
- final ActivityDisplay newDisplay = addNewActivityDisplayAt(ActivityDisplay.POSITION_TOP);
+ final DisplayContent newDisplay = addNewDisplayContentAt(DisplayContent.POSITION_TOP);
final ActivityStack stack = new StackBuilder(mRootActivityContainer)
.setDisplay(newDisplay).build();
final ActivityRecord unresizableActivity = stack.getTopNonFinishingActivity();
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java
index 47f454e..8a1a10d 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStackTests.java
@@ -54,7 +54,6 @@
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import android.content.ComponentName;
@@ -78,7 +77,7 @@
@Presubmit
@RunWith(WindowTestRunner.class)
public class ActivityStackTests extends ActivityTestsBase {
- private ActivityDisplay mDefaultDisplay;
+ private DisplayContent mDefaultDisplay;
private ActivityStack mStack;
private Task mTask;
@@ -279,7 +278,7 @@
@Test
public void testMoveStackToBackIncludingParent() {
- final ActivityDisplay display = addNewActivityDisplayAt(ActivityDisplay.POSITION_TOP);
+ final DisplayContent display = addNewDisplayContentAt(DisplayContent.POSITION_TOP);
final ActivityStack stack1 = createStackForShouldBeVisibleTest(display,
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
final ActivityStack stack2 = createStackForShouldBeVisibleTest(display,
@@ -815,7 +814,7 @@
@SuppressWarnings("TypeParameterUnusedInFormals")
private ActivityStack createStackForShouldBeVisibleTest(
- ActivityDisplay display, int windowingMode, int activityType, boolean onTop) {
+ DisplayContent display, int windowingMode, int activityType, boolean onTop) {
final ActivityStack stack;
if (activityType == ACTIVITY_TYPE_HOME) {
// Home stack and activity are created in ActivityTestsBase#setupActivityManagerService
@@ -998,7 +997,7 @@
@Test
public void testFinishCurrentActivity() {
// Create 2 activities on a new display.
- final ActivityDisplay display = addNewActivityDisplayAt(ActivityDisplay.POSITION_TOP);
+ final DisplayContent display = addNewDisplayContentAt(DisplayContent.POSITION_TOP);
final ActivityStack stack1 = createStackForShouldBeVisibleTest(display,
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
final ActivityStack stack2 = createStackForShouldBeVisibleTest(display,
@@ -1065,6 +1064,7 @@
StackOrderChangedListener listener = new StackOrderChangedListener();
mDefaultDisplay.registerStackOrderChangedListener(listener);
try {
+ mStack.mReparenting = true;
mDefaultDisplay.addStack(mStack, 0);
} finally {
mDefaultDisplay.unregisterStackOrderChangedListener(listener);
@@ -1156,10 +1156,10 @@
private void verifyShouldSleepActivities(boolean focusedStack,
boolean keyguardGoingAway, boolean displaySleeping, boolean expected) {
- final ActivityDisplay display = mock(ActivityDisplay.class);
+ final DisplayContent display = mock(DisplayContent.class);
final KeyguardController keyguardController = mSupervisor.getKeyguardController();
- doReturn(display).when(mRootActivityContainer).getActivityDisplay(anyInt());
+ doReturn(display).when(mStack).getDisplay();
doReturn(keyguardGoingAway).when(keyguardController).isKeyguardGoingAway();
doReturn(displaySleeping).when(display).isSleeping();
doReturn(focusedStack).when(mStack).isFocusedStackOnDisplay();
@@ -1168,7 +1168,7 @@
}
private static class StackOrderChangedListener
- implements ActivityDisplay.OnStackOrderChangedListener {
+ implements DisplayContent.OnStackOrderChangedListener {
public boolean mChanged = false;
@Override
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
index 018c10a..7e22dfc 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
@@ -47,9 +47,9 @@
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.times;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
-import static com.android.server.wm.ActivityDisplay.POSITION_BOTTOM;
-import static com.android.server.wm.ActivityDisplay.POSITION_TOP;
import static com.android.server.wm.ActivityTaskManagerService.ANIMATE;
+import static com.android.server.wm.WindowContainer.POSITION_BOTTOM;
+import static com.android.server.wm.WindowContainer.POSITION_TOP;
import static com.google.common.truth.Truth.assertThat;
@@ -502,7 +502,7 @@
*/
@Test
public void testTaskModeViolation() {
- final ActivityDisplay display = mService.mRootActivityContainer.getDefaultDisplay();
+ final DisplayContent display = mService.mRootActivityContainer.getDefaultDisplay();
display.removeAllTasks();
assertNoTasks(display);
@@ -517,7 +517,7 @@
assertNoTasks(display);
}
- private void assertNoTasks(ActivityDisplay display) {
+ private void assertNoTasks(DisplayContent display) {
for (int i = display.getStackCount() - 1; i >= 0; --i) {
final ActivityStack stack = display.getStackAt(i);
assertFalse(stack.hasChild());
@@ -761,8 +761,8 @@
false /* mockGetLaunchStack */);
// Create a secondary display at bottom.
- final TestActivityDisplay secondaryDisplay =
- new TestActivityDisplay.Builder(mService, 1000, 1500)
+ final TestDisplayContent secondaryDisplay =
+ new TestDisplayContent.Builder(mService, 1000, 1500)
.setPosition(POSITION_BOTTOM).build();
final ActivityStack stack = secondaryDisplay.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
@@ -800,8 +800,8 @@
false /* mockGetLaunchStack */);
// Create a secondary display with an activity.
- final TestActivityDisplay secondaryDisplay =
- new TestActivityDisplay.Builder(mService, 1000, 1500).build();
+ final TestDisplayContent secondaryDisplay =
+ new TestDisplayContent.Builder(mService, 1000, 1500).build();
mRootActivityContainer.addChild(secondaryDisplay, POSITION_TOP);
final ActivityRecord singleTaskActivity = createSingleTaskActivityOn(
secondaryDisplay.createStack(WINDOWING_MODE_FULLSCREEN,
@@ -853,7 +853,7 @@
false /* mockGetLaunchStack */);
// Create a secondary display at bottom.
- final TestActivityDisplay secondaryDisplay = addNewActivityDisplayAt(POSITION_BOTTOM);
+ final TestDisplayContent secondaryDisplay = addNewDisplayContentAt(POSITION_BOTTOM);
secondaryDisplay.createStack(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD,
true /* onTop */);
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java
index 07b7cf4..591ed51 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java
@@ -126,7 +126,7 @@
assertEquals(0, removed.size());
added.clear();
// Check adding a display
- ActivityDisplay newDisp1 = new TestActivityDisplay.Builder(mService, 600, 800).build();
+ DisplayContent newDisp1 = new TestDisplayContent.Builder(mService, 600, 800).build();
assertEquals(1, added.size());
assertEquals(0, changed.size());
assertEquals(0, removed.size());
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java
index 0021cc5..b72cc94 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityTestsBase.java
@@ -77,9 +77,9 @@
mRootActivityContainer = mService.mRootActivityContainer;
}
- /** Creates and adds a {@link TestActivityDisplay} to supervisor at the given position. */
- TestActivityDisplay addNewActivityDisplayAt(int position) {
- return new TestActivityDisplay.Builder(mService, 1000, 1500).setPosition(position).build();
+ /** Creates and adds a {@link TestDisplayContent} to supervisor at the given position. */
+ TestDisplayContent addNewDisplayContentAt(int position) {
+ return new TestDisplayContent.Builder(mService, 1000, 1500).setPosition(position).build();
}
/** Sets the default minimum task size to 1 so that tests can use small task sizes */
@@ -381,7 +381,7 @@
static class StackBuilder {
private final RootActivityContainer mRootActivityContainer;
- private ActivityDisplay mDisplay;
+ private DisplayContent mDisplay;
private int mStackId = -1;
private int mWindowingMode = WINDOWING_MODE_UNDEFINED;
private int mActivityType = ACTIVITY_TYPE_STANDARD;
@@ -408,15 +408,8 @@
return this;
}
- // TODO(display-merge): Remove
- StackBuilder setDisplay(ActivityDisplay display) {
- mDisplay = display;
- return this;
- }
-
StackBuilder setDisplay(DisplayContent display) {
- // TODO(display-merge): Remove cast
- mDisplay = (ActivityDisplay) display;
+ mDisplay = display;
return this;
}
@@ -449,7 +442,7 @@
if (mOnTop) {
// We move the task to front again in order to regain focus after activity
// added to the stack.
- // Or {@link ActivityDisplay#mPreferredTopFocusableStack} could be other
+ // Or {@link DisplayContent#mPreferredTopFocusableStack} could be other
// stacks (e.g. home stack).
stack.moveToFront("createActivityStack");
} else {
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java
index 6f1e6df..0c7fad4 100644
--- a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java
@@ -181,7 +181,7 @@
@Test
public void testLandscapeSeascapeRotationByPolicy() {
- // This instance has been spied in {@link TestActivityDisplay}.
+ // This instance has been spied in {@link TestDisplayContent}.
final DisplayRotation displayRotation = mDisplayContent.getDisplayRotation();
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
index 14c09eb..ccbafd4 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -768,9 +768,8 @@
activity.setRequestedOrientation(newOrientation);
- // TODO(display-merge): Remove cast
- verify((ActivityDisplay) dc, never()).updateDisplayOverrideConfigurationLocked(any(),
- eq(activity), anyBoolean(), same(null));
+ verify(dc, never()).updateDisplayOverrideConfigurationLocked(any(), eq(activity),
+ anyBoolean(), same(null));
assertEquals(dc.getDisplayRotation().getUserRotation(), dc.getRotation());
}
@@ -964,7 +963,7 @@
invocation -> {
continued[0] = true;
return true;
- }).when((ActivityDisplay) dc).updateDisplayOverrideConfigurationLocked();
+ }).when(dc).updateDisplayOverrideConfigurationLocked();
final boolean[] called = new boolean[1];
mWm.mDisplayRotationController =
new IDisplayWindowRotationController.Stub() {
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java
index 62ab11c..de73645 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java
@@ -36,6 +36,7 @@
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_SCREEN_DECOR;
+import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_ONLY_DRAW_BOTTOM_BAR_BACKGROUND;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
@@ -45,6 +46,7 @@
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
+import static org.junit.Assume.assumeTrue;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;
@@ -55,6 +57,10 @@
import android.util.Pair;
import android.view.DisplayCutout;
import android.view.DisplayInfo;
+import android.view.InsetsState;
+import android.view.ViewRootImpl;
+import android.view.WindowInsets.Side;
+import android.view.WindowInsets.Type;
import android.view.WindowManager;
import androidx.test.filters.FlakyTest;
@@ -97,8 +103,6 @@
final WindowManager.LayoutParams attrs = mWindow.mAttrs;
attrs.width = MATCH_PARENT;
attrs.height = MATCH_PARENT;
- attrs.flags =
- FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
attrs.format = PixelFormat.TRANSLUCENT;
}
@@ -134,8 +138,186 @@
}
@Test
+ public void layoutWindowLw_fitStatusBars() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ mWindow.mAttrs.setFitWindowInsetsTypes(Type.statusBars());
+ addWindow(mWindow);
+
+ mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
+ mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
+
+ assertInsetByTopBottom(mWindow.getStableFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDisplayFrameLw(), STATUS_BAR_HEIGHT, 0);
+ assertInsetByTopBottom(mWindow.getParentFrame(), STATUS_BAR_HEIGHT, 0);
+ assertInsetByTopBottom(mWindow.getVisibleFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getContentFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDecorFrame(), 0, 0);
+ }
+
+ @Test
+ public void layoutWindowLw_fitNavigationBars() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ mWindow.mAttrs.setFitWindowInsetsTypes(Type.navigationBars());
+ addWindow(mWindow);
+
+ mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
+ mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
+
+ assertInsetByTopBottom(mWindow.getStableFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDisplayFrameLw(), 0, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getParentFrame(), 0, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getVisibleFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getContentFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDecorFrame(), 0, 0);
+ }
+
+ @Test
public void layoutWindowLw_appDrawsBars() {
- mWindow.mAttrs.flags |= FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
+ assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ mWindow.mAttrs.flags = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
+ mWindow.mAttrs.setFitWindowInsetsTypes(Type.systemBars());
+ addWindow(mWindow);
+
+ mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
+ mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
+
+ assertInsetByTopBottom(mWindow.getStableFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDisplayFrameLw(), 0, 0);
+ assertInsetByTopBottom(mWindow.getParentFrame(), 0, 0);
+ assertInsetByTopBottom(mWindow.getVisibleFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getContentFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDecorFrame(), 0, 0);
+ }
+
+ @Test
+ public void layoutWindowLw_forceAppDrawBars() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ mWindow.mAttrs.privateFlags = PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS;
+ mWindow.mAttrs.setFitWindowInsetsTypes(Type.systemBars());
+ addWindow(mWindow);
+
+ mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
+ mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
+
+ assertInsetByTopBottom(mWindow.getStableFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDisplayFrameLw(), 0, 0);
+ assertInsetByTopBottom(mWindow.getParentFrame(), 0, 0);
+ assertInsetByTopBottom(mWindow.getVisibleFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getContentFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDecorFrame(), 0, 0);
+ }
+
+ @Test
+ public void layoutWindowLw_onlyDrawBottomBar() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ mWindow.mAttrs.flags = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
+ mWindow.mAttrs.privateFlags = PRIVATE_FLAG_ONLY_DRAW_BOTTOM_BAR_BACKGROUND;
+ mWindow.mAttrs.setFitWindowInsetsTypes(Type.systemBars());
+ addWindow(mWindow);
+
+ mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
+ mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
+
+ assertInsetByTopBottom(mWindow.getStableFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDisplayFrameLw(), STATUS_BAR_HEIGHT, 0);
+ assertInsetByTopBottom(mWindow.getParentFrame(), STATUS_BAR_HEIGHT, 0);
+ assertInsetByTopBottom(mWindow.getVisibleFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getContentFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDecorFrame(), 0, 0);
+ }
+
+ @Test
+ public void layoutWindowLw_fitAllSides() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ mWindow.mAttrs.setFitWindowInsetsSides(Side.all());
+ addWindow(mWindow);
+
+ mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
+ mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
+
+ assertInsetByTopBottom(mWindow.getStableFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDisplayFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getParentFrame(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getVisibleFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getContentFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDecorFrame(), 0, 0);
+ }
+
+ @Test
+ public void layoutWindowLw_fitTopOnly() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ mWindow.mAttrs.setFitWindowInsetsSides(Side.TOP);
+ addWindow(mWindow);
+
+ mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
+ mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
+
+ assertInsetByTopBottom(mWindow.getStableFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDisplayFrameLw(), STATUS_BAR_HEIGHT, 0);
+ assertInsetByTopBottom(mWindow.getParentFrame(), STATUS_BAR_HEIGHT, 0);
+ assertInsetByTopBottom(mWindow.getVisibleFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getContentFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDecorFrame(), 0, 0);
+ }
+
+ @Test
+ public void layoutWindowLw_fitMax() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ final InsetsState state =
+ mDisplayContent.getInsetsStateController().getInsetsForDispatch(mWindow);
+ state.getSource(InsetsState.ITYPE_STATUS_BAR).setVisible(false);
+ state.getSource(InsetsState.ITYPE_NAVIGATION_BAR).setVisible(false);
+ mWindow.mAttrs.setFitIgnoreVisibility(true);
+ addWindow(mWindow);
+
+ mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
+ mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
+
+ assertInsetByTopBottom(mWindow.getStableFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDisplayFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getParentFrame(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getVisibleFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getContentFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDecorFrame(), 0, 0);
+ }
+
+ @Test
+ public void layoutWindowLw_fitNonMax() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode == ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ final InsetsState state =
+ mDisplayContent.getInsetsStateController().getInsetsForDispatch(mWindow);
+ state.getSource(InsetsState.ITYPE_STATUS_BAR).setVisible(false);
+ state.getSource(InsetsState.ITYPE_NAVIGATION_BAR).setVisible(false);
+ mWindow.mAttrs.setFitIgnoreVisibility(false);
+ addWindow(mWindow);
+
+ mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
+ mDisplayPolicy.layoutWindowLw(mWindow, null, mFrames);
+
+ assertInsetByTopBottom(mWindow.getStableFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDisplayFrameLw(), 0, 0);
+ assertInsetByTopBottom(mWindow.getParentFrame(), 0, 0);
+ assertInsetByTopBottom(mWindow.getVisibleFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getContentFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDecorFrame(), 0, 0);
+ }
+
+ // TODO(b/118118435): remove after migration
+ @Test
+ public void layoutWindowLw_appDrawsBarsLegacy() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
addWindow(mWindow);
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
@@ -148,9 +330,12 @@
assertInsetBy(mWindow.getDisplayFrameLw(), 0, 0, 0, 0);
}
+ // TODO(b/118118435): remove after migration
@Test
public void layoutWindowLw_appWontDrawBars() {
- mWindow.mAttrs.flags &= ~FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
+ assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ mWindow.mAttrs.flags = FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR;
addWindow(mWindow);
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
@@ -163,10 +348,13 @@
assertInsetByTopBottom(mWindow.getDisplayFrameLw(), 0, NAV_BAR_HEIGHT);
}
+ // TODO(b/118118435): remove after migration
@Test
public void layoutWindowLw_appWontDrawBars_forceStatusAndNav() throws Exception {
- mWindow.mAttrs.flags &= ~FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
- mWindow.mAttrs.privateFlags |= PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS;
+ assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
+
+ mWindow.mAttrs.flags = FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR;
+ mWindow.mAttrs.privateFlags = PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS;
addWindow(mWindow);
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
@@ -179,11 +367,14 @@
assertInsetByTopBottom(mWindow.getDisplayFrameLw(), 0, 0);
}
+ // TODO(b/118118435): remove after migration (keyguard dialog is not special with the new logic)
@Test
public void layoutWindowLw_keyguardDialog_hideNav() {
mWindow.mAttrs.type = TYPE_KEYGUARD_DIALOG;
- mWindow.mAttrs.flags |= FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.systemUiVisibility = SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
+ mWindow.mAttrs.setFitWindowInsetsTypes(0 /* types */);
addWindow(mWindow);
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* uiMode */);
@@ -200,6 +391,8 @@
public void layoutWindowLw_withDisplayCutout() {
addDisplayCutout();
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
addWindow(mWindow);
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
@@ -216,6 +409,8 @@
public void layoutWindowLw_withDisplayCutout_never() {
addDisplayCutout();
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
addWindow(mWindow);
@@ -233,7 +428,11 @@
public void layoutWindowLw_withDisplayCutout_layoutFullscreen() {
addDisplayCutout();
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.subtreeSystemUiVisibility |= SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
+ mWindow.mAttrs.setFitWindowInsetsTypes(
+ mWindow.mAttrs.getFitWindowInsetsTypes() & ~Type.statusBars());
addWindow(mWindow);
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
@@ -243,14 +442,18 @@
assertInsetByTopBottom(mWindow.getStableFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
assertInsetByTopBottom(mWindow.getContentFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
assertInsetByTopBottom(mWindow.getDecorFrame(), 0, 0);
- assertInsetBy(mWindow.getDisplayFrameLw(), 0, 0, 0, 0);
+ assertInsetByTopBottom(mWindow.getDisplayFrameLw(), 0, 0);
}
@Test
public void layoutWindowLw_withDisplayCutout_fullscreen() {
addDisplayCutout();
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.subtreeSystemUiVisibility |= SYSTEM_UI_FLAG_FULLSCREEN;
+ mDisplayContent.getInsetsStateController().getInsetsForDispatch(mWindow)
+ .getSource(InsetsState.ITYPE_STATUS_BAR).setVisible(false);
addWindow(mWindow);
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
@@ -267,7 +470,11 @@
public void layoutWindowLw_withDisplayCutout_fullscreenInCutout() {
addDisplayCutout();
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.subtreeSystemUiVisibility |= SYSTEM_UI_FLAG_FULLSCREEN;
+ mDisplayContent.getInsetsStateController().getInsetsForDispatch(mWindow)
+ .getSource(InsetsState.ITYPE_STATUS_BAR).setVisible(false);
mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
addWindow(mWindow);
@@ -286,6 +493,9 @@
public void layoutWindowLw_withDisplayCutout_landscape() {
addDisplayCutout();
setRotation(ROTATION_90);
+
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
addWindow(mWindow);
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
@@ -303,6 +513,9 @@
public void layoutWindowLw_withDisplayCutout_seascape() {
addDisplayCutout();
setRotation(ROTATION_270);
+
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
addWindow(mWindow);
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
@@ -321,7 +534,11 @@
addDisplayCutout();
setRotation(ROTATION_90);
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.subtreeSystemUiVisibility |= SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
+ mWindow.mAttrs.setFitWindowInsetsTypes(
+ mWindow.mAttrs.getFitWindowInsetsTypes() & ~Type.statusBars());
addWindow(mWindow);
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
@@ -339,6 +556,7 @@
addDisplayCutout();
mWindow.mAttrs.flags = FLAG_LAYOUT_IN_SCREEN;
+ mWindow.mAttrs.setFitWindowInsetsTypes(Type.systemBars() & ~Type.statusBars());
mWindow.mAttrs.type = TYPE_APPLICATION_OVERLAY;
mWindow.mAttrs.width = DISPLAY_WIDTH;
mWindow.mAttrs.height = DISPLAY_HEIGHT;
@@ -356,7 +574,11 @@
addDisplayCutout();
setRotation(ROTATION_90);
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.subtreeSystemUiVisibility |= SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
+ mWindow.mAttrs.setFitWindowInsetsTypes(
+ mWindow.mAttrs.getFitWindowInsetsTypes() & ~Type.statusBars());
mWindow.mAttrs.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
addWindow(mWindow);
@@ -372,6 +594,8 @@
@Test
public void layoutWindowLw_withForwardInset_SoftInputAdjustResize() {
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.softInputMode = SOFT_INPUT_ADJUST_RESIZE;
addWindow(mWindow);
@@ -392,6 +616,8 @@
@Test
public void layoutWindowLw_withForwardInset_SoftInputAdjustNothing() {
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mAttrs.softInputMode = SOFT_INPUT_ADJUST_NOTHING;
addWindow(mWindow);
@@ -408,9 +634,12 @@
assertInsetBy(mWindow.getDisplayFrameLw(), 0, 0, 0, 0);
}
+ // TODO(b/118118435): remove after removing PolicyControl
@FlakyTest(bugId = 129711077)
@Test
public void layoutWindowLw_withImmersive_SoftInputAdjustResize() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
+
synchronized (mWm.mGlobalLock) {
mWindow.mAttrs.softInputMode = SOFT_INPUT_ADJUST_RESIZE;
mWindow.mAttrs.flags = 0;
@@ -433,9 +662,12 @@
}
}
+ // TODO(b/118118435): remove after removing PolicyControl
@FlakyTest(bugId = 129711077)
@Test
public void layoutWindowLw_withImmersive_SoftInputAdjustNothing() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
+
synchronized (mWm.mGlobalLock) {
mWindow.mAttrs.softInputMode = SOFT_INPUT_ADJUST_NOTHING;
mWindow.mAttrs.flags = 0;
@@ -457,9 +689,12 @@
}
}
+ // TODO(b/118118435): remove after removing PolicyControl
@FlakyTest(bugId = 129711077)
@Test
public void layoutWindowLw_withForceImmersive_fullscreen() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
+
synchronized (mWm.mGlobalLock) {
mWindow.mAttrs.softInputMode = SOFT_INPUT_ADJUST_RESIZE;
mWindow.mAttrs.flags = 0;
@@ -481,9 +716,12 @@
}
}
+ // TODO(b/118118435): remove after removing PolicyControl
@FlakyTest(bugId = 129711077)
@Test
public void layoutWindowLw_withForceImmersive_nonFullscreen() {
+ assumeTrue(ViewRootImpl.sNewInsetsMode != ViewRootImpl.NEW_INSETS_MODE_FULL);
+
synchronized (mWm.mGlobalLock) {
mWindow.mAttrs.softInputMode = SOFT_INPUT_ADJUST_RESIZE;
mWindow.mAttrs.flags = 0;
@@ -509,6 +747,9 @@
@Test
public void layoutHint_appWindow() {
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
+
// Initialize DisplayFrames
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
@@ -530,6 +771,9 @@
@Test
public void layoutHint_appWindowInTask() {
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
+
// Initialize DisplayFrames
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
@@ -553,6 +797,9 @@
@Test
public void layoutHint_appWindowInTask_outsideContentFrame() {
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
+
// Initialize DisplayFrames
mDisplayPolicy.beginLayoutLw(mFrames, 0 /* UI mode */);
@@ -581,7 +828,8 @@
public void forceShowSystemBars_clearsSystemUIFlags() {
mDisplayPolicy.mLastSystemUiFlags |= SYSTEM_UI_FLAG_FULLSCREEN;
mWindow.mAttrs.subtreeSystemUiVisibility |= SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
- mWindow.mAttrs.flags |= FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
+ mWindow.mAttrs.flags =
+ FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
mWindow.mSystemUiVisibility = SYSTEM_UI_FLAG_FULLSCREEN;
mDisplayPolicy.setForceShowSystemBars(true);
addWindow(mWindow);
@@ -600,7 +848,8 @@
@Test
public void testScreenDecorWindows() {
final WindowState decorWindow = createWindow(null, TYPE_APPLICATION_OVERLAY, "decorWindow");
- decorWindow.mAttrs.flags |= FLAG_NOT_FOCUSABLE;
+ mWindow.mAttrs.flags = FLAG_NOT_FOCUSABLE | FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR
+ | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
decorWindow.mAttrs.privateFlags |= PRIVATE_FLAG_IS_SCREEN_DECOR;
addWindow(decorWindow);
addWindow(mWindow);
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTestsBase.java
index d4558dc..d0b3350 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTestsBase.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTestsBase.java
@@ -78,6 +78,8 @@
resources.addOverride(R.dimen.navigation_bar_height, NAV_BAR_HEIGHT);
resources.addOverride(R.dimen.navigation_bar_height_landscape, NAV_BAR_HEIGHT);
resources.addOverride(R.dimen.navigation_bar_width, NAV_BAR_HEIGHT);
+ resources.addOverride(R.dimen.navigation_bar_frame_height_landscape, NAV_BAR_HEIGHT);
+ resources.addOverride(R.dimen.navigation_bar_frame_height, NAV_BAR_HEIGHT);
doReturn(resources.getResources()).when(mDisplayPolicy).getCurrentUserResources();
doReturn(true).when(mDisplayPolicy).hasNavigationBar();
doReturn(true).when(mDisplayPolicy).hasStatusBar();
diff --git a/services/tests/wmtests/src/com/android/server/wm/LaunchParamsPersisterTests.java b/services/tests/wmtests/src/com/android/server/wm/LaunchParamsPersisterTests.java
index 9e5d9da..84914bb 100644
--- a/services/tests/wmtests/src/com/android/server/wm/LaunchParamsPersisterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/LaunchParamsPersisterTests.java
@@ -80,7 +80,7 @@
private TestPersisterQueue mPersisterQueue;
private File mFolder;
- private ActivityDisplay mTestDisplay;
+ private DisplayContent mTestDisplay;
private String mDisplayUniqueId;
private Task mTestTask;
private Task mTaskWithDifferentUser;
@@ -104,9 +104,9 @@
deleteRecursively(mFolder);
mDisplayUniqueId = "test:" + Integer.toString(sNextUniqueId++);
- mTestDisplay = new TestActivityDisplay.Builder(mService, 1000, 1500)
+ mTestDisplay = new TestDisplayContent.Builder(mService, 1000, 1500)
.setUniqueId(mDisplayUniqueId).build();
- when(mRootActivityContainer.getActivityDisplay(eq(mDisplayUniqueId)))
+ when(mRootActivityContainer.getDisplayContent(eq(mDisplayUniqueId)))
.thenReturn(mTestDisplay);
ActivityStack stack = mTestDisplay.createStack(TEST_WINDOWING_MODE,
@@ -180,7 +180,7 @@
public void testReturnsEmptyDisplayIfDisplayIsNotFound() {
mTarget.saveTask(mTestTask);
- when(mRootActivityContainer.getActivityDisplay(eq(mDisplayUniqueId))).thenReturn(null);
+ when(mRootActivityContainer.getDisplayContent(eq(mDisplayUniqueId))).thenReturn(null);
mTarget.getLaunchParams(mTestTask, null, mResult);
diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
index b1cd931..eaf4aa3 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java
@@ -41,8 +41,12 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -98,7 +102,7 @@
UserManager.USER_TYPE_PROFILE_MANAGED);
private static final int INVALID_STACK_ID = 999;
- private ActivityDisplay mDisplay;
+ private DisplayContent mDisplay;
private ActivityStack mStack;
private TestTaskPersister mTaskPersister;
private TestRecentTasks mRecentTasks;
@@ -112,7 +116,8 @@
@Before
public void setUp() throws Exception {
mTaskPersister = new TestTaskPersister(mContext.getFilesDir());
- mDisplay = mRootActivityContainer.getActivityDisplay(DEFAULT_DISPLAY);
+ spyOn(mTaskPersister);
+ mDisplay = mRootActivityContainer.getDisplayContent(DEFAULT_DISPLAY);
// Set the recent tasks we should use for testing in this class.
mRecentTasks = new TestRecentTasks(mService, mTaskPersister);
@@ -171,6 +176,46 @@
}
@Test
+ public void testPersister() {
+ // Add some tasks, ensure the persister is woken
+ mRecentTasks.add(mTasks.get(0));
+ mRecentTasks.add(mTasks.get(1));
+ verify(mTaskPersister, times(1)).wakeup(eq(mTasks.get(0)), anyBoolean());
+ verify(mTaskPersister, times(1)).wakeup(eq(mTasks.get(1)), anyBoolean());
+ reset(mTaskPersister);
+
+ // Update a task, ensure the persister is woken
+ mRecentTasks.add(mTasks.get(0));
+ verify(mTaskPersister, times(1)).wakeup(eq(mTasks.get(0)), anyBoolean());
+ reset(mTaskPersister);
+
+ // Remove some tasks, ensure the persister is woken
+ mRecentTasks.remove(mTasks.get(0));
+ mRecentTasks.remove(mTasks.get(1));
+ verify(mTaskPersister, times(1)).wakeup(eq(mTasks.get(0)), anyBoolean());
+ verify(mTaskPersister, times(1)).wakeup(eq(mTasks.get(1)), anyBoolean());
+ reset(mTaskPersister);
+ }
+
+ @Test
+ public void testPersisterTrimmed() {
+ mRecentTasks.setOnlyTestVisibleRange();
+
+ // Limit the global maximum number of recent tasks to a fixed size
+ mRecentTasks.setGlobalMaxNumTasks(1 /* globalMaxNumTasks */);
+
+ mRecentTasks.add(mTasks.get(0));
+ verify(mTaskPersister, times(1)).wakeup(eq(mTasks.get(0)), anyBoolean());
+ reset(mTaskPersister);
+
+ // Add N+1 tasks to ensure the previous task is trimmed
+ mRecentTasks.add(mTasks.get(1));
+ verify(mTaskPersister, times(1)).wakeup(eq(mTasks.get(0)), anyBoolean());
+ verify(mTaskPersister, times(1)).wakeup(eq(mTasks.get(1)), anyBoolean());
+ assertTrimmed(mTasks.get(0));
+ }
+
+ @Test
public void testAddTasksNoMultiple_expectNoTrim() {
// Add same non-multiple-task document tasks will remove the task (to re-add it) but not
// trim it
@@ -608,8 +653,8 @@
mRecentTasks.setOnlyTestVisibleRange();
mRecentTasks.setParameters(-1 /* min */, 3 /* max */, -1 /* ms */);
- final ActivityDisplay singleTaskDisplay =
- addNewActivityDisplayAt(ActivityDisplay.POSITION_TOP);
+ final DisplayContent singleTaskDisplay =
+ addNewDisplayContentAt(DisplayContent.POSITION_TOP);
singleTaskDisplay.setDisplayToSingleTaskInstance();
ActivityStack singleTaskStack = singleTaskDisplay.createStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
@@ -788,7 +833,7 @@
mRecentTasks.setParameters(-1 /* min */, 1 /* max */, -1 /* ms */);
final ActivityStack homeStack = mDisplay.getHomeStack();
- final ActivityDisplay otherDisplay = addNewActivityDisplayAt(ActivityDisplay.POSITION_TOP);
+ final DisplayContent otherDisplay = addNewDisplayContentAt(DisplayContent.POSITION_TOP);
final ActivityStack otherDisplayStack = otherDisplay.createStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java
index 2374847..945928d 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java
@@ -138,8 +138,7 @@
@Test
public void testIncludedApps_expectTargetAndVisible() {
mWm.setRecentsAnimationController(mController);
- // TODO(display-merge): Remove cast
- final ActivityStack homeStack = ((ActivityDisplay) mDisplayContent).getOrCreateStack(
+ final ActivityStack homeStack = mDisplayContent.getOrCreateStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, ON_TOP);
final ActivityRecord homeActivity =
new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
@@ -164,8 +163,7 @@
@Test
public void testWallpaperIncluded_expectTarget() throws Exception {
mWm.setRecentsAnimationController(mController);
- // TODO(display-merge): Remove cast
- final ActivityStack homeStack = ((ActivityDisplay) mDisplayContent).getOrCreateStack(
+ final ActivityStack homeStack = mDisplayContent.getOrCreateStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, ON_TOP);
final ActivityRecord homeAppWindow =
new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
@@ -194,8 +192,7 @@
@Test
public void testWallpaperAnimatorCanceled_expectAnimationKeepsRunning() throws Exception {
mWm.setRecentsAnimationController(mController);
- // TODO(display-merge): Remove cast
- final ActivityStack homeStack = ((ActivityDisplay) mDisplayContent).getOrCreateStack(
+ final ActivityStack homeStack = mDisplayContent.getOrCreateStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, ON_TOP);
final ActivityRecord homeActivity =
new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
@@ -226,8 +223,7 @@
@Test
public void testFinish_expectTargetAndWallpaperAdaptersRemoved() {
mWm.setRecentsAnimationController(mController);
- // TODO(display-merge): Remove cast
- final ActivityStack homeStack = ((ActivityDisplay) mDisplayContent).getOrCreateStack(
+ final ActivityStack homeStack = mDisplayContent.getOrCreateStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, ON_TOP);
final ActivityRecord homeActivity =
new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java
index 8fbb16c..07be3e4 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationTest.java
@@ -88,7 +88,7 @@
@Test
public void testRecentsActivityVisiblility() {
- ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
+ DisplayContent display = mRootActivityContainer.getDefaultDisplay();
ActivityStack recentsStack = display.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_RECENTS, true /* onTop */);
ActivityRecord recentActivity = new ActivityBuilder(mService)
@@ -116,7 +116,7 @@
@Test
public void testPreloadRecentsActivity() {
- final ActivityDisplay defaultDisplay = mRootActivityContainer.getDefaultDisplay();
+ final DisplayContent defaultDisplay = mRootActivityContainer.getDefaultDisplay();
final ActivityStack homeStack =
defaultDisplay.getStack(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME);
defaultDisplay.positionStackAtTop(homeStack, false /* includingParents */);
@@ -149,7 +149,7 @@
mService.startRecentsActivity(recentsIntent, null /* assistDataReceiver */,
null /* recentsAnimationRunner */);
- ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
+ DisplayContent display = mRootActivityContainer.getDefaultDisplay();
ActivityStack recentsStack = display.getStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_RECENTS);
assertThat(recentsStack).isNotNull();
@@ -178,7 +178,7 @@
@Test
public void testRestartRecentsActivity() throws Exception {
// Have a recents activity that is not attached to its process (ActivityRecord.app = null).
- ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
+ DisplayContent display = mRootActivityContainer.getDefaultDisplay();
ActivityStack recentsStack = display.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_RECENTS, true /* onTop */);
ActivityRecord recentActivity = new ActivityBuilder(mService).setComponent(
@@ -207,7 +207,7 @@
@Test
public void testSetLaunchTaskBehindOfTargetActivity() {
- ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
+ DisplayContent display = mRootActivityContainer.getDefaultDisplay();
display.mDisplayContent.mBoundsAnimationController = mock(BoundsAnimationController.class);
ActivityStack homeStack = display.getHomeStack();
// Assume the home activity support recents.
@@ -253,7 +253,7 @@
@Test
public void testCancelAnimationOnVisibleStackOrderChange() {
- ActivityDisplay display = mService.mRootActivityContainer.getDefaultDisplay();
+ DisplayContent display = mService.mRootActivityContainer.getDefaultDisplay();
display.mDisplayContent.mBoundsAnimationController = mock(BoundsAnimationController.class);
ActivityStack fullscreenStack = display.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
@@ -299,7 +299,7 @@
@Test
public void testKeepAnimationOnHiddenStackOrderChange() {
- ActivityDisplay display = mService.mRootActivityContainer.getDefaultDisplay();
+ DisplayContent display = mService.mRootActivityContainer.getDefaultDisplay();
ActivityStack fullscreenStack = display.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
new ActivityBuilder(mService)
@@ -335,7 +335,7 @@
@Test
public void testMultipleUserHomeActivity_findUserHomeTask() {
- ActivityDisplay display = mService.mRootActivityContainer.getDefaultDisplay();
+ DisplayContent display = mService.mRootActivityContainer.getDefaultDisplay();
ActivityStack homeStack = display.getStack(WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_HOME);
ActivityRecord otherUserHomeActivity = new ActivityBuilder(mService)
.setStack(homeStack)
diff --git a/services/tests/wmtests/src/com/android/server/wm/RootActivityContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/RootActivityContainerTests.java
index 5417ade..2d45a59 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RootActivityContainerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RootActivityContainerTests.java
@@ -128,7 +128,7 @@
mRootActivityContainer.moveActivityToPinnedStack(firstActivity, sourceBounds,
0f /*aspectRatio*/, "initialMove");
- final ActivityDisplay display = mFullscreenStack.getDisplay();
+ final DisplayContent display = mFullscreenStack.getDisplay();
ActivityStack pinnedStack = display.getPinnedStack();
// Ensure a task has moved over.
ensureStackPlacement(pinnedStack, firstActivity);
@@ -166,7 +166,7 @@
@Test
public void testApplySleepTokens() {
- final ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
+ final DisplayContent display = mRootActivityContainer.getDefaultDisplay();
final KeyguardController keyguard = mSupervisor.getKeyguardController();
final ActivityStack stack = new StackBuilder(mRootActivityContainer)
.setCreateActivity(false)
@@ -202,7 +202,7 @@
false /* expectResumeTopActivity */);
}
- private void verifySleepTokenBehavior(ActivityDisplay display, KeyguardController keyguard,
+ private void verifySleepTokenBehavior(DisplayContent display, KeyguardController keyguard,
ActivityStack stack, boolean displaySleeping, boolean displayShouldSleep,
boolean isFocusedStack, boolean keyguardShowing, boolean expectWakeFromSleep,
boolean expectResumeTopActivity) {
@@ -225,7 +225,7 @@
*/
@Test
public void testRemovingStackOnAppCrash() {
- final ActivityDisplay defaultDisplay = mRootActivityContainer.getDefaultDisplay();
+ final DisplayContent defaultDisplay = mRootActivityContainer.getDefaultDisplay();
final int originalStackCount = defaultDisplay.getStackCount();
final ActivityStack stack = mRootActivityContainer.getDefaultDisplay().createStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, false /* onTop */);
@@ -336,7 +336,7 @@
@Test
public void testFindTaskToMoveToFrontWhenRecentsOnTop() {
// Create stack/task on default display.
- final ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
+ final DisplayContent display = mRootActivityContainer.getDefaultDisplay();
final ActivityStack targetStack = new StackBuilder(mRootActivityContainer)
.setOnTop(false)
.build();
@@ -360,14 +360,14 @@
@Test
public void testFindTaskToMoveToFrontWhenRecentsOnOtherDisplay() {
// Create stack/task on default display.
- final ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
+ final DisplayContent display = mRootActivityContainer.getDefaultDisplay();
final ActivityStack targetStack = display.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, false /* onTop */);
final Task targetTask = new TaskBuilder(mSupervisor).setStack(targetStack).build();
// Create Recents on secondary display.
- final TestActivityDisplay secondDisplay = addNewActivityDisplayAt(
- ActivityDisplay.POSITION_TOP);
+ final TestDisplayContent secondDisplay = addNewDisplayContentAt(
+ DisplayContent.POSITION_TOP);
final ActivityStack stack = secondDisplay.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_RECENTS, true /* onTop */);
final Task task = new TaskBuilder(mSupervisor).setStack(stack).build();
@@ -387,7 +387,7 @@
@Test
public void testResumeActivityWhenNonTopmostStackIsTopFocused() {
// Create a stack at bottom.
- final ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
+ final DisplayContent display = mRootActivityContainer.getDefaultDisplay();
final ActivityStack targetStack = spy(display.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, false /* onTop */));
final Task task = new TaskBuilder(mSupervisor).setStack(targetStack).build();
@@ -415,8 +415,9 @@
@Test
public void testResumeFocusedStacksStartsHomeActivity_NoActivities() {
mFullscreenStack.removeIfPossible();
- mService.mRootActivityContainer.getActivityDisplay(DEFAULT_DISPLAY).getHomeStack().removeIfPossible();
- mService.mRootActivityContainer.getActivityDisplay(DEFAULT_DISPLAY)
+ mService.mRootActivityContainer.getDisplayContent(DEFAULT_DISPLAY).getHomeStack()
+ .removeIfPossible();
+ mService.mRootActivityContainer.getDisplayContent(DEFAULT_DISPLAY)
.createStack(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, ON_TOP);
doReturn(true).when(mRootActivityContainer).resumeHomeActivity(any(), any(), anyInt());
@@ -437,13 +438,14 @@
@Test
public void testResumeFocusedStacksStartsHomeActivity_ActivityOnSecondaryScreen() {
mFullscreenStack.removeIfPossible();
- mService.mRootActivityContainer.getActivityDisplay(DEFAULT_DISPLAY).getHomeStack().removeIfPossible();
- mService.mRootActivityContainer.getActivityDisplay(DEFAULT_DISPLAY)
+ mService.mRootActivityContainer.getDisplayContent(DEFAULT_DISPLAY).getHomeStack()
+ .removeIfPossible();
+ mService.mRootActivityContainer.getDisplayContent(DEFAULT_DISPLAY)
.createStack(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, ON_TOP);
// Create an activity on secondary display.
- final TestActivityDisplay secondDisplay = addNewActivityDisplayAt(
- ActivityDisplay.POSITION_TOP);
+ final TestDisplayContent secondDisplay = addNewDisplayContentAt(
+ DisplayContent.POSITION_TOP);
final ActivityStack stack = secondDisplay.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, true /* onTop */);
final Task task = new TaskBuilder(mSupervisor).setStack(stack).build();
@@ -467,7 +469,7 @@
@Test
public void testResumeActivityLingeringTransition() {
// Create a stack at top.
- final ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
+ final DisplayContent display = mRootActivityContainer.getDefaultDisplay();
final ActivityStack targetStack = spy(display.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, false /* onTop */));
final Task task = new TaskBuilder(mSupervisor).setStack(targetStack).build();
@@ -487,7 +489,7 @@
@Test
public void testResumeActivityLingeringTransition_notExecuted() {
// Create a stack at bottom.
- final ActivityDisplay display = mRootActivityContainer.getDefaultDisplay();
+ final DisplayContent display = mRootActivityContainer.getDefaultDisplay();
final ActivityStack targetStack = spy(display.createStack(WINDOWING_MODE_FULLSCREEN,
ACTIVITY_TYPE_STANDARD, false /* onTop */));
final Task task = new TaskBuilder(mSupervisor).setStack(targetStack).build();
@@ -515,8 +517,8 @@
mockResolveSecondaryHomeActivity();
// Create secondary displays.
- final TestActivityDisplay secondDisplay =
- new TestActivityDisplay.Builder(mService, 1000, 1500)
+ final TestDisplayContent secondDisplay =
+ new TestDisplayContent.Builder(mService, 1000, 1500)
.setSystemDecorations(true).build();
doReturn(true).when(mRootActivityContainer)
@@ -582,8 +584,8 @@
@Test
public void testStartSecondaryHomeOnDisplayWithUserKeyLocked() {
// Create secondary displays.
- final TestActivityDisplay secondDisplay =
- new TestActivityDisplay.Builder(mService, 1000, 1500)
+ final TestDisplayContent secondDisplay =
+ new TestDisplayContent.Builder(mService, 1000, 1500)
.setSystemDecorations(true).build();
// Use invalid user id to let StorageManager.isUserKeyUnlocked() return false.
@@ -608,8 +610,8 @@
@Test
public void testStartSecondaryHomeOnDisplayWithoutSysDecorations() {
// Create secondary displays.
- final TestActivityDisplay secondDisplay =
- new TestActivityDisplay.Builder(mService, 1000, 1500)
+ final TestDisplayContent secondDisplay =
+ new TestDisplayContent.Builder(mService, 1000, 1500)
.setSystemDecorations(false).build();
mRootActivityContainer.startHomeOnDisplay(0 /* userId */, "testStartSecondaryHome",
@@ -831,8 +833,8 @@
@Test
public void testGetLaunchStackWithRealCallerId() {
// Create a non-system owned virtual display.
- final TestActivityDisplay secondaryDisplay =
- new TestActivityDisplay.Builder(mService, 1000, 1500)
+ final TestDisplayContent secondaryDisplay =
+ new TestDisplayContent.Builder(mService, 1000, 1500)
.setType(TYPE_VIRTUAL).setOwnerUid(100).build();
// Create an activity with specify the original launch pid / uid.
diff --git a/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java b/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java
index 66f4d2a..b32cb8b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RunningTasksTest.java
@@ -57,9 +57,9 @@
@Test
public void testCollectTasksByLastActiveTime() {
// Create a number of stacks with tasks (of incrementing active time)
- final ArrayList<ActivityDisplay> displays = new ArrayList<>();
- final ActivityDisplay display =
- new TestActivityDisplay.Builder(mService, 1000, 2500).build();
+ final ArrayList<DisplayContent> displays = new ArrayList<>();
+ final DisplayContent display =
+ new TestDisplayContent.Builder(mService, 1000, 2500).build();
displays.add(display);
final int numStacks = 2;
diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
index 46f95ed..be0fd2b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -67,7 +67,7 @@
private Task mTask;
private ActivityRecord mActivity;
- private void setUpApp(ActivityDisplay display) {
+ private void setUpApp(DisplayContent display) {
mStack = new StackBuilder(mRootActivityContainer).setDisplay(display).build();
mTask = mStack.getBottomMostTask();
mActivity = mTask.getTopNonFinishingActivity();
@@ -79,7 +79,7 @@
@Test
public void testRestartProcessIfVisible() {
- setUpApp(new TestActivityDisplay.Builder(mService, 1000, 2500).build());
+ setUpApp(new TestDisplayContent.Builder(mService, 1000, 2500).build());
doNothing().when(mSupervisor).scheduleRestartTimeout(mActivity);
mActivity.mVisibleRequested = true;
mActivity.setSavedState(null /* savedState */);
@@ -99,7 +99,7 @@
public void testKeepBoundsWhenChangingFromFreeformToFullscreen() {
removeGlobalMinSizeRestriction();
// create freeform display and a freeform app
- ActivityDisplay display = new TestActivityDisplay.Builder(mService, 2000, 1000)
+ DisplayContent display = new TestDisplayContent.Builder(mService, 2000, 1000)
.setCanRotate(false)
.setWindowingMode(WindowConfiguration.WINDOWING_MODE_FREEFORM).build();
setUpApp(display);
@@ -126,7 +126,7 @@
@Test
public void testFixedAspectRatioBoundsWithDecor() {
final int decorHeight = 200; // e.g. The device has cutout.
- setUpApp(new TestActivityDisplay.Builder(mService, 600, 800)
+ setUpApp(new TestDisplayContent.Builder(mService, 600, 800)
.setNotch(decorHeight).build());
mActivity.info.minAspectRatio = mActivity.info.maxAspectRatio = 1;
@@ -152,11 +152,11 @@
@Test
public void testFixedScreenConfigurationWhenMovingToDisplay() {
- setUpApp(new TestActivityDisplay.Builder(mService, 1000, 2500).build());
+ setUpApp(new TestDisplayContent.Builder(mService, 1000, 2500).build());
// Make a new less-tall display with lower density
- final ActivityDisplay newDisplay =
- new TestActivityDisplay.Builder(mService, 1000, 2000)
+ final DisplayContent newDisplay =
+ new TestDisplayContent.Builder(mService, 1000, 2000)
.setDensityDpi(200).build();
mActivity = new ActivityBuilder(mService)
@@ -180,7 +180,7 @@
@Test
public void testFixedScreenBoundsWhenDisplaySizeChanged() {
- setUpApp(new TestActivityDisplay.Builder(mService, 1000, 2500).build());
+ setUpApp(new TestDisplayContent.Builder(mService, 1000, 2500).build());
prepareUnresizable(-1f /* maxAspect */, SCREEN_ORIENTATION_PORTRAIT);
assertFalse(mActivity.inSizeCompatMode());
@@ -203,7 +203,7 @@
@Test
public void testLetterboxFullscreenBounds() {
- setUpApp(new TestActivityDisplay.Builder(mService, 1000, 2500).build());
+ setUpApp(new TestDisplayContent.Builder(mService, 1000, 2500).build());
// Fill out required fields on default display since WM-side is mocked out
prepareUnresizable(-1.f /* maxAspect */, SCREEN_ORIENTATION_LANDSCAPE);
@@ -213,10 +213,10 @@
@Test
public void testMoveToDifferentOrientDisplay() {
- setUpApp(new TestActivityDisplay.Builder(mService, 1000, 2500).build());
+ setUpApp(new TestDisplayContent.Builder(mService, 1000, 2500).build());
- final ActivityDisplay newDisplay =
- new TestActivityDisplay.Builder(mService, 2000, 1000)
+ final DisplayContent newDisplay =
+ new TestDisplayContent.Builder(mService, 2000, 1000)
.setCanRotate(false).build();
prepareUnresizable(-1.f /* maxAspect */, SCREEN_ORIENTATION_PORTRAIT);
@@ -235,7 +235,7 @@
@Test
public void testFixedOrientRotateCutoutDisplay() {
// Create a display with a notch/cutout
- setUpApp(new TestActivityDisplay.Builder(mService, 1000, 2500).setNotch(60).build());
+ setUpApp(new TestDisplayContent.Builder(mService, 1000, 2500).setNotch(60).build());
prepareUnresizable(1.4f /* maxAspect */, SCREEN_ORIENTATION_PORTRAIT);
final Rect origBounds = new Rect(mActivity.getBounds());
@@ -259,7 +259,7 @@
@Test
public void testFixedAspOrientChangeOrient() {
- setUpApp(new TestActivityDisplay.Builder(mService, 1000, 2500).build());
+ setUpApp(new TestDisplayContent.Builder(mService, 1000, 2500).build());
prepareUnresizable(1.4f /* maxAspect */, SCREEN_ORIENTATION_LANDSCAPE);
// The display aspect ratio 2.5 > 1.4 (max of activity), so the size is fitted.
@@ -286,7 +286,7 @@
@Test
public void testFixedScreenLayoutSizeBits() {
- setUpApp(new TestActivityDisplay.Builder(mService, 1000, 2500).build());
+ setUpApp(new TestDisplayContent.Builder(mService, 1000, 2500).build());
final int fixedScreenLayout = Configuration.SCREENLAYOUT_LONG_NO
| Configuration.SCREENLAYOUT_SIZE_NORMAL
| Configuration.SCREENLAYOUT_COMPAT_NEEDED;
@@ -314,9 +314,9 @@
@Test
public void testResetNonVisibleActivity() {
- setUpApp(new TestActivityDisplay.Builder(mService, 1000, 2500).build());
+ setUpApp(new TestDisplayContent.Builder(mService, 1000, 2500).build());
prepareUnresizable(1.5f, SCREEN_ORIENTATION_UNSPECIFIED);
- final ActivityDisplay display = mStack.getDisplay();
+ final DisplayContent display = mStack.getDisplay();
// Resize the display so the activity is in size compatibility mode.
resizeDisplay(display, 900, 1800);
@@ -354,7 +354,7 @@
*/
@Test
public void testHandleActivitySizeCompatMode() {
- setUpApp(new TestActivityDisplay.Builder(mService, 1000, 2000).build());
+ setUpApp(new TestDisplayContent.Builder(mService, 1000, 2000).build());
ActivityRecord activity = mActivity;
activity.setState(ActivityStack.ActivityState.RESUMED, "testHandleActivitySizeCompatMode");
prepareUnresizable(-1.f /* maxAspect */, SCREEN_ORIENTATION_PORTRAIT);
@@ -412,7 +412,7 @@
ensureActivityConfiguration();
}
- private void resizeDisplay(ActivityDisplay display, int width, int height) {
+ private void resizeDisplay(DisplayContent display, int width, int height) {
final DisplayContent displayContent = display.mDisplayContent;
displayContent.mBaseDisplayWidth = width;
displayContent.mBaseDisplayHeight = height;
diff --git a/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java b/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java
index a172b65..811f46f 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java
@@ -286,13 +286,12 @@
// Mock root, some default display, and home stack.
spyOn(mWmService.mRoot);
- final ActivityDisplay display = mAtmService.mRootActivityContainer.getDefaultDisplay();
+ final DisplayContent display = mAtmService.mRootActivityContainer.getDefaultDisplay();
// Set default display to be in fullscreen mode. Devices with PC feature may start their
// default display in freeform mode but some of tests in WmTests have implicit assumption on
// that the default display is in fullscreen mode.
display.setDisplayWindowingMode(WINDOWING_MODE_FULLSCREEN);
spyOn(display);
- spyOn(display.mDisplayContent);
final ActivityStack homeStack = display.getStack(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME);
spyOn(homeStack);
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
index 9a91efe..5aa41eb 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
@@ -107,7 +107,7 @@
// =============================
@Test
public void testDefaultToPrimaryDisplay() {
- createNewActivityDisplay(WINDOWING_MODE_FREEFORM);
+ createNewDisplayContent(WINDOWING_MODE_FREEFORM);
assertEquals(RESULT_CONTINUE, mTarget.onCalculate(/* task */ null, /* layout */ null,
mActivity, /* source */ null, /* options */ null, mCurrent, mResult));
@@ -127,8 +127,8 @@
@Test
public void testUsesPreviousDisplayIdIfSet() {
- createNewActivityDisplay(WINDOWING_MODE_FREEFORM);
- final TestActivityDisplay display = createNewActivityDisplay(WINDOWING_MODE_FULLSCREEN);
+ createNewDisplayContent(WINDOWING_MODE_FREEFORM);
+ final TestDisplayContent display = createNewDisplayContent(WINDOWING_MODE_FULLSCREEN);
mCurrent.mPreferredDisplayId = display.mDisplayId;
@@ -140,9 +140,9 @@
@Test
public void testUsesSourcesDisplayIdIfSet() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
- final TestActivityDisplay fullscreenDisplay = createNewActivityDisplay(
+ final TestDisplayContent fullscreenDisplay = createNewDisplayContent(
WINDOWING_MODE_FULLSCREEN);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -157,9 +157,9 @@
@Test
public void testUsesOptionsDisplayIdIfSet() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
- final TestActivityDisplay fullscreenDisplay = createNewActivityDisplay(
+ final TestDisplayContent fullscreenDisplay = createNewDisplayContent(
WINDOWING_MODE_FULLSCREEN);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -176,9 +176,9 @@
@Test
public void testUsesTasksDisplayIdPriorToSourceIfSet() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
- final TestActivityDisplay fullscreenDisplay = createNewActivityDisplay(
+ final TestDisplayContent fullscreenDisplay = createNewDisplayContent(
WINDOWING_MODE_FULLSCREEN);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -193,7 +193,7 @@
@Test
public void testUsesTaskDisplayIdIfSet() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
ActivityRecord source = createSourceActivity(freeformDisplay);
@@ -205,9 +205,9 @@
@Test
public void testUsesNoDisplaySourceHandoverDisplayIdIfSet() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
- final TestActivityDisplay fullscreenDisplay = createNewActivityDisplay(
+ final TestDisplayContent fullscreenDisplay = createNewDisplayContent(
WINDOWING_MODE_FULLSCREEN);
mCurrent.mPreferredDisplayId = fullscreenDisplay.mDisplayId;
@@ -227,7 +227,7 @@
// =====================================
@Test
public void testBoundsInOptionsInfersFreeformOnFreeformDisplay() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -258,7 +258,7 @@
@Test
public void testInheritsFreeformModeFromSourceOnFullscreenDisplay() {
- final TestActivityDisplay fullscreenDisplay = createNewActivityDisplay(
+ final TestDisplayContent fullscreenDisplay = createNewDisplayContent(
WINDOWING_MODE_FULLSCREEN);
final ActivityRecord source = createSourceActivity(fullscreenDisplay);
source.setWindowingMode(WINDOWING_MODE_FREEFORM);
@@ -272,7 +272,7 @@
@Test
public void testKeepsPictureInPictureLaunchModeInOptions() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -289,7 +289,7 @@
@Test
public void testKeepsPictureInPictureLaunchModeWithBoundsInOptions() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -321,7 +321,7 @@
@Test
public void testNonEmptyLayoutInfersFreeformOnFreeformDisplay() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -338,7 +338,7 @@
@Test
public void testNonEmptyLayoutInfersFreeformWithEmptySize() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -382,7 +382,7 @@
@Test
public void testRespectsFullyResolvedCurrentParam_Fullscreen() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -397,7 +397,7 @@
@Test
public void testRespectsModeFromFullyResolvedCurrentParam_NonEmptyBounds() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -414,7 +414,7 @@
@Test
public void testForceMaximizesUnresizeableApp() {
mService.mSizeCompatFreeform = false;
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -437,7 +437,7 @@
@Test
public void testLaunchesAppInWindowOnFreeformDisplay() {
mService.mSizeCompatFreeform = true;
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
Rect expectedLaunchBounds = new Rect(0, 0, 200, 100);
@@ -494,7 +494,7 @@
@Test
public void testUsesFullscreenWhenRequestedOnFreeformDisplay() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -510,7 +510,7 @@
@Test
public void testUsesFreeformByDefaultForPostNApp() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -525,7 +525,7 @@
@Test
public void testUsesFreeformByDefaultForPreNResizeableAppWithoutOrientationRequest() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -559,7 +559,7 @@
// ===============================
@Test
public void testKeepsBoundsWithPictureInPictureLaunchModeInOptions() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -578,7 +578,7 @@
@Test
public void testRespectsLaunchBoundsWithFreeformSourceOnFullscreenDisplay() {
- final TestActivityDisplay fullscreenDisplay = createNewActivityDisplay(
+ final TestDisplayContent fullscreenDisplay = createNewDisplayContent(
WINDOWING_MODE_FULLSCREEN);
final ActivityRecord source = createSourceActivity(fullscreenDisplay);
source.setWindowingMode(WINDOWING_MODE_FREEFORM);
@@ -595,7 +595,7 @@
@Test
public void testNonEmptyLayoutBoundsRespectsGravityWithEmptySize_LeftGravity() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -611,7 +611,7 @@
@Test
public void testNonEmptyLayoutBoundsRespectsGravityWithEmptySize_TopGravity() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -627,7 +627,7 @@
@Test
public void testNonEmptyLayoutBoundsRespectsGravityWithEmptySize_TopLeftGravity() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -644,7 +644,7 @@
@Test
public void testNonEmptyLayoutBoundsRespectsGravityWithEmptySize_RightGravity() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -660,7 +660,7 @@
@Test
public void testNonEmptyLayoutBoundsRespectsGravityWithEmptySize_BottomGravity() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -676,7 +676,7 @@
@Test
public void testNonEmptyLayoutBoundsRespectsGravityWithEmptySize_BottomRightGravity() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -693,7 +693,7 @@
@Test
public void testNonEmptyLayoutBoundsOnFreeformDisplay_CenterToDisplay() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -709,7 +709,7 @@
@Test
public void testNonEmptyLayoutBoundsOnFreeformDisplay_LeftGravity() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -725,7 +725,7 @@
@Test
public void testNonEmptyLayoutBoundsOnFreeformDisplay_TopGravity() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -741,7 +741,7 @@
@Test
public void testNonEmptyLayoutBoundsOnFreeformDisplay_TopLeftGravity() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -757,7 +757,7 @@
@Test
public void testNonEmptyLayoutBoundsOnFreeformDisplay_RightGravity() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -773,7 +773,7 @@
@Test
public void testNonEmptyLayoutBoundsOnFreeformDisplay_BottomGravity() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -789,7 +789,7 @@
@Test
public void testNonEmptyLayoutBoundsOnFreeformDisplay_RightBottomGravity() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -805,7 +805,7 @@
@Test
public void testNonEmptyLayoutFractionBoundsOnFreeformDisplay() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -821,7 +821,7 @@
@Test
public void testRespectBoundsFromFullyResolvedCurrentParam_NonEmptyBounds() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -836,7 +836,7 @@
@Test
public void testReturnBoundsForFullscreenWindowingMode() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
@@ -851,7 +851,7 @@
@Test
public void testUsesDisplayOrientationForNoSensorOrientation() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -875,7 +875,7 @@
@Test
public void testRespectsAppRequestedOrientation_Landscape() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -892,7 +892,7 @@
@Test
public void testRespectsAppRequestedOrientation_Portrait() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -909,7 +909,7 @@
@Test
public void testDefaultSizeSmallerThanBigScreen() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -933,7 +933,7 @@
@Test
public void testDefaultFreeformSizeCenteredToDisplay() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -954,7 +954,7 @@
@Test
public void testCascadesToSourceSizeForFreeform() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -981,7 +981,7 @@
@Test
public void testAdjustBoundsToFitDisplay_TopLeftOutOfDisplay() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -1003,7 +1003,7 @@
@Test
public void testAdjustBoundsToFitDisplay_BottomRightOutOfDisplay() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -1025,7 +1025,7 @@
@Test
public void testAdjustBoundsToFitNewDisplay_LargerThanDisplay() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -1052,7 +1052,7 @@
overrideConfig.setLayoutDirection(new Locale("ar", "EG"));
mRootActivityContainer.onRequestedOverrideConfigurationChanged(overrideConfig);
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -1073,7 +1073,7 @@
@Test
public void testRespectsLayoutMinDimensions() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
// This test case requires a relatively big app bounds to ensure the default size calculated
@@ -1098,7 +1098,7 @@
@Test
public void testRotatesInPlaceInitialBoundsMismatchOrientation() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
final ActivityOptions options = ActivityOptions.makeBasic();
@@ -1115,7 +1115,7 @@
@Test
public void testShiftsToRightForCloseToLeftBoundsWhenConflict() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
addFreeformTaskTo(freeformDisplay, new Rect(50, 50, 100, 150));
@@ -1132,7 +1132,7 @@
@Test
public void testShiftsToLeftForCloseToRightBoundsWhenConflict() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
addFreeformTaskTo(freeformDisplay, new Rect(1720, 50, 1830, 150));
@@ -1149,7 +1149,7 @@
@Test
public void testShiftsToRightFirstForHorizontallyCenteredAndCloseToTopWhenConflict() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
addFreeformTaskTo(freeformDisplay, new Rect(0, 0, 100, 300));
@@ -1166,7 +1166,7 @@
@Test
public void testShiftsToLeftNoSpaceOnRightForHorizontallyCenteredAndCloseToTopWhenConflict() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
addFreeformTaskTo(freeformDisplay, new Rect(120, 0, 240, 300));
@@ -1183,7 +1183,7 @@
@Test
public void testShiftsToBottomRightFirstForCenteredBoundsWhenConflict() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
addFreeformTaskTo(freeformDisplay, new Rect(120, 0, 240, 100));
@@ -1200,7 +1200,7 @@
@Test
public void testShiftsToTopLeftIfNoSpaceOnBottomRightForCenteredBoundsWhenConflict() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
addFreeformTaskTo(freeformDisplay, new Rect(120, 67, 240, 100));
@@ -1230,7 +1230,7 @@
@Test
public void testAdjustsBoundsToFitInDisplayFullyResolvedBounds() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
mCurrent.mPreferredDisplayId = Display.INVALID_DISPLAY;
@@ -1248,7 +1248,7 @@
@Test
public void testAdjustsBoundsToAvoidConflictFullyResolvedBounds() {
- final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
addFreeformTaskTo(freeformDisplay, new Rect(0, 0, 200, 100));
@@ -1283,7 +1283,7 @@
@Test
public void testNoMultiDisplaySupports() {
final boolean orgValue = mService.mSupportsMultiDisplay;
- final TestActivityDisplay display = createNewActivityDisplay(WINDOWING_MODE_FULLSCREEN);
+ final TestDisplayContent display = createNewDisplayContent(WINDOWING_MODE_FULLSCREEN);
mCurrent.mPreferredDisplayId = display.mDisplayId;
try {
@@ -1296,8 +1296,8 @@
}
}
- private TestActivityDisplay createNewActivityDisplay(int windowingMode) {
- final TestActivityDisplay display = addNewActivityDisplayAt(ActivityDisplay.POSITION_TOP);
+ private TestDisplayContent createNewDisplayContent(int windowingMode) {
+ final TestDisplayContent display = addNewDisplayContentAt(DisplayContent.POSITION_TOP);
display.setWindowingMode(windowingMode);
display.setBounds(DISPLAY_BOUNDS);
display.getConfiguration().densityDpi = DENSITY_DEFAULT;
@@ -1311,13 +1311,13 @@
return display;
}
- private ActivityRecord createSourceActivity(TestActivityDisplay display) {
+ private ActivityRecord createSourceActivity(TestDisplayContent display) {
final ActivityStack stack = display.createStack(display.getWindowingMode(),
ACTIVITY_TYPE_STANDARD, true);
return new ActivityBuilder(mService).setStack(stack).setCreateTask(true).build();
}
- private void addFreeformTaskTo(TestActivityDisplay display, Rect bounds) {
+ private void addFreeformTaskTo(TestDisplayContent display, Rect bounds) {
final ActivityStack stack = display.createStack(display.getWindowingMode(),
ACTIVITY_TYPE_STANDARD, true);
stack.setWindowingMode(WINDOWING_MODE_FREEFORM);
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java
index 39e7885..1a18df5 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java
@@ -193,7 +193,7 @@
@FlakyTest(bugId = 137879065)
public void testFitWithinBounds() {
final Rect parentBounds = new Rect(10, 10, 200, 200);
- ActivityDisplay display = mService.mRootActivityContainer.getDefaultDisplay();
+ DisplayContent display = mService.mRootActivityContainer.getDefaultDisplay();
ActivityStack stack = display.createStack(WINDOWING_MODE_FREEFORM, ACTIVITY_TYPE_STANDARD,
true /* onTop */);
Task task = new TaskBuilder(mSupervisor).setStack(stack).build();
@@ -232,7 +232,7 @@
@Test
@FlakyTest(bugId = 137879065)
public void testBoundsOnModeChangeFreeformToFullscreen() {
- ActivityDisplay display = mService.mRootActivityContainer.getDefaultDisplay();
+ DisplayContent display = mService.mRootActivityContainer.getDefaultDisplay();
ActivityStack stack = new StackBuilder(mRootActivityContainer).setDisplay(display)
.setWindowingMode(WINDOWING_MODE_FREEFORM).build();
Task task = stack.getBottomMostTask();
@@ -265,9 +265,9 @@
public void testFullscreenBoundsForcedOrientation() {
final Rect fullScreenBounds = new Rect(0, 0, 1920, 1080);
final Rect fullScreenBoundsPort = new Rect(0, 0, 1080, 1920);
- ActivityDisplay display = new TestActivityDisplay.Builder(
+ DisplayContent display = new TestDisplayContent.Builder(
mService, fullScreenBounds.width(), fullScreenBounds.height()).build();
- assertTrue(mRootActivityContainer.getActivityDisplay(display.mDisplayId) != null);
+ assertTrue(mRootActivityContainer.getDisplayContent(display.mDisplayId) != null);
// Fix the display orientation to landscape which is the natural rotation (0) for the test
// display.
final DisplayRotation dr = display.mDisplayContent.getDisplayRotation();
@@ -328,7 +328,7 @@
@Test
public void testIgnoresForcedOrientationWhenParentHandles() {
final Rect fullScreenBounds = new Rect(0, 0, 1920, 1080);
- ActivityDisplay display = new TestActivityDisplay.Builder(
+ DisplayContent display = new TestDisplayContent.Builder(
mService, fullScreenBounds.width(), fullScreenBounds.height()).build();
display.getRequestedOverrideConfiguration().orientation =
@@ -809,7 +809,7 @@
private void testStackBoundsConfiguration(int windowingMode, Rect parentBounds, Rect bounds,
Rect expectedConfigBounds) {
- ActivityDisplay display = mService.mRootActivityContainer.getDefaultDisplay();
+ DisplayContent display = mService.mRootActivityContainer.getDefaultDisplay();
ActivityStack stack = display.createStack(windowingMode, ACTIVITY_TYPE_STANDARD,
true /* onTop */);
Task task = new TaskBuilder(mSupervisor).setStack(stack).build();
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java
index 817344f..2d418ff 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskSnapshotSurfaceTest.java
@@ -74,7 +74,7 @@
0 /* systemUiVisibility */, false /* isTranslucent */);
mSurface = new TaskSnapshotSurface(mWm, new Window(), new SurfaceControl(), snapshot, "Test",
createTaskDescription(Color.WHITE, Color.RED, Color.BLUE), sysuiVis, windowFlags, 0,
- taskBounds, ORIENTATION_PORTRAIT);
+ taskBounds, ORIENTATION_PORTRAIT, null /* insetsState */);
}
private static TaskDescription createTaskDescription(int background, int statusBar,
diff --git a/services/tests/wmtests/src/com/android/server/wm/TestActivityDisplay.java b/services/tests/wmtests/src/com/android/server/wm/TestDisplayContent.java
similarity index 94%
rename from services/tests/wmtests/src/com/android/server/wm/TestActivityDisplay.java
rename to services/tests/wmtests/src/com/android/server/wm/TestDisplayContent.java
index 247cd87..325cea7 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TestActivityDisplay.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TestDisplayContent.java
@@ -35,11 +35,11 @@
import android.view.DisplayCutout;
import android.view.DisplayInfo;
-class TestActivityDisplay extends ActivityDisplay {
+class TestDisplayContent extends DisplayContent {
private final ActivityStackSupervisor mSupervisor;
- private TestActivityDisplay(ActivityStackSupervisor supervisor, Display display) {
- super(supervisor.mService.mRootActivityContainer, display);
+ private TestDisplayContent(ActivityStackSupervisor supervisor, Display display) {
+ super(display, supervisor.mService.mRootActivityContainer);
// Normally this comes from display-properties as exposed by WM. Without that, just
// hard-code to FULLSCREEN for tests.
setWindowingMode(WINDOWING_MODE_FULLSCREEN);
@@ -140,13 +140,13 @@
mInfo.logicalDensityDpi = dpi;
return this;
}
- TestActivityDisplay build() {
+ TestDisplayContent build() {
final int displayId = SystemServicesTestRule.sNextDisplayId++;
final Display display = new Display(DisplayManagerGlobal.getInstance(), displayId,
mInfo, DEFAULT_DISPLAY_ADJUSTMENTS);
- final TestActivityDisplay newDisplay;
+ final TestDisplayContent newDisplay;
synchronized (mService.mGlobalLock) {
- newDisplay = new TestActivityDisplay(mService.mStackSupervisor, display);
+ newDisplay = new TestDisplayContent(mService.mStackSupervisor, display);
mService.mRootActivityContainer.addChild(newDisplay, mPosition);
}
// disable the normal system decorations
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java
index 4d25a83..6108db3 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java
@@ -61,33 +61,33 @@
assertEquals(INVALID_DISPLAY, mWpc.getDisplayId());
// Register to display 1 as a listener.
- TestActivityDisplay testActivityDisplay1 = createTestActivityDisplayInContainer();
- mWpc.registerDisplayConfigurationListenerLocked(testActivityDisplay1);
- assertTrue(testActivityDisplay1.containsListener(mWpc));
- assertEquals(testActivityDisplay1.mDisplayId, mWpc.getDisplayId());
+ TestDisplayContent testDisplayContent1 = createTestDisplayContentInContainer();
+ mWpc.registerDisplayConfigurationListenerLocked(testDisplayContent1);
+ assertTrue(testDisplayContent1.containsListener(mWpc));
+ assertEquals(testDisplayContent1.mDisplayId, mWpc.getDisplayId());
// Move to display 2.
- TestActivityDisplay testActivityDisplay2 = createTestActivityDisplayInContainer();
- mWpc.registerDisplayConfigurationListenerLocked(testActivityDisplay2);
- assertFalse(testActivityDisplay1.containsListener(mWpc));
- assertTrue(testActivityDisplay2.containsListener(mWpc));
- assertEquals(testActivityDisplay2.mDisplayId, mWpc.getDisplayId());
+ TestDisplayContent testDisplayContent2 = createTestDisplayContentInContainer();
+ mWpc.registerDisplayConfigurationListenerLocked(testDisplayContent2);
+ assertFalse(testDisplayContent1.containsListener(mWpc));
+ assertTrue(testDisplayContent2.containsListener(mWpc));
+ assertEquals(testDisplayContent2.mDisplayId, mWpc.getDisplayId());
- // Null ActivityDisplay will not change anything.
+ // Null DisplayContent will not change anything.
mWpc.registerDisplayConfigurationListenerLocked(null);
- assertTrue(testActivityDisplay2.containsListener(mWpc));
- assertEquals(testActivityDisplay2.mDisplayId, mWpc.getDisplayId());
+ assertTrue(testDisplayContent2.containsListener(mWpc));
+ assertEquals(testDisplayContent2.mDisplayId, mWpc.getDisplayId());
// Unregister listener will remove the wpc from registered displays.
mWpc.unregisterDisplayConfigurationListenerLocked();
- assertFalse(testActivityDisplay1.containsListener(mWpc));
- assertFalse(testActivityDisplay2.containsListener(mWpc));
+ assertFalse(testDisplayContent1.containsListener(mWpc));
+ assertFalse(testDisplayContent2.containsListener(mWpc));
assertEquals(INVALID_DISPLAY, mWpc.getDisplayId());
// Unregistration still work even if the display was removed.
- mWpc.registerDisplayConfigurationListenerLocked(testActivityDisplay1);
- assertEquals(testActivityDisplay1.mDisplayId, mWpc.getDisplayId());
- mRootActivityContainer.removeChild(testActivityDisplay1);
+ mWpc.registerDisplayConfigurationListenerLocked(testDisplayContent1);
+ assertEquals(testDisplayContent1.mDisplayId, mWpc.getDisplayId());
+ mRootActivityContainer.removeChild(testDisplayContent1);
mWpc.unregisterDisplayConfigurationListenerLocked();
assertEquals(INVALID_DISPLAY, mWpc.getDisplayId());
}
@@ -129,7 +129,7 @@
orderVerifier.verifyNoMoreInteractions();
}
- private TestActivityDisplay createTestActivityDisplayInContainer() {
- return new TestActivityDisplay.Builder(mService, 1000, 1500).build();
+ private TestDisplayContent createTestDisplayContentInContainer() {
+ return new TestDisplayContent.Builder(mService, 1000, 1500).build();
}
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
index 72baedb..8ade4d2 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
@@ -61,6 +61,7 @@
import android.graphics.Insets;
import android.graphics.Matrix;
+import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;
import android.util.Size;
@@ -222,8 +223,7 @@
final WindowState appWindow = createWindow(null, TYPE_APPLICATION, "appWindow");
final WindowState imeWindow = createWindow(null, TYPE_INPUT_METHOD, "imeWindow");
- // Setting FLAG_NOT_FOCUSABLE without FLAG_ALT_FOCUSABLE_IM prevents the window from being
- // an IME target.
+ // Setting FLAG_NOT_FOCUSABLE prevents the window from being an IME target.
appWindow.mAttrs.flags |= FLAG_NOT_FOCUSABLE;
imeWindow.mAttrs.flags |= FLAG_NOT_FOCUSABLE;
@@ -231,7 +231,7 @@
appWindow.setHasSurface(true);
imeWindow.setHasSurface(true);
- // Windows without flags (FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM) can't be IME targets
+ // Windows with FLAG_NOT_FOCUSABLE can't be IME targets
assertFalse(appWindow.canBeImeTarget());
assertFalse(imeWindow.canBeImeTarget());
@@ -239,11 +239,22 @@
appWindow.mAttrs.flags |= (FLAG_NOT_FOCUSABLE | FLAG_ALT_FOCUSABLE_IM);
imeWindow.mAttrs.flags |= (FLAG_NOT_FOCUSABLE | FLAG_ALT_FOCUSABLE_IM);
- // Visible app window with flags can be IME target while an IME window can never be an IME
- // target regardless of its visibility or flags.
- assertTrue(appWindow.canBeImeTarget());
+ // Visible app window with flags FLAG_NOT_FOCUSABLE or FLAG_ALT_FOCUSABLE_IM can't be IME
+ // target while an IME window can never be an IME target regardless of its visibility
+ // or flags.
+ assertFalse(appWindow.canBeImeTarget());
assertFalse(imeWindow.canBeImeTarget());
+ // b/145812508: special legacy use-case for transparent/translucent windows.
+ appWindow.mAttrs.format = PixelFormat.TRANSPARENT;
+ assertTrue(appWindow.canBeImeTarget());
+
+ appWindow.mAttrs.format = PixelFormat.OPAQUE;
+ appWindow.mAttrs.flags &= ~FLAG_ALT_FOCUSABLE_IM;
+ assertFalse(appWindow.canBeImeTarget());
+ appWindow.mAttrs.flags &= ~FLAG_NOT_FOCUSABLE;
+ assertTrue(appWindow.canBeImeTarget());
+
// Make windows invisible
appWindow.hideLw(false /* doAnimation */);
imeWindow.hideLw(false /* doAnimation */);
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
index 22ba90b..6f53428 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
@@ -340,8 +340,8 @@
/** Creates a {@link DisplayContent} and adds it to the system. */
DisplayContent createNewDisplay(DisplayInfo info) {
- final ActivityDisplay display =
- new TestActivityDisplay.Builder(mWm.mAtmService, info).build();
+ final DisplayContent display =
+ new TestDisplayContent.Builder(mWm.mAtmService, info).build();
return display.mDisplayContent;
}
diff --git a/services/usb/java/com/android/server/usb/UsbHandlerManager.java b/services/usb/java/com/android/server/usb/UsbHandlerManager.java
index 1730d8f..f311274 100644
--- a/services/usb/java/com/android/server/usb/UsbHandlerManager.java
+++ b/services/usb/java/com/android/server/usb/UsbHandlerManager.java
@@ -19,6 +19,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.ActivityNotFoundException;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
@@ -59,8 +60,9 @@
if (uri != null && uri.length() > 0) {
// display URI to user
Intent dialogIntent = createDialogIntent();
- dialogIntent.setClassName("com.android.systemui",
- "com.android.systemui.usb.UsbAccessoryUriActivity");
+ dialogIntent.setComponent(ComponentName.unflattenFromString(
+ mContext.getResources().getString(
+ com.android.internal.R.string.config_usbAccessoryUriActivity)));
dialogIntent.putExtra(UsbManager.EXTRA_ACCESSORY, accessory);
dialogIntent.putExtra("uri", uri);
try {
@@ -84,8 +86,9 @@
@Nullable UsbAccessory accessory) {
Intent resolverIntent = createDialogIntent();
// start UsbConfirmActivity if there is only one choice
- resolverIntent.setClassName("com.android.systemui",
- "com.android.systemui.usb.UsbConfirmActivity");
+ resolverIntent.setComponent(ComponentName.unflattenFromString(
+ mContext.getResources().getString(
+ com.android.internal.R.string.config_usbConfirmActivity)));
resolverIntent.putExtra("rinfo", rInfo);
UserHandle user =
UserHandle.getUserHandleForUid(rInfo.activityInfo.applicationInfo.uid);
@@ -115,8 +118,9 @@
void selectUsbHandler(@NonNull ArrayList<ResolveInfo> matches,
@NonNull UserHandle user, @NonNull Intent intent) {
Intent resolverIntent = createDialogIntent();
- resolverIntent.setClassName("com.android.systemui",
- "com.android.systemui.usb.UsbResolverActivity");
+ resolverIntent.setComponent(ComponentName.unflattenFromString(
+ mContext.getResources().getString(
+ com.android.internal.R.string.config_usbResolverActivity)));
resolverIntent.putParcelableArrayListExtra("rlist", matches);
resolverIntent.putExtra(Intent.EXTRA_INTENT, intent);
diff --git a/services/usb/java/com/android/server/usb/UsbPortManager.java b/services/usb/java/com/android/server/usb/UsbPortManager.java
index 749258e..c3e2013 100644
--- a/services/usb/java/com/android/server/usb/UsbPortManager.java
+++ b/services/usb/java/com/android/server/usb/UsbPortManager.java
@@ -34,6 +34,7 @@
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
@@ -225,8 +226,8 @@
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.setClassName("com.android.systemui",
- "com.android.systemui.usb.UsbContaminantActivity");
+ intent.setComponent(ComponentName.unflattenFromString(r.getString(
+ com.android.internal.R.string.config_usbContaminantActivity)));
intent.putExtra(UsbManager.EXTRA_PORT, ParcelableUsbPort.of(currentPortInfo.mUsbPort));
PendingIntent pi = PendingIntent.getActivityAsUser(mContext, 0,
diff --git a/services/usb/java/com/android/server/usb/UsbSerialReader.java b/services/usb/java/com/android/server/usb/UsbSerialReader.java
index 86016bb..095e8e9 100644
--- a/services/usb/java/com/android/server/usb/UsbSerialReader.java
+++ b/services/usb/java/com/android/server/usb/UsbSerialReader.java
@@ -75,12 +75,14 @@
if (uid != Process.SYSTEM_UID) {
enforcePackageBelongsToUid(uid, packageName);
+ UserHandle user = Binder.getCallingUserHandle();
int packageTargetSdkVersion;
long token = Binder.clearCallingIdentity();
try {
PackageInfo pkg;
try {
- pkg = mContext.getPackageManager().getPackageInfo(packageName, 0);
+ pkg = mContext.getPackageManager()
+ .getPackageInfoAsUser(packageName, 0, user.getIdentifier());
} catch (PackageManager.NameNotFoundException e) {
throw new RemoteException("package " + packageName + " cannot be found");
}
diff --git a/services/usb/java/com/android/server/usb/UsbUserPermissionManager.java b/services/usb/java/com/android/server/usb/UsbUserPermissionManager.java
index 58f5484..2a94393 100644
--- a/services/usb/java/com/android/server/usb/UsbUserPermissionManager.java
+++ b/services/usb/java/com/android/server/usb/UsbUserPermissionManager.java
@@ -20,6 +20,7 @@
import android.annotation.Nullable;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -515,8 +516,8 @@
intent.putExtra(Intent.EXTRA_UID, uid);
intent.putExtra(UsbManager.EXTRA_CAN_BE_DEFAULT, canBeDefault);
intent.putExtra(UsbManager.EXTRA_PACKAGE, packageName);
- intent.setClassName("com.android.systemui",
- "com.android.systemui.usb.UsbPermissionActivity");
+ intent.setComponent(ComponentName.unflattenFromString(userContext.getResources().getString(
+ com.android.internal.R.string.config_usbPermissionActivity)));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
diff --git a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java
index 735b9a1..198b4c3 100644
--- a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java
+++ b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerHelper.java
@@ -16,11 +16,14 @@
package com.android.server.soundtrigger;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.hardware.soundtrigger.IRecognitionStatusCallback;
+import android.hardware.soundtrigger.ModelParams;
import android.hardware.soundtrigger.SoundTrigger;
import android.hardware.soundtrigger.SoundTrigger.GenericRecognitionEvent;
import android.hardware.soundtrigger.SoundTrigger.GenericSoundModel;
@@ -28,6 +31,7 @@
import android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionEvent;
import android.hardware.soundtrigger.SoundTrigger.KeyphraseRecognitionExtra;
import android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel;
+import android.hardware.soundtrigger.SoundTrigger.ModelParamRange;
import android.hardware.soundtrigger.SoundTrigger.ModuleProperties;
import android.hardware.soundtrigger.SoundTrigger.RecognitionConfig;
import android.hardware.soundtrigger.SoundTrigger.RecognitionEvent;
@@ -605,6 +609,67 @@
return STATUS_ERROR;
}
+ int setParameter(UUID modelId, @ModelParams int modelParam, int value) {
+ synchronized (mLock) {
+ MetricsLogger.count(mContext, "sth_set_parameter", 1);
+ if (modelId == null || mModule == null) {
+ return SoundTrigger.STATUS_ERROR;
+ }
+ ModelData modelData = mModelDataMap.get(modelId);
+ if (modelData == null) {
+ Slog.w(TAG, "SetParameter: Invalid model id:" + modelId);
+ return SoundTrigger.STATUS_BAD_VALUE;
+ }
+ if (!modelData.isModelLoaded()) {
+ Slog.i(TAG, "SetParameter: Given model is not loaded:" + modelId);
+ return SoundTrigger.STATUS_BAD_VALUE;
+ }
+
+ return mModule.setParameter(modelData.getHandle(), modelParam, value);
+ }
+ }
+
+ int getParameter(@NonNull UUID modelId, @ModelParams int modelParam)
+ throws UnsupportedOperationException, IllegalArgumentException {
+ synchronized (mLock) {
+ MetricsLogger.count(mContext, "sth_get_parameter", 1);
+ if (mModule == null) {
+ throw new UnsupportedOperationException("SoundTriggerModule not initialized");
+ }
+
+ ModelData modelData = mModelDataMap.get(modelId);
+ if (modelData == null) {
+ throw new IllegalArgumentException("Invalid model id:" + modelId);
+ }
+ if (!modelData.isModelLoaded()) {
+ throw new UnsupportedOperationException("Given model is not loaded:" + modelId);
+ }
+
+ return mModule.getParameter(modelData.getHandle(), modelParam);
+ }
+ }
+
+ @Nullable
+ ModelParamRange queryParameter(@NonNull UUID modelId, @ModelParams int modelParam) {
+ synchronized (mLock) {
+ MetricsLogger.count(mContext, "sth_query_parameter", 1);
+ if (mModule == null) {
+ return null;
+ }
+ ModelData modelData = mModelDataMap.get(modelId);
+ if (modelData == null) {
+ Slog.w(TAG, "queryParameter: Invalid model id:" + modelId);
+ return null;
+ }
+ if (!modelData.isModelLoaded()) {
+ Slog.i(TAG, "queryParameter: Given model is not loaded:" + modelId);
+ return null;
+ }
+
+ return mModule.queryParameter(modelData.getHandle(), modelParam);
+ }
+ }
+
//---- SoundTrigger.StatusListener methods
@Override
public void onRecognition(RecognitionEvent event) {
@@ -653,15 +718,15 @@
}
ModelData model = getModelDataForLocked(event.soundModelHandle);
if (model == null || !model.isGenericModel()) {
- Slog.w(TAG, "Generic recognition event: Model does not exist for handle: " +
- event.soundModelHandle);
+ Slog.w(TAG, "Generic recognition event: Model does not exist for handle: "
+ + event.soundModelHandle);
return;
}
IRecognitionStatusCallback callback = model.getCallback();
if (callback == null) {
- Slog.w(TAG, "Generic recognition event: Null callback for model handle: " +
- event.soundModelHandle);
+ Slog.w(TAG, "Generic recognition event: Null callback for model handle: "
+ + event.soundModelHandle);
return;
}
@@ -678,8 +743,8 @@
RecognitionConfig config = model.getRecognitionConfig();
if (config == null) {
- Slog.w(TAG, "Generic recognition event: Null RecognitionConfig for model handle: " +
- event.soundModelHandle);
+ Slog.w(TAG, "Generic recognition event: Null RecognitionConfig for model handle: "
+ + event.soundModelHandle);
return;
}
diff --git a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java
index 1dd3972..96d2df1 100644
--- a/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java
+++ b/services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java
@@ -22,7 +22,9 @@
import static android.content.pm.PackageManager.GET_META_DATA;
import static android.content.pm.PackageManager.GET_SERVICES;
import static android.content.pm.PackageManager.MATCH_DEBUG_TRIAGED_MISSING;
+import static android.hardware.soundtrigger.SoundTrigger.STATUS_BAD_VALUE;
import static android.hardware.soundtrigger.SoundTrigger.STATUS_ERROR;
+import static android.hardware.soundtrigger.SoundTrigger.STATUS_NO_INIT;
import static android.hardware.soundtrigger.SoundTrigger.STATUS_OK;
import static android.provider.Settings.Global.MAX_SOUND_TRIGGER_DETECTION_SERVICE_OPS_PER_DAY;
import static android.provider.Settings.Global.SOUND_TRIGGER_DETECTION_SERVICE_OP_TIMEOUT;
@@ -39,9 +41,11 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.hardware.soundtrigger.IRecognitionStatusCallback;
+import android.hardware.soundtrigger.ModelParams;
import android.hardware.soundtrigger.SoundTrigger;
import android.hardware.soundtrigger.SoundTrigger.GenericSoundModel;
import android.hardware.soundtrigger.SoundTrigger.KeyphraseSoundModel;
+import android.hardware.soundtrigger.SoundTrigger.ModelParamRange;
import android.hardware.soundtrigger.SoundTrigger.ModuleProperties;
import android.hardware.soundtrigger.SoundTrigger.RecognitionConfig;
import android.hardware.soundtrigger.SoundTrigger.SoundModel;
@@ -683,6 +687,101 @@
return properties;
}
}
+
+ @Override
+ public int setParameter(ParcelUuid soundModelId,
+ @ModelParams int modelParam, int value) {
+ enforceCallingPermission(Manifest.permission.MANAGE_SOUND_TRIGGER);
+ if (!isInitialized()) return STATUS_NO_INIT;
+ if (DEBUG) {
+ Slog.d(TAG, "setParameter(): id=" + soundModelId
+ + ", param=" + modelParam
+ + ", value=" + value);
+ }
+
+ sEventLogger.log(new SoundTriggerLogger.StringEvent(
+ "setParameter(): id=" + soundModelId
+ + ", param=" + modelParam
+ + ", value=" + value));
+
+ synchronized (mLock) {
+ SoundModel soundModel = mLoadedModels.get(soundModelId.getUuid());
+ if (soundModel == null) {
+ Slog.e(TAG, soundModelId + " is not loaded. Loaded models: "
+ + mLoadedModels.toString());
+
+ sEventLogger.log(new SoundTriggerLogger.StringEvent("setParameter(): "
+ + soundModelId + " is not loaded"));
+
+ return STATUS_BAD_VALUE;
+ }
+
+ return mSoundTriggerHelper.setParameter(soundModel.uuid, modelParam, value);
+ }
+ }
+
+ @Override
+ public int getParameter(@NonNull ParcelUuid soundModelId,
+ @ModelParams int modelParam)
+ throws UnsupportedOperationException, IllegalArgumentException {
+ enforceCallingPermission(Manifest.permission.MANAGE_SOUND_TRIGGER);
+ if (!isInitialized()) {
+ throw new UnsupportedOperationException("SoundTriggerHelper not initialized");
+ }
+ if (DEBUG) {
+ Slog.d(TAG, "getParameter(): id=" + soundModelId
+ + ", param=" + modelParam);
+ }
+
+ sEventLogger.log(new SoundTriggerLogger.StringEvent(
+ "getParameter(): id=" + soundModelId
+ + ", param=" + modelParam));
+
+ synchronized (mLock) {
+ SoundModel soundModel = mLoadedModels.get(soundModelId.getUuid());
+ if (soundModel == null) {
+ Slog.e(TAG, soundModelId + " is not loaded");
+
+ sEventLogger.log(new SoundTriggerLogger.StringEvent("getParameter(): "
+ + soundModelId + " is not loaded"));
+
+ throw new IllegalArgumentException("sound model is not loaded");
+ }
+
+ return mSoundTriggerHelper.getParameter(soundModel.uuid, modelParam);
+ }
+ }
+
+ @Override
+ @Nullable
+ public ModelParamRange queryParameter(@NonNull ParcelUuid soundModelId,
+ @ModelParams int modelParam) {
+ enforceCallingPermission(Manifest.permission.MANAGE_SOUND_TRIGGER);
+ if (!isInitialized()) return null;
+ if (DEBUG) {
+ Slog.d(TAG, "queryParameter(): id=" + soundModelId
+ + ", param=" + modelParam);
+ }
+
+ sEventLogger.log(new SoundTriggerLogger.StringEvent(
+ "queryParameter(): id=" + soundModelId
+ + ", param=" + modelParam));
+
+ synchronized (mLock) {
+ SoundModel soundModel = mLoadedModels.get(soundModelId.getUuid());
+ if (soundModel == null) {
+ Slog.e(TAG, soundModelId + " is not loaded");
+
+ sEventLogger.log(new SoundTriggerLogger.StringEvent(
+ "queryParameter(): "
+ + soundModelId + " is not loaded"));
+
+ return null;
+ }
+
+ return mSoundTriggerHelper.queryParameter(soundModel.uuid, modelParam);
+ }
+ }
}
/**
diff --git a/telephony/common/com/android/internal/telephony/TelephonyPermissions.java b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java
index 86630b0..fbb1380 100644
--- a/telephony/common/com/android/internal/telephony/TelephonyPermissions.java
+++ b/telephony/common/com/android/internal/telephony/TelephonyPermissions.java
@@ -27,8 +27,6 @@
import android.os.Binder;
import android.os.Build;
import android.os.Process;
-import android.os.RemoteException;
-import android.os.ServiceManager;
import android.os.UserHandle;
import android.telephony.Rlog;
import android.telephony.SubscriptionManager;
@@ -42,7 +40,6 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.function.Supplier;
/** Utility class for Telephony permission enforcement. */
public final class TelephonyPermissions {
@@ -50,9 +47,6 @@
private static final boolean DBG = false;
- private static final Supplier<ITelephony> TELEPHONY_SUPPLIER = () ->
- ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE));
-
/**
* Whether to disable the new device identifier access restrictions.
*/
@@ -138,49 +132,6 @@
public static boolean checkReadPhoneState(
Context context, int subId, int pid, int uid, String callingPackage,
@Nullable String callingFeatureId, String message) {
- return checkReadPhoneState(
- context, TELEPHONY_SUPPLIER, subId, pid, uid, callingPackage, callingFeatureId,
- message);
- }
-
- /**
- * Check whether the calling packages has carrier privileges for the passing subscription.
- * @return {@code true} if the caller has carrier privileges, {@false} otherwise.
- */
- public static boolean checkCarrierPrivilegeForSubId(int subId) {
- if (SubscriptionManager.isValidSubscriptionId(subId)
- && getCarrierPrivilegeStatus(TELEPHONY_SUPPLIER, subId, Binder.getCallingUid())
- == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
- return true;
- }
- return false;
- }
-
- /**
- * Check whether the app with the given pid/uid can read phone state.
- *
- * <p>This method behaves in one of the following ways:
- * <ul>
- * <li>return true: if the caller has the READ_PRIVILEGED_PHONE_STATE permission, the
- * READ_PHONE_STATE runtime permission, or carrier privileges on the given subId.
- * <li>throw SecurityException: if the caller didn't declare any of these permissions, or, for
- * apps which support runtime permissions, if the caller does not currently have any of
- * these permissions.
- * <li>return false: if the caller lacks all of these permissions and doesn't support runtime
- * permissions. This implies that the user revoked the ability to read phone state
- * manually (via AppOps). In this case we can't throw as it would break app compatibility,
- * so we return false to indicate that the calling function should return dummy data.
- * </ul>
- *
- * <p>Note: for simplicity, this method always returns false for callers using legacy
- * permissions and who have had READ_PHONE_STATE revoked, even if they are carrier-privileged.
- * Such apps should migrate to runtime permissions or stop requiring READ_PHONE_STATE on P+
- * devices.
- */
- @VisibleForTesting
- public static boolean checkReadPhoneState(
- Context context, Supplier<ITelephony> telephonySupplier, int subId, int pid, int uid,
- String callingPackage, @Nullable String callingFeatureId, String message) {
try {
context.enforcePermission(
android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, pid, uid, message);
@@ -195,7 +146,7 @@
// If we don't have the runtime permission, but do have carrier privileges, that
// suffices for reading phone state.
if (SubscriptionManager.isValidSubscriptionId(subId)) {
- enforceCarrierPrivilege(telephonySupplier, subId, uid, message);
+ enforceCarrierPrivilege(context, subId, uid, message);
return true;
}
throw phoneStateException;
@@ -210,6 +161,19 @@
}
/**
+ * Check whether the calling packages has carrier privileges for the passing subscription.
+ * @return {@code true} if the caller has carrier privileges, {@false} otherwise.
+ */
+ public static boolean checkCarrierPrivilegeForSubId(Context context, int subId) {
+ if (SubscriptionManager.isValidSubscriptionId(subId)
+ && getCarrierPrivilegeStatus(context, subId, Binder.getCallingUid())
+ == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
* Check whether the app with the given pid/uid can read phone state, or has carrier
* privileges on any active subscription.
*
@@ -225,28 +189,6 @@
*/
public static boolean checkReadPhoneStateOnAnyActiveSub(Context context, int pid, int uid,
String callingPackage, @Nullable String callingFeatureId, String message) {
- return checkReadPhoneStateOnAnyActiveSub(context, TELEPHONY_SUPPLIER, pid, uid,
- callingPackage, callingFeatureId, message);
- }
-
- /**
- * Check whether the app with the given pid/uid can read phone state, or has carrier
- * privileges on any active subscription.
- *
- * <p>If the app does not have carrier privilege, this method will return {@code false} instead
- * of throwing a SecurityException. Therefore, the callers cannot tell the difference
- * between M+ apps which declare the runtime permission but do not have it, and pre-M apps
- * which declare the static permission but had access revoked via AppOps. Apps in the former
- * category expect SecurityExceptions; apps in the latter don't. So this method is suitable for
- * use only if the behavior in both scenarios is meant to be identical.
- *
- * @return {@code true} if the app can read phone state or has carrier privilege;
- * {@code false} otherwise.
- */
- @VisibleForTesting
- public static boolean checkReadPhoneStateOnAnyActiveSub(
- Context context, Supplier<ITelephony> telephonySupplier, int pid, int uid,
- String callingPackage, @Nullable String callingFeatureId, String message) {
try {
context.enforcePermission(
android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, pid, uid, message);
@@ -260,7 +202,7 @@
} catch (SecurityException phoneStateException) {
// If we don't have the runtime permission, but do have carrier privileges, that
// suffices for reading phone state.
- return checkCarrierPrivilegeForAnySubId(context, telephonySupplier, uid);
+ return checkCarrierPrivilegeForAnySubId(context, uid);
}
}
@@ -375,12 +317,11 @@
}
// If the calling package has carrier privileges for specified sub, then allow access.
- if (checkCarrierPrivilegeForSubId(subId)) return true;
+ if (checkCarrierPrivilegeForSubId(context, subId)) return true;
// If the calling package has carrier privileges for any subscription
// and allowCarrierPrivilegeOnAnySub is set true, then allow access.
- if (allowCarrierPrivilegeOnAnySub && checkCarrierPrivilegeForAnySubId(
- context, TELEPHONY_SUPPLIER, uid)) {
+ if (allowCarrierPrivilegeOnAnySub && checkCarrierPrivilegeForAnySubId(context, uid)) {
return true;
}
@@ -468,7 +409,7 @@
uid) == PackageManager.PERMISSION_GRANTED) {
return false;
}
- if (checkCarrierPrivilegeForSubId(subId)) {
+ if (checkCarrierPrivilegeForSubId(context, subId)) {
return false;
}
}
@@ -484,26 +425,12 @@
public static boolean checkReadCallLog(
Context context, int subId, int pid, int uid, String callingPackage,
@Nullable String callingPackageName) {
- return checkReadCallLog(
- context, TELEPHONY_SUPPLIER, subId, pid, uid, callingPackage, callingPackageName);
- }
-
- /**
- * Check whether the app with the given pid/uid can read the call log.
- * @return {@code true} if the specified app has the read call log permission and AppOpp granted
- * to it, {@code false} otherwise.
- */
- @VisibleForTesting
- public static boolean checkReadCallLog(
- Context context, Supplier<ITelephony> telephonySupplier, int subId, int pid, int uid,
- String callingPackage, @Nullable String callingFeatureId) {
-
if (context.checkPermission(Manifest.permission.READ_CALL_LOG, pid, uid)
!= PERMISSION_GRANTED) {
// If we don't have the runtime permission, but do have carrier privileges, that
// suffices for being able to see the call phone numbers.
if (SubscriptionManager.isValidSubscriptionId(subId)) {
- enforceCarrierPrivilege(telephonySupplier, subId, uid, "readCallLog");
+ enforceCarrierPrivilege(context, subId, uid, "readCallLog");
return true;
}
return false;
@@ -513,7 +440,7 @@
// revoked.
AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
return appOps.noteOp(AppOpsManager.OPSTR_READ_CALL_LOG, uid, callingPackage,
- callingFeatureId, null) == AppOpsManager.MODE_ALLOWED;
+ callingPackageName, null) == AppOpsManager.MODE_ALLOWED;
}
/**
@@ -526,7 +453,7 @@
Context context, int subId, String callingPackage, @Nullable String callingFeatureId,
String message) {
return checkReadPhoneNumber(
- context, TELEPHONY_SUPPLIER, subId, Binder.getCallingPid(), Binder.getCallingUid(),
+ context, subId, Binder.getCallingPid(), Binder.getCallingUid(),
callingPackage, callingFeatureId, message);
}
@@ -538,7 +465,7 @@
*/
@VisibleForTesting
public static boolean checkReadPhoneNumber(
- Context context, Supplier<ITelephony> telephonySupplier, int subId, int pid, int uid,
+ Context context, int subId, int pid, int uid,
String callingPackage, @Nullable String callingFeatureId, String message) {
// Default SMS app can always read it.
AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
@@ -553,7 +480,7 @@
// First, check if we can read the phone state.
try {
return checkReadPhoneState(
- context, telephonySupplier, subId, pid, uid, callingPackage, callingFeatureId,
+ context, subId, pid, uid, callingPackage, callingFeatureId,
message);
} catch (SecurityException readPhoneStateSecurityException) {
}
@@ -595,7 +522,7 @@
}
if (DBG) Rlog.d(LOG_TAG, "No modify permission, check carrier privilege next.");
- enforceCallingOrSelfCarrierPrivilege(subId, message);
+ enforceCallingOrSelfCarrierPrivilege(context, subId, message);
}
/**
@@ -615,7 +542,7 @@
Rlog.d(LOG_TAG, "No READ_PHONE_STATE permission, check carrier privilege next.");
}
- enforceCallingOrSelfCarrierPrivilege(subId, message);
+ enforceCallingOrSelfCarrierPrivilege(context, subId, message);
}
/**
@@ -636,7 +563,7 @@
+ "check carrier privilege next.");
}
- enforceCallingOrSelfCarrierPrivilege(subId, message);
+ enforceCallingOrSelfCarrierPrivilege(context, subId, message);
}
/**
@@ -644,21 +571,18 @@
*
* @throws SecurityException if the caller does not have the required privileges
*/
- public static void enforceCallingOrSelfCarrierPrivilege(int subId, String message) {
+ public static void enforceCallingOrSelfCarrierPrivilege(
+ Context context, int subId, String message) {
// NOTE: It's critical that we explicitly pass the calling UID here rather than call
// TelephonyManager#hasCarrierPrivileges directly, as the latter only works when called from
// the phone process. When called from another process, it will check whether that process
// has carrier privileges instead.
- enforceCarrierPrivilege(subId, Binder.getCallingUid(), message);
- }
-
- private static void enforceCarrierPrivilege(int subId, int uid, String message) {
- enforceCarrierPrivilege(TELEPHONY_SUPPLIER, subId, uid, message);
+ enforceCarrierPrivilege(context, subId, Binder.getCallingUid(), message);
}
private static void enforceCarrierPrivilege(
- Supplier<ITelephony> telephonySupplier, int subId, int uid, String message) {
- if (getCarrierPrivilegeStatus(telephonySupplier, subId, uid)
+ Context context, int subId, int uid, String message) {
+ if (getCarrierPrivilegeStatus(context, subId, uid)
!= TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
if (DBG) Rlog.e(LOG_TAG, "No Carrier Privilege.");
throw new SecurityException(message);
@@ -666,13 +590,12 @@
}
/** Returns whether the provided uid has carrier privileges for any active subscription ID. */
- private static boolean checkCarrierPrivilegeForAnySubId(
- Context context, Supplier<ITelephony> telephonySupplier, int uid) {
+ private static boolean checkCarrierPrivilegeForAnySubId(Context context, int uid) {
SubscriptionManager sm = (SubscriptionManager) context.getSystemService(
Context.TELEPHONY_SUBSCRIPTION_SERVICE);
int[] activeSubIds = sm.getActiveSubscriptionIdList(/* visibleOnly */ false);
for (int activeSubId : activeSubIds) {
- if (getCarrierPrivilegeStatus(telephonySupplier, activeSubId, uid)
+ if (getCarrierPrivilegeStatus(context, activeSubId, uid)
== TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
return true;
}
@@ -680,18 +603,15 @@
return false;
}
- private static int getCarrierPrivilegeStatus(
- Supplier<ITelephony> telephonySupplier, int subId, int uid) {
- ITelephony telephony = telephonySupplier.get();
+ private static int getCarrierPrivilegeStatus(Context context, int subId, int uid) {
+ final long identity = Binder.clearCallingIdentity();
try {
- if (telephony != null) {
- return telephony.getCarrierPrivilegeStatusForUid(subId, uid);
- }
- } catch (RemoteException e) {
- // Fallback below.
+ TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(
+ Context.TELEPHONY_SERVICE);
+ return telephonyManager.createForSubscriptionId(subId).getCarrierPrivilegeStatus(uid);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
}
- Rlog.e(LOG_TAG, "Phone process is down, cannot check carrier privileges");
- return TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS;
}
/**
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 001888c..c0a73cc 100755
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -419,12 +419,33 @@
KEY_GSM_NONROAMING_NETWORKS_STRING_ARRAY = "gsm_nonroaming_networks_string_array";
/**
- * Override the device's configuration for the ImsService to use for this SIM card.
+ * The package name containing the ImsService that will be bound to the telephony framework to
+ * support both IMS MMTEL and RCS feature functionality instead of the device default
+ * ImsService for this subscription.
+ * @deprecated Use {@link #KEY_CONFIG_IMS_MMTEL_PACKAGE_OVERRIDE_STRING} and
+ * {@link #KEY_CONFIG_IMS_RCS_PACKAGE_OVERRIDE_STRING} instead to configure these values
+ * separately. If any of those values are not empty, they will override this value.
*/
public static final String KEY_CONFIG_IMS_PACKAGE_OVERRIDE_STRING =
"config_ims_package_override_string";
/**
+ * The package name containing the ImsService that will be bound to the telephony framework to
+ * support IMS MMTEL feature functionality instead of the device default ImsService for this
+ * subscription.
+ */
+ public static final String KEY_CONFIG_IMS_MMTEL_PACKAGE_OVERRIDE_STRING =
+ "config_ims_mmtel_package_override_string";
+
+ /**
+ * The package name containing the ImsService that will be bound to the telephony framework to
+ * support IMS RCS feature functionality instead of the device default ImsService for this
+ * subscription.
+ */
+ public static final String KEY_CONFIG_IMS_RCS_PACKAGE_OVERRIDE_STRING =
+ "config_ims_rcs_package_override_string";
+
+ /**
* Override the package that will manage {@link SubscriptionPlan}
* information instead of the {@link CarrierService} that defines this
* value.
@@ -2176,7 +2197,7 @@
* the start of the next month.
* <p>
* This setting may be still overridden by explicit user choice. By default,
- * the platform value will be used.
+ * {@link #DATA_CYCLE_USE_PLATFORM_DEFAULT} will be used.
*/
public static final String KEY_MONTHLY_DATA_CYCLE_DAY_INT =
"monthly_data_cycle_day_int";
@@ -2185,10 +2206,7 @@
* When {@link #KEY_MONTHLY_DATA_CYCLE_DAY_INT}, {@link #KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG},
* or {@link #KEY_DATA_WARNING_THRESHOLD_BYTES_LONG} are set to this value, the platform default
* value will be used for that key.
- *
- * @hide
*/
- @Deprecated
public static final int DATA_CYCLE_USE_PLATFORM_DEFAULT = -1;
/**
@@ -2212,8 +2230,8 @@
* If the value is set to {@link #DATA_CYCLE_THRESHOLD_DISABLED}, the data usage warning will
* be disabled.
* <p>
- * This setting may be overridden by explicit user choice. By default, the platform value
- * will be used.
+ * This setting may be overridden by explicit user choice. By default,
+ * {@link #DATA_CYCLE_USE_PLATFORM_DEFAULT} will be used.
*/
public static final String KEY_DATA_WARNING_THRESHOLD_BYTES_LONG =
"data_warning_threshold_bytes_long";
@@ -2221,8 +2239,7 @@
/**
* Controls if the device should automatically notify the user as they reach
* their cellular data warning. When set to {@code false} the carrier is
- * expected to have implemented their own notification mechanism.
- * @hide
+ * expected to have implemented their own notification mechanism. {@code true} by default.
*/
public static final String KEY_DATA_WARNING_NOTIFICATION_BOOL =
"data_warning_notification_bool";
@@ -2244,8 +2261,8 @@
* phone. If the value is set to {@link #DATA_CYCLE_THRESHOLD_DISABLED}, the data limit will be
* disabled.
* <p>
- * This setting may be overridden by explicit user choice. By default, the platform value
- * will be used.
+ * This setting may be overridden by explicit user choice. By default,
+ * {@link #DATA_CYCLE_USE_PLATFORM_DEFAULT} will be used.
*/
public static final String KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG =
"data_limit_threshold_bytes_long";
@@ -2253,8 +2270,7 @@
/**
* Controls if the device should automatically notify the user as they reach
* their cellular data limit. When set to {@code false} the carrier is
- * expected to have implemented their own notification mechanism.
- * @hide
+ * expected to have implemented their own notification mechanism. {@code true} by default.
*/
public static final String KEY_DATA_LIMIT_NOTIFICATION_BOOL =
"data_limit_notification_bool";
@@ -2262,8 +2278,7 @@
/**
* Controls if the device should automatically notify the user when rapid
* cellular data usage is observed. When set to {@code false} the carrier is
- * expected to have implemented their own notification mechanism.
- * @hide
+ * expected to have implemented their own notification mechanism. {@code true} by default.
*/
public static final String KEY_DATA_RAPID_NOTIFICATION_BOOL =
"data_rapid_notification_bool";
@@ -3486,6 +3501,8 @@
sDefaults.putStringArray(KEY_GSM_ROAMING_NETWORKS_STRING_ARRAY, null);
sDefaults.putStringArray(KEY_GSM_NONROAMING_NETWORKS_STRING_ARRAY, null);
sDefaults.putString(KEY_CONFIG_IMS_PACKAGE_OVERRIDE_STRING, null);
+ sDefaults.putString(KEY_CONFIG_IMS_MMTEL_PACKAGE_OVERRIDE_STRING, null);
+ sDefaults.putString(KEY_CONFIG_IMS_RCS_PACKAGE_OVERRIDE_STRING, null);
sDefaults.putStringArray(KEY_CDMA_ROAMING_NETWORKS_STRING_ARRAY, null);
sDefaults.putStringArray(KEY_CDMA_NONROAMING_NETWORKS_STRING_ARRAY, null);
sDefaults.putStringArray(KEY_DIAL_STRING_REPLACE_STRING_ARRAY, null);
diff --git a/telephony/java/android/telephony/ImsManager.java b/telephony/java/android/telephony/ImsManager.java
index 02d8be3..39af34c 100644
--- a/telephony/java/android/telephony/ImsManager.java
+++ b/telephony/java/android/telephony/ImsManager.java
@@ -16,7 +16,10 @@
package android.telephony.ims;
+import android.annotation.NonNull;
+import android.annotation.SystemApi;
import android.annotation.SystemService;
+import android.annotation.TestApi;
import android.content.Context;
import android.telephony.SubscriptionManager;
@@ -25,12 +28,15 @@
*
* @hide
*/
+@SystemApi
+@TestApi
@SystemService(Context.TELEPHONY_IMS_SERVICE)
public class ImsManager {
private Context mContext;
- public ImsManager(Context context) {
+ /** @hide */
+ public ImsManager(@NonNull Context context) {
mContext = context;
}
@@ -41,6 +47,7 @@
* @throws IllegalArgumentException if the subscription is invalid.
* @return a ImsRcsManager instance with the specific subscription ID.
*/
+ @NonNull
public ImsRcsManager getImsRcsManager(int subscriptionId) {
if (!SubscriptionManager.isValidSubscriptionId(subscriptionId)) {
throw new IllegalArgumentException("Invalid subscription ID: " + subscriptionId);
@@ -56,6 +63,7 @@
* @throws IllegalArgumentException if the subscription is invalid.
* @return a ImsMmTelManager instance with the specific subscription ID.
*/
+ @NonNull
public ImsMmTelManager getImsMmTelManager(int subscriptionId) {
if (!SubscriptionManager.isValidSubscriptionId(subscriptionId)) {
throw new IllegalArgumentException("Invalid subscription ID: " + subscriptionId);
diff --git a/telephony/java/android/telephony/NetworkScanRequest.java b/telephony/java/android/telephony/NetworkScanRequest.java
index 0ceb103..c8b8ffb 100644
--- a/telephony/java/android/telephony/NetworkScanRequest.java
+++ b/telephony/java/android/telephony/NetworkScanRequest.java
@@ -222,9 +222,13 @@
private NetworkScanRequest(Parcel in) {
mScanType = in.readInt();
Parcelable[] tempSpecifiers = in.readParcelableArray(Object.class.getClassLoader());
- mSpecifiers = new RadioAccessSpecifier[tempSpecifiers.length];
- for (int i = 0; i < tempSpecifiers.length; i++) {
- mSpecifiers[i] = (RadioAccessSpecifier) tempSpecifiers[i];
+ if (tempSpecifiers != null) {
+ mSpecifiers = new RadioAccessSpecifier[tempSpecifiers.length];
+ for (int i = 0; i < tempSpecifiers.length; i++) {
+ mSpecifiers[i] = (RadioAccessSpecifier) tempSpecifiers[i];
+ }
+ } else {
+ mSpecifiers = null;
}
mSearchPeriodicity = in.readInt();
mMaxSearchTime = in.readInt();
diff --git a/telephony/java/android/telephony/PreciseDataConnectionState.java b/telephony/java/android/telephony/PreciseDataConnectionState.java
index 257d634..78ad5c5 100644
--- a/telephony/java/android/telephony/PreciseDataConnectionState.java
+++ b/telephony/java/android/telephony/PreciseDataConnectionState.java
@@ -19,8 +19,10 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
+import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.net.LinkProperties;
+import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.telephony.Annotation.ApnType;
@@ -29,6 +31,8 @@
import android.telephony.Annotation.NetworkType;
import android.telephony.data.ApnSetting;
+import dalvik.system.VMRuntime;
+
import java.util.Objects;
@@ -46,35 +50,62 @@
* <li>Data connection fail cause.
* </ul>
*
- * @hide
*/
-@SystemApi
public final class PreciseDataConnectionState implements Parcelable {
private @DataState int mState = TelephonyManager.DATA_UNKNOWN;
private @NetworkType int mNetworkType = TelephonyManager.NETWORK_TYPE_UNKNOWN;
private @DataFailureCause int mFailCause = DataFailCause.NONE;
- private @ApnType int mAPNTypes = ApnSetting.TYPE_NONE;
- private String mAPN = "";
+ private @ApnType int mApnTypes = ApnSetting.TYPE_NONE;
+ private String mApn = "";
private LinkProperties mLinkProperties = null;
+ private ApnSetting mApnSetting = null;
/**
* Constructor
*
+ * @deprecated this constructor has been superseded and should not be used.
* @hide
*/
- @UnsupportedAppUsage
+ @TestApi
+ @Deprecated
+ @UnsupportedAppUsage // (maxTargetSdk = Build.VERSION_CODES.Q)
+ // FIXME: figure out how to remove the UnsupportedAppUsage and delete this constructor
public PreciseDataConnectionState(@DataState int state,
@NetworkType int networkType,
- @ApnType int apnTypes, String apn,
- LinkProperties linkProperties,
+ @ApnType int apnTypes, @NonNull String apn,
+ @Nullable LinkProperties linkProperties,
@DataFailureCause int failCause) {
+ this(state, networkType, apnTypes, apn, linkProperties, failCause, null);
+ }
+
+
+ /**
+ * Constructor
+ *
+ * @param state the state of the data connection
+ * @param networkType the access network that is/would carry this data connection
+ * @param apnTypes the APN types that this data connection carries
+ * @param apnSetting if there is a valid APN for this Data Connection, then the APN Settings;
+ * if there is no valid APN setting for the specific type, then this will be null
+ * @param linkProperties if the data connection is connected, the properties of the connection
+ * @param failCause in case a procedure related to this data connection fails, a non-zero error
+ * code indicating the cause of the failure.
+ * @hide
+ */
+ public PreciseDataConnectionState(@DataState int state,
+ @NetworkType int networkType,
+ @ApnType int apnTypes, @NonNull String apn,
+ @Nullable LinkProperties linkProperties,
+ @DataFailureCause int failCause,
+ @Nullable ApnSetting apnSetting) {
mState = state;
mNetworkType = networkType;
- mAPNTypes = apnTypes;
- mAPN = apn;
+ mApnTypes = apnTypes;
+ mApn = apn;
mLinkProperties = linkProperties;
mFailCause = failCause;
+ mApnSetting = apnSetting;
}
/**
@@ -93,76 +124,160 @@
private PreciseDataConnectionState(Parcel in) {
mState = in.readInt();
mNetworkType = in.readInt();
- mAPNTypes = in.readInt();
- mAPN = in.readString();
- mLinkProperties = (LinkProperties)in.readParcelable(null);
+ mApnTypes = in.readInt();
+ mApn = in.readString();
+ mLinkProperties = (LinkProperties) in.readParcelable(null);
mFailCause = in.readInt();
+ mApnSetting = (ApnSetting) in.readParcelable(null);
}
/**
* Returns the state of data connection that supported the apn types returned by
* {@link #getDataConnectionApnTypeBitMask()}
+ *
+ * @deprecated use {@link #getState()}
+ * @hide
*/
+ @Deprecated
+ @SystemApi
public @DataState int getDataConnectionState() {
+ if (mState == TelephonyManager.DATA_DISCONNECTING
+ && VMRuntime.getRuntime().getTargetSdkVersion() < Build.VERSION_CODES.R) {
+ return TelephonyManager.DATA_CONNECTED;
+ }
+
+ return mState;
+ }
+
+ /**
+ * Returns the high-level state of this data connection.
+ */
+ public @DataState int getState() {
return mState;
}
/**
* Returns the network type associated with this data connection.
+ *
+ * @deprecated use {@link getNetworkType()}
* @hide
*/
+ @Deprecated
+ @SystemApi
public @NetworkType int getDataConnectionNetworkType() {
return mNetworkType;
}
/**
- * Returns the data connection APN types supported by this connection and triggers
- * {@link PreciseDataConnectionState} change.
+ * Returns the network type associated with this data connection.
+ *
+ * Return the current/latest (radio) bearer technology that carries this data connection.
+ * For a variety of reasons, the network type can change during the life of the data
+ * connection, and this information is not reliable unless the physical link is currently
+ * active; (there is currently no mechanism to know whether the physical link is active at
+ * any given moment). Thus, this value is generally correct but may not be relied-upon to
+ * represent the status of the radio bearer at any given moment.
*/
- public @ApnType int getDataConnectionApnTypeBitMask() {
- return mAPNTypes;
+ public @NetworkType int getNetworkType() {
+ return mNetworkType;
}
/**
- * Returns APN {@link ApnSetting} of this data connection.
+ * Returns the APN types mapped to this data connection.
+ *
+ * @deprecated use {@link #getApnSetting()}
+ * @hide
*/
- @Nullable
+ @Deprecated
+ @SystemApi
+ public @ApnType int getDataConnectionApnTypeBitMask() {
+ return mApnTypes;
+ }
+
+ /**
+ * Returns APN of this data connection.
+ *
+ * @deprecated use {@link #getApnSetting()}
+ * @hide
+ */
+ @NonNull
+ @SystemApi
+ @Deprecated
public String getDataConnectionApn() {
- return mAPN;
+ return mApn;
}
/**
* Get the properties of the network link {@link LinkProperties}.
+ *
+ * @deprecated use {@link #getLinkProperties()}
* @hide
*/
- @UnsupportedAppUsage
+ @Deprecated
+ @SystemApi
+ @Nullable
public LinkProperties getDataConnectionLinkProperties() {
return mLinkProperties;
}
/**
- * Returns data connection fail cause, in case there was a failure.
+ * Get the properties of the network link {@link LinkProperties}.
*/
- public @Annotation.DataFailureCause int getDataConnectionFailCause() {
+ @Nullable
+ public LinkProperties getLinkProperties() {
+ return mLinkProperties;
+ }
+
+ /**
+ * Returns the cause code generated by the most recent state change.
+ *
+ * @deprecated use {@link #getLastCauseCode()}
+ * @hide
+ */
+ @Deprecated
+ @SystemApi
+ public int getDataConnectionFailCause() {
return mFailCause;
}
+ /**
+ * Returns the cause code generated by the most recent state change.
+ *
+ * Return the cause code for the most recent change in {@link #getState}. In the event of an
+ * error, this cause code will be non-zero.
+ */
+ // FIXME(b144774287): some of these cause codes should have a prescribed meaning.
+ public int getLastCauseCode() {
+ return mFailCause;
+ }
+
+ /**
+ * Return the APN Settings for this data connection.
+ *
+ * Returns the ApnSetting that was used to configure this data connection.
+ */
+ // FIXME: This shouldn't be nullable; update once the ApnSetting is supplied correctly
+ @Nullable ApnSetting getApnSetting() {
+ return mApnSetting;
+ }
+
@Override
public int describeContents() {
return 0;
}
@Override
- public void writeToParcel(Parcel out, int flags) {
+ public void writeToParcel(@NonNull Parcel out, int flags) {
out.writeInt(mState);
out.writeInt(mNetworkType);
- out.writeInt(mAPNTypes);
- out.writeString(mAPN);
+ out.writeInt(mApnTypes);
+ out.writeString(mApn);
out.writeParcelable(mLinkProperties, flags);
out.writeInt(mFailCause);
+ out.writeParcelable(mApnSetting, flags);
}
- public static final @android.annotation.NonNull Parcelable.Creator<PreciseDataConnectionState> CREATOR
+ public static final @NonNull Parcelable.Creator<PreciseDataConnectionState> CREATOR
= new Parcelable.Creator<PreciseDataConnectionState>() {
public PreciseDataConnectionState createFromParcel(Parcel in) {
@@ -176,8 +291,8 @@
@Override
public int hashCode() {
- return Objects.hash(mState, mNetworkType, mAPNTypes, mAPN, mLinkProperties,
- mFailCause);
+ return Objects.hash(mState, mNetworkType, mApnTypes, mApn, mLinkProperties,
+ mFailCause, mApnSetting);
}
@Override
@@ -188,11 +303,12 @@
}
PreciseDataConnectionState other = (PreciseDataConnectionState) obj;
- return Objects.equals(mAPN, other.mAPN) && mAPNTypes == other.mAPNTypes
+ return Objects.equals(mApn, other.mApn) && mApnTypes == other.mApnTypes
&& mFailCause == other.mFailCause
&& Objects.equals(mLinkProperties, other.mLinkProperties)
&& mNetworkType == other.mNetworkType
- && mState == other.mState;
+ && mState == other.mState
+ && Objects.equals(mApnSetting, other.mApnSetting);
}
@NonNull
@@ -202,10 +318,11 @@
sb.append("Data Connection state: " + mState);
sb.append(", Network type: " + mNetworkType);
- sb.append(", APN types: " + ApnSetting.getApnTypesStringFromBitmask(mAPNTypes));
- sb.append(", APN: " + mAPN);
+ sb.append(", APN types: " + ApnSetting.getApnTypesStringFromBitmask(mApnTypes));
+ sb.append(", APN: " + mApn);
sb.append(", Link properties: " + mLinkProperties);
sb.append(", Fail cause: " + DataFailCause.toString(mFailCause));
+ sb.append(", Apn Setting: " + mApnSetting);
return sb.toString();
}
diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java
index d2c8517..d7d85c2 100644
--- a/telephony/java/android/telephony/ServiceState.java
+++ b/telephony/java/android/telephony/ServiceState.java
@@ -941,7 +941,7 @@
rtString = "LTE_CA";
break;
case RIL_RADIO_TECHNOLOGY_NR:
- rtString = "LTE_NR";
+ rtString = "NR_SA";
break;
default:
rtString = "Unexpected";
@@ -1479,8 +1479,9 @@
return AccessNetworkType.CDMA2000;
case RIL_RADIO_TECHNOLOGY_LTE:
case RIL_RADIO_TECHNOLOGY_LTE_CA:
- case RIL_RADIO_TECHNOLOGY_NR:
return AccessNetworkType.EUTRAN;
+ case RIL_RADIO_TECHNOLOGY_NR:
+ return AccessNetworkType.NGRAN;
case RIL_RADIO_TECHNOLOGY_IWLAN:
return AccessNetworkType.IWLAN;
case RIL_RADIO_TECHNOLOGY_UNKNOWN:
diff --git a/telephony/java/android/telephony/SubscriptionInfo.java b/telephony/java/android/telephony/SubscriptionInfo.java
index b71bd85..94085e9 100644
--- a/telephony/java/android/telephony/SubscriptionInfo.java
+++ b/telephony/java/android/telephony/SubscriptionInfo.java
@@ -210,6 +210,12 @@
private int mSubscriptionType;
/**
+ * Whether uicc applications are configured to enable or disable.
+ * By default it's true.
+ */
+ private boolean mAreUiccApplicationsEnabled = true;
+
+ /**
* @hide
*/
public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
@@ -220,7 +226,7 @@
roaming, icon, mcc, mnc, countryIso, isEmbedded, nativeAccessRules, cardString, -1,
false, null, false, TelephonyManager.UNKNOWN_CARRIER_ID,
SubscriptionManager.PROFILE_CLASS_DEFAULT,
- SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, null, null);
+ SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, null, null, true);
}
/**
@@ -234,7 +240,7 @@
this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number,
roaming, icon, mcc, mnc, countryIso, isEmbedded, nativeAccessRules, cardString, -1,
isOpportunistic, groupUUID, false, carrierId, profileClass,
- SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, null, null);
+ SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, null, null, true);
}
/**
@@ -246,7 +252,8 @@
@Nullable UiccAccessRule[] nativeAccessRules, String cardString, int cardId,
boolean isOpportunistic, @Nullable String groupUUID, boolean isGroupDisabled,
int carrierId, int profileClass, int subType, @Nullable String groupOwner,
- @Nullable UiccAccessRule[] carrierConfigAccessRules) {
+ @Nullable UiccAccessRule[] carrierConfigAccessRules,
+ boolean areUiccApplicationsEnabled) {
this.mId = id;
this.mIccId = iccId;
this.mSimSlotIndex = simSlotIndex;
@@ -272,6 +279,7 @@
this.mSubscriptionType = subType;
this.mGroupOwner = groupOwner;
this.mCarrierConfigAccessRules = carrierConfigAccessRules;
+ this.mAreUiccApplicationsEnabled = areUiccApplicationsEnabled;
}
/**
@@ -660,6 +668,15 @@
return mIsGroupDisabled;
}
+ /**
+ * Return whether uicc applications are set to be enabled or disabled.
+ * @hide
+ */
+ @SystemApi
+ public boolean areUiccApplicationsEnabled() {
+ return mAreUiccApplicationsEnabled;
+ }
+
public static final @android.annotation.NonNull Parcelable.Creator<SubscriptionInfo> CREATOR = new Parcelable.Creator<SubscriptionInfo>() {
@Override
public SubscriptionInfo createFromParcel(Parcel source) {
@@ -691,12 +708,13 @@
String groupOwner = source.readString();
UiccAccessRule[] carrierConfigAccessRules = source.createTypedArray(
UiccAccessRule.CREATOR);
+ boolean areUiccApplicationsEnabled = source.readBoolean();
SubscriptionInfo info = new SubscriptionInfo(id, iccId, simSlotIndex, displayName,
carrierName, nameSource, iconTint, number, dataRoaming, iconBitmap, mcc, mnc,
countryIso, isEmbedded, nativeAccessRules, cardString, cardId, isOpportunistic,
groupUUID, isGroupDisabled, carrierid, profileClass, subType, groupOwner,
- carrierConfigAccessRules);
+ carrierConfigAccessRules, areUiccApplicationsEnabled);
info.setAssociatedPlmns(ehplmns, hplmns);
return info;
}
@@ -736,6 +754,7 @@
dest.writeStringArray(mHplmns);
dest.writeString(mGroupOwner);
dest.writeTypedArray(mCarrierConfigAccessRules, flags);
+ dest.writeBoolean(mAreUiccApplicationsEnabled);
}
@Override
@@ -778,15 +797,16 @@
+ " hplmns=" + Arrays.toString(mHplmns)
+ " subscriptionType=" + mSubscriptionType
+ " mGroupOwner=" + mGroupOwner
- + " carrierConfigAccessRules=" + mCarrierConfigAccessRules + "}";
+ + " carrierConfigAccessRules=" + mCarrierConfigAccessRules
+ + " mAreUiccApplicationsEnabled=" + mAreUiccApplicationsEnabled + "}";
}
@Override
public int hashCode() {
return Objects.hash(mId, mSimSlotIndex, mNameSource, mIconTint, mDataRoaming, mIsEmbedded,
- mIsOpportunistic, mGroupUUID, mIccId, mNumber, mMcc, mMnc,
- mCountryIso, mCardString, mCardId, mDisplayName, mCarrierName, mNativeAccessRules,
- mIsGroupDisabled, mCarrierId, mProfileClass, mGroupOwner);
+ mIsOpportunistic, mGroupUUID, mIccId, mNumber, mMcc, mMnc, mCountryIso, mCardString,
+ mCardId, mDisplayName, mCarrierName, mNativeAccessRules, mIsGroupDisabled,
+ mCarrierId, mProfileClass, mGroupOwner, mAreUiccApplicationsEnabled);
}
@Override
@@ -809,6 +829,7 @@
&& mIsEmbedded == toCompare.mIsEmbedded
&& mIsOpportunistic == toCompare.mIsOpportunistic
&& mIsGroupDisabled == toCompare.mIsGroupDisabled
+ && mAreUiccApplicationsEnabled == toCompare.mAreUiccApplicationsEnabled
&& mCarrierId == toCompare.mCarrierId
&& Objects.equals(mGroupUUID, toCompare.mGroupUUID)
&& Objects.equals(mIccId, toCompare.mIccId)
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index a82ae88..740622d 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -835,6 +835,12 @@
public static final String IMSI = "imsi";
/**
+ * Whether uicc applications is set to be enabled or disabled. By default it's enabled.
+ * @hide
+ */
+ public static final String UICC_APPLICATIONS_ENABLED = "uicc_applications_enabled";
+
+ /**
* Broadcast Action: The user has changed one of the default subs related to
* data, phone calls, or sms</p>
*
diff --git a/telephony/java/android/telephony/TelephonyFrameworkInitializer.java b/telephony/java/android/telephony/TelephonyFrameworkInitializer.java
index b75d533..407ad19 100644
--- a/telephony/java/android/telephony/TelephonyFrameworkInitializer.java
+++ b/telephony/java/android/telephony/TelephonyFrameworkInitializer.java
@@ -16,12 +16,16 @@
package android.telephony;
+import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.app.SystemServiceRegistry;
import android.content.Context;
+import android.os.TelephonyServiceManager;
import android.telephony.euicc.EuiccCardManager;
import android.telephony.euicc.EuiccManager;
+import com.android.internal.util.Preconditions;
+
/**
* Class for performing registration for all telephony services.
@@ -34,6 +38,23 @@
private TelephonyFrameworkInitializer() {
}
+ private static volatile TelephonyServiceManager sTelephonyServiceManager;
+
+ /**
+ * Sets an instance of {@link TelephonyServiceManager} that allows
+ * the telephony mainline module to register/obtain telephony binder services. This is called
+ * by the platform during the system initialization.
+ *
+ * @param telephonyServiceManager instance of {@link TelephonyServiceManager} that allows
+ * the telephony mainline module to register/obtain telephony binder services.
+ */
+ public static void setTelephonyServiceManager(
+ @NonNull TelephonyServiceManager telephonyServiceManager) {
+ Preconditions.checkState(sTelephonyServiceManager == null,
+ "setTelephonyServiceManager called twice!");
+ sTelephonyServiceManager = Preconditions.checkNotNull(telephonyServiceManager);
+ }
+
/**
* Called by {@link SystemServiceRegistry}'s static initializer and registers all telephony
* services to {@link Context}, so that {@link Context#getSystemService} can return them.
@@ -68,4 +89,9 @@
context -> new EuiccCardManager(context)
);
}
+
+ /** @hide */
+ public static TelephonyServiceManager getTelephonyServiceManager() {
+ return sTelephonyServiceManager;
+ }
}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 9f5acb3..78c5e43 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -38,6 +38,9 @@
import android.annotation.WorkerThread;
import android.app.ActivityThread;
import android.app.PendingIntent;
+import android.compat.Compatibility;
+import android.compat.annotation.ChangeId;
+import android.compat.annotation.EnabledAfter;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -142,6 +145,14 @@
private static final String TAG = "TelephonyManager";
/**
+ * To expand the error codes for {@link TelephonyManager#updateAvailableNetworks} and
+ * {@link TelephonyManager#setPreferredOpportunisticDataSubscription}.
+ */
+ @ChangeId
+ @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.Q)
+ private static final long CALLBACK_ON_MORE_ERROR_CODE_CHANGE = 130595455L;
+
+ /**
* The key to use when placing the result of {@link #requestModemActivityInfo(ResultReceiver)}
* into the ResultReceiver Bundle.
* @hide
@@ -605,6 +616,7 @@
*
* @hide
*/
+ @SystemApi
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
public static final String ACTION_EMERGENCY_ASSISTANCE =
"android.telephony.action.EMERGENCY_ASSISTANCE";
@@ -789,18 +801,6 @@
public static final String EXTRA_DATA_APN = PhoneConstants.DATA_APN_KEY;
/**
- * The lookup key used with the {@link #ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED} broadcast
- * for an String representation of the data interface.
- *
- * <p class="note">
- * Retrieve with
- * {@link android.content.Intent#getParcelableExtra(String name)}.
- *
- * @hide
- */
- public static final String EXTRA_DATA_LINK_PROPERTIES_KEY = PhoneConstants.DATA_LINK_PROPERTIES_KEY;
-
- /**
* Broadcast intent action for letting the default dialer to know to show voicemail
* notification.
*
@@ -2441,7 +2441,7 @@
/*
* When adding a network type to the list below, make sure to add the correct icon to
- * MobileSignalController.mapIconSets().
+ * MobileSignalController.mapIconSets() as well as NETWORK_TYPES
* Do not add negative types.
*/
/** Network type is unknown */
@@ -2489,8 +2489,36 @@
/** Current network is NR(New Radio) 5G. */
public static final int NETWORK_TYPE_NR = TelephonyProtoEnums.NETWORK_TYPE_NR; // 20.
- /** Max network type number. Update as new types are added. Don't add negative types. {@hide} */
- public static final int MAX_NETWORK_TYPE = NETWORK_TYPE_NR;
+ private static final @NetworkType int[] NETWORK_TYPES = {
+ NETWORK_TYPE_GPRS,
+ NETWORK_TYPE_EDGE,
+ NETWORK_TYPE_UMTS,
+ NETWORK_TYPE_CDMA,
+ NETWORK_TYPE_EVDO_0,
+ NETWORK_TYPE_EVDO_A,
+ NETWORK_TYPE_1xRTT,
+ NETWORK_TYPE_HSDPA,
+ NETWORK_TYPE_HSUPA,
+ NETWORK_TYPE_HSPA,
+ NETWORK_TYPE_IDEN,
+ NETWORK_TYPE_EVDO_B,
+ NETWORK_TYPE_LTE,
+ NETWORK_TYPE_EHRPD,
+ NETWORK_TYPE_HSPAP,
+ NETWORK_TYPE_GSM,
+ NETWORK_TYPE_TD_SCDMA,
+ NETWORK_TYPE_IWLAN,
+ NETWORK_TYPE_LTE_CA,
+ NETWORK_TYPE_NR
+ };
+
+ /**
+ * Return a collection of all network types
+ * @return network types
+ */
+ public static @NonNull @NetworkType int[] getAllNetworkTypes() {
+ return NETWORK_TYPES;
+ }
/**
* Return the current data network type.
@@ -2835,6 +2863,24 @@
//
//
+ /** @hide */
+ @IntDef(prefix = {"SIM_STATE_"},
+ value = {
+ SIM_STATE_UNKNOWN,
+ SIM_STATE_ABSENT,
+ SIM_STATE_PIN_REQUIRED,
+ SIM_STATE_PUK_REQUIRED,
+ SIM_STATE_NETWORK_LOCKED,
+ SIM_STATE_READY,
+ SIM_STATE_NOT_READY,
+ SIM_STATE_PERM_DISABLED,
+ SIM_STATE_CARD_IO_ERROR,
+ SIM_STATE_CARD_RESTRICTED,
+ SIM_STATE_LOADED,
+ SIM_STATE_PRESENT,
+ })
+ public @interface SimState {}
+
/**
* SIM card state: Unknown. Signifies that the SIM is in transition
* between states. For example, when the user inputs the SIM pin
@@ -3040,7 +3086,7 @@
* @see #SIM_STATE_CARD_IO_ERROR
* @see #SIM_STATE_CARD_RESTRICTED
*/
- public int getSimState() {
+ public @SimState int getSimState() {
int simState = getSimStateIncludingLoaded();
if (simState == SIM_STATE_LOADED) {
simState = SIM_STATE_READY;
@@ -3048,7 +3094,7 @@
return simState;
}
- private int getSimStateIncludingLoaded() {
+ private @SimState int getSimStateIncludingLoaded() {
int slotIndex = getSlotIndex();
// slotIndex may be invalid due to sim being absent. In that case query all slots to get
// sim state
@@ -3082,7 +3128,7 @@
* @hide
*/
@SystemApi
- public int getSimCardState() {
+ public @SimState int getSimCardState() {
int simState = getSimState();
return getSimCardStateFromSimState(simState);
}
@@ -3102,7 +3148,7 @@
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
- public int getSimCardState(int physicalSlotIndex) {
+ public @SimState int getSimCardState(int physicalSlotIndex) {
int simState = getSimState(getLogicalSlotIndex(physicalSlotIndex));
return getSimCardStateFromSimState(simState);
}
@@ -3112,7 +3158,7 @@
* @param simState
* @return SIM card state
*/
- private int getSimCardStateFromSimState(int simState) {
+ private @SimState int getSimCardStateFromSimState(int simState) {
switch (simState) {
case SIM_STATE_UNKNOWN:
case SIM_STATE_ABSENT:
@@ -3152,7 +3198,7 @@
* @hide
*/
@SystemApi
- public int getSimApplicationState() {
+ public @SimState int getSimApplicationState() {
int simState = getSimStateIncludingLoaded();
return getSimApplicationStateFromSimState(simState);
}
@@ -3175,7 +3221,7 @@
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
- public int getSimApplicationState(int physicalSlotIndex) {
+ public @SimState int getSimApplicationState(int physicalSlotIndex) {
int simState =
SubscriptionManager.getSimStateForSlotIndex(getLogicalSlotIndex(physicalSlotIndex));
return getSimApplicationStateFromSimState(simState);
@@ -3186,7 +3232,7 @@
* @param simState
* @return SIM application state
*/
- private int getSimApplicationStateFromSimState(int simState) {
+ private @SimState int getSimApplicationStateFromSimState(int simState) {
switch (simState) {
case SIM_STATE_UNKNOWN:
case SIM_STATE_ABSENT:
@@ -3243,7 +3289,7 @@
* @see #SIM_STATE_CARD_IO_ERROR
* @see #SIM_STATE_CARD_RESTRICTED
*/
- public int getSimState(int slotIndex) {
+ public @SimState int getSimState(int slotIndex) {
int simState = SubscriptionManager.getSimStateForSlotIndex(slotIndex);
if (simState == SIM_STATE_LOADED) {
simState = SIM_STATE_READY;
@@ -5071,6 +5117,7 @@
DATA_CONNECTING,
DATA_CONNECTED,
DATA_SUSPENDED,
+ DATA_DISCONNECTING,
})
@Retention(RetentionPolicy.SOURCE)
public @interface DataState{}
@@ -5087,6 +5134,12 @@
* traffic is temporarily unavailable. For example, in a 2G network,
* data activity may be suspended when a voice call arrives. */
public static final int DATA_SUSPENDED = 3;
+ /**
+ * Data connection state: Disconnecting.
+ *
+ * IP traffic may be available but will cease working imminently.
+ */
+ public static final int DATA_DISCONNECTING = 4;
/**
* Returns a constant indicating the current data connection state
@@ -5096,14 +5149,21 @@
* @see #DATA_CONNECTING
* @see #DATA_CONNECTED
* @see #DATA_SUSPENDED
+ * @see #DATA_DISCONNECTING
*/
public int getDataState() {
try {
ITelephony telephony = getITelephony();
if (telephony == null)
return DATA_DISCONNECTED;
- return telephony.getDataStateForSubId(
+ int state = telephony.getDataStateForSubId(
getSubId(SubscriptionManager.getActiveDataSubscriptionId()));
+ if (state == TelephonyManager.DATA_DISCONNECTING
+ && VMRuntime.getRuntime().getTargetSdkVersion() < Build.VERSION_CODES.R) {
+ return TelephonyManager.DATA_CONNECTED;
+ }
+
+ return state;
} catch (RemoteException ex) {
// the phone process is restarting.
return DATA_DISCONNECTED;
@@ -5124,6 +5184,7 @@
case DATA_CONNECTING: return "CONNECTING";
case DATA_CONNECTED: return "CONNECTED";
case DATA_SUSPENDED: return "SUSPENDED";
+ case DATA_DISCONNECTING: return "DISCONNECTING";
}
return "UNKNOWN(" + state + ")";
}
@@ -5133,7 +5194,8 @@
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
private ITelephony getITelephony() {
- return ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE));
+ return ITelephony.Stub.asInterface(TelephonyFrameworkInitializer
+ .getTelephonyServiceManager().getTelephonyServiceRegisterer().get());
}
private ITelephonyRegistry getTelephonyRegistry() {
@@ -6438,75 +6500,6 @@
}
/**
- * Sets a per-phone telephony property with the value specified.
- *
- * @hide
- */
- @UnsupportedAppUsage
- public static void setTelephonyProperty(int phoneId, String property, String value) {
- String propVal = "";
- String p[] = null;
- String prop = SystemProperties.get(property);
-
- if (value == null) {
- value = "";
- }
- value.replace(',', ' ');
- if (prop != null) {
- p = prop.split(",");
- }
-
- if (!SubscriptionManager.isValidPhoneId(phoneId)) {
- Rlog.d(TAG, "setTelephonyProperty: invalid phoneId=" + phoneId +
- " property=" + property + " value: " + value + " prop=" + prop);
- return;
- }
-
- for (int i = 0; i < phoneId; i++) {
- String str = "";
- if ((p != null) && (i < p.length)) {
- str = p[i];
- }
- propVal = propVal + str + ",";
- }
-
- propVal = propVal + value;
- if (p != null) {
- for (int i = phoneId + 1; i < p.length; i++) {
- propVal = propVal + "," + p[i];
- }
- }
-
- int propValLen = propVal.length();
- try {
- propValLen = propVal.getBytes("utf-8").length;
- } catch (java.io.UnsupportedEncodingException e) {
- Rlog.d(TAG, "setTelephonyProperty: utf-8 not supported");
- }
- if (propValLen > SystemProperties.PROP_VALUE_MAX) {
- Rlog.d(TAG, "setTelephonyProperty: property too long phoneId=" + phoneId +
- " property=" + property + " value: " + value + " propVal=" + propVal);
- return;
- }
-
- SystemProperties.set(property, propVal);
- }
-
- /**
- * Sets a global telephony property with the value specified.
- *
- * @hide
- */
- public static void setTelephonyProperty(String property, String value) {
- if (value == null) {
- value = "";
- }
- Rlog.d(TAG, "setTelephonyProperty: success" + " property=" +
- property + " value: " + value);
- SystemProperties.set(property, value);
- }
-
- /**
* Inserts or updates a list property. Expands the list if its length is not enough.
*/
private static <T> List<T> updateTelephonyProperty(List<T> prop, int phoneId, T value) {
@@ -6843,7 +6836,8 @@
* If the list is longer than the size of EFfplmn, then the file will be written from the
* beginning of the list up to the file size.
*
- * <p>Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
+ * <p>Requires Permission: {@link android.Manifest.permission#MODIFY_PHONE_STATE
+ * MODIFY_PHONE_STATE}
* or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}).
*
* @param fplmns a list of PLMNs to be forbidden.
@@ -6857,7 +6851,7 @@
public int setForbiddenPlmns(@NonNull List<String> fplmns) {
try {
ITelephony telephony = getITelephony();
- if (telephony == null) return 0;
+ if (telephony == null) return -1;
return telephony.setForbiddenPlmns(
getSubId(), APPTYPE_USIM, fplmns, getOpPackageName(), getFeatureId());
} catch (RemoteException ex) {
@@ -6866,7 +6860,7 @@
// This could happen before phone starts
Rlog.e(TAG, "setForbiddenPlmns NullPointerException: " + ex.getMessage());
}
- return 0;
+ return -1;
}
/**
@@ -8358,6 +8352,44 @@
}
/**
+ * Shut down all the live radios over all the slot index.
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
+ public void shutdownAllRadios() {
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ telephony.shutdownMobileRadios();
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#shutdownMobileRadios", e);
+ }
+ }
+
+ /**
+ * Check if any radio is on over all the slot indexes.
+ *
+ * @return {@code true} if any radio is on over any slot index.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ public boolean isAnyRadioPoweredOn() {
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ return telephony.needMobileRadioShutdown();
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#needMobileRadioShutdown", e);
+ }
+ return false;
+ }
+
+ /**
* Radio explicitly powered off (e.g, airplane mode).
* @hide
*/
@@ -9611,7 +9643,8 @@
* {@link android.telephony.ModemActivityInfo} object.
* @hide
*/
- public void requestModemActivityInfo(ResultReceiver result) {
+ @SystemApi
+ public void requestModemActivityInfo(@NonNull ResultReceiver result) {
try {
ITelephony service = getITelephony();
if (service != null) {
@@ -10266,19 +10299,25 @@
}
/**
- * Action set from carrier signalling broadcast receivers to enable/disable radio
- * Permissions {@link android.Manifest.permission.MODIFY_PHONE_STATE} is required.
- * @param subId the subscription ID that this action applies to.
+ * Carrier action to enable or disable the radio.
+ *
+ * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the
+ * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultDataSubscriptionId()}
+ *
+ * <p>Requires Permission:
+ * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}.
+ *
* @param enabled control enable or disable radio.
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
- public void carrierActionSetRadioEnabled(int subId, boolean enabled) {
+ public void setRadioEnabled(boolean enabled) {
try {
ITelephony service = getITelephony();
if (service != null) {
- service.carrierActionSetRadioEnabled(subId, enabled);
+ service.carrierActionSetRadioEnabled(
+ getSubId(SubscriptionManager.getDefaultDataSubscriptionId()), enabled);
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#carrierActionSetRadioEnabled", e);
@@ -10286,20 +10325,25 @@
}
/**
- * Action set from carrier signalling broadcast receivers to start/stop reporting default
- * network available events
- * Permissions {@link android.Manifest.permission.MODIFY_PHONE_STATE} is required.
- * @param subId the subscription ID that this action applies to.
+ * Carrier action to start or stop reporting default network available events.
+ *
+ * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the
+ * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultDataSubscriptionId()}
+ *
+ * <p>Requires Permission:
+ * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}.
+ *
* @param report control start/stop reporting network status.
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
- public void carrierActionReportDefaultNetworkStatus(int subId, boolean report) {
+ public void reportDefaultNetworkStatus(boolean report) {
try {
ITelephony service = getITelephony();
if (service != null) {
- service.carrierActionReportDefaultNetworkStatus(subId, report);
+ service.carrierActionReportDefaultNetworkStatus(
+ getSubId(SubscriptionManager.getDefaultDataSubscriptionId()), report);
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#carrierActionReportDefaultNetworkStatus", e);
@@ -10307,18 +10351,24 @@
}
/**
- * Action set from carrier signalling broadcast receivers to reset all carrier actions
- * Permissions {@link android.Manifest.permission.MODIFY_PHONE_STATE} is required.
- * @param subId the subscription ID that this action applies to.
+ * Reset all carrier actions previously set by {@link #setRadioEnabled},
+ * {@link #reportDefaultNetworkStatus} and {@link #setCarrierDataEnabled}.
+ *
+ * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the
+ * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultDataSubscriptionId()}
+ *
+ * <p>Requires Permission:
+ * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}.
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
- public void carrierActionResetAll(int subId) {
+ public void resetAllCarrierActions() {
try {
ITelephony service = getITelephony();
if (service != null) {
- service.carrierActionResetAll(subId);
+ service.carrierActionResetAll(
+ getSubId(SubscriptionManager.getDefaultDataSubscriptionId()));
}
} catch (RemoteException e) {
Log.e(TAG, "Error calling ITelephony#carrierActionResetAll", e);
@@ -11331,7 +11381,11 @@
final long identity = Binder.clearCallingIdentity();
try {
executor.execute(() -> {
- callback.accept(SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION);
+ if (Compatibility.isChangeEnabled(CALLBACK_ON_MORE_ERROR_CODE_CHANGE)) {
+ callback.accept(SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION);
+ } else {
+ callback.accept(SET_OPPORTUNISTIC_SUB_INACTIVE_SUBSCRIPTION);
+ }
});
} finally {
Binder.restoreCallingIdentity(identity);
@@ -11428,7 +11482,11 @@
final long identity = Binder.clearCallingIdentity();
try {
executor.execute(() -> {
- callback.accept(UPDATE_AVAILABLE_NETWORKS_REMOTE_SERVICE_EXCEPTION);
+ if (Compatibility.isChangeEnabled(CALLBACK_ON_MORE_ERROR_CODE_CHANGE)) {
+ callback.accept(UPDATE_AVAILABLE_NETWORKS_REMOTE_SERVICE_EXCEPTION);
+ } else {
+ callback.accept(UPDATE_AVAILABLE_NETWORKS_UNKNOWN_FAILURE);
+ }
});
} finally {
Binder.restoreCallingIdentity(identity);
@@ -11702,6 +11760,32 @@
}
/**
+ * Get the calling application status about carrier privileges for the subscription created
+ * in TelephonyManager. Used by Telephony Module for permission checking.
+ *
+ * @param uid Uid to check.
+ * @return any value of {@link #CARRIER_PRIVILEGE_STATUS_HAS_ACCESS},
+ * {@link #CARRIER_PRIVILEGE_STATUS_NO_ACCESS},
+ * {@link #CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED}, or
+ * {@link #CARRIER_PRIVILEGE_STATUS_ERROR_LOADING_RULES}
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
+ public int getCarrierPrivilegeStatus(int uid) {
+ try {
+ ITelephony telephony = getITelephony();
+ if (telephony != null) {
+ return telephony.getCarrierPrivilegeStatusForUid(getSubId(), uid);
+ }
+ } catch (RemoteException ex) {
+ Log.e(TAG, "getCarrierPrivilegeStatus RemoteException", ex);
+ }
+ return TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS;
+ }
+
+ /**
* Return whether data is enabled for certain APN type. This will tell if framework will accept
* corresponding network requests on a subId.
*
diff --git a/telephony/java/android/telephony/ims/ImsRcsManager.java b/telephony/java/android/telephony/ims/ImsRcsManager.java
index b37d7c7..d3fb37f 100644
--- a/telephony/java/android/telephony/ims/ImsRcsManager.java
+++ b/telephony/java/android/telephony/ims/ImsRcsManager.java
@@ -20,6 +20,8 @@
import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
+import android.annotation.SystemApi;
+import android.annotation.TestApi;
import android.content.Context;
import android.os.Binder;
import android.os.IBinder;
@@ -30,6 +32,7 @@
import android.telephony.ims.aidl.IImsRcsController;
import android.telephony.ims.feature.ImsFeature;
import android.telephony.ims.feature.RcsFeature;
+import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.Log;
import java.util.concurrent.Executor;
@@ -42,6 +45,8 @@
* Use {@link ImsManager#getImsRcsManager(int)} to create an instance of this manager.
* @hide
*/
+@SystemApi
+@TestApi
public class ImsRcsManager implements RegistrationManager {
private static final String TAG = "ImsRcsManager";
@@ -105,7 +110,7 @@
*
* @param capabilities The new availability of the capabilities.
*/
- public void onAvailabilityChanged(RcsFeature.RcsImsCapabilities capabilities) {
+ public void onAvailabilityChanged(@NonNull RcsFeature.RcsImsCapabilities capabilities) {
}
/**@hide*/
@@ -142,6 +147,7 @@
/**{@inheritDoc}*/
@Override
+ @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public void registerImsRegistrationCallback(
@NonNull @CallbackExecutor Executor executor,
@NonNull RegistrationCallback c)
@@ -159,6 +165,7 @@
/**{@inheritDoc}*/
@Override
+ @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public void unregisterImsRegistrationCallback(
@NonNull RegistrationManager.RegistrationCallback c) {
if (c == null) {
@@ -170,6 +177,7 @@
/**{@inheritDoc}*/
@Override
+ @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public void getRegistrationState(@NonNull @CallbackExecutor Executor executor,
@NonNull @ImsRegistrationState Consumer<Integer> stateCallback) {
if (stateCallback == null) {
@@ -184,6 +192,7 @@
/**{@inheritDoc}*/
@Override
+ @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public void getRegistrationTransportType(@NonNull @CallbackExecutor Executor executor,
@NonNull @AccessNetworkConstants.TransportType
Consumer<Integer> transportTypeCallback) {
@@ -219,7 +228,7 @@
* becomes inactive. See {@link ImsException#getCode()} for more information on the error codes.
*/
@RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
- public void registerRcsAvailabilityCallback(@CallbackExecutor Executor executor,
+ public void registerRcsAvailabilityCallback(@NonNull @CallbackExecutor Executor executor,
@NonNull AvailabilityCallback c) throws ImsException {
if (c == null) {
throw new IllegalArgumentException("Must include a non-null AvailabilityCallback.");
@@ -231,13 +240,13 @@
IImsRcsController imsRcsController = getIImsRcsController();
if (imsRcsController == null) {
Log.e(TAG, "Register availability callback: IImsRcsController is null");
- throw new ImsException("Can not find remote IMS service",
+ throw new ImsException("Cannot find remote IMS service",
ImsException.CODE_ERROR_SERVICE_UNAVAILABLE);
}
c.setExecutor(executor);
try {
- imsRcsController.registerRcsAvailabilityCallback(c.getBinder());
+ imsRcsController.registerRcsAvailabilityCallback(mSubId, c.getBinder());
} catch (RemoteException e) {
Log.e(TAG, "Error calling IImsRcsController#registerRcsAvailabilityCallback", e);
throw new ImsException("Remote IMS Service is not available",
@@ -267,12 +276,12 @@
IImsRcsController imsRcsController = getIImsRcsController();
if (imsRcsController == null) {
Log.e(TAG, "Unregister availability callback: IImsRcsController is null");
- throw new ImsException("Can not find remote IMS service",
+ throw new ImsException("Cannot find remote IMS service",
ImsException.CODE_ERROR_SERVICE_UNAVAILABLE);
}
try {
- imsRcsController.unregisterRcsAvailabilityCallback(c.getBinder());
+ imsRcsController.unregisterRcsAvailabilityCallback(mSubId, c.getBinder());
} catch (RemoteException e) {
Log.e(TAG, "Error calling IImsRcsController#unregisterRcsAvailabilityCallback", e);
throw new ImsException("Remote IMS Service is not available",
@@ -287,6 +296,9 @@
* RCS capabilities provided over-the-top by applications.
*
* @param capability The RCS capability to query.
+ * @param radioTech The radio tech that this capability failed for, defined as
+ * {@link ImsRegistrationImplBase#REGISTRATION_TECH_LTE} or
+ * {@link ImsRegistrationImplBase#REGISTRATION_TECH_IWLAN}.
* @return true if the RCS capability is capable for this subscription, false otherwise. This
* does not necessarily mean that we are registered for IMS and the capability is available, but
* rather the subscription is capable of this service over IMS.
@@ -297,17 +309,17 @@
* See {@link ImsException#getCode()} for more information on the error codes.
*/
@RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
- public boolean isCapable(@RcsFeature.RcsImsCapabilities.RcsImsCapabilityFlag int capability)
- throws ImsException {
+ public boolean isCapable(@RcsFeature.RcsImsCapabilities.RcsImsCapabilityFlag int capability,
+ @ImsRegistrationImplBase.ImsRegistrationTech int radioTech) throws ImsException {
IImsRcsController imsRcsController = getIImsRcsController();
if (imsRcsController == null) {
Log.e(TAG, "isCapable: IImsRcsController is null");
- throw new ImsException("Can not find remote IMS service",
+ throw new ImsException("Cannot find remote IMS service",
ImsException.CODE_ERROR_SERVICE_UNAVAILABLE);
}
try {
- return imsRcsController.isCapable(mSubId, capability);
+ return imsRcsController.isCapable(mSubId, capability, radioTech);
} catch (RemoteException e) {
Log.e(TAG, "Error calling IImsRcsController#isCapable", e);
throw new ImsException("Remote IMS Service is not available",
@@ -336,7 +348,7 @@
IImsRcsController imsRcsController = getIImsRcsController();
if (imsRcsController == null) {
Log.e(TAG, "isAvailable: IImsRcsController is null");
- throw new ImsException("Can not find remote IMS service",
+ throw new ImsException("Cannot find remote IMS service",
ImsException.CODE_ERROR_SERVICE_UNAVAILABLE);
}
diff --git a/telephony/java/android/telephony/ims/aidl/IImsRcsController.aidl b/telephony/java/android/telephony/ims/aidl/IImsRcsController.aidl
index b379bd0..e81bac0 100644
--- a/telephony/java/android/telephony/ims/aidl/IImsRcsController.aidl
+++ b/telephony/java/android/telephony/ims/aidl/IImsRcsController.aidl
@@ -26,9 +26,9 @@
* {@hide}
*/
interface IImsRcsController {
- void registerRcsAvailabilityCallback(IImsCapabilityCallback c);
- void unregisterRcsAvailabilityCallback(IImsCapabilityCallback c);
- boolean isCapable(int subId, int capability);
+ void registerRcsAvailabilityCallback(int subId, IImsCapabilityCallback c);
+ void unregisterRcsAvailabilityCallback(int subId, IImsCapabilityCallback c);
+ boolean isCapable(int subId, int capability, int radioTech);
boolean isAvailable(int subId, int capability);
// ImsUceAdapter specific
diff --git a/telephony/java/android/telephony/ims/feature/ImsFeature.java b/telephony/java/android/telephony/ims/feature/ImsFeature.java
index 72390d0..4cb8575 100644
--- a/telephony/java/android/telephony/ims/feature/ImsFeature.java
+++ b/telephony/java/android/telephony/ims/feature/ImsFeature.java
@@ -22,7 +22,6 @@
import android.annotation.TestApi;
import android.content.Context;
import android.os.IInterface;
-import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.telephony.SubscriptionManager;
import android.telephony.ims.aidl.IImsCapabilityCallback;
@@ -31,6 +30,7 @@
import com.android.ims.internal.IImsFeatureStatusCallback;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.telephony.util.RemoteCallbackListExt;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -310,12 +310,12 @@
/** @hide */
protected final Object mLock = new Object();
- private final RemoteCallbackList<IImsFeatureStatusCallback> mStatusCallbacks =
- new RemoteCallbackList<>();
+ private final RemoteCallbackListExt<IImsFeatureStatusCallback> mStatusCallbacks =
+ new RemoteCallbackListExt<>();
private @ImsState int mState = STATE_UNAVAILABLE;
private int mSlotId = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
- private final RemoteCallbackList<IImsCapabilityCallback> mCapabilityCallbacks =
- new RemoteCallbackList<>();
+ private final RemoteCallbackListExt<IImsCapabilityCallback> mCapabilityCallbacks =
+ new RemoteCallbackListExt<>();
private Capabilities mCapabilityStatus = new Capabilities();
/**
@@ -391,7 +391,7 @@
* Internal method called by ImsFeature when setFeatureState has changed.
*/
private void notifyFeatureState(@ImsState int state) {
- mStatusCallbacks.broadcast((c) -> {
+ mStatusCallbacks.broadcastAction((c) -> {
try {
c.notifyImsFeatureStatus(state);
} catch (RemoteException e) {
@@ -470,7 +470,7 @@
synchronized (mLock) {
mCapabilityStatus = caps.copy();
}
- mCapabilityCallbacks.broadcast((callback) -> {
+ mCapabilityCallbacks.broadcastAction((callback) -> {
try {
callback.onCapabilitiesStatusChanged(caps.mCapabilities);
} catch (RemoteException e) {
diff --git a/telephony/java/android/telephony/ims/feature/RcsFeature.java b/telephony/java/android/telephony/ims/feature/RcsFeature.java
index 0eaf8dc..884a0bc 100644
--- a/telephony/java/android/telephony/ims/feature/RcsFeature.java
+++ b/telephony/java/android/telephony/ims/feature/RcsFeature.java
@@ -193,7 +193,6 @@
* of the capability and notify the capability status as true using
* {@link #notifyCapabilitiesStatusChanged(RcsImsCapabilities)}. This will signal to the
* framework that the capability is available for usage.
- * @hide
*/
public static class RcsImsCapabilities extends Capabilities {
/** @hide*/
@@ -207,7 +206,6 @@
/**
* Undefined capability type for initialization
- * @hide
*/
public static final int CAPABILITY_TYPE_NONE = 0;
@@ -215,7 +213,6 @@
* This carrier supports User Capability Exchange using SIP OPTIONS as defined by the
* framework. If set, the RcsFeature should support capability exchange using SIP OPTIONS.
* If not set, this RcsFeature should not service capability requests.
- * @hide
*/
public static final int CAPABILITY_TYPE_OPTIONS_UCE = 1 << 0;
@@ -224,33 +221,27 @@
* framework. If set, the RcsFeature should support capability exchange using a presence
* server. If not set, this RcsFeature should not publish capabilities or service capability
* requests using presence.
- * @hide
*/
public static final int CAPABILITY_TYPE_PRESENCE_UCE = 1 << 1;
- /**@hide*/
public RcsImsCapabilities(@RcsImsCapabilityFlag int capabilities) {
super(capabilities);
}
- /**@hide*/
private RcsImsCapabilities(Capabilities c) {
super(c.getMask());
}
- /**@hide*/
@Override
public void addCapabilities(@RcsImsCapabilityFlag int capabilities) {
super.addCapabilities(capabilities);
}
- /**@hide*/
@Override
public void removeCapabilities(@RcsImsCapabilityFlag int capabilities) {
super.removeCapabilities(capabilities);
}
- /**@hide*/
@Override
public boolean isCapable(@RcsImsCapabilityFlag int capabilities) {
return super.isCapable(capabilities);
@@ -295,10 +286,9 @@
* set, the {@link RcsFeature} has brought up the capability and is ready for framework
* requests. To change the status of the capabilities
* {@link #notifyCapabilitiesStatusChanged(RcsImsCapabilities)} should be called.
- * @hide
*/
@Override
- public final RcsImsCapabilities queryCapabilityStatus() {
+ public @NonNull final RcsImsCapabilities queryCapabilityStatus() {
return new RcsImsCapabilities(super.queryCapabilityStatus());
}
@@ -306,7 +296,6 @@
* Notify the framework that the capabilities status has changed. If a capability is enabled,
* this signals to the framework that the capability has been initialized and is ready.
* Call {@link #queryCapabilityStatus()} to return the current capability status.
- * @hide
*/
public final void notifyCapabilitiesStatusChanged(@NonNull RcsImsCapabilities c) {
if (c == null) {
@@ -321,7 +310,6 @@
* {@link #changeEnabledCapabilities(CapabilityChangeRequest, CapabilityCallbackProxy)} to
* enable or disable capability A, this method should return the correct configuration for
* capability A afterwards (until it has changed).
- * @hide
*/
public boolean queryCapabilityConfiguration(
@RcsImsCapabilities.RcsImsCapabilityFlag int capability,
@@ -343,11 +331,10 @@
* If for some reason one or more of these capabilities can not be enabled/disabled,
* {@link CapabilityCallbackProxy#onChangeCapabilityConfigurationError(int, int, int)} should
* be called for each capability change that resulted in an error.
- * @hide
*/
@Override
- public void changeEnabledCapabilities(CapabilityChangeRequest request,
- CapabilityCallbackProxy c) {
+ public void changeEnabledCapabilities(@NonNull CapabilityChangeRequest request,
+ @NonNull CapabilityCallbackProxy c) {
// Base Implementation - Override to provide functionality
}
diff --git a/telephony/java/android/telephony/ims/stub/ImsConfigImplBase.java b/telephony/java/android/telephony/ims/stub/ImsConfigImplBase.java
index 4c0de7f..d18e93c 100644
--- a/telephony/java/android/telephony/ims/stub/ImsConfigImplBase.java
+++ b/telephony/java/android/telephony/ims/stub/ImsConfigImplBase.java
@@ -21,7 +21,6 @@
import android.annotation.TestApi;
import android.content.Context;
import android.os.PersistableBundle;
-import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.telephony.ims.aidl.IImsConfig;
import android.telephony.ims.aidl.IImsConfigCallback;
@@ -29,6 +28,7 @@
import com.android.ims.ImsConfig;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.telephony.util.RemoteCallbackListExt;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -248,7 +248,8 @@
})
public @interface SetConfigResult {}
- private final RemoteCallbackList<IImsConfigCallback> mCallbacks = new RemoteCallbackList<>();
+ private final RemoteCallbackListExt<IImsConfigCallback> mCallbacks =
+ new RemoteCallbackListExt<>();
ImsConfigStub mImsConfigStub;
/**
@@ -289,7 +290,7 @@
if (mCallbacks == null) {
return;
}
- mCallbacks.broadcast(c -> {
+ mCallbacks.broadcastAction(c -> {
try {
c.onIntConfigChanged(item, value);
} catch (RemoteException e) {
@@ -303,7 +304,7 @@
if (mCallbacks == null) {
return;
}
- mCallbacks.broadcast(c -> {
+ mCallbacks.broadcastAction(c -> {
try {
c.onStringConfigChanged(item, value);
} catch (RemoteException e) {
diff --git a/telephony/java/android/telephony/ims/stub/ImsRegistrationImplBase.java b/telephony/java/android/telephony/ims/stub/ImsRegistrationImplBase.java
index c0f16e5..14a64d2 100644
--- a/telephony/java/android/telephony/ims/stub/ImsRegistrationImplBase.java
+++ b/telephony/java/android/telephony/ims/stub/ImsRegistrationImplBase.java
@@ -20,7 +20,6 @@
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.net.Uri;
-import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.RegistrationManager;
@@ -29,6 +28,7 @@
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.telephony.util.RemoteCallbackListExt;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -94,8 +94,8 @@
}
};
- private final RemoteCallbackList<IImsRegistrationCallback> mCallbacks
- = new RemoteCallbackList<>();
+ private final RemoteCallbackListExt<IImsRegistrationCallback> mCallbacks =
+ new RemoteCallbackListExt<>();
private final Object mLock = new Object();
// Locked on mLock
private @ImsRegistrationTech
@@ -129,7 +129,7 @@
*/
public final void onRegistered(@ImsRegistrationTech int imsRadioTech) {
updateToState(imsRadioTech, RegistrationManager.REGISTRATION_STATE_REGISTERED);
- mCallbacks.broadcast((c) -> {
+ mCallbacks.broadcastAction((c) -> {
try {
c.onRegistered(imsRadioTech);
} catch (RemoteException e) {
@@ -147,7 +147,7 @@
*/
public final void onRegistering(@ImsRegistrationTech int imsRadioTech) {
updateToState(imsRadioTech, RegistrationManager.REGISTRATION_STATE_REGISTERING);
- mCallbacks.broadcast((c) -> {
+ mCallbacks.broadcastAction((c) -> {
try {
c.onRegistering(imsRadioTech);
} catch (RemoteException e) {
@@ -175,7 +175,7 @@
*/
public final void onDeregistered(ImsReasonInfo info) {
updateToDisconnectedState(info);
- mCallbacks.broadcast((c) -> {
+ mCallbacks.broadcastAction((c) -> {
try {
c.onDeregistered(info);
} catch (RemoteException e) {
@@ -194,7 +194,7 @@
*/
public final void onTechnologyChangeFailed(@ImsRegistrationTech int imsRadioTech,
ImsReasonInfo info) {
- mCallbacks.broadcast((c) -> {
+ mCallbacks.broadcastAction((c) -> {
try {
c.onTechnologyChangeFailed(imsRadioTech, info);
} catch (RemoteException e) {
@@ -210,7 +210,7 @@
* @param uris
*/
public final void onSubscriberAssociatedUriChanged(Uri[] uris) {
- mCallbacks.broadcast((c) -> {
+ mCallbacks.broadcastAction((c) -> {
try {
c.onSubscriberAssociatedUriChanged(uris);
} catch (RemoteException e) {
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 0ec54ec..97b24ae 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -888,12 +888,13 @@
/**
* @return true if the ImsService to bind to for the slot id specified was set, false otherwise.
*/
- boolean setImsService(int slotId, boolean isCarrierImsService, String packageName);
+ boolean setBoundImsServiceOverride(int slotIndex, boolean isCarrierService,
+ in int[] featureTypes, in String packageName);
/**
* @return the package name of the carrier/device ImsService associated with this slot.
*/
- String getImsService(int slotId, boolean isCarrierImsService);
+ String getBoundImsServicePackage(int slotIndex, boolean isCarrierImsService, int featureType);
/**
* Get the MmTelFeature state attached to this subscription id.
diff --git a/telephony/java/com/android/internal/telephony/PhoneConstantConversions.java b/telephony/java/com/android/internal/telephony/PhoneConstantConversions.java
index f7f0f29..8640acc 100644
--- a/telephony/java/com/android/internal/telephony/PhoneConstantConversions.java
+++ b/telephony/java/com/android/internal/telephony/PhoneConstantConversions.java
@@ -16,14 +16,10 @@
package com.android.internal.telephony;
-import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
-import android.telephony.PreciseCallState;
import com.android.internal.telephony.PhoneConstants;
-import java.util.List;
-
public class PhoneConstantConversions {
/**
* Convert the {@link PhoneConstants.State} enum into the TelephonyManager.CALL_STATE_*
@@ -67,6 +63,8 @@
return TelephonyManager.DATA_CONNECTED;
case SUSPENDED:
return TelephonyManager.DATA_SUSPENDED;
+ case DISCONNECTING:
+ return TelephonyManager.DATA_DISCONNECTING;
default:
return TelephonyManager.DATA_DISCONNECTED;
}
@@ -84,6 +82,8 @@
return PhoneConstants.DataState.CONNECTED;
case TelephonyManager.DATA_SUSPENDED:
return PhoneConstants.DataState.SUSPENDED;
+ case TelephonyManager.DATA_DISCONNECTING:
+ return PhoneConstants.DataState.DISCONNECTING;
default:
return PhoneConstants.DataState.DISCONNECTED;
}
diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java
index fde2c5a..fadb573 100644
--- a/telephony/java/com/android/internal/telephony/PhoneConstants.java
+++ b/telephony/java/com/android/internal/telephony/PhoneConstants.java
@@ -46,6 +46,7 @@
* <ul>
* <li>CONNECTED = IP traffic should be available</li>
* <li>CONNECTING = Currently setting up data connection</li>
+ * <li>DISCONNECTING = IP temporarily available</li>
* <li>DISCONNECTED = IP not available</li>
* <li>SUSPENDED = connection is created but IP traffic is
* temperately not available. i.e. voice call is in place
@@ -55,10 +56,15 @@
@UnsupportedAppUsage(implicitMember =
"values()[Lcom/android/internal/telephony/PhoneConstants$DataState;")
public enum DataState {
- @UnsupportedAppUsage CONNECTED,
- @UnsupportedAppUsage CONNECTING,
- @UnsupportedAppUsage DISCONNECTED,
- @UnsupportedAppUsage SUSPENDED;
+ @UnsupportedAppUsage
+ CONNECTED,
+ @UnsupportedAppUsage
+ CONNECTING,
+ @UnsupportedAppUsage
+ DISCONNECTED,
+ @UnsupportedAppUsage
+ SUSPENDED,
+ DISCONNECTING;
};
public static final String STATE_KEY = "state";
@@ -91,20 +97,12 @@
public static final String PHONE_NAME_KEY = "phoneName";
public static final String DATA_NETWORK_TYPE_KEY = "networkType";
- public static final String DATA_FAILURE_CAUSE_KEY = "failCause";
public static final String DATA_APN_TYPE_KEY = "apnType";
public static final String DATA_APN_KEY = "apn";
- public static final String DATA_LINK_PROPERTIES_KEY = "linkProperties";
- public static final String DATA_NETWORK_CAPABILITIES_KEY = "networkCapabilities";
- public static final String DATA_IFACE_NAME_KEY = "iface";
- public static final String NETWORK_UNAVAILABLE_KEY = "networkUnvailable";
- public static final String DATA_NETWORK_ROAMING_KEY = "networkRoaming";
public static final String PHONE_IN_ECM_STATE = "phoneinECMState";
public static final String PHONE_IN_EMERGENCY_CALL = "phoneInEmergencyCall";
- public static final String REASON_LINK_PROPERTIES_CHANGED = "linkPropertiesChanged";
-
/**
* Return codes for supplyPinReturnResult and
* supplyPukReturnResult APIs
diff --git a/telephony/java/com/android/internal/telephony/util/RemoteCallbackListExt.java b/telephony/java/com/android/internal/telephony/util/RemoteCallbackListExt.java
new file mode 100644
index 0000000..d66bda9
--- /dev/null
+++ b/telephony/java/com/android/internal/telephony/util/RemoteCallbackListExt.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2019 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 com.android.internal.telephony.util;
+
+import android.os.IInterface;
+import android.os.RemoteCallbackList;
+
+import java.util.function.Consumer;
+
+/**
+ * Extension of RemoteCallbackList
+ * @param <E> defines the type of registered callbacks
+ */
+public class RemoteCallbackListExt<E extends IInterface> extends RemoteCallbackList<E> {
+ /**
+ * Performs {@code action} on each callback, calling
+ * {@link RemoteCallbackListExt#beginBroadcast()}
+ * /{@link RemoteCallbackListExt#finishBroadcast()} before/after looping
+ * @param action to be performed on each callback
+ *
+ */
+ public void broadcastAction(Consumer<E> action) {
+ int itemCount = beginBroadcast();
+ try {
+ for (int i = 0; i < itemCount; i++) {
+ action.accept(getBroadcastItem(i));
+ }
+ } finally {
+ finishBroadcast();
+ }
+ }
+}
diff --git a/tests/ActivityManagerPerfTests/stub-app/Android.bp b/tests/ActivityManagerPerfTests/stub-app/Android.bp
new file mode 100644
index 0000000..a3c1f5b
--- /dev/null
+++ b/tests/ActivityManagerPerfTests/stub-app/Android.bp
@@ -0,0 +1,68 @@
+// Copyright (C) 2019 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.
+
+android_test_helper_app {
+ name: "ActivityManagerPerfTestsStubApp1",
+ static_libs: ["ActivityManagerPerfTestsUtils"],
+ srcs: [
+ "src/**/*.java",
+ ],
+ resource_dirs: [
+ "app1/res",
+ "res",
+ ],
+ platform_apis: true,
+ certificate: "platform",
+ aaptflags: [
+ "--rename-manifest-package com.android.stubs.am1",
+ "--auto-add-overlay",
+ ],
+}
+
+android_test_helper_app {
+ name: "ActivityManagerPerfTestsStubApp2",
+ static_libs: ["ActivityManagerPerfTestsUtils"],
+ srcs: [
+ "src/**/*.java",
+ ],
+ resource_dirs: [
+ "app2/res",
+ "res",
+ ],
+ platform_apis: true,
+ certificate: "platform",
+ aaptflags: [
+ "--rename-manifest-package com.android.stubs.am2",
+ "--auto-add-overlay",
+ ],
+}
+
+android_test_helper_app {
+ name: "ActivityManagerPerfTestsStubApp3",
+ static_libs: ["ActivityManagerPerfTestsUtils"],
+ srcs: [
+ "src/**/*.java",
+ ],
+ resource_dirs: [
+ "app3/res",
+ "res",
+ ],
+ platform_apis: true,
+ certificate: "platform",
+ aaptflags: [
+ "--rename-manifest-package com.android.stubs.am3",
+ "--auto-add-overlay",
+ ],
+}
+
diff --git a/tests/ActivityManagerPerfTests/stub-app/AndroidManifest.xml b/tests/ActivityManagerPerfTests/stub-app/AndroidManifest.xml
new file mode 100644
index 0000000..a57f64c
--- /dev/null
+++ b/tests/ActivityManagerPerfTests/stub-app/AndroidManifest.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2019 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.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.stubs.am">
+
+ <uses-permission android:name="android.permission.START_ACTIVITIES_FROM_BACKGROUND"/>
+ <application android:label="Android TestCase" >
+ <provider
+ android:authorities="@string/authority"
+ android:name=".TestContentProvider"
+ android:exported="true" />
+ <receiver
+ android:name=".TestBroadcastReceiver"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="com.android.stubs.am.ACTION_BROADCAST_TEST" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </receiver>
+ <service
+ android:name=".InitService"
+ android:exported="true" />
+ <service
+ android:name=".TestService"
+ android:exported="true" />
+ <activity
+ android:name=".TestActivity"
+ android:excludeFromRecents="true"
+ android:turnScreenOn="true"
+ android:launchMode="singleTask">
+ <intent-filter>
+ <action android:name="com.android.stubs.am.ACTION_START_TEST_ACTIVITY" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
+
diff --git a/tests/ActivityManagerPerfTests/stub-app/app1/res/values/config.xml b/tests/ActivityManagerPerfTests/stub-app/app1/res/values/config.xml
new file mode 100644
index 0000000..667472d
--- /dev/null
+++ b/tests/ActivityManagerPerfTests/stub-app/app1/res/values/config.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2019 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="authority" translatable="false">com.android.stubs.am1.testapp</string>
+</resources>
diff --git a/tests/ActivityManagerPerfTests/stub-app/app2/res/values/config.xml b/tests/ActivityManagerPerfTests/stub-app/app2/res/values/config.xml
new file mode 100644
index 0000000..0852735
--- /dev/null
+++ b/tests/ActivityManagerPerfTests/stub-app/app2/res/values/config.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2019 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="authority" translatable="false">com.android.stubs.am2.testapp</string>
+</resources>
diff --git a/tests/ActivityManagerPerfTests/stub-app/app3/res/values/config.xml b/tests/ActivityManagerPerfTests/stub-app/app3/res/values/config.xml
new file mode 100644
index 0000000..6895d72
--- /dev/null
+++ b/tests/ActivityManagerPerfTests/stub-app/app3/res/values/config.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2019 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="authority" translatable="false">com.android.stubs.am3.testapp</string>
+</resources>
diff --git a/tests/ActivityManagerPerfTests/stub-app/res/layout/activity_content.xml b/tests/ActivityManagerPerfTests/stub-app/res/layout/activity_content.xml
new file mode 100644
index 0000000..f79f006
--- /dev/null
+++ b/tests/ActivityManagerPerfTests/stub-app/res/layout/activity_content.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 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.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"/>
diff --git a/tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/InitService.java b/tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/InitService.java
new file mode 100644
index 0000000..18fdc44
--- /dev/null
+++ b/tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/InitService.java
@@ -0,0 +1,301 @@
+/*
+ * Copyright (C) 2019 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 com.android.stubs.am;
+
+import static com.android.frameworks.perftests.am.util.Constants.COMMAND_ACQUIRE_CONTENT_PROVIDER;
+import static com.android.frameworks.perftests.am.util.Constants.COMMAND_BIND_SERVICE;
+import static com.android.frameworks.perftests.am.util.Constants.COMMAND_RELEASE_CONTENT_PROVIDER;
+import static com.android.frameworks.perftests.am.util.Constants.COMMAND_SEND_BROADCAST;
+import static com.android.frameworks.perftests.am.util.Constants.COMMAND_START_ACTIVITY;
+import static com.android.frameworks.perftests.am.util.Constants.COMMAND_STOP_ACTIVITY;
+import static com.android.frameworks.perftests.am.util.Constants.COMMAND_UNBIND_SERVICE;
+
+import android.app.Service;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.IContentProvider;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.net.Uri;
+import android.os.Binder;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.IBinder;
+import android.os.Looper;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
+import android.util.ArrayMap;
+import android.util.Log;
+
+import com.android.frameworks.perftests.am.util.Constants;
+import com.android.frameworks.perftests.am.util.ICommandReceiver;
+
+public class InitService extends Service {
+ private static final String TAG = "InitService";
+ public static final boolean VERBOSE = false;
+
+ private static class Stub extends ICommandReceiver.Stub {
+ private final Context mContext;
+ private final Messenger mCallback;
+ private final Handler mHandler;
+ private final Messenger mMessenger;
+ final ArrayMap<String, MyServiceConnection> mServices =
+ new ArrayMap<String, MyServiceConnection>();
+ final ArrayMap<Uri, IContentProvider> mProviders =
+ new ArrayMap<Uri, IContentProvider>();
+
+ Stub(Context context, Messenger callback) {
+ mContext = context;
+ mCallback = callback;
+ HandlerThread thread = new HandlerThread("result handler");
+ thread.start();
+ mHandler = new H(thread.getLooper());
+ mMessenger = new Messenger(mHandler);
+ }
+
+ private class H extends Handler {
+ H(Looper looper) {
+ super(looper);
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ if (msg.what == Constants.MSG_DEFAULT) {
+ if (VERBOSE) {
+ Log.i(TAG, "H: received seq=" + msg.arg1 + ", result=" + msg.arg2);
+ }
+ sendResult(mCallback, Constants.REPLY_COMMAND_RESULT, msg.arg1, msg.arg2, null);
+ } else if (msg.what == Constants.MSG_UNBIND_DONE) {
+ if (VERBOSE) {
+ Log.i(TAG, "H: received unbind=" + msg.obj);
+ }
+ synchronized (InitService.sStub) {
+ Bundle b = (Bundle) msg.obj;
+ String pkg = b.getString(Constants.EXTRA_SOURCE_PACKAGE, "");
+ MyServiceConnection c = mServices.remove(pkg);
+ if (c != null) {
+ sendResult(mCallback, Constants.REPLY_COMMAND_RESULT, c.mSeq,
+ Constants.RESULT_NO_ERROR, null);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void sendCommand(int command, int seq, String sourcePackage, String targetPackage,
+ int flags, Bundle bundle) {
+ if (VERBOSE) {
+ Log.i(TAG, "Received command=" + command + ", seq=" + seq + ", from="
+ + sourcePackage + ", to=" + targetPackage + ", flags=" + flags);
+ }
+ switch (command) {
+ case COMMAND_BIND_SERVICE:
+ handleBindService(seq, targetPackage, flags, bundle);
+ break;
+ case COMMAND_UNBIND_SERVICE:
+ handleUnbindService(seq, targetPackage);
+ break;
+ case COMMAND_ACQUIRE_CONTENT_PROVIDER:
+ acquireProvider(seq, bundle.getParcelable(Constants.EXTRA_URI));
+ break;
+ case COMMAND_RELEASE_CONTENT_PROVIDER:
+ releaseProvider(seq, bundle.getParcelable(Constants.EXTRA_URI));
+ break;
+ case COMMAND_SEND_BROADCAST:
+ sendBroadcast(seq, targetPackage);
+ break;
+ case COMMAND_START_ACTIVITY:
+ startActivity(seq, targetPackage);
+ break;
+ case COMMAND_STOP_ACTIVITY:
+ stopActivity(seq, targetPackage);
+ break;
+ }
+ }
+
+ private void handleBindService(int seq, String targetPackage, int flags, Bundle bundle) {
+ Intent intent = new Intent();
+ intent.setClassName(targetPackage, "com.android.stubs.am.TestService");
+ intent.putExtra(Constants.EXTRA_RECEIVER_CALLBACK, mMessenger);
+ if (bundle != null) {
+ intent.putExtras(bundle);
+ }
+ synchronized (this) {
+ if (!mServices.containsKey(targetPackage)) {
+ MyServiceConnection c = new MyServiceConnection(mCallback);
+ c.mSeq = seq;
+ if (!mContext.bindService(intent, c, flags)) {
+ Log.e(TAG, "Unable to bind to service in " + targetPackage);
+ sendResult(mCallback, Constants.REPLY_COMMAND_RESULT, seq,
+ Constants.RESULT_ERROR, null);
+ } else {
+ if (VERBOSE) {
+ Log.i(TAG, "Bind to service " + intent);
+ }
+ mServices.put(targetPackage, c);
+ }
+ } else {
+ sendResult(mCallback, Constants.REPLY_COMMAND_RESULT, seq,
+ Constants.RESULT_NO_ERROR, null);
+ }
+ }
+ }
+
+ private void handleUnbindService(int seq, String target) {
+ MyServiceConnection c = null;
+ synchronized (this) {
+ c = mServices.get(target);
+ }
+ if (c != null) {
+ c.mSeq = seq;
+ mContext.unbindService(c);
+ }
+ }
+
+ private void acquireProvider(int seq, Uri uri) {
+ ContentResolver resolver = mContext.getContentResolver();
+ IContentProvider provider = resolver.acquireProvider(uri);
+ if (provider != null) {
+ synchronized (mProviders) {
+ mProviders.put(uri, provider);
+ }
+ sendResult(mCallback, Constants.REPLY_COMMAND_RESULT, seq,
+ Constants.RESULT_NO_ERROR, null);
+ } else {
+ sendResult(mCallback, Constants.REPLY_COMMAND_RESULT, seq,
+ Constants.RESULT_ERROR, null);
+ }
+ }
+
+ private void releaseProvider(int seq, Uri uri) {
+ ContentResolver resolver = mContext.getContentResolver();
+ IContentProvider provider;
+ synchronized (mProviders) {
+ provider = mProviders.get(uri);
+ }
+ if (provider != null) {
+ resolver.releaseProvider(provider);
+ synchronized (mProviders) {
+ mProviders.remove(uri);
+ }
+ }
+ sendResult(mCallback, Constants.REPLY_COMMAND_RESULT, seq,
+ Constants.RESULT_NO_ERROR, null);
+ }
+
+ private void sendBroadcast(final int seq, String targetPackage) {
+ Intent intent = new Intent(Constants.STUB_ACTION_BROADCAST);
+ intent.setPackage(targetPackage);
+ mContext.sendOrderedBroadcast(intent, null, new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ sendResult(mCallback, Constants.REPLY_COMMAND_RESULT, seq,
+ Constants.RESULT_NO_ERROR, null);
+ }
+ }, null, 0, null, null);
+ }
+
+ private void startActivity(int seq, String targetPackage) {
+ Intent intent = new Intent(Constants.STUB_ACTION_ACTIVITY);
+ intent.setClassName(targetPackage, "com.android.stubs.am.TestActivity");
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+ intent.putExtra(Constants.EXTRA_ARG1, seq);
+ intent.putExtra(Constants.EXTRA_RECEIVER_CALLBACK, mMessenger);
+ mContext.startActivity(intent);
+ }
+
+ private void stopActivity(int seq, String targetPackage) {
+ Intent intent = new Intent(Constants.STUB_ACTION_ACTIVITY);
+ intent.setClassName(targetPackage, "com.android.stubs.am.TestActivity");
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+ intent.putExtra(Constants.EXTRA_REQ_FINISH_ACTIVITY, true);
+ intent.putExtra(Constants.EXTRA_ARG1, seq);
+ intent.putExtra(Constants.EXTRA_RECEIVER_CALLBACK, mMessenger);
+ mContext.startActivity(intent);
+ }
+ };
+
+ private static void sendResult(Messenger callback, int what, int seq, int result, Object obj) {
+ Message msg = Message.obtain();
+ msg.what = what;
+ msg.arg1 = seq;
+ msg.arg2 = result;
+ msg.obj = obj;
+ try {
+ if (VERBOSE) {
+ Log.i(TAG, "Sending result seq=" + seq + ", result=" + result);
+ }
+ callback.send(msg);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error in sending result back", e);
+ }
+ msg.recycle();
+ }
+
+ private static class MyServiceConnection implements ServiceConnection {
+ private Messenger mCallback;
+ int mSeq;
+
+ MyServiceConnection(Messenger callback) {
+ mCallback = callback;
+ }
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ sendResult(mCallback, Constants.REPLY_COMMAND_RESULT, mSeq,
+ Constants.RESULT_NO_ERROR, null);
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ synchronized (sStub) {
+ MyServiceConnection c = sStub.mServices.remove(name.getPackageName());
+ if (c != null) {
+ sendResult(mCallback, Constants.REPLY_COMMAND_RESULT, c.mSeq,
+ Constants.RESULT_NO_ERROR, null);
+ }
+ }
+ }
+ }
+
+ private static Stub sStub = null;
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return new Binder();
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ Messenger callback = intent.getParcelableExtra(Constants.EXTRA_RECEIVER_CALLBACK);
+ if (sStub == null) {
+ sStub = new Stub(getApplicationContext(), callback);
+ }
+
+ Bundle extras = new Bundle();
+ extras.putString(Constants.EXTRA_SOURCE_PACKAGE, getPackageName());
+ extras.putBinder(Constants.EXTRA_RECEIVER_CALLBACK, sStub);
+ sendResult(callback, Constants.REPLY_PACKAGE_START_RESULT,
+ intent.getIntExtra(Constants.EXTRA_SEQ, -1), 0, extras);
+ return START_NOT_STICKY;
+ }
+}
diff --git a/tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/TestActivity.java b/tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/TestActivity.java
new file mode 100644
index 0000000..f7ea356
--- /dev/null
+++ b/tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/TestActivity.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2019 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 com.android.stubs.am;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
+import android.util.Log;
+
+import com.android.frameworks.perftests.am.util.Constants;
+
+public class TestActivity extends Activity {
+ private static final String TAG = "TestActivity";
+ private static final boolean VERBOSE = InitService.VERBOSE;
+
+ private Messenger mResultTo;
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ if (VERBOSE) {
+ Log.i(TAG, getPackageName() + " onCreate()");
+ }
+ setContentView(R.layout.activity_content);
+ mResultTo = getIntent().getParcelableExtra(Constants.EXTRA_RECEIVER_CALLBACK);
+ }
+
+ @Override
+ public void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ setIntent(intent);
+ mResultTo = intent.getParcelableExtra(Constants.EXTRA_RECEIVER_CALLBACK);
+ if (intent.getBooleanExtra(Constants.EXTRA_REQ_FINISH_ACTIVITY, false)) {
+ if (VERBOSE) {
+ Log.i(TAG, getPackageName() + " finishing activity");
+ }
+ finish();
+ }
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ if (VERBOSE) {
+ Log.i(TAG, getPackageName() + " onResume()");
+ }
+ sendResult(Constants.RESULT_NO_ERROR);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ if (VERBOSE) {
+ Log.i(TAG, getPackageName() + " onDestroy()");
+ }
+ sendResult(Constants.RESULT_NO_ERROR);
+ }
+
+ private void sendResult(int result) {
+ Message msg = Message.obtain();
+ msg.arg1 = getIntent().getIntExtra(Constants.EXTRA_ARG1, -1);
+ msg.arg2 = result;
+ try {
+ mResultTo.send(msg);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error in sending result back", e);
+ }
+ }
+}
diff --git a/tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/TestBroadcastReceiver.java b/tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/TestBroadcastReceiver.java
new file mode 100644
index 0000000..36c7a0a
--- /dev/null
+++ b/tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/TestBroadcastReceiver.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2019 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 com.android.stubs.am;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+public class TestBroadcastReceiver extends BroadcastReceiver {
+ private static final String TAG = "TestBroadcastReceiver";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.i(TAG, context.getPackageName() + " received broadcast: " + intent);
+ }
+}
diff --git a/tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/TestContentProvider.java b/tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/TestContentProvider.java
new file mode 100644
index 0000000..4fdbf1f
--- /dev/null
+++ b/tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/TestContentProvider.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2019 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 com.android.stubs.am;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.net.Uri;
+import android.util.Log;
+
+public class TestContentProvider extends ContentProvider {
+ private static final String TAG = "TestContentProvider";
+ private static final boolean VERBOSE = InitService.VERBOSE;
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ return null;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
+ String sortOrder) {
+ return null;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return null;
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ return 0;
+ }
+
+ @Override
+ public boolean onCreate() {
+ if (VERBOSE) {
+ Log.i(TAG, getContext().getPackageName() + " onCreate()");
+ }
+ return false;
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ return 0;
+ }
+}
diff --git a/tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/TestService.java b/tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/TestService.java
new file mode 100644
index 0000000..ba220e0
--- /dev/null
+++ b/tests/ActivityManagerPerfTests/stub-app/src/com/android/stubs/am/TestService.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2019 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 com.android.stubs.am;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.Binder;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
+import android.util.Log;
+
+import com.android.frameworks.perftests.am.util.Constants;
+
+public class TestService extends Service {
+ private static final String TAG = "TestService";
+ private static final boolean VERBOSE = InitService.VERBOSE;
+
+ private Binder mStub = new Binder();
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ if (VERBOSE) {
+ Log.i(TAG, getPackageName() + " onBind()");
+ }
+ return mStub;
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ if (VERBOSE) {
+ Log.i(TAG, getPackageName() + " onStartCommand()");
+ }
+ return START_NOT_STICKY;
+ }
+
+ @Override
+ public boolean onUnbind(Intent intent) {
+ if (VERBOSE) {
+ Log.i(TAG, getPackageName() + " onUnbind()");
+ }
+ Messenger messenger = intent.getParcelableExtra(Constants.EXTRA_RECEIVER_CALLBACK);
+ Message msg = Message.obtain();
+ msg.what = Constants.MSG_UNBIND_DONE;
+ Bundle b = new Bundle();
+ b.putString(Constants.EXTRA_SOURCE_PACKAGE, getPackageName());
+ msg.obj = b;
+ try {
+ messenger.send(msg);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error in sending result back", e);
+ }
+ return false;
+ }
+}
diff --git a/tests/ActivityManagerPerfTests/tests/AndroidTest.xml b/tests/ActivityManagerPerfTests/tests/AndroidTest.xml
index 76c40b2..475bb82 100644
--- a/tests/ActivityManagerPerfTests/tests/AndroidTest.xml
+++ b/tests/ActivityManagerPerfTests/tests/AndroidTest.xml
@@ -17,6 +17,9 @@
<target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
<option name="test-file-name" value="ActivityManagerPerfTests.apk"/>
<option name="test-file-name" value="ActivityManagerPerfTestsTestApp.apk"/>
+ <option name="test-file-name" value="ActivityManagerPerfTestsStubApp1.apk"/>
+ <option name="test-file-name" value="ActivityManagerPerfTestsStubApp2.apk"/>
+ <option name="test-file-name" value="ActivityManagerPerfTestsStubApp3.apk"/>
<option name="cleanup-apks" value="true"/>
</target_preparer>
@@ -26,4 +29,4 @@
<option name="package" value="com.android.frameworks.perftests.amtests"/>
<option name="runner" value="androidx.test.runner.AndroidJUnitRunner"/>
</test>
-</configuration>
\ No newline at end of file
+</configuration>
diff --git a/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/OomAdjPerfTest.java b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/OomAdjPerfTest.java
new file mode 100644
index 0000000..1d3ff06
--- /dev/null
+++ b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/tests/OomAdjPerfTest.java
@@ -0,0 +1,241 @@
+/*
+ * Copyright (C) 2019 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 com.android.frameworks.perftests.am.tests;
+
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.net.Uri;
+import android.os.HandlerThread;
+import android.perftests.utils.ManualBenchmarkState;
+import android.perftests.utils.PerfManualStatusReporter;
+import android.perftests.utils.TraceMarkParser;
+import android.perftests.utils.TraceMarkParser.TraceMarkLine;
+import android.perftests.utils.TraceMarkParser.TraceMarkSlice;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.LargeTest;
+
+import com.android.frameworks.perftests.am.util.AtraceUtils;
+import com.android.frameworks.perftests.am.util.TargetPackageUtils;
+import com.android.frameworks.perftests.am.util.Utils;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This benchmark test basically manipulates 3 test packages, let them bind to
+ * each other, send broadcast to each other, etc. All of these actions essentially
+ * triggers OomAdjuster to update the oom_adj scores and proc state of them.
+ * In the meanwhile it'll also monitor the atrace output, extract duration between
+ * the start and exit entries of the updateOomAdjLocked, include each of them
+ * into the stats; when there are enough samples in the stats, the test will
+ * stop and output the mean/stddev time spent on the updateOomAdjLocked.
+ */
+@RunWith(JUnit4.class)
+@LargeTest
+public final class OomAdjPerfTest {
+ private static final String TAG = "OomAdjPerfTest";
+ private static final boolean VERBOSE = true;
+
+ private static final String STUB_PACKAGE1_NAME = "com.android.stubs.am1";
+ private static final String STUB_PACKAGE2_NAME = "com.android.stubs.am2";
+ private static final String STUB_PACKAGE3_NAME = "com.android.stubs.am3";
+
+ private static final Uri STUB_PACKAGE1_URI = new Uri.Builder().scheme(
+ ContentResolver.SCHEME_CONTENT).authority("com.android.stubs.am1.testapp").build();
+ private static final Uri STUB_PACKAGE2_URI = new Uri.Builder().scheme(
+ ContentResolver.SCHEME_CONTENT).authority("com.android.stubs.am2.testapp").build();
+ private static final Uri STUB_PACKAGE3_URI = new Uri.Builder().scheme(
+ ContentResolver.SCHEME_CONTENT).authority("com.android.stubs.am3.testapp").build();
+ private static final long NANOS_PER_MICROSECOND = 1000L;
+
+ private static final String ATRACE_CATEGORY = "am";
+ private static final String ATRACE_OOMADJ_PREFIX = "updateOomAdj_";
+
+ @Rule
+ public PerfManualStatusReporter mPerfManualStatusReporter = new PerfManualStatusReporter();
+ private TraceMarkParser mTraceMarkParser = new TraceMarkParser(this::shouldFilterTraceLine);
+ private final ArrayList<Long> mDurations = new ArrayList<Long>();
+ private Context mContext;
+ private HandlerThread mHandlerThread;
+
+ @Before
+ public void setUp() {
+ mContext = InstrumentationRegistry.getTargetContext();
+ mHandlerThread = new HandlerThread("command receiver");
+ mHandlerThread.start();
+ TargetPackageUtils.initCommandResultReceiver(mHandlerThread.getLooper());
+
+ Utils.runShellCommand("cmd deviceidle whitelist +" + STUB_PACKAGE1_NAME);
+ Utils.runShellCommand("cmd deviceidle whitelist +" + STUB_PACKAGE2_NAME);
+ Utils.runShellCommand("cmd deviceidle whitelist +" + STUB_PACKAGE3_NAME);
+ TargetPackageUtils.startStubPackage(mContext, STUB_PACKAGE1_NAME);
+ TargetPackageUtils.startStubPackage(mContext, STUB_PACKAGE2_NAME);
+ TargetPackageUtils.startStubPackage(mContext, STUB_PACKAGE3_NAME);
+ }
+
+ @After
+ public void tearDown() {
+ TargetPackageUtils.stopStubPackage(mContext, STUB_PACKAGE1_NAME);
+ TargetPackageUtils.stopStubPackage(mContext, STUB_PACKAGE2_NAME);
+ TargetPackageUtils.stopStubPackage(mContext, STUB_PACKAGE3_NAME);
+ Utils.runShellCommand("cmd deviceidle whitelist -" + STUB_PACKAGE1_NAME);
+ Utils.runShellCommand("cmd deviceidle whitelist -" + STUB_PACKAGE2_NAME);
+ Utils.runShellCommand("cmd deviceidle whitelist -" + STUB_PACKAGE3_NAME);
+ mHandlerThread.quitSafely();
+ }
+
+ @Test
+ public void testOomAdj() {
+ final AtraceUtils atraceUtils = AtraceUtils.getInstance(
+ InstrumentationRegistry.getInstrumentation());
+ final ManualBenchmarkState state = mPerfManualStatusReporter.getBenchmarkState();
+ atraceUtils.startTrace(ATRACE_CATEGORY);
+ while (state.keepRunning(mDurations)) {
+ runCUJWithOomComputationOnce();
+
+ // Now kick off the trace dump
+ mDurations.clear();
+ atraceUtils.performDump(mTraceMarkParser, this::handleTraceMarkSlices);
+ }
+ atraceUtils.stopTrace();
+ }
+
+ private boolean shouldFilterTraceLine(final TraceMarkLine line) {
+ return line.name.startsWith(ATRACE_OOMADJ_PREFIX);
+ }
+
+ private void handleTraceMarkSlices(String key, List<TraceMarkSlice> slices) {
+ for (TraceMarkSlice slice: slices) {
+ mDurations.add(slice.getDurationInMicroseconds() * NANOS_PER_MICROSECOND);
+ }
+ }
+
+ /**
+ * This tries to mimic a user journey, involes multiple activity/service starts/stop,
+ * the time spent on oom adj computation would be different between all these samples,
+ * but with enough samples, we'll be able to know the overall distribution of the time
+ * spent on it.
+ */
+ private void runCUJWithOomComputationOnce() {
+ // Start activity from package1
+ TargetPackageUtils.startActivity(STUB_PACKAGE1_NAME, STUB_PACKAGE1_NAME);
+ // Start activity from package2
+ TargetPackageUtils.startActivity(STUB_PACKAGE2_NAME, STUB_PACKAGE2_NAME);
+ // Start activity from package3
+ TargetPackageUtils.startActivity(STUB_PACKAGE3_NAME, STUB_PACKAGE3_NAME);
+
+ // Stop activity in package1
+ TargetPackageUtils.stopActivity(STUB_PACKAGE1_NAME, STUB_PACKAGE1_NAME);
+ // Stop activity in package2
+ TargetPackageUtils.stopActivity(STUB_PACKAGE2_NAME, STUB_PACKAGE2_NAME);
+ // Stop activity in package3
+ TargetPackageUtils.stopActivity(STUB_PACKAGE3_NAME, STUB_PACKAGE3_NAME);
+
+ // Bind from package1 to package2
+ TargetPackageUtils.bindService(STUB_PACKAGE1_NAME, STUB_PACKAGE2_NAME,
+ Context.BIND_AUTO_CREATE);
+ // Acquire content provider from package 1 to package3
+ TargetPackageUtils.acquireProvider(STUB_PACKAGE1_NAME, STUB_PACKAGE3_NAME,
+ STUB_PACKAGE3_URI);
+ // Start activity from package1
+ TargetPackageUtils.startActivity(STUB_PACKAGE1_NAME, STUB_PACKAGE1_NAME);
+ // Bind from package2 to package3
+ TargetPackageUtils.bindService(STUB_PACKAGE2_NAME, STUB_PACKAGE3_NAME,
+ Context.BIND_AUTO_CREATE);
+ // Unbind from package 1 to package 2
+ TargetPackageUtils.unbindService(STUB_PACKAGE1_NAME, STUB_PACKAGE2_NAME, 0);
+ // Stop activity in package1
+ TargetPackageUtils.stopActivity(STUB_PACKAGE1_NAME, STUB_PACKAGE1_NAME);
+
+ // Send broadcast to all of them
+ TargetPackageUtils.sendBroadcast(STUB_PACKAGE1_NAME, STUB_PACKAGE1_NAME);
+ TargetPackageUtils.sendBroadcast(STUB_PACKAGE2_NAME, STUB_PACKAGE2_NAME);
+ TargetPackageUtils.sendBroadcast(STUB_PACKAGE3_NAME, STUB_PACKAGE3_NAME);
+
+ // Bind from package1 to package2 again
+ TargetPackageUtils.bindService(STUB_PACKAGE1_NAME, STUB_PACKAGE2_NAME,
+ Context.BIND_AUTO_CREATE);
+ // Create a cycle: package3 to package1
+ TargetPackageUtils.bindService(STUB_PACKAGE3_NAME, STUB_PACKAGE1_NAME,
+ Context.BIND_AUTO_CREATE);
+
+ // Send broadcast to all of them again
+ TargetPackageUtils.sendBroadcast(STUB_PACKAGE1_NAME, STUB_PACKAGE1_NAME);
+ TargetPackageUtils.sendBroadcast(STUB_PACKAGE2_NAME, STUB_PACKAGE2_NAME);
+ TargetPackageUtils.sendBroadcast(STUB_PACKAGE3_NAME, STUB_PACKAGE3_NAME);
+ // Start activity in package3
+ TargetPackageUtils.startActivity(STUB_PACKAGE3_NAME, STUB_PACKAGE3_NAME);
+
+ // Break the cycle: unbind from package3 to package1
+ TargetPackageUtils.unbindService(STUB_PACKAGE3_NAME, STUB_PACKAGE1_NAME, 0);
+
+ // Bind from package3 to package1 with waive priority
+ TargetPackageUtils.bindService(STUB_PACKAGE3_NAME, STUB_PACKAGE1_NAME,
+ Context.BIND_AUTO_CREATE | Context.BIND_WAIVE_PRIORITY);
+ // Release provider connection
+ TargetPackageUtils.releaseProvider(STUB_PACKAGE1_NAME, STUB_PACKAGE3_NAME,
+ STUB_PACKAGE3_URI);
+ // Unbind from package1 to package2
+ TargetPackageUtils.unbindService(STUB_PACKAGE1_NAME, STUB_PACKAGE2_NAME, 0);
+ // Unbind from package2 to packagae3
+ TargetPackageUtils.unbindService(STUB_PACKAGE2_NAME, STUB_PACKAGE3_NAME, 0);
+
+ // Bind from package3 to package2 with BIND_ABOVE_CLIENT
+ TargetPackageUtils.bindService(STUB_PACKAGE3_NAME, STUB_PACKAGE2_NAME,
+ Context.BIND_AUTO_CREATE | Context.BIND_ABOVE_CLIENT);
+ // Unbind from package3 to packagae2
+ TargetPackageUtils.unbindService(STUB_PACKAGE3_NAME, STUB_PACKAGE2_NAME, 0);
+
+ // Bind from package3 to package2 with BIND_ALLOW_OOM_MANAGEMENT
+ TargetPackageUtils.bindService(STUB_PACKAGE3_NAME, STUB_PACKAGE2_NAME,
+ Context.BIND_AUTO_CREATE | Context.BIND_ALLOW_OOM_MANAGEMENT);
+ // Unbind from package3 to packagae2
+ TargetPackageUtils.unbindService(STUB_PACKAGE3_NAME, STUB_PACKAGE2_NAME, 0);
+
+ // Bind from package3 to package2 with BIND_IMPORTANT
+ TargetPackageUtils.bindService(STUB_PACKAGE3_NAME, STUB_PACKAGE2_NAME,
+ Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT);
+ // Unbind from package3 to packagae2
+ TargetPackageUtils.unbindService(STUB_PACKAGE3_NAME, STUB_PACKAGE2_NAME, 0);
+
+ // Bind from package3 to package2 with BIND_NOT_FOREGROUND
+ TargetPackageUtils.bindService(STUB_PACKAGE3_NAME, STUB_PACKAGE2_NAME,
+ Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND);
+ // Unbind from package3 to packagae2
+ TargetPackageUtils.unbindService(STUB_PACKAGE3_NAME, STUB_PACKAGE2_NAME, 0);
+
+ // Bind from package3 to package2 with BIND_NOT_PERCEPTIBLE
+ TargetPackageUtils.bindService(STUB_PACKAGE3_NAME, STUB_PACKAGE2_NAME,
+ Context.BIND_AUTO_CREATE | Context.BIND_NOT_PERCEPTIBLE);
+ // Unbind from package3 to packagae2
+ TargetPackageUtils.unbindService(STUB_PACKAGE3_NAME, STUB_PACKAGE2_NAME, 0);
+
+ // Stop activity in package3
+ TargetPackageUtils.stopActivity(STUB_PACKAGE3_NAME, STUB_PACKAGE3_NAME);
+ // Unbind from package3 to package1
+ TargetPackageUtils.unbindService(STUB_PACKAGE3_NAME, STUB_PACKAGE1_NAME, 0);
+ }
+}
diff --git a/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/util/AtraceUtils.java b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/util/AtraceUtils.java
new file mode 100644
index 0000000..fcccfce
--- /dev/null
+++ b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/util/AtraceUtils.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2019 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 com.android.frameworks.perftests.am.util;
+
+import android.app.Instrumentation;
+import android.app.UiAutomation;
+import android.os.ParcelFileDescriptor;
+import android.perftests.utils.TraceMarkParser;
+import android.perftests.utils.TraceMarkParser.TraceMarkSlice;
+import android.util.Log;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.List;
+import java.util.function.BiConsumer;
+
+// Simplified version of AtraceLogger.
+public class AtraceUtils {
+ private static final String TAG = "AtraceUtils";
+ private static final boolean VERBOSE = true;
+
+ private static final String ATRACE_START = "atrace --async_start -b %d -c %s";
+ private static final String ATRACE_DUMP = "atrace --async_dump";
+ private static final String ATRACE_STOP = "atrace --async_stop";
+ private static final int DEFAULT_ATRACE_BUF_SIZE = 1024;
+
+ private UiAutomation mAutomation;
+ private static AtraceUtils sUtils = null;
+ private boolean mStarted = false;
+
+ private AtraceUtils(Instrumentation instrumentation) {
+ mAutomation = instrumentation.getUiAutomation();
+ }
+
+ public static AtraceUtils getInstance(Instrumentation instrumentation) {
+ if (sUtils == null) {
+ sUtils = new AtraceUtils(instrumentation);
+ }
+ return sUtils;
+ }
+
+ /**
+ * @param categories The list of the categories to trace, separated with space.
+ */
+ public void startTrace(String categories) {
+ synchronized (this) {
+ if (mStarted) {
+ throw new IllegalStateException("atrace already started");
+ }
+ Utils.runShellCommand(String.format(
+ ATRACE_START, DEFAULT_ATRACE_BUF_SIZE, categories));
+ mStarted = true;
+ }
+ }
+
+ public void stopTrace() {
+ synchronized (this) {
+ mStarted = false;
+ Utils.runShellCommand(ATRACE_STOP);
+ }
+ }
+
+ /**
+ * @param parser The function that can accept the buffer of atrace dump and parse it.
+ * @param handler The parse result handler
+ */
+ public void performDump(TraceMarkParser parser,
+ BiConsumer<String, List<TraceMarkSlice>> handler) {
+ parser.reset();
+ try {
+ if (VERBOSE) {
+ Log.i(TAG, "Collecting atrace dump...");
+ }
+ writeDataToBuf(mAutomation.executeShellCommand(ATRACE_DUMP), parser);
+ } catch (IOException e) {
+ Log.e(TAG, "Error in reading dump", e);
+ }
+ parser.forAllSlices(handler);
+ }
+
+ // The given file descriptor here will be closed by this function
+ private void writeDataToBuf(ParcelFileDescriptor pfDescriptor,
+ TraceMarkParser parser) throws IOException {
+ InputStream inputStream = new ParcelFileDescriptor.AutoCloseInputStream(pfDescriptor);
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ parser.visit(line);
+ }
+ }
+ }
+}
diff --git a/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/util/TargetPackageUtils.java b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/util/TargetPackageUtils.java
index 046dd6b..d7f4d9d 100644
--- a/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/util/TargetPackageUtils.java
+++ b/tests/ActivityManagerPerfTests/tests/src/com/android/frameworks/perftests/am/util/TargetPackageUtils.java
@@ -22,12 +22,18 @@
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
+import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
-import android.os.ResultReceiver;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
import android.os.SystemClock;
+import android.util.ArrayMap;
+import android.util.Log;
+import android.util.Pair;
import org.junit.Assert;
@@ -36,6 +42,7 @@
public class TargetPackageUtils {
private static final String TAG = TargetPackageUtils.class.getSimpleName();
+ public static final boolean VERBOSE = true;
public static final String PACKAGE_NAME = "com.android.frameworks.perftests.amteststestapp";
public static final String ACTIVITY_NAME = PACKAGE_NAME + ".TestActivity";
@@ -48,6 +55,12 @@
// Cache for test app's uid, so we only have to query it once.
private static int sTestAppUid = -1;
+ private static final ArrayMap<String, ICommandReceiver> sStubPackages =
+ new ArrayMap<String, ICommandReceiver>();
+ private static final ArrayMap<Integer, CountDownLatch> sCommandLatches =
+ new ArrayMap<Integer, CountDownLatch>();
+ private static int sSeqNum = 0;
+
/**
* Kills the test package synchronously.
*/
@@ -145,5 +158,160 @@
}
}
+ private static boolean isUidRunning(int uid) {
+ return !Utils.runShellCommand(String.format("cmd activity get-uid-state %d", uid))
+ .contains("(NONEXISTENT)");
+ }
+
+ public static void startStubPackage(Context context, String pkgName) {
+ stopStubPackage(context, pkgName);
+ try {
+ Pair<Integer, CountDownLatch> pair = obtainLatch();
+ Intent intent = new Intent();
+ intent.setComponent(new ComponentName(pkgName, Constants.STUB_INIT_SERVICE_NAME));
+ intent.putExtra(Constants.EXTRA_SOURCE_PACKAGE, context.getPackageName());
+ intent.putExtra(Constants.EXTRA_RECEIVER_CALLBACK, sMessenger);
+ intent.putExtra(Constants.EXTRA_SEQ, pair.first);
+ context.startService(intent);
+ Assert.assertTrue("Timeout when waiting for starting package " + pkgName,
+ pair.second.await(AWAIT_SERVICE_CONNECT_MS, TimeUnit.MILLISECONDS));
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static void stopStubPackage(Context context, String pkgName) {
+ final PackageManager pm = context.getPackageManager();
+ try {
+ final int uid = pm.getPackageUid(pkgName, 0);
+ if (isUidRunning(uid)) {
+ ActivityManager am = context.getSystemService(ActivityManager.class);
+ am.forceStopPackage(pkgName);
+ while (isUidRunning(uid)) {
+ SystemClock.sleep(WAIT_TIME_MS);
+ }
+ }
+ } catch (PackageManager.NameNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static void initCommandResultReceiver(Looper looper) {
+ if (sMessenger == null) {
+ sMessenger = new Messenger(new H(looper));
+ }
+ }
+
+ private static void onPackageStartResult(int seq, Bundle bundle) {
+ ICommandReceiver receiver = ICommandReceiver.Stub.asInterface(
+ bundle.getBinder(Constants.EXTRA_RECEIVER_CALLBACK));
+ String sourcePkg = bundle.getString(Constants.EXTRA_SOURCE_PACKAGE);
+ sStubPackages.put(sourcePkg, receiver);
+ releaseLatch(seq);
+ }
+
+ private static void onCommandResult(int seq, int result) {
+ Assert.assertTrue("Error in command seq " + seq, result == Constants.RESULT_NO_ERROR);
+ releaseLatch(seq);
+ }
+
+ private static Messenger sMessenger = null;
+ private static class H extends Handler {
+ H(Looper looper) {
+ super(looper);
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case Constants.REPLY_PACKAGE_START_RESULT:
+ onPackageStartResult(msg.arg1 /* seq */, (Bundle) msg.obj);
+ break;
+ case Constants.REPLY_COMMAND_RESULT:
+ onCommandResult(msg.arg1, msg.arg2);
+ break;
+ }
+ }
+ }
+
+ private static Pair<Integer, CountDownLatch> obtainLatch() {
+ CountDownLatch latch = new CountDownLatch(1);
+ int seq;
+ synchronized (sCommandLatches) {
+ seq = sSeqNum++;
+ sCommandLatches.put(seq, latch);
+ }
+ return new Pair<>(seq, latch);
+ }
+
+ private static void releaseLatch(int seq) {
+ synchronized (sCommandLatches) {
+ CountDownLatch latch = sCommandLatches.get(seq);
+ if (latch != null) {
+ latch.countDown();
+ sCommandLatches.remove(seq);
+ }
+ }
+ }
+
+ public static void sendCommand(int command, String sourcePackage, String targetPackage,
+ int flags, Bundle bundle, boolean waitForResult) {
+ ICommandReceiver receiver = sStubPackages.get(sourcePackage);
+ Assert.assertTrue("Package hasn't been started: " + sourcePackage, receiver != null);
+ try {
+ Pair<Integer, CountDownLatch> pair = null;
+ if (waitForResult) {
+ pair = obtainLatch();
+ }
+ if (VERBOSE) {
+ Log.i(TAG, "Sending command=" + command + ", seq=" + pair.first + ", from="
+ + sourcePackage + ", to=" + targetPackage + ", flags=" + flags);
+ }
+ receiver.sendCommand(command, pair.first, sourcePackage, targetPackage, flags, bundle);
+ if (waitForResult) {
+ Assert.assertTrue("Timeout when waiting for command " + command + " from "
+ + sourcePackage + " to " + targetPackage,
+ pair.second.await(AWAIT_SERVICE_CONNECT_MS, TimeUnit.MILLISECONDS));
+ }
+ } catch (RemoteException | InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static void bindService(String sourcePackage, String targetPackage, int flags) {
+ sendCommand(Constants.COMMAND_BIND_SERVICE, sourcePackage, targetPackage, flags, null,
+ true);
+ }
+
+ public static void unbindService(String sourcePackage, String targetPackage, int flags) {
+ sendCommand(Constants.COMMAND_UNBIND_SERVICE, sourcePackage, targetPackage, flags, null,
+ true);
+ }
+
+ public static void acquireProvider(String sourcePackage, String targetPackage, Uri uri) {
+ Bundle bundle = new Bundle();
+ bundle.putParcelable(Constants.EXTRA_URI, uri);
+ sendCommand(Constants.COMMAND_ACQUIRE_CONTENT_PROVIDER, sourcePackage, targetPackage, 0,
+ bundle, true);
+ }
+
+ public static void releaseProvider(String sourcePackage, String targetPackage, Uri uri) {
+ Bundle bundle = new Bundle();
+ bundle.putParcelable(Constants.EXTRA_URI, uri);
+ sendCommand(Constants.COMMAND_RELEASE_CONTENT_PROVIDER, sourcePackage, targetPackage, 0,
+ bundle, true);
+ }
+
+ public static void sendBroadcast(String sourcePackage, String targetPackage) {
+ sendCommand(Constants.COMMAND_SEND_BROADCAST, sourcePackage, targetPackage, 0, null, true);
+ }
+
+ public static void startActivity(String sourcePackage, String targetPackage) {
+ sendCommand(Constants.COMMAND_START_ACTIVITY, sourcePackage, targetPackage, 0, null, true);
+ }
+
+ public static void stopActivity(String sourcePackage, String targetPackage) {
+ sendCommand(Constants.COMMAND_STOP_ACTIVITY, sourcePackage, targetPackage, 0, null, true);
+ }
}
diff --git a/tests/ActivityManagerPerfTests/utils/Android.bp b/tests/ActivityManagerPerfTests/utils/Android.bp
index 300b7ea..766c3ac 100644
--- a/tests/ActivityManagerPerfTests/utils/Android.bp
+++ b/tests/ActivityManagerPerfTests/utils/Android.bp
@@ -18,6 +18,7 @@
srcs: [
"src/**/*.java",
"src/com/android/frameworks/perftests/am/util/ITimeReceiverCallback.aidl",
+ "src/com/android/frameworks/perftests/am/util/ICommandReceiver.aidl",
],
static_libs: [
"androidx.test.rules",
diff --git a/tests/ActivityManagerPerfTests/utils/src/com/android/frameworks/perftests/am/util/Constants.java b/tests/ActivityManagerPerfTests/utils/src/com/android/frameworks/perftests/am/util/Constants.java
index 9b076c5..8e58665 100644
--- a/tests/ActivityManagerPerfTests/utils/src/com/android/frameworks/perftests/am/util/Constants.java
+++ b/tests/ActivityManagerPerfTests/utils/src/com/android/frameworks/perftests/am/util/Constants.java
@@ -30,4 +30,33 @@
public static final String EXTRA_RECEIVER_CALLBACK = "receiver_callback_binder";
public static final String EXTRA_LOOPER_IDLE_CALLBACK = "looper_idle_callback_binder";
+ public static final String EXTRA_SOURCE_PACKAGE = "source_package";
+ public static final String EXTRA_URI = "uri";
+ public static final String EXTRA_REQ_FINISH_ACTIVITY = "req_finish_activity";
+ public static final String EXTRA_SEQ = "seq";
+ public static final String EXTRA_ARG1 = "arg1";
+ public static final String EXTRA_ARG2 = "arg2";
+
+ public static final int RESULT_NO_ERROR = 0;
+ public static final int RESULT_ERROR = 1;
+ public static final String STUB_INIT_SERVICE_NAME = "com.android.stubs.am.InitService";
+
+ public static final int COMMAND_BIND_SERVICE = 1;
+ public static final int COMMAND_UNBIND_SERVICE = 2;
+ public static final int COMMAND_ACQUIRE_CONTENT_PROVIDER = 3;
+ public static final int COMMAND_RELEASE_CONTENT_PROVIDER = 4;
+ public static final int COMMAND_SEND_BROADCAST = 5;
+ public static final int COMMAND_START_ACTIVITY = 6;
+ public static final int COMMAND_STOP_ACTIVITY = 7;
+
+ public static final int MSG_DEFAULT = 0;
+ public static final int MSG_UNBIND_DONE = 1;
+
+ public static final int REPLY_PACKAGE_START_RESULT = 0;
+ public static final int REPLY_COMMAND_RESULT = 1;
+
+ public static final String STUB_ACTION_ACTIVITY =
+ "com.android.stubs.am.ACTION_START_TEST_ACTIVITY";
+ public static final String STUB_ACTION_BROADCAST =
+ "com.android.stubs.am.ACTION_BROADCAST_TEST";
}
diff --git a/tests/ActivityManagerPerfTests/utils/src/com/android/frameworks/perftests/am/util/ICommandReceiver.aidl b/tests/ActivityManagerPerfTests/utils/src/com/android/frameworks/perftests/am/util/ICommandReceiver.aidl
new file mode 100644
index 0000000..59ea761
--- /dev/null
+++ b/tests/ActivityManagerPerfTests/utils/src/com/android/frameworks/perftests/am/util/ICommandReceiver.aidl
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2019 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 com.android.frameworks.perftests.am.util;
+
+import android.os.Bundle;
+
+interface ICommandReceiver {
+ oneway void sendCommand(int command, int seq, String sourcePackage, String targetPackage,
+ int flags, in Bundle bundle);
+}
diff --git a/tests/ManagedProfileLifecycleStressTest/src/com/android/test/stress/ManagedProfileLifecycleStressTest.java b/tests/ManagedProfileLifecycleStressTest/src/com/android/test/stress/ManagedProfileLifecycleStressTest.java
index e323592..026677e 100644
--- a/tests/ManagedProfileLifecycleStressTest/src/com/android/test/stress/ManagedProfileLifecycleStressTest.java
+++ b/tests/ManagedProfileLifecycleStressTest/src/com/android/test/stress/ManagedProfileLifecycleStressTest.java
@@ -53,6 +53,8 @@
*/
@Test
public void testCreateStartDelete() throws Exception {
+ // Disable package verifier for ADB installs.
+ getDevice().executeShellCommand("settings put global verifier_verify_adb_installs 0");
int iteration = 0;
final long deadline = System.nanoTime() + TimeUnit.MINUTES.toNanos(TIME_LIMIT_MINUTES);
while (System.nanoTime() < deadline) {
diff --git a/tests/net/java/android/net/TcpKeepalivePacketDataTest.java b/tests/net/java/android/net/TcpKeepalivePacketDataTest.java
index 5cb0d7e..e632aaf 100644
--- a/tests/net/java/android/net/TcpKeepalivePacketDataTest.java
+++ b/tests/net/java/android/net/TcpKeepalivePacketDataTest.java
@@ -22,8 +22,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import android.net.SocketKeepalive.InvalidPacketException;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/tools/localedata/extract_icu_data.py b/tools/localedata/extract_icu_data.py
index 6b4c346..ca1847a 100755
--- a/tools/localedata/extract_icu_data.py
+++ b/tools/localedata/extract_icu_data.py
@@ -176,6 +176,9 @@
dump_representative_locales(representative_locales)
return likely_script_dict
+def escape_script_variable_name(script):
+ """Escape characters, e.g. '~', in a C++ variable name"""
+ return script.replace("~", "_")
def read_parent_data(icu_data_dir):
"""Read locale parent data from ICU data files."""
@@ -221,7 +224,7 @@
for script in sorted_scripts:
parent_dict = script_organized_dict[script]
print ('const std::unordered_map<uint32_t, uint32_t> %s_PARENTS({'
- % script.upper())
+ % escape_script_variable_name(script.upper()))
for locale in sorted(parent_dict.keys()):
parent = parent_dict[locale]
print ' {0x%08Xu, 0x%08Xu}, // %s -> %s' % (
@@ -239,7 +242,7 @@
for script in sorted_scripts:
print " {{'%c', '%c', '%c', '%c'}, &%s_PARENTS}," % (
script[0], script[1], script[2], script[3],
- script.upper())
+ escape_script_variable_name(script.upper()))
print '};'
diff --git a/wifi/Android.bp b/wifi/Android.bp
new file mode 100644
index 0000000..08115ec
--- /dev/null
+++ b/wifi/Android.bp
@@ -0,0 +1,87 @@
+// Copyright (C) 2019 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.
+
+
+filegroup {
+ name: "framework-wifi-updatable-sources",
+ srcs: [
+ "java/**/*.java",
+ "java/**/*.aidl",
+ ],
+ exclude_srcs: [
+ ":framework-wifi-non-updatable-sources"
+ ],
+ path: "java",
+}
+
+filegroup {
+ name: "framework-wifi-non-updatable-sources",
+ srcs: [
+ // TODO(b/146011398) package android.net.wifi is now split amongst 2 jars: framework.jar and
+ // framework-wifi.jar. This is not a good idea, should move WifiNetworkScoreCache
+ // to a separate package.
+ "java/android/net/wifi/WifiNetworkScoreCache.java",
+ "java/android/net/wifi/WifiCondManager.java",
+ "java/android/net/wifi/wificond/*.java",
+ ":libwificond_ipc_aidl",
+ ],
+}
+
+filegroup {
+ name: "framework-wifi-annotations",
+ srcs: ["java/android/net/wifi/WifiAnnotations.java"],
+}
+
+java_library {
+ name: "framework-wifi",
+ sdk_version: "core_platform", // TODO(b/140299412) should be core_current
+ libs: [
+ "framework-minus-apex", // TODO(b/140299412) should be framework-system-stubs
+ ],
+ srcs: [
+ ":framework-wifi-updatable-sources",
+ ],
+ installable: true,
+ optimize: {
+ enabled: false
+ }
+}
+
+droidstubs {
+ name: "framework-wifi-stubs-srcs",
+ srcs: [
+ ":framework-annotations",
+ ":framework-wifi-updatable-sources",
+ ],
+ aidl: {
+ include_dirs: ["frameworks/base/core/java"],
+ },
+ defaults: [ "framework-module-stubs-defaults-systemapi" ],
+ sdk_version: "core_current",
+ libs: ["android_system_stubs_current"],
+}
+
+java_library {
+ name: "framework-wifi-stubs",
+ srcs: [":framework-wifi-stubs-srcs"],
+ aidl: {
+ export_include_dirs: [
+ "java",
+ ],
+ },
+ sdk_version: "core_current",
+ libs: ["android_system_stubs_current"],
+ installable: false,
+}
+
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index b52880e..1678d5a 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -108,7 +108,9 @@
String getCountryCode();
- boolean isDualBandSupported();
+ boolean is5GHzBandSupported();
+
+ boolean is6GHzBandSupported();
boolean needs5GHzToAnyApBandConversion();
@@ -186,7 +188,7 @@
byte[] retrieveSoftApBackupData();
- void restoreSoftApBackupData(in byte[] data);
+ SoftApConfiguration restoreSoftApBackupData(in byte[] data);
void restoreSupplicantBackupData(in byte[] supplicantData, in byte[] ipConfigData);
diff --git a/wifi/java/android/net/wifi/WifiAnnotations.java b/wifi/java/android/net/wifi/WifiAnnotations.java
new file mode 100644
index 0000000..4a7dee1
--- /dev/null
+++ b/wifi/java/android/net/wifi/WifiAnnotations.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2019 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 android.net.wifi;
+
+import android.annotation.IntDef;
+import android.annotation.StringDef;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Wifi annotations meant to be statically linked into client modules, since they cannot be
+ * exposed as @SystemApi.
+ *
+ * e.g. {@link IntDef}, {@link StringDef}
+ *
+ * @hide
+ */
+public final class WifiAnnotations {
+ private WifiAnnotations() {}
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = {"SCAN_TYPE_"}, value = {
+ WifiScanner.SCAN_TYPE_LOW_LATENCY,
+ WifiScanner.SCAN_TYPE_LOW_POWER,
+ WifiScanner.SCAN_TYPE_HIGH_ACCURACY})
+ public @interface ScanType {}
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = {"WIFI_BAND_"}, value = {
+ WifiScanner.WIFI_BAND_UNSPECIFIED,
+ WifiScanner.WIFI_BAND_24_GHZ,
+ WifiScanner.WIFI_BAND_5_GHZ,
+ WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY,
+ WifiScanner.WIFI_BAND_6_GHZ})
+ public @interface WifiBandBasic {}
+}
diff --git a/wifi/java/android/net/wifi/WifiCondManager.java b/wifi/java/android/net/wifi/WifiCondManager.java
new file mode 100644
index 0000000..c05ba34
--- /dev/null
+++ b/wifi/java/android/net/wifi/WifiCondManager.java
@@ -0,0 +1,983 @@
+/*
+ * Copyright (C) 2017 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 android.net.wifi;
+
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.app.AlarmManager;
+import android.content.Context;
+import android.net.wifi.wificond.ChannelSettings;
+import android.net.wifi.wificond.HiddenNetwork;
+import android.net.wifi.wificond.NativeScanResult;
+import android.net.wifi.wificond.NativeWifiClient;
+import android.net.wifi.wificond.PnoSettings;
+import android.net.wifi.wificond.SingleScanSettings;
+import android.os.Binder;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.SystemClock;
+import android.util.Log;
+
+import com.android.internal.annotations.VisibleForTesting;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * This class provides methods for WifiNative to send control commands to wificond.
+ * NOTE: This class should only be used from WifiNative.
+ * @hide
+ */
+public class WifiCondManager implements IBinder.DeathRecipient {
+ private static final String TAG = "WifiCondManager";
+ private boolean mVerboseLoggingEnabled = false;
+
+ /**
+ * The {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()}
+ * timeout, in milliseconds, after which
+ * {@link SendMgmtFrameCallback#onFailure(int)} will be called with reason
+ * {@link #SEND_MGMT_FRAME_ERROR_TIMEOUT}.
+ */
+ public static final int SEND_MGMT_FRAME_TIMEOUT_MS = 1000;
+
+ private static final String TIMEOUT_ALARM_TAG = TAG + " Send Management Frame Timeout";
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = {"SCAN_TYPE_"},
+ value = {SCAN_TYPE_SINGLE_SCAN,
+ SCAN_TYPE_PNO_SCAN})
+ public @interface ScanResultType {}
+
+ /** Get scan results for a single scan */
+ public static final int SCAN_TYPE_SINGLE_SCAN = 0;
+
+ /** Get scan results for Pno Scan */
+ public static final int SCAN_TYPE_PNO_SCAN = 1;
+
+ private AlarmManager mAlarmManager;
+ private Handler mEventHandler;
+
+ // Cached wificond binder handlers.
+ private IWificond mWificond;
+ private HashMap<String, IClientInterface> mClientInterfaces = new HashMap<>();
+ private HashMap<String, IApInterface> mApInterfaces = new HashMap<>();
+ private HashMap<String, IWifiScannerImpl> mWificondScanners = new HashMap<>();
+ private HashMap<String, IScanEvent> mScanEventHandlers = new HashMap<>();
+ private HashMap<String, IPnoScanEvent> mPnoScanEventHandlers = new HashMap<>();
+ private HashMap<String, IApInterfaceEventCallback> mApInterfaceListeners = new HashMap<>();
+ private Runnable mDeathEventHandler;
+ /**
+ * Ensures that no more than one sendMgmtFrame operation runs concurrently.
+ */
+ private AtomicBoolean mSendMgmtFrameInProgress = new AtomicBoolean(false);
+
+ /**
+ * Interface for a callback to be used to handle scan results.
+ */
+ public interface ScanEventCallback {
+ /**
+ * Called when scan results are available.
+ */
+ void onScanResultReady();
+
+ /**
+ * Called when a scan has failed.
+ */
+ void onScanFailed();
+ }
+
+ /**
+ * Interface for a callback to provide information about PNO scan request.
+ */
+ public interface PnoScanRequestCallback {
+ /**
+ * Called when the PNO scan is requested.
+ */
+ void onPnoRequestSucceeded();
+
+ /**
+ * Called when a PNO scan request fails.
+ */
+ void onPnoRequestFailed();
+ }
+
+ private class ScanEventHandler extends IScanEvent.Stub {
+ private ScanEventCallback mCallback;
+
+ ScanEventHandler(@NonNull ScanEventCallback callback) {
+ mCallback = callback;
+ }
+
+ @Override
+ public void OnScanResultReady() {
+ Log.d(TAG, "Scan result ready event");
+ mCallback.onScanResultReady();
+ }
+
+ @Override
+ public void OnScanFailed() {
+ Log.d(TAG, "Scan failed event");
+ mCallback.onScanFailed();
+ }
+ }
+
+ /**
+ * Result of a signal poll.
+ */
+ public static class SignalPollResult {
+ // RSSI value in dBM.
+ public int currentRssi;
+ //Transmission bit rate in Mbps.
+ public int txBitrate;
+ // Association frequency in MHz.
+ public int associationFrequency;
+ //Last received packet bit rate in Mbps.
+ public int rxBitrate;
+ }
+
+ /**
+ * WiFi interface transimission counters.
+ */
+ public static class TxPacketCounters {
+ // Number of successfully transmitted packets.
+ public int txSucceeded;
+ // Number of tramsmission failures.
+ public int txFailed;
+ }
+
+ /**
+ * Callbacks for SoftAp interface.
+ */
+ public interface SoftApListener {
+ /**
+ * Invoked when there is some fatal failure in the lower layers.
+ */
+ void onFailure();
+
+ /**
+ * Invoked when the associated stations changes.
+ */
+ void onConnectedClientsChanged(NativeWifiClient client, boolean isConnected);
+
+ /**
+ * Invoked when the channel switch event happens.
+ */
+ void onSoftApChannelSwitched(int frequency, int bandwidth);
+ }
+
+ /**
+ * Callback to notify the results of a
+ * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()} call.
+ * Note: no callbacks will be triggered if the iface dies while sending a frame.
+ */
+ public interface SendMgmtFrameCallback {
+ /**
+ * Called when the management frame was successfully sent and ACKed by the recipient.
+ * @param elapsedTimeMs The elapsed time between when the management frame was sent and when
+ * the ACK was processed, in milliseconds, as measured by wificond.
+ * This includes the time that the send frame spent queuing before it
+ * was sent, any firmware retries, and the time the received ACK spent
+ * queuing before it was processed.
+ */
+ void onAck(int elapsedTimeMs);
+
+ /**
+ * Called when the send failed.
+ * @param reason The error code for the failure.
+ */
+ void onFailure(@SendMgmtFrameError int reason);
+ }
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = {"SEND_MGMT_FRAME_ERROR_"},
+ value = {SEND_MGMT_FRAME_ERROR_UNKNOWN,
+ SEND_MGMT_FRAME_ERROR_MCS_UNSUPPORTED,
+ SEND_MGMT_FRAME_ERROR_NO_ACK,
+ SEND_MGMT_FRAME_ERROR_TIMEOUT,
+ SEND_MGMT_FRAME_ERROR_ALREADY_STARTED})
+ public @interface SendMgmtFrameError {}
+
+ // Send management frame error codes
+
+ /**
+ * Unknown error occurred during call to
+ * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()}.
+ */
+ public static final int SEND_MGMT_FRAME_ERROR_UNKNOWN = 1;
+
+ /**
+ * Specifying the MCS rate in
+ * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()} is not
+ * supported by this device.
+ */
+ public static final int SEND_MGMT_FRAME_ERROR_MCS_UNSUPPORTED = 2;
+
+ /**
+ * Driver reported that no ACK was received for the frame transmitted using
+ * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()}.
+ */
+ public static final int SEND_MGMT_FRAME_ERROR_NO_ACK = 3;
+
+ /**
+ * Error code for when the driver fails to report on the status of the frame sent by
+ * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()}
+ * after {@link #SEND_MGMT_FRAME_TIMEOUT_MS} milliseconds.
+ */
+ public static final int SEND_MGMT_FRAME_ERROR_TIMEOUT = 4;
+
+ /**
+ * An existing call to
+ * {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int) sendMgmtFrame()}
+ * is in progress. Another frame cannot be sent until the first call completes.
+ */
+ public static final int SEND_MGMT_FRAME_ERROR_ALREADY_STARTED = 5;
+
+
+ public WifiCondManager(Context context) {
+ mAlarmManager = (AlarmManager) context.getSystemService(AlarmManager.class);
+ mEventHandler = new Handler(context.getMainLooper());
+ }
+
+ @VisibleForTesting
+ public WifiCondManager(Context context, IWificond wificond) {
+ this(context);
+ mWificond = wificond;
+ }
+
+ private class PnoScanEventHandler extends IPnoScanEvent.Stub {
+ private ScanEventCallback mCallback;
+
+ PnoScanEventHandler(@NonNull ScanEventCallback callback) {
+ mCallback = callback;
+ }
+
+ @Override
+ public void OnPnoNetworkFound() {
+ Log.d(TAG, "Pno scan result event");
+ mCallback.onScanResultReady();
+ }
+
+ @Override
+ public void OnPnoScanFailed() {
+ Log.d(TAG, "Pno Scan failed event");
+ mCallback.onScanFailed();
+ }
+ }
+
+ /**
+ * Listener for AP Interface events.
+ */
+ private class ApInterfaceEventCallback extends IApInterfaceEventCallback.Stub {
+ private SoftApListener mSoftApListener;
+
+ ApInterfaceEventCallback(SoftApListener listener) {
+ mSoftApListener = listener;
+ }
+
+ @Override
+ public void onConnectedClientsChanged(NativeWifiClient client, boolean isConnected) {
+ if (mVerboseLoggingEnabled) {
+ Log.d(TAG, "onConnectedClientsChanged called with "
+ + client.macAddress + " isConnected: " + isConnected);
+ }
+
+ mSoftApListener.onConnectedClientsChanged(client, isConnected);
+ }
+
+ @Override
+ public void onSoftApChannelSwitched(int frequency, int bandwidth) {
+ mSoftApListener.onSoftApChannelSwitched(frequency, bandwidth);
+ }
+ }
+
+ /**
+ * Callback triggered by wificond.
+ */
+ private class SendMgmtFrameEvent extends ISendMgmtFrameEvent.Stub {
+ private SendMgmtFrameCallback mCallback;
+ private AlarmManager.OnAlarmListener mTimeoutCallback;
+ /**
+ * ensures that mCallback is only called once
+ */
+ private boolean mWasCalled;
+
+ private void runIfFirstCall(Runnable r) {
+ if (mWasCalled) return;
+ mWasCalled = true;
+
+ mSendMgmtFrameInProgress.set(false);
+ r.run();
+ }
+
+ SendMgmtFrameEvent(@NonNull SendMgmtFrameCallback callback) {
+ mCallback = callback;
+ // called in main thread
+ mTimeoutCallback = () -> runIfFirstCall(() -> {
+ if (mVerboseLoggingEnabled) {
+ Log.e(TAG, "Timed out waiting for ACK");
+ }
+ mCallback.onFailure(SEND_MGMT_FRAME_ERROR_TIMEOUT);
+ });
+ mWasCalled = false;
+
+ mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
+ SystemClock.elapsedRealtime() + SEND_MGMT_FRAME_TIMEOUT_MS,
+ TIMEOUT_ALARM_TAG, mTimeoutCallback, mEventHandler);
+ }
+
+ // called in binder thread
+ @Override
+ public void OnAck(int elapsedTimeMs) {
+ // post to main thread
+ mEventHandler.post(() -> runIfFirstCall(() -> {
+ mAlarmManager.cancel(mTimeoutCallback);
+ mCallback.onAck(elapsedTimeMs);
+ }));
+ }
+
+ // called in binder thread
+ @Override
+ public void OnFailure(int reason) {
+ // post to main thread
+ mEventHandler.post(() -> runIfFirstCall(() -> {
+ mAlarmManager.cancel(mTimeoutCallback);
+ mCallback.onFailure(reason);
+ }));
+ }
+ }
+
+ /**
+ * Called by the binder subsystem upon remote object death.
+ * Invoke all the register death handlers and clear state.
+ */
+ @Override
+ public void binderDied() {
+ mEventHandler.post(() -> {
+ Log.e(TAG, "Wificond died!");
+ clearState();
+ // Invalidate the global wificond handle on death. Will be refreshed
+ // on the next setup call.
+ mWificond = null;
+ if (mDeathEventHandler != null) {
+ mDeathEventHandler.run();
+ }
+ });
+ }
+
+ /** Enable or disable verbose logging of WificondControl.
+ * @param enable True to enable verbose logging. False to disable verbose logging.
+ */
+ public void enableVerboseLogging(boolean enable) {
+ mVerboseLoggingEnabled = enable;
+ }
+
+ /**
+ * Initializes wificond & registers a death notification for wificond.
+ * This method clears any existing state in wificond daemon.
+ *
+ * @return Returns true on success.
+ */
+ public boolean initialize(@NonNull Runnable deathEventHandler) {
+ if (mDeathEventHandler != null) {
+ Log.e(TAG, "Death handler already present");
+ }
+ mDeathEventHandler = deathEventHandler;
+ tearDownInterfaces();
+ return true;
+ }
+
+ /**
+ * Helper method to retrieve the global wificond handle and register for
+ * death notifications.
+ */
+ private boolean retrieveWificondAndRegisterForDeath() {
+ if (mWificond != null) {
+ if (mVerboseLoggingEnabled) {
+ Log.d(TAG, "Wificond handle already retrieved");
+ }
+ // We already have a wificond handle.
+ return true;
+ }
+ IBinder binder = ServiceManager.getService(Context.WIFI_COND_SERVICE);
+ mWificond = IWificond.Stub.asInterface(binder);
+ if (mWificond == null) {
+ Log.e(TAG, "Failed to get reference to wificond");
+ return false;
+ }
+ try {
+ mWificond.asBinder().linkToDeath(this, 0);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to register death notification for wificond");
+ // The remote has already died.
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Setup interface for client mode via wificond.
+ * @return true on success.
+ */
+ public boolean setupInterfaceForClientMode(@NonNull String ifaceName,
+ @NonNull ScanEventCallback scanCallback, @NonNull ScanEventCallback pnoScanCallback) {
+ Log.d(TAG, "Setting up interface for client mode");
+ if (!retrieveWificondAndRegisterForDeath()) {
+ return false;
+ }
+
+ IClientInterface clientInterface = null;
+ try {
+ clientInterface = mWificond.createClientInterface(ifaceName);
+ } catch (RemoteException e1) {
+ Log.e(TAG, "Failed to get IClientInterface due to remote exception");
+ return false;
+ }
+
+ if (clientInterface == null) {
+ Log.e(TAG, "Could not get IClientInterface instance from wificond");
+ return false;
+ }
+ Binder.allowBlocking(clientInterface.asBinder());
+
+ // Refresh Handlers
+ mClientInterfaces.put(ifaceName, clientInterface);
+ try {
+ IWifiScannerImpl wificondScanner = clientInterface.getWifiScannerImpl();
+ if (wificondScanner == null) {
+ Log.e(TAG, "Failed to get WificondScannerImpl");
+ return false;
+ }
+ mWificondScanners.put(ifaceName, wificondScanner);
+ Binder.allowBlocking(wificondScanner.asBinder());
+ ScanEventHandler scanEventHandler = new ScanEventHandler(scanCallback);
+ mScanEventHandlers.put(ifaceName, scanEventHandler);
+ wificondScanner.subscribeScanEvents(scanEventHandler);
+ PnoScanEventHandler pnoScanEventHandler = new PnoScanEventHandler(pnoScanCallback);
+ mPnoScanEventHandlers.put(ifaceName, pnoScanEventHandler);
+ wificondScanner.subscribePnoScanEvents(pnoScanEventHandler);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to refresh wificond scanner due to remote exception");
+ }
+
+ return true;
+ }
+
+ /**
+ * Teardown a specific STA interface configured in wificond.
+ *
+ * @return Returns true on success.
+ */
+ public boolean tearDownClientInterface(@NonNull String ifaceName) {
+ if (getClientInterface(ifaceName) == null) {
+ Log.e(TAG, "No valid wificond client interface handler");
+ return false;
+ }
+ try {
+ IWifiScannerImpl scannerImpl = mWificondScanners.get(ifaceName);
+ if (scannerImpl != null) {
+ scannerImpl.unsubscribeScanEvents();
+ scannerImpl.unsubscribePnoScanEvents();
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to unsubscribe wificond scanner due to remote exception");
+ return false;
+ }
+
+ if (mWificond == null) {
+ Log.e(TAG, "Reference to wifiCond is null");
+ return false;
+ }
+
+ boolean success;
+ try {
+ success = mWificond.tearDownClientInterface(ifaceName);
+ } catch (RemoteException e1) {
+ Log.e(TAG, "Failed to teardown client interface due to remote exception");
+ return false;
+ }
+ if (!success) {
+ Log.e(TAG, "Failed to teardown client interface");
+ return false;
+ }
+
+ mClientInterfaces.remove(ifaceName);
+ mWificondScanners.remove(ifaceName);
+ mScanEventHandlers.remove(ifaceName);
+ mPnoScanEventHandlers.remove(ifaceName);
+ return true;
+ }
+
+ /**
+ * Setup interface for softAp mode via wificond.
+ * @return true on success.
+ */
+ public boolean setupInterfaceForSoftApMode(@NonNull String ifaceName) {
+ Log.d(TAG, "Setting up interface for soft ap mode");
+ if (!retrieveWificondAndRegisterForDeath()) {
+ return false;
+ }
+
+ IApInterface apInterface = null;
+ try {
+ apInterface = mWificond.createApInterface(ifaceName);
+ } catch (RemoteException e1) {
+ Log.e(TAG, "Failed to get IApInterface due to remote exception");
+ return false;
+ }
+
+ if (apInterface == null) {
+ Log.e(TAG, "Could not get IApInterface instance from wificond");
+ return false;
+ }
+ Binder.allowBlocking(apInterface.asBinder());
+
+ // Refresh Handlers
+ mApInterfaces.put(ifaceName, apInterface);
+ return true;
+ }
+
+ /**
+ * Teardown a specific AP interface configured in wificond.
+ *
+ * @return Returns true on success.
+ */
+ public boolean tearDownSoftApInterface(@NonNull String ifaceName) {
+ if (getApInterface(ifaceName) == null) {
+ Log.e(TAG, "No valid wificond ap interface handler");
+ return false;
+ }
+
+ if (mWificond == null) {
+ Log.e(TAG, "Reference to wifiCond is null");
+ return false;
+ }
+
+ boolean success;
+ try {
+ success = mWificond.tearDownApInterface(ifaceName);
+ } catch (RemoteException e1) {
+ Log.e(TAG, "Failed to teardown AP interface due to remote exception");
+ return false;
+ }
+ if (!success) {
+ Log.e(TAG, "Failed to teardown AP interface");
+ return false;
+ }
+ mApInterfaces.remove(ifaceName);
+ mApInterfaceListeners.remove(ifaceName);
+ return true;
+ }
+
+ /**
+ * Teardown all interfaces configured in wificond.
+ * @return Returns true on success.
+ */
+ public boolean tearDownInterfaces() {
+ Log.d(TAG, "tearing down interfaces in wificond");
+ // Explicitly refresh the wificodn handler because |tearDownInterfaces()|
+ // could be used to cleanup before we setup any interfaces.
+ if (!retrieveWificondAndRegisterForDeath()) {
+ return false;
+ }
+
+ try {
+ for (Map.Entry<String, IWifiScannerImpl> entry : mWificondScanners.entrySet()) {
+ entry.getValue().unsubscribeScanEvents();
+ entry.getValue().unsubscribePnoScanEvents();
+ }
+ mWificond.tearDownInterfaces();
+ clearState();
+ return true;
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to tear down interfaces due to remote exception");
+ }
+
+ return false;
+ }
+
+ /** Helper function to look up the interface handle using name */
+ private IClientInterface getClientInterface(@NonNull String ifaceName) {
+ return mClientInterfaces.get(ifaceName);
+ }
+
+ /**
+ * Request signal polling to wificond.
+ * @param ifaceName Name of the interface.
+ * Returns an SignalPollResult object.
+ * Returns null on failure.
+ */
+ public SignalPollResult signalPoll(@NonNull String ifaceName) {
+ IClientInterface iface = getClientInterface(ifaceName);
+ if (iface == null) {
+ Log.e(TAG, "No valid wificond client interface handler");
+ return null;
+ }
+
+ int[] resultArray;
+ try {
+ resultArray = iface.signalPoll();
+ if (resultArray == null || resultArray.length != 4) {
+ Log.e(TAG, "Invalid signal poll result from wificond");
+ return null;
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to do signal polling due to remote exception");
+ return null;
+ }
+ SignalPollResult pollResult = new SignalPollResult();
+ pollResult.currentRssi = resultArray[0];
+ pollResult.txBitrate = resultArray[1];
+ pollResult.associationFrequency = resultArray[2];
+ pollResult.rxBitrate = resultArray[3];
+ return pollResult;
+ }
+
+ /**
+ * Fetch TX packet counters on current connection from wificond.
+ * @param ifaceName Name of the interface.
+ * Returns an TxPacketCounters object.
+ * Returns null on failure.
+ */
+ public TxPacketCounters getTxPacketCounters(@NonNull String ifaceName) {
+ IClientInterface iface = getClientInterface(ifaceName);
+ if (iface == null) {
+ Log.e(TAG, "No valid wificond client interface handler");
+ return null;
+ }
+
+ int[] resultArray;
+ try {
+ resultArray = iface.getPacketCounters();
+ if (resultArray == null || resultArray.length != 2) {
+ Log.e(TAG, "Invalid signal poll result from wificond");
+ return null;
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to do signal polling due to remote exception");
+ return null;
+ }
+ TxPacketCounters counters = new TxPacketCounters();
+ counters.txSucceeded = resultArray[0];
+ counters.txFailed = resultArray[1];
+ return counters;
+ }
+
+ /** Helper function to look up the scanner impl handle using name */
+ private IWifiScannerImpl getScannerImpl(@NonNull String ifaceName) {
+ return mWificondScanners.get(ifaceName);
+ }
+
+ /**
+ * Fetch the latest scan result from kernel via wificond.
+ * @param ifaceName Name of the interface.
+ * @return Returns an array of native scan results or an empty array on failure.
+ */
+ @NonNull public List<NativeScanResult> getScanResults(@NonNull String ifaceName,
+ @ScanResultType int scanType) {
+ IWifiScannerImpl scannerImpl = getScannerImpl(ifaceName);
+ if (scannerImpl == null) {
+ Log.e(TAG, "No valid wificond scanner interface handler");
+ return new ArrayList<>();
+ }
+ List<NativeScanResult> results = null;
+ try {
+ if (scanType == SCAN_TYPE_SINGLE_SCAN) {
+ results = Arrays.asList(scannerImpl.getScanResults());
+ } else {
+ results = Arrays.asList(scannerImpl.getPnoScanResults());
+ }
+ } catch (RemoteException e1) {
+ Log.e(TAG, "Failed to create ScanDetail ArrayList");
+ }
+ if (results == null) {
+ results = new ArrayList<>();
+ }
+ if (mVerboseLoggingEnabled) {
+ Log.d(TAG, "get " + results.size() + " scan results from wificond");
+ }
+
+ return results;
+ }
+
+ /**
+ * Return scan type for the parcelable {@link SingleScanSettings}
+ */
+ private static int getScanType(@WifiAnnotations.ScanType int scanType) {
+ switch (scanType) {
+ case WifiScanner.SCAN_TYPE_LOW_LATENCY:
+ return IWifiScannerImpl.SCAN_TYPE_LOW_SPAN;
+ case WifiScanner.SCAN_TYPE_LOW_POWER:
+ return IWifiScannerImpl.SCAN_TYPE_LOW_POWER;
+ case WifiScanner.SCAN_TYPE_HIGH_ACCURACY:
+ return IWifiScannerImpl.SCAN_TYPE_HIGH_ACCURACY;
+ default:
+ throw new IllegalArgumentException("Invalid scan type " + scanType);
+ }
+ }
+
+ /**
+ * Start a scan using wificond for the given parameters.
+ * @param ifaceName Name of the interface.
+ * @param scanType Type of scan to perform.
+ * @param freqs list of frequencies to scan for, if null scan all supported channels.
+ * @param hiddenNetworkSSIDs List of hidden networks to be scanned for.
+ * @return Returns true on success.
+ */
+ public boolean scan(@NonNull String ifaceName, @WifiAnnotations.ScanType int scanType,
+ Set<Integer> freqs, List<byte[]> hiddenNetworkSSIDs) {
+ IWifiScannerImpl scannerImpl = getScannerImpl(ifaceName);
+ if (scannerImpl == null) {
+ Log.e(TAG, "No valid wificond scanner interface handler");
+ return false;
+ }
+ SingleScanSettings settings = new SingleScanSettings();
+ try {
+ settings.scanType = getScanType(scanType);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Invalid scan type ", e);
+ return false;
+ }
+ settings.channelSettings = new ArrayList<>();
+ settings.hiddenNetworks = new ArrayList<>();
+
+ if (freqs != null) {
+ for (Integer freq : freqs) {
+ ChannelSettings channel = new ChannelSettings();
+ channel.frequency = freq;
+ settings.channelSettings.add(channel);
+ }
+ }
+ if (hiddenNetworkSSIDs != null) {
+ for (byte[] ssid : hiddenNetworkSSIDs) {
+ HiddenNetwork network = new HiddenNetwork();
+ network.ssid = ssid;
+
+ // settings.hiddenNetworks is expected to be very small, so this shouldn't cause
+ // any performance issues.
+ if (!settings.hiddenNetworks.contains(network)) {
+ settings.hiddenNetworks.add(network);
+ }
+ }
+ }
+
+ try {
+ return scannerImpl.scan(settings);
+ } catch (RemoteException e1) {
+ Log.e(TAG, "Failed to request scan due to remote exception");
+ }
+ return false;
+ }
+
+ /**
+ * Start PNO scan.
+ * @param ifaceName Name of the interface.
+ * @param pnoSettings Pno scan configuration.
+ * @return true on success.
+ */
+ public boolean startPnoScan(@NonNull String ifaceName, PnoSettings pnoSettings,
+ PnoScanRequestCallback callback) {
+ IWifiScannerImpl scannerImpl = getScannerImpl(ifaceName);
+ if (scannerImpl == null) {
+ Log.e(TAG, "No valid wificond scanner interface handler");
+ return false;
+ }
+
+ try {
+ boolean success = scannerImpl.startPnoScan(pnoSettings);
+ if (success) {
+ callback.onPnoRequestSucceeded();
+ } else {
+ callback.onPnoRequestFailed();
+ }
+ return success;
+ } catch (RemoteException e1) {
+ Log.e(TAG, "Failed to start pno scan due to remote exception");
+ }
+ return false;
+ }
+
+ /**
+ * Stop PNO scan.
+ * @param ifaceName Name of the interface.
+ * @return true on success.
+ */
+ public boolean stopPnoScan(@NonNull String ifaceName) {
+ IWifiScannerImpl scannerImpl = getScannerImpl(ifaceName);
+ if (scannerImpl == null) {
+ Log.e(TAG, "No valid wificond scanner interface handler");
+ return false;
+ }
+ try {
+ return scannerImpl.stopPnoScan();
+ } catch (RemoteException e1) {
+ Log.e(TAG, "Failed to stop pno scan due to remote exception");
+ }
+ return false;
+ }
+
+ /**
+ * Abort ongoing single scan.
+ * @param ifaceName Name of the interface.
+ */
+ public void abortScan(@NonNull String ifaceName) {
+ IWifiScannerImpl scannerImpl = getScannerImpl(ifaceName);
+ if (scannerImpl == null) {
+ Log.e(TAG, "No valid wificond scanner interface handler");
+ return;
+ }
+ try {
+ scannerImpl.abortScan();
+ } catch (RemoteException e1) {
+ Log.e(TAG, "Failed to request abortScan due to remote exception");
+ }
+ }
+
+ /**
+ * Query the list of valid frequencies for the provided band.
+ * The result depends on the on the country code that has been set.
+ *
+ * @param band as specified by one of the WifiScanner.WIFI_BAND_* constants.
+ * The following bands are supported {@link @WifiScanner.WifiBandBasic}:
+ * WifiScanner.WIFI_BAND_24_GHZ
+ * WifiScanner.WIFI_BAND_5_GHZ
+ * WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY
+ * WifiScanner.WIFI_BAND_6_GHZ
+ * @return frequencies vector of valid frequencies (MHz), or null for error.
+ * @throws IllegalArgumentException if band is not recognized.
+ */
+ public int [] getChannelsForBand(@WifiAnnotations.WifiBandBasic int band) {
+ if (mWificond == null) {
+ Log.e(TAG, "No valid wificond scanner interface handler");
+ return null;
+ }
+ try {
+ switch (band) {
+ case WifiScanner.WIFI_BAND_24_GHZ:
+ return mWificond.getAvailable2gChannels();
+ case WifiScanner.WIFI_BAND_5_GHZ:
+ return mWificond.getAvailable5gNonDFSChannels();
+ case WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY:
+ return mWificond.getAvailableDFSChannels();
+ case WifiScanner.WIFI_BAND_6_GHZ:
+ return mWificond.getAvailable6gChannels();
+ default:
+ throw new IllegalArgumentException("unsupported band " + band);
+ }
+ } catch (RemoteException e1) {
+ Log.e(TAG, "Failed to request getChannelsForBand due to remote exception");
+ }
+ return null;
+ }
+
+ /** Helper function to look up the interface handle using name */
+ private IApInterface getApInterface(@NonNull String ifaceName) {
+ return mApInterfaces.get(ifaceName);
+ }
+
+ /**
+ * Register the provided listener for SoftAp events.
+ *
+ * @param ifaceName Name of the interface.
+ * @param listener Callback for AP events.
+ * @return true on success, false otherwise.
+ */
+ public boolean registerApListener(@NonNull String ifaceName, SoftApListener listener) {
+ IApInterface iface = getApInterface(ifaceName);
+ if (iface == null) {
+ Log.e(TAG, "No valid ap interface handler");
+ return false;
+ }
+ try {
+ IApInterfaceEventCallback callback = new ApInterfaceEventCallback(listener);
+ mApInterfaceListeners.put(ifaceName, callback);
+ boolean success = iface.registerCallback(callback);
+ if (!success) {
+ Log.e(TAG, "Failed to register ap callback.");
+ return false;
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Exception in registering AP callback: " + e);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * See {@link #sendMgmtFrame(String, byte[], SendMgmtFrameCallback, int)}
+ */
+ public void sendMgmtFrame(@NonNull String ifaceName, @NonNull byte[] frame,
+ @NonNull SendMgmtFrameCallback callback, int mcs) {
+
+ if (callback == null) {
+ Log.e(TAG, "callback cannot be null!");
+ return;
+ }
+
+ if (frame == null) {
+ Log.e(TAG, "frame cannot be null!");
+ callback.onFailure(SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ return;
+ }
+
+ // TODO (b/112029045) validate mcs
+ IClientInterface clientInterface = getClientInterface(ifaceName);
+ if (clientInterface == null) {
+ Log.e(TAG, "No valid wificond client interface handler");
+ callback.onFailure(SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ return;
+ }
+
+ if (!mSendMgmtFrameInProgress.compareAndSet(false, true)) {
+ Log.e(TAG, "An existing management frame transmission is in progress!");
+ callback.onFailure(SEND_MGMT_FRAME_ERROR_ALREADY_STARTED);
+ return;
+ }
+
+ SendMgmtFrameEvent sendMgmtFrameEvent = new SendMgmtFrameEvent(callback);
+ try {
+ clientInterface.SendMgmtFrame(frame, sendMgmtFrameEvent, mcs);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Exception while starting link probe: " + e);
+ // Call sendMgmtFrameEvent.OnFailure() instead of callback.onFailure() so that
+ // sendMgmtFrameEvent can clean up internal state, such as cancelling the timer.
+ sendMgmtFrameEvent.OnFailure(SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ }
+ }
+
+ /**
+ * Clear all internal handles.
+ */
+ private void clearState() {
+ // Refresh handlers
+ mClientInterfaces.clear();
+ mWificondScanners.clear();
+ mPnoScanEventHandlers.clear();
+ mScanEventHandlers.clear();
+ mApInterfaces.clear();
+ mApInterfaceListeners.clear();
+ mSendMgmtFrameInProgress.set(false);
+ }
+}
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 50d62a0..9691bda 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -51,16 +51,16 @@
import android.os.WorkSource;
import android.os.connectivity.WifiActivityEnergyInfo;
import android.text.TextUtils;
+import android.util.CloseGuard;
import android.util.Log;
import android.util.Pair;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
-import dalvik.system.CloseGuard;
-
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.net.InetAddress;
import java.util.ArrayList;
@@ -2156,8 +2156,6 @@
/** @hide */
public static final long WIFI_FEATURE_INFRA = 0x0001L; // Basic infrastructure mode
/** @hide */
- public static final long WIFI_FEATURE_INFRA_5G = 0x0002L; // Support for 5 GHz Band
- /** @hide */
public static final long WIFI_FEATURE_PASSPOINT = 0x0004L; // Support for GAS/ANQP
/** @hide */
public static final long WIFI_FEATURE_P2P = 0x0008L; // Wifi-Direct
@@ -2227,8 +2225,6 @@
public static final long WIFI_FEATURE_MBO = 0x800000000L; // MBO Support
/** @hide */
public static final long WIFI_FEATURE_OCE = 0x1000000000L; // OCE Support
- /** @hide */
- public static final long WIFI_FEATURE_INFRA_6G = 0x2000000000L; // Support 6 GHz band
private long getSupportedFeatures() {
try {
@@ -2242,22 +2238,7 @@
return (getSupportedFeatures() & feature) == feature;
}
- /**
- * @return true if this adapter supports 5 GHz band
- */
- public boolean is5GHzBandSupported() {
- return isFeatureSupported(WIFI_FEATURE_INFRA_5G);
- }
-
- /**
- * @return true if the device supports operating in the 6 GHz band and Wi-Fi is enabled,
- * false otherwise.
- */
- public boolean is6GHzBandSupported() {
- return isFeatureSupported(WIFI_FEATURE_INFRA_6G);
- }
-
- /**
+ /**
* @return true if this adapter supports Passpoint
* @hide
*/
@@ -2379,6 +2360,30 @@
}
/**
+ * Check if the chipset supports 5GHz band.
+ * @return {@code true} if supported, {@code false} otherwise.
+ */
+ public boolean is5GHzBandSupported() {
+ try {
+ return mService.is5GHzBandSupported();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Check if the chipset supports 6GHz band.
+ * @return {@code true} if supported, {@code false} otherwise.
+ */
+ public boolean is6GHzBandSupported() {
+ try {
+ return mService.is6GHzBandSupported();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Interface for Wi-Fi activity energy info listener. Should be implemented by applications and
* set when calling {@link WifiManager#getWifiActivityEnergyInfoAsync}.
*
@@ -2592,21 +2597,6 @@
}
/**
- * Check if the chipset supports dual frequency band (2.4 GHz and 5 GHz).
- * No permissions are required to call this method.
- * @return {@code true} if supported, {@code false} otherwise.
- * @hide
- */
- @SystemApi
- public boolean isDualBandSupported() {
- try {
- return mService.isDualBandSupported();
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
* Check if the device is dual mode capable i.e. supports concurrent STA + Soft AP.
*
* If the device is dual mode capable, it may require conversion of the user's Soft AP band
@@ -3574,7 +3564,7 @@
*/
public class LocalOnlyHotspotReservation implements AutoCloseable {
- private final CloseGuard mCloseGuard = CloseGuard.get();
+ private final CloseGuard mCloseGuard = new CloseGuard();
private final WifiConfiguration mConfig;
private boolean mClosed = false;
@@ -3601,6 +3591,8 @@
}
} catch (Exception e) {
Log.e(TAG, "Failed to stop Local Only Hotspot.");
+ } finally {
+ Reference.reachabilityFence(this);
}
}
@@ -3725,7 +3717,7 @@
* @hide
*/
public class LocalOnlyHotspotSubscription implements AutoCloseable {
- private final CloseGuard mCloseGuard = CloseGuard.get();
+ private final CloseGuard mCloseGuard = new CloseGuard();
/** @hide */
@VisibleForTesting
@@ -3740,6 +3732,8 @@
mCloseGuard.close();
} catch (Exception e) {
Log.e(TAG, "Failed to unregister LocalOnlyHotspotObserver.");
+ } finally {
+ Reference.reachabilityFence(this);
}
}
@@ -4686,10 +4680,13 @@
}
/**
- * Retrieve the soft ap config data to be backed to save current config data.
+ * Returns a byte stream representing the data that needs to be backed up to save the
+ * current soft ap config data.
+ *
+ * This soft ap config can be restored by calling {@link #restoreSoftApBackupData(byte[])}
* @hide
*/
- @Nullable
+ @NonNull
@SystemApi
@RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
public byte[] retrieveSoftApBackupData() {
@@ -4701,15 +4698,17 @@
}
/**
- * Restore soft ap config from the backed up data.
+ * Returns soft ap config from the backed up data.
+ * @param data byte stream in the same format produced by {@link #retrieveSoftApBackupData()}
+ *
* @hide
*/
@Nullable
@SystemApi
@RequiresPermission(android.Manifest.permission.NETWORK_SETTINGS)
- public void restoreSoftApBackupData(@NonNull byte[] data) {
+ public SoftApConfiguration restoreSoftApBackupData(@NonNull byte[] data) {
try {
- mService.restoreSoftApBackupData(data);
+ return mService.restoreSoftApBackupData(data);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
diff --git a/wifi/java/android/net/wifi/WifiScanner.java b/wifi/java/android/net/wifi/WifiScanner.java
index 760497b..8fedda4 100644
--- a/wifi/java/android/net/wifi/WifiScanner.java
+++ b/wifi/java/android/net/wifi/WifiScanner.java
@@ -89,16 +89,6 @@
/** 6 GHz band */
public static final int WIFI_BAND_6_GHZ = 1 << WIFI_BAND_INDEX_6_GHZ;
- /** @hide */
- @Retention(RetentionPolicy.SOURCE)
- @IntDef(prefix = {"WIFI_BAND_"}, value = {
- WIFI_BAND_UNSPECIFIED,
- WIFI_BAND_24_GHZ,
- WIFI_BAND_5_GHZ,
- WIFI_BAND_5_GHZ_DFS_ONLY,
- WIFI_BAND_6_GHZ})
- public @interface WifiBandBasic {}
-
/**
* Combination of bands
* Note that those are only the common band combinations,
@@ -249,14 +239,6 @@
*/
public static final int REPORT_EVENT_NO_BATCH = (1 << 2);
- /** @hide */
- @Retention(RetentionPolicy.SOURCE)
- @IntDef(prefix = {"SCAN_TYPE_"}, value = {
- SCAN_TYPE_LOW_LATENCY,
- SCAN_TYPE_LOW_POWER,
- SCAN_TYPE_HIGH_ACCURACY})
- public @interface ScanType {}
-
/**
* Optimize the scan for lower latency.
* @see ScanSettings#type
@@ -354,7 +336,7 @@
* {@link #SCAN_TYPE_HIGH_ACCURACY}.
* Default value: {@link #SCAN_TYPE_LOW_LATENCY}.
*/
- @ScanType
+ @WifiAnnotations.ScanType
@RequiresPermission(android.Manifest.permission.NETWORK_STACK)
public int type = SCAN_TYPE_LOW_LATENCY;
/**
diff --git a/wifi/java/android/net/wifi/aware/DiscoverySession.java b/wifi/java/android/net/wifi/aware/DiscoverySession.java
index d97f6fb..4d92ae1 100644
--- a/wifi/java/android/net/wifi/aware/DiscoverySession.java
+++ b/wifi/java/android/net/wifi/aware/DiscoverySession.java
@@ -20,12 +20,12 @@
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.net.NetworkSpecifier;
+import android.util.CloseGuard;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
-import dalvik.system.CloseGuard;
-
+import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
/**
@@ -58,7 +58,7 @@
/** @hide */
protected boolean mTerminated = false;
- private final CloseGuard mCloseGuard = CloseGuard.get();
+ private final CloseGuard mCloseGuard = new CloseGuard();
/**
* Return the maximum permitted retry count when sending messages using
@@ -108,6 +108,7 @@
mTerminated = true;
mMgr.clear();
mCloseGuard.close();
+ Reference.reachabilityFence(this);
}
/**
diff --git a/wifi/java/android/net/wifi/aware/WifiAwareSession.java b/wifi/java/android/net/wifi/aware/WifiAwareSession.java
index 3c97813..fe0872c 100644
--- a/wifi/java/android/net/wifi/aware/WifiAwareSession.java
+++ b/wifi/java/android/net/wifi/aware/WifiAwareSession.java
@@ -23,12 +23,12 @@
import android.os.Binder;
import android.os.Handler;
import android.os.Looper;
+import android.util.CloseGuard;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
-import dalvik.system.CloseGuard;
-
+import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
/**
@@ -45,7 +45,7 @@
private final int mClientId;
private boolean mTerminated = true;
- private final CloseGuard mCloseGuard = CloseGuard.get();
+ private final CloseGuard mCloseGuard = new CloseGuard();
/** @hide */
public WifiAwareSession(WifiAwareManager manager, Binder binder, int clientId) {
@@ -80,6 +80,7 @@
mTerminated = true;
mMgr.clear();
mCloseGuard.close();
+ Reference.reachabilityFence(this);
}
/** @hide */
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
index 1c20679..6120e4e 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
@@ -44,15 +44,15 @@
import android.os.Messenger;
import android.os.RemoteException;
import android.text.TextUtils;
+import android.util.CloseGuard;
import android.util.Log;
import com.android.internal.util.AsyncChannel;
import com.android.internal.util.Protocol;
-import dalvik.system.CloseGuard;
-
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.ref.Reference;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -869,7 +869,7 @@
private final Object mListenerMapLock = new Object();
private int mListenerKey = 0;
- private final CloseGuard mCloseGuard = CloseGuard.get();
+ private final CloseGuard mCloseGuard = new CloseGuard();
/**
* Close the current P2P connection and indicate to the P2P service that connections
@@ -888,6 +888,7 @@
mAsyncChannel.disconnect();
mCloseGuard.close();
+ Reference.reachabilityFence(this);
}
/** @hide */
diff --git a/wifi/java/android/net/wifi/wificond/ChannelSettings.java b/wifi/java/android/net/wifi/wificond/ChannelSettings.java
new file mode 100644
index 0000000..c2d65b5
--- /dev/null
+++ b/wifi/java/android/net/wifi/wificond/ChannelSettings.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2016 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 android.net.wifi.wificond;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+import java.util.Objects;
+
+/**
+ * ChannelSettings for wificond
+ *
+ * @hide
+ */
+public class ChannelSettings implements Parcelable {
+ private static final String TAG = "ChannelSettings";
+
+ public int frequency;
+
+ /** public constructor */
+ public ChannelSettings() { }
+
+ /** override comparator */
+ @Override
+ public boolean equals(Object rhs) {
+ if (this == rhs) return true;
+ if (!(rhs instanceof ChannelSettings)) {
+ return false;
+ }
+ ChannelSettings channel = (ChannelSettings) rhs;
+ if (channel == null) {
+ return false;
+ }
+ return frequency == channel.frequency;
+ }
+
+ /** override hash code */
+ @Override
+ public int hashCode() {
+ return Objects.hash(frequency);
+ }
+
+ /** implement Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * implement Parcelable interface
+ * |flags| is ignored.
+ **/
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(frequency);
+ }
+
+ /** implement Parcelable interface */
+ public static final Parcelable.Creator<ChannelSettings> CREATOR =
+ new Parcelable.Creator<ChannelSettings>() {
+ /**
+ * Caller is responsible for providing a valid parcel.
+ */
+ @Override
+ public ChannelSettings createFromParcel(Parcel in) {
+ ChannelSettings result = new ChannelSettings();
+ result.frequency = in.readInt();
+ if (in.dataAvail() != 0) {
+ Log.e(TAG, "Found trailing data after parcel parsing.");
+ }
+
+ return result;
+ }
+
+ @Override
+ public ChannelSettings[] newArray(int size) {
+ return new ChannelSettings[size];
+ }
+ };
+}
diff --git a/wifi/java/android/net/wifi/wificond/HiddenNetwork.java b/wifi/java/android/net/wifi/wificond/HiddenNetwork.java
new file mode 100644
index 0000000..38dacea
--- /dev/null
+++ b/wifi/java/android/net/wifi/wificond/HiddenNetwork.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2016 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 android.net.wifi.wificond;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Arrays;
+
+/**
+ * HiddenNetwork for wificond
+ *
+ * @hide
+ */
+public class HiddenNetwork implements Parcelable {
+ private static final String TAG = "HiddenNetwork";
+
+ public byte[] ssid;
+
+ /** public constructor */
+ public HiddenNetwork() { }
+
+ /** override comparator */
+ @Override
+ public boolean equals(Object rhs) {
+ if (this == rhs) return true;
+ if (!(rhs instanceof HiddenNetwork)) {
+ return false;
+ }
+ HiddenNetwork network = (HiddenNetwork) rhs;
+ return Arrays.equals(ssid, network.ssid);
+ }
+
+ /** override hash code */
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(ssid);
+ }
+
+ /** implement Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * implement Parcelable interface
+ * |flags| is ignored.
+ */
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeByteArray(ssid);
+ }
+
+ /** implement Parcelable interface */
+ public static final Parcelable.Creator<HiddenNetwork> CREATOR =
+ new Parcelable.Creator<HiddenNetwork>() {
+ /**
+ * Caller is responsible for providing a valid parcel.
+ */
+ @Override
+ public HiddenNetwork createFromParcel(Parcel in) {
+ HiddenNetwork result = new HiddenNetwork();
+ result.ssid = in.createByteArray();
+ return result;
+ }
+
+ @Override
+ public HiddenNetwork[] newArray(int size) {
+ return new HiddenNetwork[size];
+ }
+ };
+}
diff --git a/wifi/java/android/net/wifi/wificond/NativeScanResult.java b/wifi/java/android/net/wifi/wificond/NativeScanResult.java
new file mode 100644
index 0000000..ff8e935
--- /dev/null
+++ b/wifi/java/android/net/wifi/wificond/NativeScanResult.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2016 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 android.net.wifi.wificond;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.List;
+
+/**
+ * ScanResult from wificond
+ *
+ * @hide
+ */
+public class NativeScanResult implements Parcelable {
+ private static final int CAPABILITY_SIZE = 16;
+
+ public byte[] ssid;
+ public byte[] bssid;
+ public byte[] infoElement;
+ public int frequency;
+ public int signalMbm;
+ public long tsf;
+ public BitSet capability;
+ public boolean associated;
+ public List<RadioChainInfo> radioChainInfos;
+
+ /** public constructor */
+ public NativeScanResult() { }
+
+ /** copy constructor */
+ public NativeScanResult(NativeScanResult source) {
+ ssid = source.ssid.clone();
+ bssid = source.bssid.clone();
+ infoElement = source.infoElement.clone();
+ frequency = source.frequency;
+ signalMbm = source.signalMbm;
+ tsf = source.tsf;
+ capability = (BitSet) source.capability.clone();
+ associated = source.associated;
+ }
+
+ /** implement Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** implement Parcelable interface */
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeByteArray(ssid);
+ out.writeByteArray(bssid);
+ out.writeByteArray(infoElement);
+ out.writeInt(frequency);
+ out.writeInt(signalMbm);
+ out.writeLong(tsf);
+ int capabilityInt = 0;
+ for (int i = 0; i < CAPABILITY_SIZE; i++) {
+ if (capability.get(i)) {
+ capabilityInt |= 1 << i;
+ }
+ }
+ out.writeInt(capabilityInt);
+ out.writeInt(associated ? 1 : 0);
+ out.writeTypedList(radioChainInfos);
+ }
+
+ /** implement Parcelable interface */
+ public static final Parcelable.Creator<NativeScanResult> CREATOR =
+ new Parcelable.Creator<NativeScanResult>() {
+ @Override
+ public NativeScanResult createFromParcel(Parcel in) {
+ NativeScanResult result = new NativeScanResult();
+ result.ssid = in.createByteArray();
+ result.bssid = in.createByteArray();
+ result.infoElement = in.createByteArray();
+ result.frequency = in.readInt();
+ result.signalMbm = in.readInt();
+ result.tsf = in.readLong();
+ int capabilityInt = in.readInt();
+ result.capability = new BitSet(CAPABILITY_SIZE);
+ for (int i = 0; i < CAPABILITY_SIZE; i++) {
+ if ((capabilityInt & (1 << i)) != 0) {
+ result.capability.set(i);
+ }
+ }
+ result.associated = (in.readInt() != 0);
+ result.radioChainInfos = new ArrayList<>();
+ in.readTypedList(result.radioChainInfos, RadioChainInfo.CREATOR);
+ return result;
+ }
+
+ @Override
+ public NativeScanResult[] newArray(int size) {
+ return new NativeScanResult[size];
+ }
+ };
+}
diff --git a/wifi/java/android/net/wifi/wificond/NativeWifiClient.java b/wifi/java/android/net/wifi/wificond/NativeWifiClient.java
new file mode 100644
index 0000000..4994ebd
--- /dev/null
+++ b/wifi/java/android/net/wifi/wificond/NativeWifiClient.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2019 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 android.net.wifi.wificond;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Arrays;
+
+/**
+ * NativeWifiClient for wificond
+ *
+ * @hide
+ */
+public class NativeWifiClient implements Parcelable {
+ public byte[] macAddress;
+
+ /** public constructor */
+ public NativeWifiClient() { }
+
+ /** override comparator */
+ @Override
+ public boolean equals(Object rhs) {
+ if (this == rhs) return true;
+ if (!(rhs instanceof NativeWifiClient)) {
+ return false;
+ }
+ NativeWifiClient other = (NativeWifiClient) rhs;
+ return Arrays.equals(macAddress, other.macAddress);
+ }
+
+ /** override hash code */
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(macAddress);
+ }
+
+ /** implement Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * implement Parcelable interface
+ * |flag| is ignored.
+ */
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeByteArray(macAddress);
+ }
+
+ /** implement Parcelable interface */
+ public static final Parcelable.Creator<NativeWifiClient> CREATOR =
+ new Parcelable.Creator<NativeWifiClient>() {
+ @Override
+ public NativeWifiClient createFromParcel(Parcel in) {
+ NativeWifiClient result = new NativeWifiClient();
+ result.macAddress = in.createByteArray();
+ return result;
+ }
+
+ @Override
+ public NativeWifiClient[] newArray(int size) {
+ return new NativeWifiClient[size];
+ }
+ };
+}
diff --git a/wifi/java/android/net/wifi/wificond/PnoNetwork.java b/wifi/java/android/net/wifi/wificond/PnoNetwork.java
new file mode 100644
index 0000000..f923fd3
--- /dev/null
+++ b/wifi/java/android/net/wifi/wificond/PnoNetwork.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2016 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 android.net.wifi.wificond;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Arrays;
+import java.util.Objects;
+
+/**
+ * PnoNetwork for wificond
+ *
+ * @hide
+ */
+public class PnoNetwork implements Parcelable {
+
+ public boolean isHidden;
+ public byte[] ssid;
+ public int[] frequencies;
+
+ /** public constructor */
+ public PnoNetwork() { }
+
+ /** override comparator */
+ @Override
+ public boolean equals(Object rhs) {
+ if (this == rhs) return true;
+ if (!(rhs instanceof PnoNetwork)) {
+ return false;
+ }
+ PnoNetwork network = (PnoNetwork) rhs;
+ return Arrays.equals(ssid, network.ssid)
+ && Arrays.equals(frequencies, network.frequencies)
+ && isHidden == network.isHidden;
+ }
+
+ /** override hash code */
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ isHidden,
+ Arrays.hashCode(ssid),
+ Arrays.hashCode(frequencies));
+ }
+
+ /** implement Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * implement Parcelable interface
+ * |flag| is ignored.
+ */
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(isHidden ? 1 : 0);
+ out.writeByteArray(ssid);
+ out.writeIntArray(frequencies);
+ }
+
+ /** implement Parcelable interface */
+ public static final Parcelable.Creator<PnoNetwork> CREATOR =
+ new Parcelable.Creator<PnoNetwork>() {
+ @Override
+ public PnoNetwork createFromParcel(Parcel in) {
+ PnoNetwork result = new PnoNetwork();
+ result.isHidden = in.readInt() != 0 ? true : false;
+ result.ssid = in.createByteArray();
+ result.frequencies = in.createIntArray();
+ return result;
+ }
+
+ @Override
+ public PnoNetwork[] newArray(int size) {
+ return new PnoNetwork[size];
+ }
+ };
+}
diff --git a/wifi/java/android/net/wifi/wificond/PnoSettings.java b/wifi/java/android/net/wifi/wificond/PnoSettings.java
new file mode 100644
index 0000000..96cf24f
--- /dev/null
+++ b/wifi/java/android/net/wifi/wificond/PnoSettings.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2016 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 android.net.wifi.wificond;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.ArrayList;
+import java.util.Objects;
+
+/**
+ * PnoSettings for wificond
+ *
+ * @hide
+ */
+public class PnoSettings implements Parcelable {
+ public int intervalMs;
+ public int min2gRssi;
+ public int min5gRssi;
+ public int min6gRssi;
+ public ArrayList<PnoNetwork> pnoNetworks;
+
+ /** public constructor */
+ public PnoSettings() { }
+
+ /** override comparator */
+ @Override
+ public boolean equals(Object rhs) {
+ if (this == rhs) return true;
+ if (!(rhs instanceof PnoSettings)) {
+ return false;
+ }
+ PnoSettings settings = (PnoSettings) rhs;
+ if (settings == null) {
+ return false;
+ }
+ return intervalMs == settings.intervalMs
+ && min2gRssi == settings.min2gRssi
+ && min5gRssi == settings.min5gRssi
+ && min6gRssi == settings.min6gRssi
+ && pnoNetworks.equals(settings.pnoNetworks);
+ }
+
+ /** override hash code */
+ @Override
+ public int hashCode() {
+ return Objects.hash(intervalMs, min2gRssi, min5gRssi, min6gRssi, pnoNetworks);
+ }
+
+ /** implement Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * implement Parcelable interface
+ * |flag| is ignored.
+ **/
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(intervalMs);
+ out.writeInt(min2gRssi);
+ out.writeInt(min5gRssi);
+ out.writeInt(min6gRssi);
+ out.writeTypedList(pnoNetworks);
+ }
+
+ /** implement Parcelable interface */
+ public static final Parcelable.Creator<PnoSettings> CREATOR =
+ new Parcelable.Creator<PnoSettings>() {
+ @Override
+ public PnoSettings createFromParcel(Parcel in) {
+ PnoSettings result = new PnoSettings();
+ result.intervalMs = in.readInt();
+ result.min2gRssi = in.readInt();
+ result.min5gRssi = in.readInt();
+ result.min6gRssi = in.readInt();
+
+ result.pnoNetworks = new ArrayList<PnoNetwork>();
+ in.readTypedList(result.pnoNetworks, PnoNetwork.CREATOR);
+
+ return result;
+ }
+
+ @Override
+ public PnoSettings[] newArray(int size) {
+ return new PnoSettings[size];
+ }
+ };
+}
diff --git a/wifi/java/android/net/wifi/wificond/RadioChainInfo.java b/wifi/java/android/net/wifi/wificond/RadioChainInfo.java
new file mode 100644
index 0000000..2b03450
--- /dev/null
+++ b/wifi/java/android/net/wifi/wificond/RadioChainInfo.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2016 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 android.net.wifi.wificond;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Objects;
+
+/**
+ * RadioChainInfo for wificond
+ *
+ * @hide
+ */
+public class RadioChainInfo implements Parcelable {
+ private static final String TAG = "RadioChainInfo";
+
+ public int chainId;
+ public int level;
+
+
+ /** public constructor */
+ public RadioChainInfo() { }
+
+ public RadioChainInfo(int chainId, int level) {
+ this.chainId = chainId;
+ this.level = level;
+ }
+
+ /** override comparator */
+ @Override
+ public boolean equals(Object rhs) {
+ if (this == rhs) return true;
+ if (!(rhs instanceof RadioChainInfo)) {
+ return false;
+ }
+ RadioChainInfo chainInfo = (RadioChainInfo) rhs;
+ if (chainInfo == null) {
+ return false;
+ }
+ return chainId == chainInfo.chainId && level == chainInfo.level;
+ }
+
+ /** override hash code */
+ @Override
+ public int hashCode() {
+ return Objects.hash(chainId, level);
+ }
+
+
+ /** implement Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * implement Parcelable interface
+ * |flags| is ignored.
+ */
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(chainId);
+ out.writeInt(level);
+ }
+
+ /** implement Parcelable interface */
+ public static final Parcelable.Creator<RadioChainInfo> CREATOR =
+ new Parcelable.Creator<RadioChainInfo>() {
+ /**
+ * Caller is responsible for providing a valid parcel.
+ */
+ @Override
+ public RadioChainInfo createFromParcel(Parcel in) {
+ RadioChainInfo result = new RadioChainInfo();
+ result.chainId = in.readInt();
+ result.level = in.readInt();
+ return result;
+ }
+
+ @Override
+ public RadioChainInfo[] newArray(int size) {
+ return new RadioChainInfo[size];
+ }
+ };
+}
diff --git a/wifi/java/android/net/wifi/wificond/SingleScanSettings.java b/wifi/java/android/net/wifi/wificond/SingleScanSettings.java
new file mode 100644
index 0000000..8065c01
--- /dev/null
+++ b/wifi/java/android/net/wifi/wificond/SingleScanSettings.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2016 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 android.net.wifi.wificond;
+
+import android.net.wifi.IWifiScannerImpl;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.Objects;
+
+/**
+ * SingleScanSettings for wificond
+ *
+ * @hide
+ */
+public class SingleScanSettings implements Parcelable {
+ private static final String TAG = "SingleScanSettings";
+
+ public int scanType;
+ public ArrayList<ChannelSettings> channelSettings;
+ public ArrayList<HiddenNetwork> hiddenNetworks;
+
+ /** public constructor */
+ public SingleScanSettings() { }
+
+ /** override comparator */
+ @Override
+ public boolean equals(Object rhs) {
+ if (this == rhs) return true;
+ if (!(rhs instanceof SingleScanSettings)) {
+ return false;
+ }
+ SingleScanSettings settings = (SingleScanSettings) rhs;
+ if (settings == null) {
+ return false;
+ }
+ return scanType == settings.scanType
+ && channelSettings.equals(settings.channelSettings)
+ && hiddenNetworks.equals(settings.hiddenNetworks);
+ }
+
+ /** override hash code */
+ @Override
+ public int hashCode() {
+ return Objects.hash(scanType, channelSettings, hiddenNetworks);
+ }
+
+
+ /** implement Parcelable interface */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ private static boolean isValidScanType(int scanType) {
+ return scanType == IWifiScannerImpl.SCAN_TYPE_LOW_SPAN
+ || scanType == IWifiScannerImpl.SCAN_TYPE_LOW_POWER
+ || scanType == IWifiScannerImpl.SCAN_TYPE_HIGH_ACCURACY;
+ }
+
+ /**
+ * implement Parcelable interface
+ * |flags| is ignored.
+ */
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ if (!isValidScanType(scanType)) {
+ Log.wtf(TAG, "Invalid scan type " + scanType);
+ }
+ out.writeInt(scanType);
+ out.writeTypedList(channelSettings);
+ out.writeTypedList(hiddenNetworks);
+ }
+
+ /** implement Parcelable interface */
+ public static final Parcelable.Creator<SingleScanSettings> CREATOR =
+ new Parcelable.Creator<SingleScanSettings>() {
+ /**
+ * Caller is responsible for providing a valid parcel.
+ */
+ @Override
+ public SingleScanSettings createFromParcel(Parcel in) {
+ SingleScanSettings result = new SingleScanSettings();
+ result.scanType = in.readInt();
+ if (!isValidScanType(result.scanType)) {
+ Log.wtf(TAG, "Invalid scan type " + result.scanType);
+ }
+ result.channelSettings = new ArrayList<ChannelSettings>();
+ in.readTypedList(result.channelSettings, ChannelSettings.CREATOR);
+ result.hiddenNetworks = new ArrayList<HiddenNetwork>();
+ in.readTypedList(result.hiddenNetworks, HiddenNetwork.CREATOR);
+ if (in.dataAvail() != 0) {
+ Log.e(TAG, "Found trailing data after parcel parsing.");
+ }
+ return result;
+ }
+
+ @Override
+ public SingleScanSettings[] newArray(int size) {
+ return new SingleScanSettings[size];
+ }
+ };
+}
diff --git a/wifi/java/com/android/server/wifi/BaseWifiService.java b/wifi/java/com/android/server/wifi/BaseWifiService.java
index 524a53c..d58083c 100644
--- a/wifi/java/com/android/server/wifi/BaseWifiService.java
+++ b/wifi/java/com/android/server/wifi/BaseWifiService.java
@@ -28,7 +28,6 @@
import android.net.wifi.IOnWifiActivityEnergyInfoListener;
import android.net.wifi.IOnWifiUsabilityStatsListener;
import android.net.wifi.IScanResultsCallback;
-import android.net.wifi.IScanResultsListener;
import android.net.wifi.ISoftApCallback;
import android.net.wifi.ISuggestionConnectionStatusListener;
import android.net.wifi.ITrafficStateCallback;
@@ -227,12 +226,23 @@
throw new UnsupportedOperationException();
}
- @Override
+ /** @deprecated use {@link #is5GHzBandSupported} instead */
+ @Deprecated
public boolean isDualBandSupported() {
throw new UnsupportedOperationException();
}
@Override
+ public boolean is5GHzBandSupported() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean is6GHzBandSupported() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public boolean needs5GHzToAnyApBandConversion() {
throw new UnsupportedOperationException();
}
@@ -414,7 +424,7 @@
}
@Override
- public void restoreSoftApBackupData(byte[] data) {
+ public SoftApConfiguration restoreSoftApBackupData(byte[] data) {
throw new UnsupportedOperationException();
}
diff --git a/wifi/tests/Android.mk b/wifi/tests/Android.mk
index 3453d6e..d2c385b4 100644
--- a/wifi/tests/Android.mk
+++ b/wifi/tests/Android.mk
@@ -59,6 +59,8 @@
LOCAL_PACKAGE_NAME := FrameworksWifiApiTests
LOCAL_PRIVATE_PLATFORM_APIS := true
-LOCAL_COMPATIBILITY_SUITE := device-tests
+LOCAL_COMPATIBILITY_SUITE := \
+ device-tests \
+ mts \
include $(BUILD_PACKAGE)
diff --git a/wifi/tests/AndroidTest.xml b/wifi/tests/AndroidTest.xml
index cae19e4..987fee7 100644
--- a/wifi/tests/AndroidTest.xml
+++ b/wifi/tests/AndroidTest.xml
@@ -14,7 +14,7 @@
limitations under the License.
-->
<configuration description="Runs Frameworks Wifi API Tests.">
- <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="test-file-name" value="FrameworksWifiApiTests.apk" />
</target_preparer>
diff --git a/wifi/tests/runtests.sh b/wifi/tests/runtests.sh
index 7a0dfb0..4024371 100755
--- a/wifi/tests/runtests.sh
+++ b/wifi/tests/runtests.sh
@@ -16,7 +16,6 @@
set -x # print commands
-adb root
adb wait-for-device
TARGET_ARCH=$($ANDROID_BUILD_TOP/build/soong/soong_ui.bash --dumpvar-mode TARGET_ARCH)
diff --git a/wifi/tests/src/android/net/wifi/WifiCondManagerTest.java b/wifi/tests/src/android/net/wifi/WifiCondManagerTest.java
new file mode 100644
index 0000000..48a9afa
--- /dev/null
+++ b/wifi/tests/src/android/net/wifi/WifiCondManagerTest.java
@@ -0,0 +1,1281 @@
+/*
+ * Copyright (C) 2017 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 android.net.wifi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyLong;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
+import android.app.AlarmManager;
+import android.app.test.TestAlarmManager;
+import android.content.Context;
+import android.net.wifi.util.HexEncoding;
+import android.net.wifi.wificond.ChannelSettings;
+import android.net.wifi.wificond.HiddenNetwork;
+import android.net.wifi.wificond.NativeWifiClient;
+import android.net.wifi.wificond.PnoNetwork;
+import android.net.wifi.wificond.PnoSettings;
+import android.net.wifi.wificond.SingleScanSettings;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.test.TestLooper;
+
+import androidx.test.filters.SmallTest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.AdditionalMatchers;
+import org.mockito.ArgumentCaptor;
+import org.mockito.ArgumentMatcher;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Unit tests for {@link android.net.wifi.WifiCondManager}.
+ */
+@SmallTest
+public class WifiCondManagerTest {
+ @Mock
+ private IWificond mWificond;
+ @Mock
+ private IBinder mWifiCondBinder;
+ @Mock
+ private IClientInterface mClientInterface;
+ @Mock
+ private IWifiScannerImpl mWifiScannerImpl;
+ @Mock
+ private IApInterface mApInterface;
+ @Mock
+ private WifiCondManager.SoftApListener mSoftApListener;
+ @Mock
+ private WifiCondManager.SendMgmtFrameCallback mSendMgmtFrameCallback;
+ @Mock
+ private WifiCondManager.ScanEventCallback mNormalScanCallback;
+ @Mock
+ private WifiCondManager.ScanEventCallback mPnoScanCallback;
+ @Mock
+ private WifiCondManager.PnoScanRequestCallback mPnoScanRequestCallback;
+ @Mock
+ private Context mContext;
+ private TestLooper mLooper;
+ private TestAlarmManager mTestAlarmManager;
+ private AlarmManager mAlarmManager;
+ private WifiCondManager mWificondControl;
+ private static final String TEST_INTERFACE_NAME = "test_wlan_if";
+ private static final String TEST_INTERFACE_NAME1 = "test_wlan_if1";
+ private static final String TEST_INVALID_INTERFACE_NAME = "asdf";
+ private static final byte[] TEST_SSID =
+ new byte[]{'G', 'o', 'o', 'g', 'l', 'e', 'G', 'u', 'e', 's', 't'};
+ private static final byte[] TEST_PSK =
+ new byte[]{'T', 'e', 's', 't'};
+
+ private static final Set<Integer> SCAN_FREQ_SET =
+ new HashSet<Integer>() {{
+ add(2410);
+ add(2450);
+ add(5050);
+ add(5200);
+ }};
+ private static final String TEST_QUOTED_SSID_1 = "\"testSsid1\"";
+ private static final String TEST_QUOTED_SSID_2 = "\"testSsid2\"";
+ private static final int[] TEST_FREQUENCIES_1 = {};
+ private static final int[] TEST_FREQUENCIES_2 = {2500, 5124};
+
+ private static final List<byte[]> SCAN_HIDDEN_NETWORK_SSID_LIST =
+ new ArrayList<byte[]>() {{
+ add(LocalNativeUtil.byteArrayFromArrayList(
+ LocalNativeUtil.decodeSsid(TEST_QUOTED_SSID_1)));
+ add(LocalNativeUtil.byteArrayFromArrayList(
+ LocalNativeUtil.decodeSsid(TEST_QUOTED_SSID_2)));
+ }};
+
+ private static final PnoSettings TEST_PNO_SETTINGS =
+ new PnoSettings() {{
+ intervalMs = 6000;
+ pnoNetworks = new ArrayList<>();
+ PnoNetwork network = new PnoNetwork();
+ network.ssid = LocalNativeUtil.byteArrayFromArrayList(
+ LocalNativeUtil.decodeSsid(TEST_QUOTED_SSID_1));
+ network.isHidden = true;
+ network.frequencies = TEST_FREQUENCIES_1;
+ pnoNetworks.add(network);
+ network.ssid = LocalNativeUtil.byteArrayFromArrayList(
+ LocalNativeUtil.decodeSsid(TEST_QUOTED_SSID_2));
+ network.isHidden = false;
+ network.frequencies = TEST_FREQUENCIES_2;
+ pnoNetworks.add(network);
+ }};
+
+ private static final int TEST_MCS_RATE = 5;
+ private static final int TEST_SEND_MGMT_FRAME_ELAPSED_TIME_MS = 100;
+ private static final byte[] TEST_PROBE_FRAME = {
+ 0x40, 0x00, 0x3c, 0x00, (byte) 0xa8, (byte) 0xbd, 0x27, 0x5b,
+ 0x33, 0x72, (byte) 0xf4, (byte) 0xf5, (byte) 0xe8, 0x51, (byte) 0x9e, 0x09,
+ (byte) 0xa8, (byte) 0xbd, 0x27, 0x5b, 0x33, 0x72, (byte) 0xb0, 0x66,
+ 0x00, 0x00
+ };
+
+ @Before
+ public void setUp() throws Exception {
+ // Setup mocks for successful WificondControl operation. Failure case mocks should be
+ // created in specific tests
+ MockitoAnnotations.initMocks(this);
+
+ mTestAlarmManager = new TestAlarmManager();
+ mAlarmManager = mTestAlarmManager.getAlarmManager();
+ when(mContext.getSystemServiceName(AlarmManager.class)).thenReturn(Context.ALARM_SERVICE);
+ when(mContext.getSystemService(AlarmManager.class)).thenReturn(mAlarmManager);
+
+ mLooper = new TestLooper();
+ when(mContext.getMainLooper()).thenReturn(mLooper.getLooper());
+
+ when(mWificond.asBinder()).thenReturn(mWifiCondBinder);
+ when(mClientInterface.getWifiScannerImpl()).thenReturn(mWifiScannerImpl);
+ when(mWificond.createClientInterface(any())).thenReturn(mClientInterface);
+ when(mWificond.createApInterface(any())).thenReturn(mApInterface);
+ when(mWificond.tearDownClientInterface(any())).thenReturn(true);
+ when(mWificond.tearDownApInterface(any())).thenReturn(true);
+ when(mClientInterface.getWifiScannerImpl()).thenReturn(mWifiScannerImpl);
+ when(mClientInterface.getInterfaceName()).thenReturn(TEST_INTERFACE_NAME);
+ mWificondControl = new WifiCondManager(mContext, mWificond);
+ assertEquals(true, mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME,
+ mNormalScanCallback, mPnoScanCallback));
+ }
+
+ /**
+ * Verifies that setupInterfaceForClientMode(TEST_INTERFACE_NAME) calls Wificond.
+ */
+ @Test
+ public void testSetupInterfaceForClientMode() throws Exception {
+ when(mWificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(mClientInterface);
+ verify(mWificond).createClientInterface(TEST_INTERFACE_NAME);
+ }
+
+ /**
+ * Verifies that setupInterfaceForClientMode(TEST_INTERFACE_NAME) calls subscribeScanEvents().
+ */
+ @Test
+ public void testSetupInterfaceForClientModeCallsScanEventSubscripiton() throws Exception {
+ verify(mWifiScannerImpl).subscribeScanEvents(any(IScanEvent.class));
+ }
+
+ /**
+ * Verifies that tearDownClientInterface(TEST_INTERFACE_NAME) calls Wificond.
+ */
+ @Test
+ public void testTeardownClientInterface() throws Exception {
+ when(mWificond.tearDownClientInterface(TEST_INTERFACE_NAME)).thenReturn(true);
+
+ assertTrue(mWificondControl.tearDownClientInterface(TEST_INTERFACE_NAME));
+ verify(mWifiScannerImpl).unsubscribeScanEvents();
+ verify(mWifiScannerImpl).unsubscribePnoScanEvents();
+ verify(mWificond).tearDownClientInterface(TEST_INTERFACE_NAME);
+ }
+
+ /**
+ * Verifies that tearDownClientInterface(TEST_INTERFACE_NAME) calls Wificond.
+ */
+ @Test
+ public void testTeardownClientInterfaceOnInvalidIface() throws Exception {
+ when(mWificond.tearDownClientInterface(TEST_INTERFACE_NAME1)).thenReturn(true);
+
+ assertFalse(mWificondControl.tearDownClientInterface(TEST_INTERFACE_NAME1));
+ verify(mWifiScannerImpl, never()).unsubscribeScanEvents();
+ verify(mWifiScannerImpl, never()).unsubscribePnoScanEvents();
+ verify(mWificond, never()).tearDownClientInterface(any());
+ }
+
+ /**
+ * Verifies that tearDownClientInterface(TEST_INTERFACE_NAME) calls Wificond.
+ */
+ @Test
+ public void testTeardownClientInterfaceFailDueToExceptionScannerUnsubscribe() throws Exception {
+ when(mWificond.tearDownClientInterface(TEST_INTERFACE_NAME)).thenReturn(true);
+ doThrow(new RemoteException()).when(mWifiScannerImpl).unsubscribeScanEvents();
+
+ assertFalse(mWificondControl.tearDownClientInterface(TEST_INTERFACE_NAME));
+ verify(mWifiScannerImpl).unsubscribeScanEvents();
+ verify(mWifiScannerImpl, never()).unsubscribePnoScanEvents();
+ verify(mWificond, never()).tearDownClientInterface(TEST_INTERFACE_NAME);
+ }
+
+ /**
+ * Verifies that tearDownClientInterface(TEST_INTERFACE_NAME) calls Wificond.
+ */
+ @Test
+ public void testTeardownClientInterfaceErrorWhenWificondFailed() throws Exception {
+ when(mWificond.tearDownClientInterface(TEST_INTERFACE_NAME)).thenReturn(false);
+
+ assertFalse(mWificondControl.tearDownClientInterface(TEST_INTERFACE_NAME));
+ verify(mWifiScannerImpl).unsubscribeScanEvents();
+ verify(mWifiScannerImpl).unsubscribePnoScanEvents();
+ verify(mWificond).tearDownClientInterface(TEST_INTERFACE_NAME);
+ }
+
+ /**
+ * Verifies that the client handles are cleared after teardown.
+ */
+ @Test
+ public void testTeardownClientInterfaceClearsHandles() throws Exception {
+ testTeardownClientInterface();
+
+ assertNull(mWificondControl.signalPoll(TEST_INTERFACE_NAME));
+ verify(mClientInterface, never()).signalPoll();
+
+ assertFalse(mWificondControl.scan(
+ TEST_INTERFACE_NAME, WifiScanner.SCAN_TYPE_LOW_LATENCY,
+ SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST));
+ verify(mWifiScannerImpl, never()).scan(any());
+ }
+
+ /**
+ * Verifies that setupInterfaceForSoftApMode(TEST_INTERFACE_NAME) calls wificond.
+ */
+ @Test
+ public void testSetupInterfaceForSoftApMode() throws Exception {
+ when(mWificond.createApInterface(TEST_INTERFACE_NAME)).thenReturn(mApInterface);
+
+ assertEquals(true, mWificondControl.setupInterfaceForSoftApMode(TEST_INTERFACE_NAME));
+ verify(mWificond).createApInterface(TEST_INTERFACE_NAME);
+ }
+
+ /**
+ * Verifies that setupInterfaceForSoftAp() returns null when wificond is not started.
+ */
+ @Test
+ public void testSetupInterfaceForSoftApModeErrorWhenWificondIsNotStarted() throws Exception {
+ // Invoke wificond death handler to clear the handle.
+ mWificondControl.binderDied();
+ mLooper.dispatchAll();
+
+ assertEquals(false, mWificondControl.setupInterfaceForSoftApMode(TEST_INTERFACE_NAME));
+ }
+
+ /**
+ * Verifies that setupInterfaceForSoftApMode(TEST_INTERFACE_NAME) returns null when wificond
+ * failed to setup AP interface.
+ */
+ @Test
+ public void testSetupInterfaceForSoftApModeErrorWhenWificondFailedToSetupInterface()
+ throws Exception {
+ when(mWificond.createApInterface(TEST_INTERFACE_NAME)).thenReturn(null);
+
+ assertEquals(false, mWificondControl.setupInterfaceForSoftApMode(TEST_INTERFACE_NAME));
+ }
+
+ /**
+ * Verifies that tearDownClientInterface(TEST_INTERFACE_NAME) calls Wificond.
+ */
+ @Test
+ public void testTeardownSoftApInterface() throws Exception {
+ testSetupInterfaceForSoftApMode();
+ when(mWificond.tearDownApInterface(TEST_INTERFACE_NAME)).thenReturn(true);
+
+ assertTrue(mWificondControl.tearDownSoftApInterface(TEST_INTERFACE_NAME));
+ verify(mWificond).tearDownApInterface(TEST_INTERFACE_NAME);
+ }
+
+ /**
+ * Verifies that tearDownSoftapInterface(TEST_INTERFACE_NAME) calls Wificond.
+ */
+ @Test
+ public void testTeardownSoftApInterfaceOnInvalidIface() throws Exception {
+ testSetupInterfaceForSoftApMode();
+ when(mWificond.tearDownApInterface(TEST_INTERFACE_NAME1)).thenReturn(true);
+
+ assertFalse(mWificondControl.tearDownSoftApInterface(TEST_INTERFACE_NAME1));
+ verify(mWificond, never()).tearDownApInterface(any());
+ }
+
+ /**
+ * Verifies that tearDownClientInterface(TEST_INTERFACE_NAME) calls Wificond.
+ */
+ @Test
+ public void testTeardownSoftApInterfaceErrorWhenWificondFailed() throws Exception {
+ testSetupInterfaceForSoftApMode();
+ when(mWificond.tearDownApInterface(TEST_INTERFACE_NAME)).thenReturn(false);
+
+ assertFalse(mWificondControl.tearDownSoftApInterface(TEST_INTERFACE_NAME));
+ verify(mWificond).tearDownApInterface(TEST_INTERFACE_NAME);
+ }
+
+ /**
+ * Verifies that the SoftAp handles are cleared after teardown.
+ */
+ @Test
+ public void testTeardownSoftApInterfaceClearsHandles() throws Exception {
+ testTeardownSoftApInterface();
+
+ assertFalse(mWificondControl.registerApListener(
+ TEST_INTERFACE_NAME, mSoftApListener));
+ verify(mApInterface, never()).registerCallback(any());
+ }
+
+ /**
+ * Verifies that we can setup concurrent interfaces.
+ */
+ @Test
+ public void testSetupMultipleInterfaces() throws Exception {
+ when(mWificond.createApInterface(TEST_INTERFACE_NAME1)).thenReturn(mApInterface);
+
+ assertEquals(true, mWificondControl.setupInterfaceForSoftApMode(TEST_INTERFACE_NAME1));
+
+ verify(mWificond).createClientInterface(TEST_INTERFACE_NAME);
+ verify(mWificond).createApInterface(TEST_INTERFACE_NAME1);
+ }
+
+ /**
+ * Verifies that we can setup concurrent interfaces.
+ */
+ @Test
+ public void testTeardownMultipleInterfaces() throws Exception {
+ testSetupMultipleInterfaces();
+ assertTrue(mWificondControl.tearDownClientInterface(TEST_INTERFACE_NAME));
+ assertTrue(mWificondControl.tearDownSoftApInterface(TEST_INTERFACE_NAME1));
+
+ verify(mWificond).tearDownClientInterface(TEST_INTERFACE_NAME);
+ verify(mWificond).tearDownApInterface(TEST_INTERFACE_NAME1);
+ }
+
+ /**
+ * Verifies that tearDownInterfaces() calls wificond.
+ */
+ @Test
+ public void testTearDownInterfaces() throws Exception {
+ assertTrue(mWificondControl.tearDownInterfaces());
+ verify(mWificond).tearDownInterfaces();
+ }
+
+ /**
+ * Verifies that tearDownInterfaces() calls unsubscribeScanEvents() when there was
+ * a configured client interface.
+ */
+ @Test
+ public void testTearDownInterfacesRemovesScanEventSubscription() throws Exception {
+ assertTrue(mWificondControl.tearDownInterfaces());
+ verify(mWifiScannerImpl).unsubscribeScanEvents();
+ }
+
+
+ /**
+ * Verifies that tearDownInterfaces() returns false when wificond is not started.
+ */
+ @Test
+ public void testTearDownInterfacesErrorWhenWificondIsNotStarterd() throws Exception {
+ // Invoke wificond death handler to clear the handle.
+ mWificondControl.binderDied();
+ mLooper.dispatchAll();
+ assertFalse(mWificondControl.tearDownInterfaces());
+ }
+
+ /**
+ * Verifies that signalPoll() calls wificond.
+ */
+ @Test
+ public void testSignalPoll() throws Exception {
+ when(mWificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(mClientInterface);
+
+ mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME, mNormalScanCallback,
+ mPnoScanCallback);
+ mWificondControl.signalPoll(TEST_INTERFACE_NAME);
+ verify(mClientInterface).signalPoll();
+ }
+
+ /**
+ * Verifies that signalPoll() returns null when there is no configured client interface.
+ */
+ @Test
+ public void testSignalPollErrorWhenNoClientInterfaceConfigured() throws Exception {
+ when(mWificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(mClientInterface);
+
+ // Configure client interface.
+ assertEquals(true, mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME,
+ mNormalScanCallback, mPnoScanCallback));
+
+ // Tear down interfaces.
+ assertTrue(mWificondControl.tearDownInterfaces());
+
+ // Signal poll should fail.
+ assertEquals(null, mWificondControl.signalPoll(TEST_INTERFACE_NAME));
+ }
+
+ /**
+ * Verifies that getTxPacketCounters() calls wificond.
+ */
+ @Test
+ public void testGetTxPacketCounters() throws Exception {
+ when(mWificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(mClientInterface);
+
+ mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME, mNormalScanCallback,
+ mPnoScanCallback);
+ mWificondControl.getTxPacketCounters(TEST_INTERFACE_NAME);
+ verify(mClientInterface).getPacketCounters();
+ }
+
+ /**
+ * Verifies that getTxPacketCounters() returns null when there is no configured client
+ * interface.
+ */
+ @Test
+ public void testGetTxPacketCountersErrorWhenNoClientInterfaceConfigured() throws Exception {
+ when(mWificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(mClientInterface);
+
+ // Configure client interface.
+ assertEquals(true, mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME,
+ mNormalScanCallback, mPnoScanCallback));
+
+ // Tear down interfaces.
+ assertTrue(mWificondControl.tearDownInterfaces());
+
+ // Signal poll should fail.
+ assertEquals(null, mWificondControl.getTxPacketCounters(TEST_INTERFACE_NAME));
+ }
+
+ /**
+ * Verifies that getScanResults() returns null when there is no configured client
+ * interface.
+ */
+ @Test
+ public void testGetScanResultsErrorWhenNoClientInterfaceConfigured() throws Exception {
+ when(mWificond.createClientInterface(TEST_INTERFACE_NAME)).thenReturn(mClientInterface);
+
+ // Configure client interface.
+ assertEquals(true, mWificondControl.setupInterfaceForClientMode(TEST_INTERFACE_NAME,
+ mNormalScanCallback, mPnoScanCallback));
+
+ // Tear down interfaces.
+ assertTrue(mWificondControl.tearDownInterfaces());
+
+ // getScanResults should fail.
+ assertEquals(0,
+ mWificondControl.getScanResults(TEST_INTERFACE_NAME,
+ WifiCondManager.SCAN_TYPE_SINGLE_SCAN).size());
+ }
+
+ /**
+ * Verifies that Scan() can convert input parameters to SingleScanSettings correctly.
+ */
+ @Test
+ public void testScan() throws Exception {
+ when(mWifiScannerImpl.scan(any(SingleScanSettings.class))).thenReturn(true);
+ assertTrue(mWificondControl.scan(
+ TEST_INTERFACE_NAME, WifiScanner.SCAN_TYPE_LOW_POWER,
+ SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST));
+ verify(mWifiScannerImpl).scan(argThat(new ScanMatcher(
+ IWifiScannerImpl.SCAN_TYPE_LOW_POWER,
+ SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST)));
+ }
+
+ /**
+ * Verifies that Scan() removes duplicates hiddenSsids passed in from input.
+ */
+ @Test
+ public void testScanWithDuplicateHiddenSsids() throws Exception {
+ when(mWifiScannerImpl.scan(any(SingleScanSettings.class))).thenReturn(true);
+ // Create a list of hiddenSsid that has a duplicate element
+ List<byte[]> hiddenSsidWithDup = new ArrayList<>(SCAN_HIDDEN_NETWORK_SSID_LIST);
+ hiddenSsidWithDup.add(SCAN_HIDDEN_NETWORK_SSID_LIST.get(0));
+ assertEquals(hiddenSsidWithDup.get(0),
+ hiddenSsidWithDup.get(hiddenSsidWithDup.size() - 1));
+ // Pass the List with duplicate elements into scan()
+ assertTrue(mWificondControl.scan(
+ TEST_INTERFACE_NAME, WifiScanner.SCAN_TYPE_LOW_POWER,
+ SCAN_FREQ_SET, hiddenSsidWithDup));
+ // But the argument passed down should have the duplicate removed.
+ verify(mWifiScannerImpl).scan(argThat(new ScanMatcher(
+ IWifiScannerImpl.SCAN_TYPE_LOW_POWER,
+ SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST)));
+ }
+
+ /**
+ * Verifies that Scan() can handle null input parameters correctly.
+ */
+ @Test
+ public void testScanNullParameters() throws Exception {
+ when(mWifiScannerImpl.scan(any(SingleScanSettings.class))).thenReturn(true);
+ assertTrue(mWificondControl.scan(
+ TEST_INTERFACE_NAME, WifiScanner.SCAN_TYPE_HIGH_ACCURACY, null, null));
+ verify(mWifiScannerImpl).scan(argThat(new ScanMatcher(
+ IWifiScannerImpl.SCAN_TYPE_HIGH_ACCURACY, null, null)));
+ }
+
+ /**
+ * Verifies that Scan() can handle wificond scan failure.
+ */
+ @Test
+ public void testScanFailure() throws Exception {
+ when(mWifiScannerImpl.scan(any(SingleScanSettings.class))).thenReturn(false);
+ assertFalse(mWificondControl.scan(
+ TEST_INTERFACE_NAME, WifiScanner.SCAN_TYPE_LOW_LATENCY,
+ SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST));
+ verify(mWifiScannerImpl).scan(any(SingleScanSettings.class));
+ }
+
+ /**
+ * Verifies that Scan() can handle invalid type.
+ */
+ @Test
+ public void testScanFailureDueToInvalidType() throws Exception {
+ assertFalse(mWificondControl.scan(
+ TEST_INTERFACE_NAME, 100,
+ SCAN_FREQ_SET, SCAN_HIDDEN_NETWORK_SSID_LIST));
+ verify(mWifiScannerImpl, never()).scan(any(SingleScanSettings.class));
+ }
+
+ /**
+ * Verifies that startPnoScan() can convert input parameters to PnoSettings correctly.
+ */
+ @Test
+ public void testStartPnoScan() throws Exception {
+ when(mWifiScannerImpl.startPnoScan(any(PnoSettings.class))).thenReturn(true);
+ assertTrue(mWificondControl.startPnoScan(TEST_INTERFACE_NAME, TEST_PNO_SETTINGS,
+ mPnoScanRequestCallback));
+ verify(mWifiScannerImpl).startPnoScan(argThat(new PnoScanMatcher(TEST_PNO_SETTINGS)));
+ verify(mPnoScanRequestCallback).onPnoRequestSucceeded();
+ }
+
+ /**
+ * Verifies that stopPnoScan() calls underlying wificond.
+ */
+ @Test
+ public void testStopPnoScan() throws Exception {
+ when(mWifiScannerImpl.stopPnoScan()).thenReturn(true);
+ assertTrue(mWificondControl.stopPnoScan(TEST_INTERFACE_NAME));
+ verify(mWifiScannerImpl).stopPnoScan();
+ }
+
+ /**
+ * Verifies that stopPnoScan() can handle wificond failure.
+ */
+ @Test
+ public void testStopPnoScanFailure() throws Exception {
+
+ when(mWifiScannerImpl.stopPnoScan()).thenReturn(false);
+ assertFalse(mWificondControl.stopPnoScan(TEST_INTERFACE_NAME));
+ verify(mWifiScannerImpl).stopPnoScan();
+ }
+
+ /**
+ * Verifies that WificondControl can invoke WifiMonitor broadcast methods upon scan
+ * result event.
+ */
+ @Test
+ public void testScanResultEvent() throws Exception {
+ ArgumentCaptor<IScanEvent> messageCaptor = ArgumentCaptor.forClass(IScanEvent.class);
+ verify(mWifiScannerImpl).subscribeScanEvents(messageCaptor.capture());
+ IScanEvent scanEvent = messageCaptor.getValue();
+ assertNotNull(scanEvent);
+ scanEvent.OnScanResultReady();
+
+ verify(mNormalScanCallback).onScanResultReady();
+ }
+
+ /**
+ * Verifies that WificondControl can invoke WifiMonitor broadcast methods upon scan
+ * failed event.
+ */
+ @Test
+ public void testScanFailedEvent() throws Exception {
+ ArgumentCaptor<IScanEvent> messageCaptor = ArgumentCaptor.forClass(IScanEvent.class);
+ verify(mWifiScannerImpl).subscribeScanEvents(messageCaptor.capture());
+ IScanEvent scanEvent = messageCaptor.getValue();
+ assertNotNull(scanEvent);
+ scanEvent.OnScanFailed();
+
+ verify(mNormalScanCallback).onScanFailed();
+ }
+
+ /**
+ * Verifies that WificondControl can invoke WifiMonitor broadcast methods upon pno scan
+ * result event.
+ */
+ @Test
+ public void testPnoScanResultEvent() throws Exception {
+ ArgumentCaptor<IPnoScanEvent> messageCaptor = ArgumentCaptor.forClass(IPnoScanEvent.class);
+ verify(mWifiScannerImpl).subscribePnoScanEvents(messageCaptor.capture());
+ IPnoScanEvent pnoScanEvent = messageCaptor.getValue();
+ assertNotNull(pnoScanEvent);
+ pnoScanEvent.OnPnoNetworkFound();
+ verify(mPnoScanCallback).onScanResultReady();
+ }
+
+ /**
+ * Verifies that WificondControl can invoke WifiMetrics pno scan count methods upon pno event.
+ */
+ @Test
+ public void testPnoScanEventsForMetrics() throws Exception {
+ ArgumentCaptor<IPnoScanEvent> messageCaptor = ArgumentCaptor.forClass(IPnoScanEvent.class);
+ verify(mWifiScannerImpl).subscribePnoScanEvents(messageCaptor.capture());
+ IPnoScanEvent pnoScanEvent = messageCaptor.getValue();
+ assertNotNull(pnoScanEvent);
+
+ pnoScanEvent.OnPnoNetworkFound();
+ verify(mPnoScanCallback).onScanResultReady();
+
+ pnoScanEvent.OnPnoScanFailed();
+ verify(mPnoScanCallback).onScanFailed();
+ }
+
+ /**
+ * Verifies that startPnoScan() can invoke WifiMetrics pno scan count methods correctly.
+ */
+ @Test
+ public void testStartPnoScanForMetrics() throws Exception {
+ when(mWifiScannerImpl.startPnoScan(any(PnoSettings.class))).thenReturn(false);
+
+ assertFalse(mWificondControl.startPnoScan(TEST_INTERFACE_NAME, TEST_PNO_SETTINGS,
+ mPnoScanRequestCallback));
+ verify(mPnoScanRequestCallback).onPnoRequestFailed();
+ }
+
+ /**
+ * Verifies that abortScan() calls underlying wificond.
+ */
+ @Test
+ public void testAbortScan() throws Exception {
+ mWificondControl.abortScan(TEST_INTERFACE_NAME);
+ verify(mWifiScannerImpl).abortScan();
+ }
+
+ /**
+ * Ensures that the Ap interface callbacks are forwarded to the
+ * SoftApListener used for starting soft AP.
+ */
+ @Test
+ public void testSoftApListenerInvocation() throws Exception {
+ testSetupInterfaceForSoftApMode();
+
+ WifiConfiguration config = new WifiConfiguration();
+ config.SSID = new String(TEST_SSID, StandardCharsets.UTF_8);
+
+ when(mApInterface.registerCallback(any())).thenReturn(true);
+
+ final ArgumentCaptor<IApInterfaceEventCallback> apInterfaceCallbackCaptor =
+ ArgumentCaptor.forClass(IApInterfaceEventCallback.class);
+
+ assertTrue(mWificondControl.registerApListener(
+ TEST_INTERFACE_NAME, mSoftApListener));
+ verify(mApInterface).registerCallback(apInterfaceCallbackCaptor.capture());
+
+ final NativeWifiClient testClient = new NativeWifiClient();
+ apInterfaceCallbackCaptor.getValue().onConnectedClientsChanged(testClient, true);
+ verify(mSoftApListener).onConnectedClientsChanged(eq(testClient), eq(true));
+
+ int channelFrequency = 2437;
+ int channelBandwidth = IApInterfaceEventCallback.BANDWIDTH_20;
+ apInterfaceCallbackCaptor.getValue().onSoftApChannelSwitched(channelFrequency,
+ channelBandwidth);
+ verify(mSoftApListener).onSoftApChannelSwitched(eq(channelFrequency), eq(channelBandwidth));
+ }
+
+ /**
+ * Verifies registration and invocation of wificond death handler.
+ */
+ @Test
+ public void testRegisterDeathHandler() throws Exception {
+ Runnable deathHandler = mock(Runnable.class);
+ assertTrue(mWificondControl.initialize(deathHandler));
+ verify(mWificond).tearDownInterfaces();
+ mWificondControl.binderDied();
+ mLooper.dispatchAll();
+ verify(deathHandler).run();
+ }
+
+ /**
+ * Verifies handling of wificond death and ensures that all internal state is cleared and
+ * handlers are invoked.
+ */
+ @Test
+ public void testDeathHandling() throws Exception {
+ Runnable deathHandler = mock(Runnable.class);
+ assertTrue(mWificondControl.initialize(deathHandler));
+
+ testSetupInterfaceForClientMode();
+
+ mWificondControl.binderDied();
+ mLooper.dispatchAll();
+ verify(deathHandler).run();
+
+ // The handles should be cleared after death.
+ assertNull(mWificondControl.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ));
+ verify(mWificond, never()).getAvailable5gNonDFSChannels();
+ }
+
+ /**
+ * sendMgmtFrame() should fail if a null callback is passed in.
+ */
+ @Test
+ public void testSendMgmtFrameNullCallback() throws Exception {
+ mWificondControl.sendMgmtFrame(TEST_INTERFACE_NAME, TEST_PROBE_FRAME, null, TEST_MCS_RATE);
+
+ verify(mClientInterface, never()).SendMgmtFrame(any(), any(), anyInt());
+ }
+
+ /**
+ * sendMgmtFrame() should fail if a null frame is passed in.
+ */
+ @Test
+ public void testSendMgmtFrameNullFrame() throws Exception {
+ mWificondControl.sendMgmtFrame(TEST_INTERFACE_NAME, null,
+ mSendMgmtFrameCallback, TEST_MCS_RATE);
+
+ verify(mClientInterface, never()).SendMgmtFrame(any(), any(), anyInt());
+ verify(mSendMgmtFrameCallback).onFailure(anyInt());
+ }
+
+ /**
+ * sendMgmtFrame() should fail if an interface name that does not exist is passed in.
+ */
+ @Test
+ public void testSendMgmtFrameInvalidInterfaceName() throws Exception {
+ mWificondControl.sendMgmtFrame(TEST_INVALID_INTERFACE_NAME, TEST_PROBE_FRAME,
+ mSendMgmtFrameCallback, TEST_MCS_RATE);
+
+ verify(mClientInterface, never()).SendMgmtFrame(any(), any(), anyInt());
+ verify(mSendMgmtFrameCallback).onFailure(anyInt());
+ }
+
+ /**
+ * sendMgmtFrame() should fail if it is called a second time before the first call completed.
+ */
+ @Test
+ public void testSendMgmtFrameCalledTwiceBeforeFinished() throws Exception {
+ WifiCondManager.SendMgmtFrameCallback cb1 = mock(
+ WifiCondManager.SendMgmtFrameCallback.class);
+ WifiCondManager.SendMgmtFrameCallback cb2 = mock(
+ WifiCondManager.SendMgmtFrameCallback.class);
+
+ mWificondControl.sendMgmtFrame(TEST_INTERFACE_NAME, TEST_PROBE_FRAME, cb1, TEST_MCS_RATE);
+ verify(cb1, never()).onFailure(anyInt());
+ verify(mClientInterface, times(1))
+ .SendMgmtFrame(AdditionalMatchers.aryEq(TEST_PROBE_FRAME),
+ any(), eq(TEST_MCS_RATE));
+
+ mWificondControl.sendMgmtFrame(TEST_INTERFACE_NAME, TEST_PROBE_FRAME, cb2, TEST_MCS_RATE);
+ verify(cb2).onFailure(WifiCondManager.SEND_MGMT_FRAME_ERROR_ALREADY_STARTED);
+ // verify SendMgmtFrame() still was only called once i.e. not called again
+ verify(mClientInterface, times(1))
+ .SendMgmtFrame(any(), any(), anyInt());
+ }
+
+ /**
+ * Tests that when a RemoteException is triggered on AIDL call, onFailure() is called only once.
+ */
+ @Test
+ public void testSendMgmtFrameThrowsException() throws Exception {
+ WifiCondManager.SendMgmtFrameCallback cb = mock(
+ WifiCondManager.SendMgmtFrameCallback.class);
+
+ final ArgumentCaptor<ISendMgmtFrameEvent> sendMgmtFrameEventCaptor =
+ ArgumentCaptor.forClass(ISendMgmtFrameEvent.class);
+
+ doThrow(new RemoteException()).when(mClientInterface)
+ .SendMgmtFrame(any(), sendMgmtFrameEventCaptor.capture(), anyInt());
+
+ final ArgumentCaptor<AlarmManager.OnAlarmListener> alarmListenerCaptor =
+ ArgumentCaptor.forClass(AlarmManager.OnAlarmListener.class);
+ final ArgumentCaptor<Handler> handlerCaptor = ArgumentCaptor.forClass(Handler.class);
+ doNothing().when(mAlarmManager).set(anyInt(), anyLong(), any(),
+ alarmListenerCaptor.capture(), handlerCaptor.capture());
+
+ mWificondControl.sendMgmtFrame(TEST_INTERFACE_NAME, TEST_PROBE_FRAME,
+ cb, TEST_MCS_RATE);
+ mLooper.dispatchAll();
+
+ verify(cb).onFailure(anyInt());
+ verify(mAlarmManager).cancel(eq(alarmListenerCaptor.getValue()));
+
+ sendMgmtFrameEventCaptor.getValue().OnFailure(
+ WifiCondManager.SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ mLooper.dispatchAll();
+
+ handlerCaptor.getValue().post(() -> alarmListenerCaptor.getValue().onAlarm());
+ mLooper.dispatchAll();
+
+ verifyNoMoreInteractions(cb);
+ }
+
+ /**
+ * Tests that the onAck() callback is triggered correctly.
+ */
+ @Test
+ public void testSendMgmtFrameSuccess() throws Exception {
+ WifiCondManager.SendMgmtFrameCallback cb = mock(
+ WifiCondManager.SendMgmtFrameCallback.class);
+
+ final ArgumentCaptor<ISendMgmtFrameEvent> sendMgmtFrameEventCaptor =
+ ArgumentCaptor.forClass(ISendMgmtFrameEvent.class);
+ doNothing().when(mClientInterface)
+ .SendMgmtFrame(any(), sendMgmtFrameEventCaptor.capture(), anyInt());
+ final ArgumentCaptor<AlarmManager.OnAlarmListener> alarmListenerCaptor =
+ ArgumentCaptor.forClass(AlarmManager.OnAlarmListener.class);
+ final ArgumentCaptor<Handler> handlerCaptor = ArgumentCaptor.forClass(Handler.class);
+ doNothing().when(mAlarmManager).set(anyInt(), anyLong(), any(),
+ alarmListenerCaptor.capture(), handlerCaptor.capture());
+ mWificondControl.sendMgmtFrame(TEST_INTERFACE_NAME, TEST_PROBE_FRAME, cb, TEST_MCS_RATE);
+
+ sendMgmtFrameEventCaptor.getValue().OnAck(TEST_SEND_MGMT_FRAME_ELAPSED_TIME_MS);
+ mLooper.dispatchAll();
+ verify(cb).onAck(eq(TEST_SEND_MGMT_FRAME_ELAPSED_TIME_MS));
+ verify(cb, never()).onFailure(anyInt());
+ verify(mAlarmManager).cancel(eq(alarmListenerCaptor.getValue()));
+
+ // verify that even if timeout is triggered afterwards, SendMgmtFrameCallback is not
+ // triggered again
+ handlerCaptor.getValue().post(() -> alarmListenerCaptor.getValue().onAlarm());
+ mLooper.dispatchAll();
+ verify(cb, times(1)).onAck(anyInt());
+ verify(cb, never()).onFailure(anyInt());
+ }
+
+ /**
+ * Tests that the onFailure() callback is triggered correctly.
+ */
+ @Test
+ public void testSendMgmtFrameFailure() throws Exception {
+ WifiCondManager.SendMgmtFrameCallback cb = mock(
+ WifiCondManager.SendMgmtFrameCallback.class);
+
+ final ArgumentCaptor<ISendMgmtFrameEvent> sendMgmtFrameEventCaptor =
+ ArgumentCaptor.forClass(ISendMgmtFrameEvent.class);
+ doNothing().when(mClientInterface)
+ .SendMgmtFrame(any(), sendMgmtFrameEventCaptor.capture(), anyInt());
+ final ArgumentCaptor<AlarmManager.OnAlarmListener> alarmListenerCaptor =
+ ArgumentCaptor.forClass(AlarmManager.OnAlarmListener.class);
+ final ArgumentCaptor<Handler> handlerCaptor = ArgumentCaptor.forClass(Handler.class);
+ doNothing().when(mAlarmManager).set(anyInt(), anyLong(), any(),
+ alarmListenerCaptor.capture(), handlerCaptor.capture());
+ mWificondControl.sendMgmtFrame(TEST_INTERFACE_NAME, TEST_PROBE_FRAME, cb, TEST_MCS_RATE);
+
+ sendMgmtFrameEventCaptor.getValue().OnFailure(
+ WifiCondManager.SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ mLooper.dispatchAll();
+ verify(cb, never()).onAck(anyInt());
+ verify(cb).onFailure(WifiCondManager.SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ verify(mAlarmManager).cancel(eq(alarmListenerCaptor.getValue()));
+
+ // verify that even if timeout is triggered afterwards, SendMgmtFrameCallback is not
+ // triggered again
+ handlerCaptor.getValue().post(() -> alarmListenerCaptor.getValue().onAlarm());
+ mLooper.dispatchAll();
+ verify(cb, never()).onAck(anyInt());
+ verify(cb, times(1)).onFailure(anyInt());
+ }
+
+ /**
+ * Tests that the onTimeout() callback is triggered correctly.
+ */
+ @Test
+ public void testSendMgmtFrameTimeout() throws Exception {
+ WifiCondManager.SendMgmtFrameCallback cb = mock(
+ WifiCondManager.SendMgmtFrameCallback.class);
+
+ final ArgumentCaptor<ISendMgmtFrameEvent> sendMgmtFrameEventCaptor =
+ ArgumentCaptor.forClass(ISendMgmtFrameEvent.class);
+ doNothing().when(mClientInterface)
+ .SendMgmtFrame(any(), sendMgmtFrameEventCaptor.capture(), anyInt());
+ final ArgumentCaptor<AlarmManager.OnAlarmListener> alarmListenerCaptor =
+ ArgumentCaptor.forClass(AlarmManager.OnAlarmListener.class);
+ final ArgumentCaptor<Handler> handlerCaptor = ArgumentCaptor.forClass(Handler.class);
+ doNothing().when(mAlarmManager).set(anyInt(), anyLong(), any(),
+ alarmListenerCaptor.capture(), handlerCaptor.capture());
+ mWificondControl.sendMgmtFrame(TEST_INTERFACE_NAME, TEST_PROBE_FRAME, cb, TEST_MCS_RATE);
+
+ handlerCaptor.getValue().post(() -> alarmListenerCaptor.getValue().onAlarm());
+ mLooper.dispatchAll();
+ verify(cb, never()).onAck(anyInt());
+ verify(cb).onFailure(WifiCondManager.SEND_MGMT_FRAME_ERROR_TIMEOUT);
+
+ // verify that even if onAck() callback is triggered after timeout,
+ // SendMgmtFrameCallback is not triggered again
+ sendMgmtFrameEventCaptor.getValue().OnAck(TEST_SEND_MGMT_FRAME_ELAPSED_TIME_MS);
+ mLooper.dispatchAll();
+ verify(cb, never()).onAck(anyInt());
+ verify(cb, times(1)).onFailure(anyInt());
+ }
+
+ /**
+ * Tests every possible test outcome followed by every other test outcome to ensure that the
+ * internal state is reset correctly between calls.
+ * i.e. (success, success), (success, failure), (success, timeout),
+ * (failure, failure), (failure, success), (failure, timeout),
+ * (timeout, timeout), (timeout, success), (timeout, failure)
+ *
+ * Also tests that internal state is reset correctly after a transient AIDL RemoteException.
+ */
+ @Test
+ public void testSendMgmtFrameMixed() throws Exception {
+ testSendMgmtFrameThrowsException();
+ testSendMgmtFrameSuccess();
+ testSendMgmtFrameSuccess();
+ testSendMgmtFrameFailure();
+ testSendMgmtFrameFailure();
+ testSendMgmtFrameTimeout();
+ testSendMgmtFrameTimeout();
+ testSendMgmtFrameSuccess();
+ testSendMgmtFrameTimeout();
+ testSendMgmtFrameFailure();
+ testSendMgmtFrameSuccess();
+ }
+
+ /**
+ * Tests that OnAck() does not perform any non-thread-safe operations on the binder thread.
+ *
+ * The sequence of instructions are:
+ * 1. post onAlarm() onto main thread
+ * 2. OnAck()
+ * 3. mLooper.dispatchAll()
+ *
+ * The actual order of execution is:
+ * 1. binder thread portion of OnAck()
+ * 2. onAlarm() (which purely executes on the main thread)
+ * 3. main thread portion of OnAck()
+ *
+ * If the binder thread portion of OnAck() is not thread-safe, it can possibly mess up
+ * onAlarm(). Tests that this does not occur.
+ */
+ @Test
+ public void testSendMgmtFrameTimeoutAckThreadSafe() throws Exception {
+ final ArgumentCaptor<ISendMgmtFrameEvent> sendMgmtFrameEventCaptor =
+ ArgumentCaptor.forClass(ISendMgmtFrameEvent.class);
+ doNothing().when(mClientInterface)
+ .SendMgmtFrame(any(), sendMgmtFrameEventCaptor.capture(), anyInt());
+ final ArgumentCaptor<AlarmManager.OnAlarmListener> alarmListenerCaptor =
+ ArgumentCaptor.forClass(AlarmManager.OnAlarmListener.class);
+ final ArgumentCaptor<Handler> handlerCaptor = ArgumentCaptor.forClass(Handler.class);
+ doNothing().when(mAlarmManager).set(anyInt(), anyLong(), any(),
+ alarmListenerCaptor.capture(), handlerCaptor.capture());
+ mWificondControl.sendMgmtFrame(TEST_INTERFACE_NAME, TEST_PROBE_FRAME,
+ mSendMgmtFrameCallback, TEST_MCS_RATE);
+
+ // AlarmManager should post the onAlarm() callback onto the handler, but since we are
+ // triggering onAlarm() ourselves during the test, manually post onto handler
+ handlerCaptor.getValue().post(() -> alarmListenerCaptor.getValue().onAlarm());
+ // OnAck posts to the handler
+ sendMgmtFrameEventCaptor.getValue().OnAck(TEST_SEND_MGMT_FRAME_ELAPSED_TIME_MS);
+ mLooper.dispatchAll();
+ verify(mSendMgmtFrameCallback, never()).onAck(anyInt());
+ verify(mSendMgmtFrameCallback).onFailure(WifiCondManager.SEND_MGMT_FRAME_ERROR_TIMEOUT);
+ }
+
+ /**
+ * See {@link #testSendMgmtFrameTimeoutAckThreadSafe()}. This test replaces OnAck() with
+ * OnFailure().
+ */
+ @Test
+ public void testSendMgmtFrameTimeoutFailureThreadSafe() throws Exception {
+ final ArgumentCaptor<ISendMgmtFrameEvent> sendMgmtFrameEventCaptor =
+ ArgumentCaptor.forClass(ISendMgmtFrameEvent.class);
+ doNothing().when(mClientInterface)
+ .SendMgmtFrame(any(), sendMgmtFrameEventCaptor.capture(), anyInt());
+ final ArgumentCaptor<AlarmManager.OnAlarmListener> alarmListenerCaptor =
+ ArgumentCaptor.forClass(AlarmManager.OnAlarmListener.class);
+ final ArgumentCaptor<Handler> handlerCaptor = ArgumentCaptor.forClass(Handler.class);
+ doNothing().when(mAlarmManager).set(anyInt(), anyLong(), any(),
+ alarmListenerCaptor.capture(), handlerCaptor.capture());
+ mWificondControl.sendMgmtFrame(TEST_INTERFACE_NAME, TEST_PROBE_FRAME,
+ mSendMgmtFrameCallback, TEST_MCS_RATE);
+
+ // AlarmManager should post the onAlarm() callback onto the handler, but since we are
+ // triggering onAlarm() ourselves during the test, manually post onto handler
+ handlerCaptor.getValue().post(() -> alarmListenerCaptor.getValue().onAlarm());
+ // OnFailure posts to the handler
+ sendMgmtFrameEventCaptor.getValue().OnFailure(
+ WifiCondManager.SEND_MGMT_FRAME_ERROR_UNKNOWN);
+ mLooper.dispatchAll();
+ verify(mSendMgmtFrameCallback).onFailure(WifiCondManager.SEND_MGMT_FRAME_ERROR_TIMEOUT);
+ }
+
+ // Create a ArgumentMatcher which captures a SingleScanSettings parameter and checks if it
+ // matches the provided frequency set and ssid set.
+ private class ScanMatcher implements ArgumentMatcher<SingleScanSettings> {
+ int mExpectedScanType;
+ private final Set<Integer> mExpectedFreqs;
+ private final List<byte[]> mExpectedSsids;
+
+ ScanMatcher(int expectedScanType, Set<Integer> expectedFreqs, List<byte[]> expectedSsids) {
+ this.mExpectedScanType = expectedScanType;
+ this.mExpectedFreqs = expectedFreqs;
+ this.mExpectedSsids = expectedSsids;
+ }
+
+ @Override
+ public boolean matches(SingleScanSettings settings) {
+ if (settings.scanType != mExpectedScanType) {
+ return false;
+ }
+ ArrayList<ChannelSettings> channelSettings = settings.channelSettings;
+ ArrayList<HiddenNetwork> hiddenNetworks = settings.hiddenNetworks;
+ if (mExpectedFreqs != null) {
+ Set<Integer> freqSet = new HashSet<Integer>();
+ for (ChannelSettings channel : channelSettings) {
+ freqSet.add(channel.frequency);
+ }
+ if (!mExpectedFreqs.equals(freqSet)) {
+ return false;
+ }
+ } else {
+ if (channelSettings != null && channelSettings.size() > 0) {
+ return false;
+ }
+ }
+
+ if (mExpectedSsids != null) {
+ List<byte[]> ssidSet = new ArrayList<>();
+ for (HiddenNetwork network : hiddenNetworks) {
+ ssidSet.add(network.ssid);
+ }
+ if (!mExpectedSsids.equals(ssidSet)) {
+ return false;
+ }
+
+ } else {
+ if (hiddenNetworks != null && hiddenNetworks.size() > 0) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "ScanMatcher{mExpectedFreqs=" + mExpectedFreqs
+ + ", mExpectedSsids=" + mExpectedSsids + '}';
+ }
+ }
+
+ // Create a ArgumentMatcher which captures a PnoSettings parameter and checks if it
+ // matches the WifiNative.PnoSettings;
+ private class PnoScanMatcher implements ArgumentMatcher<PnoSettings> {
+ private final PnoSettings mExpectedPnoSettings;
+
+ PnoScanMatcher(PnoSettings expectedPnoSettings) {
+ this.mExpectedPnoSettings = expectedPnoSettings;
+ }
+
+ @Override
+ public boolean matches(PnoSettings settings) {
+ if (mExpectedPnoSettings == null) {
+ return false;
+ }
+ if (settings.intervalMs != mExpectedPnoSettings.intervalMs
+ || settings.min2gRssi != mExpectedPnoSettings.min2gRssi
+ || settings.min5gRssi != mExpectedPnoSettings.min5gRssi
+ || settings.min6gRssi != mExpectedPnoSettings.min6gRssi) {
+ return false;
+ }
+ if (settings.pnoNetworks == null || mExpectedPnoSettings.pnoNetworks == null) {
+ return false;
+ }
+ if (settings.pnoNetworks.size() != mExpectedPnoSettings.pnoNetworks.size()) {
+ return false;
+ }
+
+ for (int i = 0; i < settings.pnoNetworks.size(); i++) {
+ if (!Arrays.equals(settings.pnoNetworks.get(i).ssid,
+ mExpectedPnoSettings.pnoNetworks.get(i).ssid)) {
+ return false;
+ }
+ if (settings.pnoNetworks.get(i).isHidden != mExpectedPnoSettings.pnoNetworks.get(
+ i).isHidden) {
+ return false;
+ }
+ if (!Arrays.equals(settings.pnoNetworks.get(i).frequencies,
+ mExpectedPnoSettings.pnoNetworks.get(i).frequencies)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "PnoScanMatcher{" + "mExpectedPnoSettings=" + mExpectedPnoSettings + '}';
+ }
+ }
+
+ private static class LocalNativeUtil {
+ private static final int SSID_BYTES_MAX_LEN = 32;
+
+ /**
+ * Converts an ArrayList<Byte> of UTF_8 byte values to string.
+ * The string will either be:
+ * a) UTF-8 String encapsulated in quotes (if all the bytes are UTF-8 encodeable and non
+ * null),
+ * or
+ * b) Hex string with no delimiters.
+ *
+ * @param bytes List of bytes for ssid.
+ * @throws IllegalArgumentException for null bytes.
+ */
+ public static String bytesToHexOrQuotedString(ArrayList<Byte> bytes) {
+ if (bytes == null) {
+ throw new IllegalArgumentException("null ssid bytes");
+ }
+ byte[] byteArray = byteArrayFromArrayList(bytes);
+ // Check for 0's in the byte stream in which case we cannot convert this into a string.
+ if (!bytes.contains(Byte.valueOf((byte) 0))) {
+ CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder();
+ try {
+ CharBuffer decoded = decoder.decode(ByteBuffer.wrap(byteArray));
+ return "\"" + decoded.toString() + "\"";
+ } catch (CharacterCodingException cce) {
+ }
+ }
+ return hexStringFromByteArray(byteArray);
+ }
+
+ /**
+ * Converts an ssid string to an arraylist of UTF_8 byte values.
+ * These forms are acceptable:
+ * a) UTF-8 String encapsulated in quotes, or
+ * b) Hex string with no delimiters.
+ *
+ * @param ssidStr String to be converted.
+ * @throws IllegalArgumentException for null string.
+ */
+ public static ArrayList<Byte> decodeSsid(String ssidStr) {
+ ArrayList<Byte> ssidBytes = hexOrQuotedStringToBytes(ssidStr);
+ if (ssidBytes.size() > SSID_BYTES_MAX_LEN) {
+ throw new IllegalArgumentException(
+ "ssid bytes size out of range: " + ssidBytes.size());
+ }
+ return ssidBytes;
+ }
+
+ /**
+ * Convert from an array list of Byte to an array of primitive bytes.
+ */
+ public static byte[] byteArrayFromArrayList(ArrayList<Byte> bytes) {
+ byte[] byteArray = new byte[bytes.size()];
+ int i = 0;
+ for (Byte b : bytes) {
+ byteArray[i++] = b;
+ }
+ return byteArray;
+ }
+
+ /**
+ * Converts a byte array to hex string.
+ *
+ * @param bytes List of bytes for ssid.
+ * @throws IllegalArgumentException for null bytes.
+ */
+ public static String hexStringFromByteArray(byte[] bytes) {
+ if (bytes == null) {
+ throw new IllegalArgumentException("null hex bytes");
+ }
+ return new String(HexEncoding.encode(bytes)).toLowerCase();
+ }
+
+ /**
+ * Converts an string to an arraylist of UTF_8 byte values.
+ * These forms are acceptable:
+ * a) UTF-8 String encapsulated in quotes, or
+ * b) Hex string with no delimiters.
+ *
+ * @param str String to be converted.
+ * @throws IllegalArgumentException for null string.
+ */
+ public static ArrayList<Byte> hexOrQuotedStringToBytes(String str) {
+ if (str == null) {
+ throw new IllegalArgumentException("null string");
+ }
+ int length = str.length();
+ if ((length > 1) && (str.charAt(0) == '"') && (str.charAt(length - 1) == '"')) {
+ str = str.substring(1, str.length() - 1);
+ return stringToByteArrayList(str);
+ } else {
+ return byteArrayToArrayList(hexStringToByteArray(str));
+ }
+ }
+
+ /**
+ * Convert the string to byte array list.
+ *
+ * @return the UTF_8 char byte values of str, as an ArrayList.
+ * @throws IllegalArgumentException if a null or unencodable string is sent.
+ */
+ public static ArrayList<Byte> stringToByteArrayList(String str) {
+ if (str == null) {
+ throw new IllegalArgumentException("null string");
+ }
+ // Ensure that the provided string is UTF_8 encoded.
+ CharsetEncoder encoder = StandardCharsets.UTF_8.newEncoder();
+ try {
+ ByteBuffer encoded = encoder.encode(CharBuffer.wrap(str));
+ byte[] byteArray = new byte[encoded.remaining()];
+ encoded.get(byteArray);
+ return byteArrayToArrayList(byteArray);
+ } catch (CharacterCodingException cce) {
+ throw new IllegalArgumentException("cannot be utf-8 encoded", cce);
+ }
+ }
+
+ /**
+ * Convert from an array of primitive bytes to an array list of Byte.
+ */
+ public static ArrayList<Byte> byteArrayToArrayList(byte[] bytes) {
+ ArrayList<Byte> byteList = new ArrayList<>();
+ for (Byte b : bytes) {
+ byteList.add(b);
+ }
+ return byteList;
+ }
+
+ /**
+ * Converts a hex string to byte array.
+ *
+ * @param hexStr String to be converted.
+ * @throws IllegalArgumentException for null string.
+ */
+ public static byte[] hexStringToByteArray(String hexStr) {
+ if (hexStr == null) {
+ throw new IllegalArgumentException("null hex string");
+ }
+ return HexEncoding.decode(hexStr.toCharArray(), false);
+ }
+ }
+}
diff --git a/wifi/tests/src/android/net/wifi/WifiManagerTest.java b/wifi/tests/src/android/net/wifi/WifiManagerTest.java
index f92d38c..62ff9f6 100644
--- a/wifi/tests/src/android/net/wifi/WifiManagerTest.java
+++ b/wifi/tests/src/android/net/wifi/WifiManagerTest.java
@@ -1696,8 +1696,6 @@
assertTrue(mWifiManager.isPasspointSupported());
assertTrue(mWifiManager.isP2pSupported());
assertFalse(mWifiManager.isPortableHotspotSupported());
- assertFalse(mWifiManager.is5GHzBandSupported());
- assertFalse(mWifiManager.is6GHzBandSupported());
assertFalse(mWifiManager.isDeviceToDeviceRttSupported());
assertFalse(mWifiManager.isDeviceToApRttSupported());
assertFalse(mWifiManager.isPreferredNetworkOffloadSupported());
@@ -1782,13 +1780,23 @@
}
/**
- * Test behavior of {@link WifiManager#isDualBandSupported()}
+ * Test behavior of {@link WifiManager#is5GHzBandSupported()}
*/
@Test
- public void testIsDualBandSupported() throws Exception {
- when(mWifiService.isDualBandSupported()).thenReturn(true);
- assertTrue(mWifiManager.isDualBandSupported());
- verify(mWifiService).isDualBandSupported();
+ public void testIs5GHzBandSupported() throws Exception {
+ when(mWifiService.is5GHzBandSupported()).thenReturn(true);
+ assertTrue(mWifiManager.is5GHzBandSupported());
+ verify(mWifiService).is5GHzBandSupported();
+ }
+
+ /**
+ * Test behavior of {@link WifiManager#is6GHzBandSupported()}
+ */
+ @Test
+ public void testIs6GHzBandSupported() throws Exception {
+ when(mWifiService.is6GHzBandSupported()).thenReturn(true);
+ assertTrue(mWifiManager.is6GHzBandSupported());
+ verify(mWifiService).is6GHzBandSupported();
}
/**
diff --git a/wifi/tests/src/android/net/wifi/wificond/NativeScanResultTest.java b/wifi/tests/src/android/net/wifi/wificond/NativeScanResultTest.java
new file mode 100644
index 0000000..06f12f7
--- /dev/null
+++ b/wifi/tests/src/android/net/wifi/wificond/NativeScanResultTest.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2017 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 android.net.wifi.wificond;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import android.os.Parcel;
+
+import androidx.test.filters.SmallTest;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+
+/**
+ * Unit tests for {@link android.net.wifi.wificond.NativeScanResult}.
+ */
+@SmallTest
+public class NativeScanResultTest {
+
+ private static final byte[] TEST_SSID =
+ new byte[] {'G', 'o', 'o', 'g', 'l', 'e', 'G', 'u', 'e', 's', 't'};
+ private static final byte[] TEST_BSSID =
+ new byte[] {(byte) 0x12, (byte) 0xef, (byte) 0xa1,
+ (byte) 0x2c, (byte) 0x97, (byte) 0x8b};
+ private static final byte[] TEST_INFO_ELEMENT =
+ new byte[] {(byte) 0x01, (byte) 0x03, (byte) 0x12, (byte) 0xbe, (byte) 0xff};
+ private static final int TEST_FREQUENCY = 2456;
+ private static final int TEST_SIGNAL_MBM = -45;
+ private static final long TEST_TSF = 34455441;
+ private static final BitSet TEST_CAPABILITY = new BitSet(16) {{ set(2); set(5); }};
+ private static final boolean TEST_ASSOCIATED = true;
+ private static final int[] RADIO_CHAIN_IDS = { 0, 1 };
+ private static final int[] RADIO_CHAIN_LEVELS = { -56, -65 };
+
+ /**
+ * NativeScanResult object can be serialized and deserialized, while keeping the
+ * values unchanged.
+ */
+ @Test
+ public void canSerializeAndDeserialize() {
+ NativeScanResult scanResult = new NativeScanResult();
+ scanResult.ssid = TEST_SSID;
+ scanResult.bssid = TEST_BSSID;
+ scanResult.infoElement = TEST_INFO_ELEMENT;
+ scanResult.frequency = TEST_FREQUENCY;
+ scanResult.signalMbm = TEST_SIGNAL_MBM;
+ scanResult.tsf = TEST_TSF;
+ scanResult.capability = TEST_CAPABILITY;
+ scanResult.associated = TEST_ASSOCIATED;
+ scanResult.radioChainInfos = new ArrayList<>(Arrays.asList(
+ new RadioChainInfo(RADIO_CHAIN_IDS[0], RADIO_CHAIN_LEVELS[0]),
+ new RadioChainInfo(RADIO_CHAIN_IDS[1], RADIO_CHAIN_LEVELS[1])));
+ Parcel parcel = Parcel.obtain();
+ scanResult.writeToParcel(parcel, 0);
+ // Rewind the pointer to the head of the parcel.
+ parcel.setDataPosition(0);
+ NativeScanResult scanResultDeserialized = NativeScanResult.CREATOR.createFromParcel(parcel);
+
+ assertArrayEquals(scanResult.ssid, scanResultDeserialized.ssid);
+ assertArrayEquals(scanResult.bssid, scanResultDeserialized.bssid);
+ assertArrayEquals(scanResult.infoElement, scanResultDeserialized.infoElement);
+ assertEquals(scanResult.frequency, scanResultDeserialized.frequency);
+ assertEquals(scanResult.signalMbm, scanResultDeserialized.signalMbm);
+ assertEquals(scanResult.tsf, scanResultDeserialized.tsf);
+ assertEquals(scanResult.capability, scanResultDeserialized.capability);
+ assertEquals(scanResult.associated, scanResultDeserialized.associated);
+ assertTrue(scanResult.radioChainInfos.containsAll(scanResultDeserialized.radioChainInfos));
+ }
+}
diff --git a/wifi/tests/src/android/net/wifi/wificond/PnoSettingsTest.java b/wifi/tests/src/android/net/wifi/wificond/PnoSettingsTest.java
new file mode 100644
index 0000000..775acc7
--- /dev/null
+++ b/wifi/tests/src/android/net/wifi/wificond/PnoSettingsTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2017 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 android.net.wifi.wificond;
+
+import static org.junit.Assert.assertEquals;
+
+import android.os.Parcel;
+
+import androidx.test.filters.SmallTest;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+
+/**
+ * Unit tests for {@link android.net.wifi.wificond.PnoSettingsResult}.
+ */
+@SmallTest
+public class PnoSettingsTest {
+
+ private static final byte[] TEST_SSID_1 =
+ new byte[] {'G', 'o', 'o', 'g', 'l', 'e', 'G', 'u', 'e', 's', 't'};
+ private static final byte[] TEST_SSID_2 =
+ new byte[] {'A', 'n', 'd', 'r', 'o', 'i', 'd', 'T', 'e', 's', 't'};
+ private static final int[] TEST_FREQUENCIES_1 = {};
+ private static final int[] TEST_FREQUENCIES_2 = {2500, 5124};
+ private static final int TEST_INTERVAL_MS = 30000;
+ private static final int TEST_MIN_2G_RSSI = -60;
+ private static final int TEST_MIN_5G_RSSI = -65;
+ private static final int TEST_VALUE = 42;
+
+ private PnoNetwork mPnoNetwork1;
+ private PnoNetwork mPnoNetwork2;
+
+ @Before
+ public void setUp() {
+ mPnoNetwork1 = new PnoNetwork();
+ mPnoNetwork1.ssid = TEST_SSID_1;
+ mPnoNetwork1.isHidden = true;
+ mPnoNetwork1.frequencies = TEST_FREQUENCIES_1;
+
+ mPnoNetwork2 = new PnoNetwork();
+ mPnoNetwork2.ssid = TEST_SSID_2;
+ mPnoNetwork2.isHidden = false;
+ mPnoNetwork2.frequencies = TEST_FREQUENCIES_2;
+ }
+
+ /**
+ * PnoSettings object can be serialized and deserialized, while keeping the
+ * values unchanged.
+ */
+ @Test
+ public void canSerializeAndDeserialize() {
+ PnoSettings pnoSettings = new PnoSettings();
+ pnoSettings.intervalMs = TEST_INTERVAL_MS;
+ pnoSettings.min2gRssi = TEST_MIN_2G_RSSI;
+ pnoSettings.min5gRssi = TEST_MIN_5G_RSSI;
+ pnoSettings.pnoNetworks = new ArrayList<>(Arrays.asList(mPnoNetwork1, mPnoNetwork2));
+
+ Parcel parcel = Parcel.obtain();
+ pnoSettings.writeToParcel(parcel, 0);
+ // Rewind the pointer to the head of the parcel.
+ parcel.setDataPosition(0);
+ PnoSettings pnoSettingsDeserialized = PnoSettings.CREATOR.createFromParcel(parcel);
+
+ assertEquals(pnoSettings, pnoSettingsDeserialized);
+ assertEquals(pnoSettings.hashCode(), pnoSettingsDeserialized.hashCode());
+ }
+
+ /**
+ * Tests usage of {@link PnoSettings} as a HashMap key type.
+ */
+ @Test
+ public void testAsHashMapKey() {
+ PnoSettings pnoSettings1 = new PnoSettings();
+ pnoSettings1.intervalMs = TEST_INTERVAL_MS;
+ pnoSettings1.min2gRssi = TEST_MIN_2G_RSSI;
+ pnoSettings1.min5gRssi = TEST_MIN_5G_RSSI;
+ pnoSettings1.pnoNetworks = new ArrayList<>(Arrays.asList(mPnoNetwork1, mPnoNetwork2));
+
+ PnoSettings pnoSettings2 = new PnoSettings();
+ pnoSettings2.intervalMs = TEST_INTERVAL_MS;
+ pnoSettings2.min2gRssi = TEST_MIN_2G_RSSI;
+ pnoSettings2.min5gRssi = TEST_MIN_5G_RSSI;
+ pnoSettings2.pnoNetworks = new ArrayList<>(Arrays.asList(mPnoNetwork1, mPnoNetwork2));
+
+ assertEquals(pnoSettings1, pnoSettings2);
+ assertEquals(pnoSettings1.hashCode(), pnoSettings2.hashCode());
+
+ HashMap<PnoSettings, Integer> map = new HashMap<>();
+ map.put(pnoSettings1, TEST_VALUE);
+
+ assertEquals(TEST_VALUE, map.get(pnoSettings2).intValue());
+ }
+}
diff --git a/wifi/tests/src/android/net/wifi/wificond/SingleScanSettingsTest.java b/wifi/tests/src/android/net/wifi/wificond/SingleScanSettingsTest.java
new file mode 100644
index 0000000..ef59839
--- /dev/null
+++ b/wifi/tests/src/android/net/wifi/wificond/SingleScanSettingsTest.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2017 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 android.net.wifi.wificond;
+
+import static org.junit.Assert.assertEquals;
+
+import android.net.wifi.IWifiScannerImpl;
+import android.os.Parcel;
+
+import androidx.test.filters.SmallTest;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+
+/**
+ * Unit tests for {@link android.net.wifi.wificond.SingleScanSettingsResult}.
+ */
+@SmallTest
+public class SingleScanSettingsTest {
+
+ private static final byte[] TEST_SSID_1 =
+ new byte[] {'G', 'o', 'o', 'g', 'l', 'e', 'G', 'u', 'e', 's', 't'};
+ private static final byte[] TEST_SSID_2 =
+ new byte[] {'A', 'n', 'd', 'r', 'o', 'i', 'd', 'T', 'e', 's', 't'};
+ private static final int TEST_FREQUENCY_1 = 2456;
+ private static final int TEST_FREQUENCY_2 = 5215;
+ private static final int TEST_VALUE = 42;
+
+ private ChannelSettings mChannelSettings1;
+ private ChannelSettings mChannelSettings2;
+ private HiddenNetwork mHiddenNetwork1;
+ private HiddenNetwork mHiddenNetwork2;
+
+ @Before
+ public void setUp() {
+ mChannelSettings1 = new ChannelSettings();
+ mChannelSettings1.frequency = TEST_FREQUENCY_1;
+ mChannelSettings2 = new ChannelSettings();
+ mChannelSettings2.frequency = TEST_FREQUENCY_2;
+
+ mHiddenNetwork1 = new HiddenNetwork();
+ mHiddenNetwork1.ssid = TEST_SSID_1;
+ mHiddenNetwork2 = new HiddenNetwork();
+ mHiddenNetwork2.ssid = TEST_SSID_2;
+ }
+
+ /**
+ * SingleScanSettings object can be serialized and deserialized, while keeping the
+ * values unchanged.
+ */
+ @Test
+ public void canSerializeAndDeserialize() {
+ SingleScanSettings scanSettings = new SingleScanSettings();
+ scanSettings.scanType = IWifiScannerImpl.SCAN_TYPE_HIGH_ACCURACY;
+
+ scanSettings.channelSettings =
+ new ArrayList<>(Arrays.asList(mChannelSettings1, mChannelSettings2));
+ scanSettings.hiddenNetworks =
+ new ArrayList<>(Arrays.asList(mHiddenNetwork1, mHiddenNetwork2));
+
+ Parcel parcel = Parcel.obtain();
+ scanSettings.writeToParcel(parcel, 0);
+ // Rewind the pointer to the head of the parcel.
+ parcel.setDataPosition(0);
+ SingleScanSettings scanSettingsDeserialized =
+ SingleScanSettings.CREATOR.createFromParcel(parcel);
+
+ assertEquals(scanSettings, scanSettingsDeserialized);
+ assertEquals(scanSettings.hashCode(), scanSettingsDeserialized.hashCode());
+ }
+
+ /**
+ * Tests usage of {@link SingleScanSettings} as a HashMap key type.
+ */
+ @Test
+ public void testAsHashMapKey() {
+ SingleScanSettings scanSettings1 = new SingleScanSettings();
+ scanSettings1.scanType = IWifiScannerImpl.SCAN_TYPE_HIGH_ACCURACY;
+ scanSettings1.channelSettings =
+ new ArrayList<>(Arrays.asList(mChannelSettings1, mChannelSettings2));
+ scanSettings1.hiddenNetworks =
+ new ArrayList<>(Arrays.asList(mHiddenNetwork1, mHiddenNetwork2));
+
+ SingleScanSettings scanSettings2 = new SingleScanSettings();
+ scanSettings2.scanType = IWifiScannerImpl.SCAN_TYPE_HIGH_ACCURACY;
+ scanSettings2.channelSettings =
+ new ArrayList<>(Arrays.asList(mChannelSettings1, mChannelSettings2));
+ scanSettings2.hiddenNetworks =
+ new ArrayList<>(Arrays.asList(mHiddenNetwork1, mHiddenNetwork2));
+
+ assertEquals(scanSettings1, scanSettings2);
+ assertEquals(scanSettings1.hashCode(), scanSettings2.hashCode());
+
+ HashMap<SingleScanSettings, Integer> map = new HashMap<>();
+ map.put(scanSettings1, TEST_VALUE);
+
+ assertEquals(TEST_VALUE, map.get(scanSettings2).intValue());
+ }
+}