Merge "Atoms.proto PROFILE_CLONE entry" into sc-dev
diff --git a/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__arm_CtsShimPriv_apk.asciipb b/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__arm_CtsShimPriv_apk.asciipb
index 1bd90a8..cfcb4e7 100644
--- a/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__arm_CtsShimPriv_apk.asciipb
+++ b/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__arm_CtsShimPriv_apk.asciipb
@@ -1,6 +1,6 @@
drops {
android_build_drop {
- build_id: "7197701"
+ build_id: "7351002"
target: "CtsShim"
source_file: "aosp_arm64/CtsShimPriv.apk"
}
diff --git a/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__arm_CtsShim_apk.asciipb b/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__arm_CtsShim_apk.asciipb
index 544bca02..0948e47 100644
--- a/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__arm_CtsShim_apk.asciipb
+++ b/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__arm_CtsShim_apk.asciipb
@@ -1,6 +1,6 @@
drops {
android_build_drop {
- build_id: "7197701"
+ build_id: "7351002"
target: "CtsShim"
source_file: "aosp_arm64/CtsShim.apk"
}
diff --git a/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__x86_CtsShimPriv_apk.asciipb b/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__x86_CtsShimPriv_apk.asciipb
index 72386bb..db64475 100644
--- a/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__x86_CtsShimPriv_apk.asciipb
+++ b/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__x86_CtsShimPriv_apk.asciipb
@@ -1,6 +1,6 @@
drops {
android_build_drop {
- build_id: "7197701"
+ build_id: "7351002"
target: "CtsShim"
source_file: "aosp_x86_64/CtsShimPriv.apk"
}
diff --git a/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__x86_CtsShim_apk.asciipb b/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__x86_CtsShim_apk.asciipb
index 893eac2..80812df 100644
--- a/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__x86_CtsShim_apk.asciipb
+++ b/.prebuilt_info/prebuilt_info_packages_CtsShim_apk__x86_CtsShim_apk.asciipb
@@ -1,6 +1,6 @@
drops {
android_build_drop {
- build_id: "7197701"
+ build_id: "7351002"
target: "CtsShim"
source_file: "aosp_x86_64/CtsShim.apk"
}
diff --git a/Android.bp b/Android.bp
index d75239a..7c9cdcf 100644
--- a/Android.bp
+++ b/Android.bp
@@ -483,6 +483,19 @@
"--api-lint-ignore-prefix junit. " +
"--api-lint-ignore-prefix org. "
+packages_to_document = [
+ "android",
+ "dalvik",
+ "java",
+ "javax",
+ "junit",
+ "org.apache.http",
+ "org.json",
+ "org.w3c.dom",
+ "org.xml.sax",
+ "org.xmlpull",
+]
+
filegroup {
name: "android-non-updatable-stub-sources",
srcs: [
@@ -535,7 +548,7 @@
"android.hardware.usb.gadget-V1.0-java",
"android.hardware.vibrator-V1.3-java",
"framework-protos",
- "stable.core.platform.api.stubs",
+ "art.module.public.api",
// There are a few classes from modules used by the core that
// need to be resolved by metalava. We use a prebuilt stub of the
// full sdk to ensure we can resolve them. If a new class gets added,
@@ -544,6 +557,7 @@
// NOTE: The below can be removed once the prebuilt stub contains IKE.
"sdk_system_current_android.net.ipsec.ike",
],
+ filter_packages: packages_to_document,
high_mem: true, // Lots of sources => high memory use, see b/170701554
installable: false,
annotations_enabled: true,
diff --git a/ApiDocs.bp b/ApiDocs.bp
index 0f218b5..0aed5d9 100644
--- a/ApiDocs.bp
+++ b/ApiDocs.bp
@@ -93,13 +93,14 @@
":updatable-media-srcs",
// No longer part of the stubs, but are included in the docs.
- "test-base/src/**/*.java",
- "test-mock/src/**/*.java",
- "test-runner/src/**/*.java",
+ ":android-test-base-sources",
+ ":android-test-mock-sources",
+ ":android-test-runner-sources",
],
libs: framework_docs_only_libs,
create_doc_stubs: true,
annotations_enabled: true,
+ filter_packages: packages_to_document,
api_levels_annotations_enabled: true,
api_levels_annotations_dirs: [
"sdk-dir",
diff --git a/StubLibraries.bp b/StubLibraries.bp
index 7b8a687..ed24d43 100644
--- a/StubLibraries.bp
+++ b/StubLibraries.bp
@@ -27,24 +27,10 @@
// Common metalava configs
/////////////////////////////////////////////////////////////////////
-packages_to_document = [
- "android",
- "dalvik",
- "java",
- "javax",
- "junit",
- "org.apache.http",
- "org.json",
- "org.w3c.dom",
- "org.xml.sax",
- "org.xmlpull",
-]
-
stubs_defaults {
name: "metalava-non-updatable-api-stubs-default",
defaults: ["android-non-updatable-stubs-defaults"],
api_levels_annotations_enabled: false,
- filter_packages: packages_to_document,
defaults_visibility: ["//visibility:private"],
}
diff --git a/apct-tests/perftests/core/src/android/app/ResourcesManagerPerfTest.java b/apct-tests/perftests/core/src/android/app/ResourcesManagerPerfTest.java
index afd8e29..ac63653 100644
--- a/apct-tests/perftests/core/src/android/app/ResourcesManagerPerfTest.java
+++ b/apct-tests/perftests/core/src/android/app/ResourcesManagerPerfTest.java
@@ -144,7 +144,7 @@
while (state.keepRunning()) {
state.pauseTiming();
// Invalidate cache.
- resourcesManager.applyConfigurationToResourcesLocked(
+ resourcesManager.applyConfigurationToResources(
resourcesManager.getConfiguration(), null);
state.resumeTiming();
diff --git a/apex/appsearch/Android.bp b/apex/appsearch/Android.bp
index 87f65a9..c592d13 100644
--- a/apex/appsearch/Android.bp
+++ b/apex/appsearch/Android.bp
@@ -24,8 +24,8 @@
apex {
name: "com.android.appsearch",
manifest: "apex_manifest.json",
+ bootclasspath_fragments: ["com.android.appsearch-bootclasspath-fragment"],
java_libs: [
- "framework-appsearch",
"service-appsearch",
],
key: "com.android.appsearch.key",
@@ -45,3 +45,10 @@
// com.android.appsearch.pk8 (the private key)
certificate: "com.android.appsearch",
}
+
+// Encapsulate the contributions made by the com.android.appsearch to the bootclasspath.
+bootclasspath_fragment {
+ name: "com.android.appsearch-bootclasspath-fragment",
+ contents: ["framework-appsearch"],
+ apex_available: ["com.android.appsearch"],
+}
diff --git a/apex/appsearch/framework/api/current.txt b/apex/appsearch/framework/api/current.txt
index 4dff436..5a2f702 100644
--- a/apex/appsearch/framework/api/current.txt
+++ b/apex/appsearch/framework/api/current.txt
@@ -290,14 +290,12 @@
method @NonNull public String getDatabaseName();
method @NonNull public android.app.appsearch.GenericDocument getGenericDocument();
method @NonNull public java.util.List<android.app.appsearch.SearchResult.MatchInfo> getMatchInfos();
- method @Deprecated @NonNull public java.util.List<android.app.appsearch.SearchResult.MatchInfo> getMatches();
method @NonNull public String getPackageName();
method public double getRankingSignal();
}
public static final class SearchResult.Builder {
ctor public SearchResult.Builder(@NonNull String, @NonNull String);
- method @Deprecated @NonNull public android.app.appsearch.SearchResult.Builder addMatch(@NonNull android.app.appsearch.SearchResult.MatchInfo);
method @NonNull public android.app.appsearch.SearchResult.Builder addMatchInfo(@NonNull android.app.appsearch.SearchResult.MatchInfo);
method @NonNull public android.app.appsearch.SearchResult build();
method @NonNull public android.app.appsearch.SearchResult.Builder setGenericDocument(@NonNull android.app.appsearch.GenericDocument);
diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchBatchResult.aidl b/apex/appsearch/framework/java/android/app/appsearch/AppSearchBatchResult.aidl
deleted file mode 100644
index 4686de8..0000000
--- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchBatchResult.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright 2020, 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.app.appsearch;
-
-/** {@hide} */
-parcelable AppSearchBatchResult;
\ No newline at end of file
diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchManager.java b/apex/appsearch/framework/java/android/app/appsearch/AppSearchManager.java
index c4dd1a0..bc3c79f 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchManager.java
+++ b/apex/appsearch/framework/java/android/app/appsearch/AppSearchManager.java
@@ -18,6 +18,7 @@
import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.SystemService;
+import android.app.appsearch.aidl.IAppSearchManager;
import android.content.Context;
import com.android.internal.util.Preconditions;
diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchManagerFrameworkInitializer.java b/apex/appsearch/framework/java/android/app/appsearch/AppSearchManagerFrameworkInitializer.java
index ec0533e..7dc527a 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchManagerFrameworkInitializer.java
+++ b/apex/appsearch/framework/java/android/app/appsearch/AppSearchManagerFrameworkInitializer.java
@@ -17,6 +17,7 @@
import android.annotation.SystemApi;
import android.app.SystemServiceRegistry;
+import android.app.appsearch.aidl.IAppSearchManager;
import android.content.Context;
/**
diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchMigrationHelper.java b/apex/appsearch/framework/java/android/app/appsearch/AppSearchMigrationHelper.java
index 0089c6d..353051c 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchMigrationHelper.java
+++ b/apex/appsearch/framework/java/android/app/appsearch/AppSearchMigrationHelper.java
@@ -23,6 +23,9 @@
import android.annotation.NonNull;
import android.annotation.UserIdInt;
import android.annotation.WorkerThread;
+import android.app.appsearch.aidl.AppSearchResultParcel;
+import android.app.appsearch.aidl.IAppSearchManager;
+import android.app.appsearch.aidl.IAppSearchResultCallback;
import android.app.appsearch.exceptions.AppSearchException;
import android.os.Bundle;
import android.os.Parcel;
@@ -105,8 +108,8 @@
mUserId,
new IAppSearchResultCallback.Stub() {
@Override
- public void onResult(AppSearchResult result) {
- future.complete(result);
+ public void onResult(AppSearchResultParcel resultParcel) {
+ future.complete(resultParcel.getResult());
}
});
AppSearchResult<Void> result = future.get();
@@ -145,8 +148,8 @@
mService.putDocumentsFromFile(mPackageName, mDatabaseName, fileDescriptor, mUserId,
new IAppSearchResultCallback.Stub() {
@Override
- public void onResult(AppSearchResult result) {
- future.complete(result);
+ public void onResult(AppSearchResultParcel resultParcel) {
+ future.complete(resultParcel.getResult());
}
});
AppSearchResult<List<Bundle>> result = future.get();
diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java b/apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java
index c112d0e..5910130 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java
+++ b/apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java
@@ -19,6 +19,11 @@
import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.UserIdInt;
+import android.app.appsearch.aidl.AppSearchBatchResultParcel;
+import android.app.appsearch.aidl.AppSearchResultParcel;
+import android.app.appsearch.aidl.IAppSearchBatchResultCallback;
+import android.app.appsearch.aidl.IAppSearchManager;
+import android.app.appsearch.aidl.IAppSearchResultCallback;
import android.app.appsearch.exceptions.AppSearchException;
import android.app.appsearch.util.SchemaMigrationUtil;
import android.compat.annotation.UnsupportedAppUsage;
@@ -86,13 +91,15 @@
@NonNull Consumer<AppSearchResult<AppSearchSession>> callback) {
try {
mService.initialize(mUserId, new IAppSearchResultCallback.Stub() {
- public void onResult(AppSearchResult result) {
+ @Override
+ public void onResult(AppSearchResultParcel resultParcel) {
executor.execute(() -> {
+ AppSearchResult<Void> result = resultParcel.getResult();
if (result.isSuccess()) {
callback.accept(
AppSearchResult.newSuccessfulResult(AppSearchSession.this));
} else {
- callback.accept(result);
+ callback.accept(AppSearchResult.newFailedResult(result));
}
});
}
@@ -191,15 +198,16 @@
mDatabaseName,
mUserId,
new IAppSearchResultCallback.Stub() {
- public void onResult(AppSearchResult result) {
+ @Override
+ public void onResult(AppSearchResultParcel resultParcel) {
executor.execute(() -> {
+ AppSearchResult<Bundle> result = resultParcel.getResult();
if (result.isSuccess()) {
- Bundle responseBundle = (Bundle) result.getResultValue();
GetSchemaResponse response =
- new GetSchemaResponse(responseBundle);
+ new GetSchemaResponse(result.getResultValue());
callback.accept(AppSearchResult.newSuccessfulResult(response));
} else {
- callback.accept(result);
+ callback.accept(AppSearchResult.newFailedResult(result));
}
});
}
@@ -227,15 +235,17 @@
mDatabaseName,
mUserId,
new IAppSearchResultCallback.Stub() {
- public void onResult(AppSearchResult result) {
+ @Override
+ public void onResult(AppSearchResultParcel resultParcel) {
executor.execute(() -> {
+ AppSearchResult<List<String>> result = resultParcel.getResult();
if (result.isSuccess()) {
Set<String> namespaces =
- new ArraySet<>((List<String>) result.getResultValue());
+ new ArraySet<>(result.getResultValue());
callback.accept(
AppSearchResult.newSuccessfulResult(namespaces));
} else {
- callback.accept(result);
+ callback.accept(AppSearchResult.newFailedResult(result));
}
});
}
@@ -280,13 +290,14 @@
/*binderCallStartTimeMillis=*/ SystemClock.elapsedRealtime(),
new IAppSearchBatchResultCallback.Stub() {
@Override
- public void onResult(AppSearchBatchResult result) {
- executor.execute(() -> callback.onResult(result));
+ public void onResult(AppSearchBatchResultParcel resultParcel) {
+ executor.execute(() -> callback.onResult(resultParcel.getResult()));
}
@Override
- public void onSystemError(AppSearchResult result) {
- executor.execute(() -> sendSystemErrorToCallback(result, callback));
+ public void onSystemError(AppSearchResultParcel resultParcel) {
+ executor.execute(() -> sendSystemErrorToCallback(
+ resultParcel.getResult(), callback));
}
});
mIsMutated = true;
@@ -341,15 +352,17 @@
mUserId,
new IAppSearchBatchResultCallback.Stub() {
@Override
- public void onResult(AppSearchBatchResult result) {
+ public void onResult(AppSearchBatchResultParcel resultParcel) {
executor.execute(() -> {
+ AppSearchBatchResult<String, Bundle> result =
+ resultParcel.getResult();
AppSearchBatchResult.Builder<String, GenericDocument>
documentResultBuilder =
new AppSearchBatchResult.Builder<>();
// Translate successful results
for (Map.Entry<String, Bundle> bundleEntry :
- ((Map<String, Bundle>) result.getSuccesses()).entrySet()) {
+ result.getSuccesses().entrySet()) {
GenericDocument document;
try {
document = new GenericDocument(bundleEntry.getValue());
@@ -380,8 +393,9 @@
}
@Override
- public void onSystemError(AppSearchResult result) {
- executor.execute(() -> sendSystemErrorToCallback(result, callback));
+ public void onSystemError(AppSearchResultParcel result) {
+ executor.execute(
+ () -> sendSystemErrorToCallback(result.getResult(), callback));
}
});
} catch (RemoteException e) {
@@ -492,8 +506,9 @@
/*systemUsage=*/ false,
mUserId,
new IAppSearchResultCallback.Stub() {
- public void onResult(AppSearchResult result) {
- executor.execute(() -> callback.accept(result));
+ @Override
+ public void onResult(AppSearchResultParcel resultParcel) {
+ executor.execute(() -> callback.accept(resultParcel.getResult()));
}
});
mIsMutated = true;
@@ -550,13 +565,14 @@
new ArrayList<>(request.getIds()), mUserId,
new IAppSearchBatchResultCallback.Stub() {
@Override
- public void onResult(AppSearchBatchResult result) {
- executor.execute(() -> callback.onResult(result));
+ public void onResult(AppSearchBatchResultParcel resultParcel) {
+ executor.execute(() -> callback.onResult(resultParcel.getResult()));
}
@Override
- public void onSystemError(AppSearchResult result) {
- executor.execute(() -> sendSystemErrorToCallback(result, callback));
+ public void onSystemError(AppSearchResultParcel resultParcel) {
+ executor.execute(() -> sendSystemErrorToCallback(
+ resultParcel.getResult(), callback));
}
});
mIsMutated = true;
@@ -598,8 +614,9 @@
mService.removeByQuery(mPackageName, mDatabaseName, queryExpression,
searchSpec.getBundle(), mUserId,
new IAppSearchResultCallback.Stub() {
- public void onResult(AppSearchResult result) {
- executor.execute(() -> callback.accept(result));
+ @Override
+ public void onResult(AppSearchResultParcel resultParcel) {
+ executor.execute(() -> callback.accept(resultParcel.getResult()));
}
});
mIsMutated = true;
@@ -629,15 +646,15 @@
mDatabaseName,
mUserId,
new IAppSearchResultCallback.Stub() {
- public void onResult(AppSearchResult result) {
+ @Override
+ public void onResult(AppSearchResultParcel resultParcel) {
executor.execute(() -> {
+ AppSearchResult<Bundle> result = resultParcel.getResult();
if (result.isSuccess()) {
- Bundle responseBundle = (Bundle) result.getResultValue();
- StorageInfo response =
- new StorageInfo(responseBundle);
+ StorageInfo response = new StorageInfo(result.getResultValue());
callback.accept(AppSearchResult.newSuccessfulResult(response));
} else {
- callback.accept(result);
+ callback.accept(AppSearchResult.newFailedResult(result));
}
});
}
@@ -686,13 +703,14 @@
request.getVersion(),
mUserId,
new IAppSearchResultCallback.Stub() {
- public void onResult(AppSearchResult result) {
+ @Override
+ public void onResult(AppSearchResultParcel resultParcel) {
executor.execute(() -> {
+ AppSearchResult<Bundle> result = resultParcel.getResult();
if (result.isSuccess()) {
try {
SetSchemaResponse setSchemaResponse =
- new SetSchemaResponse(
- (Bundle) result.getResultValue());
+ new SetSchemaResponse(result.getResultValue());
if (!request.isForceOverride()) {
// Throw exception if there is any deleted types or
// incompatible types. That's the only case we swallowed
@@ -707,7 +725,7 @@
callback.accept(AppSearchResult.throwableToFailedResult(t));
}
} else {
- callback.accept(result);
+ callback.accept(AppSearchResult.newFailedResult(result));
}
});
}
@@ -772,8 +790,9 @@
request.getVersion(),
mUserId,
new IAppSearchResultCallback.Stub() {
- public void onResult(AppSearchResult result) {
- setSchemaFuture.complete(result);
+ @Override
+ public void onResult(AppSearchResultParcel resultParcel) {
+ setSchemaFuture.complete(resultParcel.getResult());
}
});
AppSearchResult<Bundle> setSchemaResult = setSchemaFuture.get();
@@ -823,8 +842,8 @@
mUserId,
new IAppSearchResultCallback.Stub() {
@Override
- public void onResult(AppSearchResult result) {
- setSchema2Future.complete(result);
+ public void onResult(AppSearchResultParcel resultParcel) {
+ setSchema2Future.complete(resultParcel.getResult());
}
});
AppSearchResult<Bundle> setSchema2Result = setSchema2Future.get();
diff --git a/apex/appsearch/framework/java/android/app/appsearch/GlobalSearchSession.java b/apex/appsearch/framework/java/android/app/appsearch/GlobalSearchSession.java
index d49f472..7d246c2 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/GlobalSearchSession.java
+++ b/apex/appsearch/framework/java/android/app/appsearch/GlobalSearchSession.java
@@ -16,10 +16,12 @@
package android.app.appsearch;
-
import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.UserIdInt;
+import android.app.appsearch.aidl.AppSearchResultParcel;
+import android.app.appsearch.aidl.IAppSearchManager;
+import android.app.appsearch.aidl.IAppSearchResultCallback;
import android.os.RemoteException;
import android.util.Log;
@@ -71,13 +73,15 @@
@NonNull Consumer<AppSearchResult<GlobalSearchSession>> callback) {
try {
mService.initialize(mUserId, new IAppSearchResultCallback.Stub() {
- public void onResult(AppSearchResult result) {
+ @Override
+ public void onResult(AppSearchResultParcel resultParcel) {
executor.execute(() -> {
+ AppSearchResult<Void> result = resultParcel.getResult();
if (result.isSuccess()) {
callback.accept(
AppSearchResult.newSuccessfulResult(GlobalSearchSession.this));
} else {
- callback.accept(result);
+ callback.accept(AppSearchResult.newFailedResult(result));
}
});
}
@@ -159,8 +163,9 @@
/*systemUsage=*/ true,
mUserId,
new IAppSearchResultCallback.Stub() {
- public void onResult(AppSearchResult result) {
- executor.execute(() -> callback.accept(result));
+ @Override
+ public void onResult(AppSearchResultParcel resultParcel) {
+ executor.execute(() -> callback.accept(resultParcel.getResult()));
}
});
mIsMutated = true;
diff --git a/apex/appsearch/framework/java/android/app/appsearch/SearchResults.java b/apex/appsearch/framework/java/android/app/appsearch/SearchResults.java
index 531c984..4368672 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/SearchResults.java
+++ b/apex/appsearch/framework/java/android/app/appsearch/SearchResults.java
@@ -20,6 +20,9 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
+import android.app.appsearch.aidl.AppSearchResultParcel;
+import android.app.appsearch.aidl.IAppSearchManager;
+import android.app.appsearch.aidl.IAppSearchResultCallback;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
@@ -139,18 +142,20 @@
@NonNull @CallbackExecutor Executor executor,
@NonNull Consumer<AppSearchResult<List<SearchResult>>> callback) {
return new IAppSearchResultCallback.Stub() {
- public void onResult(AppSearchResult result) {
- executor.execute(() -> invokeCallback(result, callback));
+ @Override
+ public void onResult(AppSearchResultParcel resultParcel) {
+ executor.execute(() -> invokeCallback(resultParcel.getResult(), callback));
}
};
}
- private void invokeCallback(AppSearchResult result,
+ private void invokeCallback(
+ @NonNull AppSearchResult<Bundle> searchResultPageResult,
@NonNull Consumer<AppSearchResult<List<SearchResult>>> callback) {
- if (result.isSuccess()) {
+ if (searchResultPageResult.isSuccess()) {
try {
SearchResultPage searchResultPage =
- new SearchResultPage((Bundle) result.getResultValue());
+ new SearchResultPage(searchResultPageResult.getResultValue());
mNextPageToken = searchResultPage.getNextPageToken();
callback.accept(AppSearchResult.newSuccessfulResult(
searchResultPage.getResults()));
@@ -158,7 +163,7 @@
callback.accept(AppSearchResult.throwableToFailedResult(t));
}
} else {
- callback.accept(result);
+ callback.accept(AppSearchResult.newFailedResult(searchResultPageResult));
}
}
}
diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl b/apex/appsearch/framework/java/android/app/appsearch/aidl/AppSearchBatchResultParcel.aidl
similarity index 80%
copy from apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl
copy to apex/appsearch/framework/java/android/app/appsearch/aidl/AppSearchBatchResultParcel.aidl
index 37ce990..89908cd 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl
+++ b/apex/appsearch/framework/java/android/app/appsearch/aidl/AppSearchBatchResultParcel.aidl
@@ -1,5 +1,5 @@
/**
- * Copyright 2020, The Android Open Source Project
+ * Copyright 2021, 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.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.app.appsearch;
+package android.app.appsearch.aidl;
/** {@hide} */
-parcelable AppSearchResult<ValueType>;
\ No newline at end of file
+parcelable AppSearchBatchResultParcel<ValueType>;
diff --git a/apex/appsearch/framework/java/android/app/appsearch/aidl/AppSearchBatchResultParcel.java b/apex/appsearch/framework/java/android/app/appsearch/aidl/AppSearchBatchResultParcel.java
new file mode 100644
index 0000000..b0cc10c
--- /dev/null
+++ b/apex/appsearch/framework/java/android/app/appsearch/aidl/AppSearchBatchResultParcel.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2021 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.app.appsearch.aidl;
+
+import android.annotation.NonNull;
+import android.app.appsearch.AppSearchBatchResult;
+import android.app.appsearch.AppSearchResult;
+import android.os.Bundle;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Parcelable wrapper around {@link AppSearchBatchResult}.
+ *
+ * <p>{@link AppSearchBatchResult} can contain any type of key and value, including non-parcelable
+ * values. For the specific case of sending {@link AppSearchBatchResult} across Binder, this class
+ * wraps an {@link AppSearchBatchResult} that has String keys and Parcelable values. It provides
+ * parcelability of the whole structure.
+ *
+ * @param <ValueType> The type of result object for successful calls. Must be a parcelable type.
+ * @hide
+ */
+public final class AppSearchBatchResultParcel<ValueType> implements Parcelable {
+ private final AppSearchBatchResult<String, ValueType> mResult;
+
+ /** Creates a new {@link AppSearchBatchResultParcel} from the given result. */
+ public AppSearchBatchResultParcel(@NonNull AppSearchBatchResult<String, ValueType> result) {
+ mResult = Objects.requireNonNull(result);
+ }
+
+ private AppSearchBatchResultParcel(@NonNull Parcel in) {
+ Bundle bundle = in.readBundle();
+ AppSearchBatchResult.Builder<String, ValueType> builder =
+ new AppSearchBatchResult.Builder<>();
+ for (String key : bundle.keySet()) {
+ AppSearchResultParcel<ValueType> resultParcel = bundle.getParcelable(key);
+ builder.setResult(key, resultParcel.getResult());
+ }
+ mResult = builder.build();
+ }
+
+ @NonNull
+ public AppSearchBatchResult<String, ValueType> getResult() {
+ return mResult;
+ }
+
+ /** @hide */
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ Bundle bundle = new Bundle();
+ for (Map.Entry<String, AppSearchResult<ValueType>> entry
+ : mResult.getAll().entrySet()) {
+ bundle.putParcelable(entry.getKey(), new AppSearchResultParcel<>(entry.getValue()));
+ }
+ dest.writeBundle(bundle);
+ }
+
+ /** @hide */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** @hide */
+ @NonNull
+ public static final Creator<AppSearchBatchResultParcel<?>> CREATOR =
+ new Creator<AppSearchBatchResultParcel<?>>() {
+ @NonNull
+ @Override
+ public AppSearchBatchResultParcel<?> createFromParcel(@NonNull Parcel in) {
+ return new AppSearchBatchResultParcel<>(in);
+ }
+
+ @NonNull
+ @Override
+ public AppSearchBatchResultParcel<?>[] newArray(int size) {
+ return new AppSearchBatchResultParcel<?>[size];
+ }
+ };
+}
diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl b/apex/appsearch/framework/java/android/app/appsearch/aidl/AppSearchResultParcel.aidl
similarity index 81%
rename from apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl
rename to apex/appsearch/framework/java/android/app/appsearch/aidl/AppSearchResultParcel.aidl
index 37ce990..4e35bd5 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl
+++ b/apex/appsearch/framework/java/android/app/appsearch/aidl/AppSearchResultParcel.aidl
@@ -1,5 +1,5 @@
/**
- * Copyright 2020, The Android Open Source Project
+ * Copyright 2021, 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.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.app.appsearch;
+package android.app.appsearch.aidl;
/** {@hide} */
-parcelable AppSearchResult<ValueType>;
\ No newline at end of file
+parcelable AppSearchResultParcel<ValueType>;
diff --git a/apex/appsearch/framework/java/android/app/appsearch/aidl/AppSearchResultParcel.java b/apex/appsearch/framework/java/android/app/appsearch/aidl/AppSearchResultParcel.java
new file mode 100644
index 0000000..8b137d3
--- /dev/null
+++ b/apex/appsearch/framework/java/android/app/appsearch/aidl/AppSearchResultParcel.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2021 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.app.appsearch.aidl;
+
+import android.annotation.NonNull;
+import android.app.appsearch.AppSearchResult;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Objects;
+
+/**
+ * Parcelable wrapper around {@link AppSearchResult}.
+ *
+ * <p>{@link AppSearchResult} can contain any value, including non-parcelable values. For the
+ * specific case of sending {@link AppSearchResult} across Binder, this class wraps an
+ * {@link AppSearchResult} that contains a parcelable type and provides parcelability of the whole
+ * structure.
+ *
+ * @param <ValueType> The type of result object for successful calls. Must be a parcelable type.
+ * @hide
+ */
+public final class AppSearchResultParcel<ValueType> implements Parcelable {
+ private final AppSearchResult<ValueType> mResult;
+
+ /** Creates a new {@link AppSearchResultParcel} from the given result. */
+ public AppSearchResultParcel(@NonNull AppSearchResult<ValueType> result) {
+ mResult = Objects.requireNonNull(result);
+ }
+
+ private AppSearchResultParcel(@NonNull Parcel in) {
+ int resultCode = in.readInt();
+ ValueType resultValue = (ValueType) in.readValue(/*loader=*/ null);
+ String errorMessage = in.readString();
+ if (resultCode == AppSearchResult.RESULT_OK) {
+ mResult = AppSearchResult.newSuccessfulResult(resultValue);
+ } else {
+ mResult = AppSearchResult.newFailedResult(resultCode, errorMessage);
+ }
+ }
+
+ @NonNull
+ public AppSearchResult<ValueType> getResult() {
+ return mResult;
+ }
+
+ /** @hide */
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeInt(mResult.getResultCode());
+ if (mResult.isSuccess()) {
+ dest.writeValue(mResult.getResultValue());
+ } else {
+ dest.writeValue(null);
+ }
+ dest.writeString(mResult.getErrorMessage());
+ }
+
+ /** @hide */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** @hide */
+ @NonNull
+ public static final Creator<AppSearchResultParcel<?>> CREATOR =
+ new Creator<AppSearchResultParcel<?>>() {
+ @NonNull
+ @Override
+ public AppSearchResultParcel<?> createFromParcel(@NonNull Parcel in) {
+ return new AppSearchResultParcel<>(in);
+ }
+
+ @NonNull
+ @Override
+ public AppSearchResultParcel<?>[] newArray(int size) {
+ return new AppSearchResultParcel<?>[size];
+ }
+ };
+}
diff --git a/apex/appsearch/framework/java/android/app/appsearch/IAppSearchBatchResultCallback.aidl b/apex/appsearch/framework/java/android/app/appsearch/aidl/IAppSearchBatchResultCallback.aidl
similarity index 70%
rename from apex/appsearch/framework/java/android/app/appsearch/IAppSearchBatchResultCallback.aidl
rename to apex/appsearch/framework/java/android/app/appsearch/aidl/IAppSearchBatchResultCallback.aidl
index 64b331e..1fe19cc 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/IAppSearchBatchResultCallback.aidl
+++ b/apex/appsearch/framework/java/android/app/appsearch/aidl/IAppSearchBatchResultCallback.aidl
@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.app.appsearch;
+package android.app.appsearch.aidl;
-import android.app.appsearch.AppSearchBatchResult;
-import android.app.appsearch.AppSearchResult;
+import android.app.appsearch.aidl.AppSearchBatchResultParcel;
+import android.app.appsearch.aidl.AppSearchResultParcel;
/** {@hide} */
oneway interface IAppSearchBatchResultCallback {
- void onResult(in AppSearchBatchResult result);
- void onSystemError(in AppSearchResult result);
+ void onResult(in AppSearchBatchResultParcel resultParcel);
+ void onSystemError(in AppSearchResultParcel resultParcel);
}
diff --git a/apex/appsearch/framework/java/android/app/appsearch/IAppSearchManager.aidl b/apex/appsearch/framework/java/android/app/appsearch/aidl/IAppSearchManager.aidl
similarity index 98%
rename from apex/appsearch/framework/java/android/app/appsearch/IAppSearchManager.aidl
rename to apex/appsearch/framework/java/android/app/appsearch/aidl/IAppSearchManager.aidl
index 507bd68..6f7e82e 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/IAppSearchManager.aidl
+++ b/apex/appsearch/framework/java/android/app/appsearch/aidl/IAppSearchManager.aidl
@@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.app.appsearch;
+package android.app.appsearch.aidl;
import android.os.Bundle;
-import android.app.appsearch.IAppSearchBatchResultCallback;
-import android.app.appsearch.IAppSearchResultCallback;
+import android.app.appsearch.aidl.IAppSearchBatchResultCallback;
+import android.app.appsearch.aidl.IAppSearchResultCallback;
import android.os.ParcelFileDescriptor;
/** {@hide} */
@@ -200,7 +200,7 @@
* @param searchSpecBundle SearchSpec bundle.
* @param userId Id of the calling user.
* @param callback {@link IAppSearchResultCallback#onResult} will be called with an
- * {@link AppSearchResult}<{@code null}>.
+ * {@link AppSearchResult}<{@code Void}>.
*/
void writeQueryResultsToFile(
in String packageName,
diff --git a/apex/appsearch/framework/java/android/app/appsearch/IAppSearchResultCallback.aidl b/apex/appsearch/framework/java/android/app/appsearch/aidl/IAppSearchResultCallback.aidl
similarity index 81%
rename from apex/appsearch/framework/java/android/app/appsearch/IAppSearchResultCallback.aidl
rename to apex/appsearch/framework/java/android/app/appsearch/aidl/IAppSearchResultCallback.aidl
index 299c995..097f0d1 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/IAppSearchResultCallback.aidl
+++ b/apex/appsearch/framework/java/android/app/appsearch/aidl/IAppSearchResultCallback.aidl
@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.app.appsearch;
+package android.app.appsearch.aidl;
-import android.app.appsearch.AppSearchResult;
+import android.app.appsearch.aidl.AppSearchResultParcel;
/** {@hide} */
oneway interface IAppSearchResultCallback {
- void onResult(in AppSearchResult result);
+ void onResult(in AppSearchResultParcel resultParcel);
}
diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchBatchResult.java b/apex/appsearch/framework/java/external/android/app/appsearch/AppSearchBatchResult.java
similarity index 63%
rename from apex/appsearch/framework/java/android/app/appsearch/AppSearchBatchResult.java
rename to apex/appsearch/framework/java/external/android/app/appsearch/AppSearchBatchResult.java
index 9ae0d62..f0b04fc 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchBatchResult.java
+++ b/apex/appsearch/framework/java/external/android/app/appsearch/AppSearchBatchResult.java
@@ -13,37 +13,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package android.app.appsearch;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.os.Parcel;
-import android.os.Parcelable;
import android.util.ArrayMap;
-import com.android.internal.util.Preconditions;
-
-import java.util.Collections;
import java.util.Map;
import java.util.Objects;
/**
* Provides results for AppSearch batch operations which encompass multiple documents.
*
- * <p>Individual results of a batch operation are separated into two maps: one for successes and
- * one for failures. For successes, {@link #getSuccesses()} will return a map of keys to
- * instances of the value type. For failures, {@link #getFailures()} will return a map of keys to
- * {@link AppSearchResult} objects.
+ * <p>Individual results of a batch operation are separated into two maps: one for successes and one
+ * for failures. For successes, {@link #getSuccesses()} will return a map of keys to instances of
+ * the value type. For failures, {@link #getFailures()} will return a map of keys to {@link
+ * AppSearchResult} objects.
*
* <p>Alternatively, {@link #getAll()} returns a map of keys to {@link AppSearchResult} objects for
* both successes and failures.
*
+ * @param <KeyType> The type of the keys for which the results will be reported.
+ * @param <ValueType> The type of the result objects for successful results.
* @see AppSearchSession#put
* @see AppSearchSession#getByDocumentId
* @see AppSearchSession#remove
*/
-public final class AppSearchBatchResult<KeyType, ValueType> implements Parcelable {
+public final class AppSearchBatchResult<KeyType, ValueType> {
@NonNull private final Map<KeyType, ValueType> mSuccesses;
@NonNull private final Map<KeyType, AppSearchResult<ValueType>> mFailures;
@NonNull private final Map<KeyType, AppSearchResult<ValueType>> mAll;
@@ -57,27 +53,6 @@
mAll = all;
}
- private AppSearchBatchResult(@NonNull Parcel in) {
- mAll = Collections.unmodifiableMap(in.readHashMap(/*loader=*/ null));
- Map<KeyType, ValueType> successes = new ArrayMap<>();
- Map<KeyType, AppSearchResult<ValueType>> failures = new ArrayMap<>();
- for (Map.Entry<KeyType, AppSearchResult<ValueType>> entry : mAll.entrySet()) {
- if (entry.getValue().isSuccess()) {
- successes.put(entry.getKey(), entry.getValue().getResultValue());
- } else {
- failures.put(entry.getKey(), entry.getValue());
- }
- }
- mSuccesses = Collections.unmodifiableMap(successes);
- mFailures = Collections.unmodifiableMap(failures);
- }
-
- /** @hide */
- @Override
- public void writeToParcel(@NonNull Parcel dest, int flags) {
- dest.writeMap(mAll);
- }
-
/** Returns {@code true} if this {@link AppSearchBatchResult} has no failures. */
public boolean isSuccess() {
return mFailures.isEmpty();
@@ -99,8 +74,8 @@
}
/**
- * Returns a {@link Map} of keys mapped to instances of {@link AppSearchResult} for all
- * failed individual results.
+ * Returns a {@link Map} of keys mapped to instances of {@link AppSearchResult} for all failed
+ * individual results.
*
* <p>The values of the {@link Map} will not be {@code null}.
*/
@@ -122,6 +97,7 @@
/**
* Asserts that this {@link AppSearchBatchResult} has no failures.
+ *
* @hide
*/
public void checkSuccess() {
@@ -136,53 +112,29 @@
return "{\n successes: " + mSuccesses + "\n failures: " + mFailures + "\n}";
}
- /** @hide */
- @Override
- public int describeContents() {
- return 0;
- }
-
- /** @hide */
- @NonNull
- public static final Creator<AppSearchBatchResult> CREATOR =
- new Creator<AppSearchBatchResult>() {
- @NonNull
- @Override
- public AppSearchBatchResult createFromParcel(@NonNull Parcel in) {
- return new AppSearchBatchResult(in);
- }
-
- @NonNull
- @Override
- public AppSearchBatchResult[] newArray(int size) {
- return new AppSearchBatchResult[size];
- }
- };
-
/**
* Builder for {@link AppSearchBatchResult} objects.
*
- * <p>Once {@link #build} is called, the instance can no longer be used.
+ * @param <KeyType> The type of the keys for which the results will be reported.
+ * @param <ValueType> The type of the result objects for successful results.
*/
public static final class Builder<KeyType, ValueType> {
- private final Map<KeyType, ValueType> mSuccesses = new ArrayMap<>();
- private final Map<KeyType, AppSearchResult<ValueType>> mFailures = new ArrayMap<>();
- private final Map<KeyType, AppSearchResult<ValueType>> mAll = new ArrayMap<>();
+ private ArrayMap<KeyType, ValueType> mSuccesses = new ArrayMap<>();
+ private ArrayMap<KeyType, AppSearchResult<ValueType>> mFailures = new ArrayMap<>();
+ private ArrayMap<KeyType, AppSearchResult<ValueType>> mAll = new ArrayMap<>();
private boolean mBuilt = false;
/**
* Associates the {@code key} with the provided successful return value.
*
* <p>Any previous mapping for a key, whether success or failure, is deleted.
- *
- * @throws IllegalStateException if the builder has already been used.
*/
- @SuppressWarnings("MissingGetterMatchingBuilder") // See getSuccesses
+ @SuppressWarnings("MissingGetterMatchingBuilder") // See getSuccesses
@NonNull
public Builder<KeyType, ValueType> setSuccess(
@NonNull KeyType key, @Nullable ValueType result) {
- Preconditions.checkState(!mBuilt, "Builder has already been used");
Objects.requireNonNull(key);
+ resetIfBuilt();
return setResult(key, AppSearchResult.newSuccessfulResult(result));
}
@@ -190,17 +142,15 @@
* Associates the {@code key} with the provided failure code and error message.
*
* <p>Any previous mapping for a key, whether success or failure, is deleted.
- *
- * @throws IllegalStateException if the builder has already been used.
*/
- @SuppressWarnings("MissingGetterMatchingBuilder") // See getFailures
+ @SuppressWarnings("MissingGetterMatchingBuilder") // See getFailures
@NonNull
public Builder<KeyType, ValueType> setFailure(
@NonNull KeyType key,
@AppSearchResult.ResultCode int resultCode,
@Nullable String errorMessage) {
- Preconditions.checkState(!mBuilt, "Builder has already been used");
Objects.requireNonNull(key);
+ resetIfBuilt();
return setResult(key, AppSearchResult.newFailedResult(resultCode, errorMessage));
}
@@ -208,16 +158,14 @@
* Associates the {@code key} with the provided {@code result}.
*
* <p>Any previous mapping for a key, whether success or failure, is deleted.
- *
- * @throws IllegalStateException if the builder has already been used.
*/
- @SuppressWarnings("MissingGetterMatchingBuilder") // See getAll
+ @SuppressWarnings("MissingGetterMatchingBuilder") // See getAll
@NonNull
public Builder<KeyType, ValueType> setResult(
@NonNull KeyType key, @NonNull AppSearchResult<ValueType> result) {
- Preconditions.checkState(!mBuilt, "Builder has already been used");
Objects.requireNonNull(key);
Objects.requireNonNull(result);
+ resetIfBuilt();
if (result.isSuccess()) {
mSuccesses.put(key, result.getResultValue());
mFailures.remove(key);
@@ -231,14 +179,21 @@
/**
* Builds an {@link AppSearchBatchResult} object from the contents of this {@link Builder}.
- *
- * @throws IllegalStateException if the builder has already been used.
*/
@NonNull
public AppSearchBatchResult<KeyType, ValueType> build() {
- Preconditions.checkState(!mBuilt, "Builder has already been used");
mBuilt = true;
- return new AppSearchBatchResult<>(mSuccesses, mFailures, mAll);
+ return new AppSearchBatchResult<>(
+ new ArrayMap<>(mSuccesses), new ArrayMap<>(mFailures), new ArrayMap<>(mAll));
+ }
+
+ private void resetIfBuilt() {
+ if (mBuilt) {
+ mSuccesses = new ArrayMap<>(mSuccesses);
+ mFailures = new ArrayMap<>(mFailures);
+ mAll = new ArrayMap<>(mAll);
+ mBuilt = false;
+ }
}
}
}
diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.java b/apex/appsearch/framework/java/external/android/app/appsearch/AppSearchResult.java
similarity index 82%
rename from apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.java
rename to apex/appsearch/framework/java/external/android/app/appsearch/AppSearchResult.java
index b06e215..30c98b0 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.java
+++ b/apex/appsearch/framework/java/external/android/app/appsearch/AppSearchResult.java
@@ -13,15 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package android.app.appsearch;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.appsearch.exceptions.AppSearchException;
-import android.os.Parcel;
-import android.os.Parcelable;
import android.util.Log;
import com.android.internal.util.Preconditions;
@@ -36,24 +33,26 @@
*
* @param <ValueType> The type of result object for successful calls.
*/
-public final class AppSearchResult<ValueType> implements Parcelable {
+public final class AppSearchResult<ValueType> {
private static final String TAG = "AppSearchResult";
/**
* Result codes from {@link AppSearchSession} methods.
+ *
* @hide
*/
- @IntDef(value = {
- RESULT_OK,
- RESULT_UNKNOWN_ERROR,
- RESULT_INTERNAL_ERROR,
- RESULT_INVALID_ARGUMENT,
- RESULT_IO_ERROR,
- RESULT_OUT_OF_SPACE,
- RESULT_NOT_FOUND,
- RESULT_INVALID_SCHEMA,
- RESULT_SECURITY_ERROR,
- })
+ @IntDef(
+ value = {
+ RESULT_OK,
+ RESULT_UNKNOWN_ERROR,
+ RESULT_INTERNAL_ERROR,
+ RESULT_INVALID_ARGUMENT,
+ RESULT_IO_ERROR,
+ RESULT_OUT_OF_SPACE,
+ RESULT_NOT_FOUND,
+ RESULT_INVALID_SCHEMA,
+ RESULT_SECURITY_ERROR,
+ })
@Retention(RetentionPolicy.SOURCE)
public @interface ResultCode {}
@@ -109,20 +108,6 @@
mErrorMessage = errorMessage;
}
- private AppSearchResult(@NonNull Parcel in) {
- mResultCode = in.readInt();
- mResultValue = (ValueType) in.readValue(/*loader=*/ null);
- mErrorMessage = in.readString();
- }
-
- /** @hide */
- @Override
- public void writeToParcel(@NonNull Parcel dest, int flags) {
- dest.writeInt(mResultCode);
- dest.writeValue(mResultValue);
- dest.writeString(mErrorMessage);
- }
-
/** Returns {@code true} if {@link #getResultCode} equals {@link AppSearchResult#RESULT_OK}. */
public boolean isSuccess() {
return getResultCode() == RESULT_OK;
@@ -154,8 +139,8 @@
*
* <p>If {@link #isSuccess} is {@code true}, the error message is always {@code null}. The error
* message may be {@code null} even if {@link #isSuccess} is {@code false}. See the
- * documentation of the particular {@link AppSearchSession} call producing this
- * {@link AppSearchResult} for what is returned by {@link #getErrorMessage}.
+ * documentation of the particular {@link AppSearchSession} call producing this {@link
+ * AppSearchResult} for what is returned by {@link #getErrorMessage}.
*/
@Nullable
public String getErrorMessage() {
@@ -190,40 +175,14 @@
return "[FAILURE(" + mResultCode + ")]: " + mErrorMessage;
}
- /** @hide */
- @Override
- public int describeContents() {
- return 0;
- }
-
- /** @hide */
- @NonNull
- public static final Creator<AppSearchResult> CREATOR = new Creator<AppSearchResult>() {
- @NonNull
- @Override
- public AppSearchResult createFromParcel(@NonNull Parcel in) {
- return new AppSearchResult(in);
- }
-
- @NonNull
- @Override
- public AppSearchResult[] newArray(int size) {
- return new AppSearchResult[size];
- }
- };
-
- /**
- * Creates a new successful {@link AppSearchResult}.
- */
+ /** Creates a new successful {@link AppSearchResult}. */
@NonNull
public static <ValueType> AppSearchResult<ValueType> newSuccessfulResult(
@Nullable ValueType value) {
return new AppSearchResult<>(RESULT_OK, value, /*errorMessage=*/ null);
}
- /**
- * Creates a new failed {@link AppSearchResult}.
- */
+ /** Creates a new failed {@link AppSearchResult}. */
@NonNull
public static <ValueType> AppSearchResult<ValueType> newFailedResult(
@ResultCode int resultCode, @Nullable String errorMessage) {
@@ -238,7 +197,8 @@
@NonNull
public static <ValueType> AppSearchResult<ValueType> newFailedResult(
@NonNull AppSearchResult<?> otherFailedResult) {
- Preconditions.checkState(!otherFailedResult.isSuccess(),
+ Preconditions.checkState(
+ !otherFailedResult.isSuccess(),
"Cannot convert a success result to a failed result");
return AppSearchResult.newFailedResult(
otherFailedResult.getResultCode(), otherFailedResult.getErrorMessage());
diff --git a/apex/appsearch/framework/java/external/android/app/appsearch/GenericDocument.java b/apex/appsearch/framework/java/external/android/app/appsearch/GenericDocument.java
index 736deab..cc48ccb 100644
--- a/apex/appsearch/framework/java/external/android/app/appsearch/GenericDocument.java
+++ b/apex/appsearch/framework/java/external/android/app/appsearch/GenericDocument.java
@@ -892,129 +892,121 @@
@Override
@NonNull
public String toString() {
- return formatGenericDocumentString(this, /*indentLevel=*/ 0);
+ StringBuilder stringBuilder = new StringBuilder();
+ appendGenericDocumentString(this, /*indentLevel=*/ 0, stringBuilder);
+ return stringBuilder.toString();
}
- @NonNull
- private static String formatGenericDocumentString(
- @NonNull GenericDocument document, int indentLevel) {
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append(getIndent(indentLevel)).append("{\n");
+ private static void appendGenericDocumentString(
+ @NonNull GenericDocument document, int indentLevel, @NonNull StringBuilder builder) {
+ Objects.requireNonNull(document);
+ Objects.requireNonNull(builder);
- String indentLevelOneString = getIndent(indentLevel + 1);
+ builder.append(getIndent(indentLevel)).append("{\n");
- stringBuilder
- .append(indentLevelOneString)
+ String indent1 = getIndent(indentLevel + 1);
+
+ builder.append(indent1)
.append("namespace: \"")
.append(document.getNamespace())
.append("\",\n");
- stringBuilder
- .append(indentLevelOneString)
- .append("id: \"")
- .append(document.getId())
- .append("\",\n");
+ builder.append(indent1).append("id: \"").append(document.getId()).append("\",\n");
- stringBuilder
- .append(indentLevelOneString)
- .append("score: " + document.getScore())
- .append(",\n");
+ builder.append(indent1).append("score: ").append(document.getScore()).append(",\n");
- stringBuilder
- .append(indentLevelOneString)
+ builder.append(indent1)
.append("schemaType: \"")
.append(document.getSchemaType())
.append("\",\n");
- stringBuilder
- .append(indentLevelOneString)
- .append("creationTimestampMillis: " + document.getCreationTimestampMillis())
+ builder.append(indent1)
+ .append("creationTimestampMillis: ")
+ .append(document.getCreationTimestampMillis())
.append(",\n");
- stringBuilder
- .append(indentLevelOneString)
- .append("timeToLiveMillis: " + document.getTtlMillis())
+ builder.append(indent1)
+ .append("timeToLiveMillis: ")
+ .append(document.getTtlMillis())
.append(",\n");
- stringBuilder.append(indentLevelOneString).append("properties: {\n");
+ builder.append(indent1).append("properties: {\n");
- int idx = 0;
- for (String propertyName : document.getPropertyNames()) {
- Object property = document.getProperty(propertyName);
- stringBuilder
- .append(getIndent(indentLevel + 2))
+ String[] sortedProperties = document.getPropertyNames().toArray(new String[0]);
+ Arrays.sort(sortedProperties);
+
+ for (int i = 0; i < sortedProperties.length; i++) {
+ Object property = document.getProperty(sortedProperties[i]);
+ builder.append(getIndent(indentLevel + 2))
.append("\"")
- .append(propertyName)
+ .append(sortedProperties[i])
.append("\"")
.append(": ");
- stringBuilder.append(getPropertyString(property, indentLevel + 2));
- if (idx != document.getPropertyNames().size() - 1) {
- stringBuilder.append(",\n");
+ appendPropertyString(property, indentLevel + 2, builder);
+ if (i != sortedProperties.length - 1) {
+ builder.append(",\n");
}
- ++idx;
}
- stringBuilder.append("\n");
- stringBuilder.append(indentLevelOneString).append("}");
+ builder.append("\n");
+ builder.append(indent1).append("}");
- stringBuilder.append("\n");
- stringBuilder.append(getIndent(indentLevel)).append("}");
-
- return stringBuilder.toString();
+ builder.append("\n");
+ builder.append(getIndent(indentLevel)).append("}");
}
/**
- * Creates string for property.
+ * Appends a string for the given property to the given builder.
*
* @param property property object to create string for.
* @param indentLevel base indent level for property.
+ * @param builder the builder to append to.
*/
- @NonNull
- private static String getPropertyString(@NonNull Object property, int indentLevel) {
+ private static void appendPropertyString(
+ @NonNull Object property, int indentLevel, @NonNull StringBuilder builder) {
Objects.requireNonNull(property);
+ Objects.requireNonNull(builder);
- StringBuilder str = new StringBuilder("[");
-
+ builder.append("[");
if (property instanceof GenericDocument[]) {
GenericDocument[] documentValues = (GenericDocument[]) property;
for (int i = 0; i < documentValues.length; ++i) {
- str.append("\n");
- str.append(formatGenericDocumentString(documentValues[i], indentLevel + 1));
+ builder.append("\n");
+ appendGenericDocumentString(documentValues[i], indentLevel + 1, builder);
if (i != documentValues.length - 1) {
- str.append(", ");
+ builder.append(", ");
}
- str.append("\n");
+ builder.append("\n");
}
- str.append(getIndent(indentLevel));
+ builder.append(getIndent(indentLevel));
} else {
int propertyArrLength = Array.getLength(property);
for (int i = 0; i < propertyArrLength; i++) {
Object propertyElement = Array.get(property, i);
if (propertyElement instanceof String) {
- str.append("\"").append(propertyElement).append("\"");
+ builder.append("\"").append(propertyElement).append("\"");
} else if (propertyElement instanceof byte[]) {
- str.append(Arrays.toString((byte[]) propertyElement));
+ builder.append(Arrays.toString((byte[]) propertyElement));
} else {
- str.append(propertyElement);
+ builder.append(propertyElement);
}
if (i != propertyArrLength - 1) {
- str.append(", ");
+ builder.append(", ");
}
}
}
- str.append("]");
- return str.toString();
+ builder.append("]");
}
- /** Creates string for given indent level. */
+ /** Appends a string for given indent level to the given builder. */
@NonNull
private static String getIndent(int indentLevel) {
- StringBuilder indentedString = new StringBuilder();
+ StringBuilder builder = new StringBuilder();
for (int i = 0; i < indentLevel; ++i) {
- indentedString.append(" ");
+ builder.append(" ");
}
- return indentedString.toString();
+ return builder.toString();
}
/**
diff --git a/apex/appsearch/framework/java/external/android/app/appsearch/SearchResult.java b/apex/appsearch/framework/java/external/android/app/appsearch/SearchResult.java
index 0d186f2..4beb667 100644
--- a/apex/appsearch/framework/java/external/android/app/appsearch/SearchResult.java
+++ b/apex/appsearch/framework/java/external/android/app/appsearch/SearchResult.java
@@ -18,6 +18,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.compat.annotation.UnsupportedAppUsage;
import android.os.Bundle;
import com.android.internal.util.Preconditions;
@@ -82,8 +83,12 @@
return mDocument;
}
- /** @deprecated This method exists only for dogfooder transition and must be removed. */
+ /**
+ * @deprecated TODO(b/181887768): Exists for dogfood transition; must be removed.
+ * @hide
+ */
@Deprecated
+ @UnsupportedAppUsage
@NonNull
public List<MatchInfo> getMatches() {
return getMatchInfos();
@@ -191,8 +196,12 @@
return this;
}
- /** @deprecated This method exists only for dogfooder transition and must be removed. */
+ /**
+ * @deprecated TODO(b/181887768): Exists for dogfood transition; must be removed.
+ * @hide
+ */
@Deprecated
+ @UnsupportedAppUsage
@NonNull
public Builder addMatch(@NonNull MatchInfo matchInfo) {
return addMatchInfo(matchInfo);
diff --git a/apex/appsearch/service/java/com/android/server/appsearch/AppSearchManagerService.java b/apex/appsearch/service/java/com/android/server/appsearch/AppSearchManagerService.java
index a4188a2..777f9fe 100644
--- a/apex/appsearch/service/java/com/android/server/appsearch/AppSearchManagerService.java
+++ b/apex/appsearch/service/java/com/android/server/appsearch/AppSearchManagerService.java
@@ -29,18 +29,21 @@
import android.app.appsearch.AppSearchSchema;
import android.app.appsearch.GenericDocument;
import android.app.appsearch.GetSchemaResponse;
-import android.app.appsearch.IAppSearchBatchResultCallback;
-import android.app.appsearch.IAppSearchManager;
-import android.app.appsearch.IAppSearchResultCallback;
import android.app.appsearch.PackageIdentifier;
import android.app.appsearch.SearchResultPage;
import android.app.appsearch.SearchSpec;
import android.app.appsearch.SetSchemaResponse;
import android.app.appsearch.StorageInfo;
+import android.app.appsearch.aidl.AppSearchBatchResultParcel;
+import android.app.appsearch.aidl.AppSearchResultParcel;
+import android.app.appsearch.aidl.IAppSearchBatchResultCallback;
+import android.app.appsearch.aidl.IAppSearchManager;
+import android.app.appsearch.aidl.IAppSearchResultCallback;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManagerInternal;
import android.content.pm.PackageStats;
@@ -56,14 +59,15 @@
import android.util.Log;
import com.android.internal.annotations.GuardedBy;
+import com.android.server.LocalManagerRegistry;
import com.android.server.LocalServices;
import com.android.server.SystemService;
import com.android.server.appsearch.external.localstorage.AppSearchImpl;
import com.android.server.appsearch.external.localstorage.stats.CallStats;
import com.android.server.appsearch.stats.LoggerInstanceManager;
import com.android.server.appsearch.stats.PlatformLogger;
-import com.android.server.usage.StorageStatsManagerInternal;
-import com.android.server.usage.StorageStatsManagerInternal.StorageStatsAugmenter;
+import com.android.server.usage.StorageStatsManagerLocal;
+import com.android.server.usage.StorageStatsManagerLocal.StorageStatsAugmenter;
import com.google.android.icing.proto.PersistType;
@@ -120,7 +124,7 @@
mUserManager = mContext.getSystemService(UserManager.class);
mLoggerInstanceManager = LoggerInstanceManager.getInstance();
registerReceivers();
- LocalServices.getService(StorageStatsManagerInternal.class)
+ LocalManagerRegistry.getManager(StorageStatsManagerLocal.class)
.registerStorageStatsAugmenter(new AppSearchStorageStatsAugmenter(), TAG);
}
@@ -230,6 +234,18 @@
}
}
+ @Override
+ public void onUserStopping(@NonNull TargetUser user) {
+ synchronized (mUnlockedUserIdsLocked) {
+ mUnlockedUserIdsLocked.remove(user.getUserIdentifier());
+ try {
+ mImplInstanceManager.closeAndRemoveAppSearchImplForUser(user.getUserIdentifier());
+ } catch (Throwable t) {
+ Log.e(TAG, "Error handling user stopping.", t);
+ }
+ }
+ }
+
private void verifyUserUnlocked(int callingUserId) {
if (isUserLocked(callingUserId)) {
throw new IllegalStateException("User " + callingUserId + " is locked or not running.");
@@ -869,7 +885,7 @@
private void invokeCallbackOnResult(
IAppSearchResultCallback callback, AppSearchResult<?> result) {
try {
- callback.onResult(result);
+ callback.onResult(new AppSearchResultParcel<>(result));
} catch (RemoteException e) {
Log.e(TAG, "Unable to send result to the callback", e);
}
@@ -877,9 +893,9 @@
/** Invokes the {@link IAppSearchBatchResultCallback} with the result. */
private void invokeCallbackOnResult(
- IAppSearchBatchResultCallback callback, AppSearchBatchResult<?, ?> result) {
+ IAppSearchBatchResultCallback callback, AppSearchBatchResult<String, ?> result) {
try {
- callback.onResult(result);
+ callback.onResult(new AppSearchBatchResultParcel<>(result));
} catch (RemoteException e) {
Log.e(TAG, "Unable to send result to the callback", e);
}
@@ -891,8 +907,9 @@
* <p>The throwable is convert to a {@link AppSearchResult};
*/
private void invokeCallbackOnError(IAppSearchResultCallback callback, Throwable throwable) {
+ AppSearchResult<?> result = throwableToFailedResult(throwable);
try {
- callback.onResult(throwableToFailedResult(throwable));
+ callback.onResult(new AppSearchResultParcel<>(result));
} catch (RemoteException e) {
Log.e(TAG, "Unable to send result to the callback", e);
}
@@ -905,8 +922,9 @@
*/
private void invokeCallbackOnError(
@NonNull IAppSearchBatchResultCallback callback, @NonNull Throwable throwable) {
+ AppSearchResult<?> result = throwableToFailedResult(throwable);
try {
- callback.onSystemError(throwableToFailedResult(throwable));
+ callback.onSystemError(new AppSearchResultParcel<>(result));
} catch (RemoteException e) {
Log.e(TAG, "Unable to send error to the callback", e);
}
@@ -931,13 +949,15 @@
// TODO(b/179160886): Cache the previous storage stats.
private class AppSearchStorageStatsAugmenter implements StorageStatsAugmenter {
@Override
- public void augmentStatsForPackage(
+ public void augmentStatsForPackageForUser(
@NonNull PackageStats stats,
@NonNull String packageName,
- @UserIdInt int userId,
- boolean callerHasStatsPermission) {
+ @NonNull UserHandle userHandle,
+ boolean canCallerAccessAllStats) {
Objects.requireNonNull(stats);
Objects.requireNonNull(packageName);
+ Objects.requireNonNull(userHandle);
+ int userId = userHandle.getIdentifier();
try {
verifyUserUnlocked(userId);
AppSearchImpl impl = mImplInstanceManager.getOrCreateAppSearchImpl(mContext,
@@ -956,7 +976,7 @@
@Override
public void augmentStatsForUid(
- @NonNull PackageStats stats, int uid, boolean callerHasStatsPermission) {
+ @NonNull PackageStats stats, int uid, boolean canCallerAccessAllStats) {
Objects.requireNonNull(stats);
int userId = UserHandle.getUserId(uid);
try {
@@ -967,12 +987,40 @@
}
AppSearchImpl impl = mImplInstanceManager.getOrCreateAppSearchImpl(mContext,
userId);
- for (String packageName : packagesForUid) {
- stats.dataSize += impl.getStorageInfoForPackage(packageName).getSizeBytes();
+ for (int i = 0; i < packagesForUid.length; i++) {
+ stats.dataSize +=
+ impl.getStorageInfoForPackage(packagesForUid[i]).getSizeBytes();
}
} catch (Throwable t) {
Log.e(TAG, "Unable to augment storage stats for uid " + uid, t);
}
}
+
+ @Override
+ public void augmentStatsForUser(
+ @NonNull PackageStats stats, @NonNull UserHandle userHandle) {
+ // TODO(b/179160886): this implementation could incur many jni calls and a lot of
+ // in-memory processing from getStorageInfoForPackage. Instead, we can just compute the
+ // size of the icing dir (or use the overall StorageInfo without interpolating it).
+ Objects.requireNonNull(stats);
+ Objects.requireNonNull(userHandle);
+ int userId = userHandle.getIdentifier();
+ try {
+ verifyUserUnlocked(userId);
+ List<PackageInfo> packagesForUser =
+ mPackageManager.getInstalledPackagesAsUser(/*flags=*/0, userId);
+ if (packagesForUser == null) {
+ return;
+ }
+ AppSearchImpl impl =
+ mImplInstanceManager.getOrCreateAppSearchImpl(mContext, userId);
+ for (int i = 0; i < packagesForUser.size(); i++) {
+ String packageName = packagesForUser.get(i).packageName;
+ stats.dataSize += impl.getStorageInfoForPackage(packageName).getSizeBytes();
+ }
+ } catch (Throwable t) {
+ Log.e(TAG, "Unable to augment storage stats for user " + userId, t);
+ }
+ }
}
}
diff --git a/apex/appsearch/service/java/com/android/server/appsearch/ImplInstanceManager.java b/apex/appsearch/service/java/com/android/server/appsearch/ImplInstanceManager.java
index 94ee830..b815de4 100644
--- a/apex/appsearch/service/java/com/android/server/appsearch/ImplInstanceManager.java
+++ b/apex/appsearch/service/java/com/android/server/appsearch/ImplInstanceManager.java
@@ -117,11 +117,29 @@
*/
public void removeAppSearchImplForUser(@UserIdInt int userId) {
synchronized (mInstancesLocked) {
+ // no need to close and persist data to disk since we are removing them now.
mInstancesLocked.remove(userId);
}
}
/**
+ * Close and remove an instance of {@link AppSearchImpl} for the given user.
+ *
+ * <p>All mutation apply to this {@link AppSearchImpl} will be persisted to disk.
+ *
+ * @param userId The multi-user userId of the user that need to be removed.
+ */
+ public void closeAndRemoveAppSearchImplForUser(@UserIdInt int userId) {
+ synchronized (mInstancesLocked) {
+ AppSearchImpl appSearchImpl = mInstancesLocked.get(userId);
+ if (appSearchImpl != null) {
+ appSearchImpl.close();
+ mInstancesLocked.remove(userId);
+ }
+ }
+ }
+
+ /**
* Gets an instance of AppSearchImpl for the given user.
*
* <p>This method should only be called by an initialized SearchSession, which has been already
diff --git a/apex/appsearch/service/java/com/android/server/appsearch/external/localstorage/converter/SearchResultToProtoConverter.java b/apex/appsearch/service/java/com/android/server/appsearch/external/localstorage/converter/SearchResultToProtoConverter.java
index ecc774c..6b443b3 100644
--- a/apex/appsearch/service/java/com/android/server/appsearch/external/localstorage/converter/SearchResultToProtoConverter.java
+++ b/apex/appsearch/service/java/com/android/server/appsearch/external/localstorage/converter/SearchResultToProtoConverter.java
@@ -128,14 +128,14 @@
return new SearchResult.MatchInfo.Builder(propertyPath)
.setExactMatchRange(
new SearchResult.MatchRange(
- snippetMatchProto.getExactMatchPosition(),
- snippetMatchProto.getExactMatchPosition()
- + snippetMatchProto.getExactMatchBytes()))
+ snippetMatchProto.getExactMatchUtf16Position(),
+ snippetMatchProto.getExactMatchUtf16Position()
+ + snippetMatchProto.getExactMatchUtf16Length()))
.setSnippetRange(
new SearchResult.MatchRange(
- snippetMatchProto.getWindowPosition(),
- snippetMatchProto.getWindowPosition()
- + snippetMatchProto.getWindowBytes()))
+ snippetMatchProto.getWindowUtf16Position(),
+ snippetMatchProto.getWindowUtf16Position()
+ + snippetMatchProto.getWindowUtf16Length()))
.build();
}
}
diff --git a/apex/appsearch/service/java/com/android/server/appsearch/external/localstorage/stats/CallStats.java b/apex/appsearch/service/java/com/android/server/appsearch/external/localstorage/stats/CallStats.java
index cf640c1..ea5263a 100644
--- a/apex/appsearch/service/java/com/android/server/appsearch/external/localstorage/stats/CallStats.java
+++ b/apex/appsearch/service/java/com/android/server/appsearch/external/localstorage/stats/CallStats.java
@@ -43,13 +43,16 @@
CALL_TYPE_SET_SCHEMA,
CALL_TYPE_PUT_DOCUMENTS,
CALL_TYPE_GET_DOCUMENTS,
- CALL_TYPE_REMOVE_DOCUMENTS,
+ CALL_TYPE_REMOVE_DOCUMENTS_BY_ID,
CALL_TYPE_PUT_DOCUMENT,
CALL_TYPE_GET_DOCUMENT,
- CALL_TYPE_REMOVE_DOCUMENT,
- CALL_TYPE_QUERY,
+ CALL_TYPE_REMOVE_DOCUMENT_BY_ID,
+ CALL_TYPE_SEARCH,
CALL_TYPE_OPTIMIZE,
CALL_TYPE_FLUSH,
+ CALL_TYPE_GLOBAL_SEARCH,
+ CALL_TYPE_REMOVE_DOCUMENTS_BY_SEARCH,
+ CALL_TYPE_REMOVE_DOCUMENT_BY_SEARCH,
})
@Retention(RetentionPolicy.SOURCE)
public @interface CallType {}
@@ -59,13 +62,16 @@
public static final int CALL_TYPE_SET_SCHEMA = 2;
public static final int CALL_TYPE_PUT_DOCUMENTS = 3;
public static final int CALL_TYPE_GET_DOCUMENTS = 4;
- public static final int CALL_TYPE_REMOVE_DOCUMENTS = 5;
+ public static final int CALL_TYPE_REMOVE_DOCUMENTS_BY_ID = 5;
public static final int CALL_TYPE_PUT_DOCUMENT = 6;
public static final int CALL_TYPE_GET_DOCUMENT = 7;
- public static final int CALL_TYPE_REMOVE_DOCUMENT = 8;
- public static final int CALL_TYPE_QUERY = 9;
+ public static final int CALL_TYPE_REMOVE_DOCUMENT_BY_ID = 8;
+ public static final int CALL_TYPE_SEARCH = 9;
public static final int CALL_TYPE_OPTIMIZE = 10;
public static final int CALL_TYPE_FLUSH = 11;
+ public static final int CALL_TYPE_GLOBAL_SEARCH = 12;
+ public static final int CALL_TYPE_REMOVE_DOCUMENTS_BY_SEARCH = 13;
+ public static final int CALL_TYPE_REMOVE_DOCUMENT_BY_SEARCH = 14;
@NonNull private final GeneralStats mGeneralStats;
@CallType private final int mCallType;
diff --git a/apex/appsearch/synced_jetpack_changeid.txt b/apex/appsearch/synced_jetpack_changeid.txt
index d07a3b9..85d85aa 100644
--- a/apex/appsearch/synced_jetpack_changeid.txt
+++ b/apex/appsearch/synced_jetpack_changeid.txt
@@ -1 +1 @@
-Ibbf4260deb720ce724be81ee4394ea96181ee0f7
+I0216abecc41d020f16ed8947a9f37b710afd331e
diff --git a/apex/appsearch/testing/Android.bp b/apex/appsearch/testing/Android.bp
index ec64941..5407cb4 100644
--- a/apex/appsearch/testing/Android.bp
+++ b/apex/appsearch/testing/Android.bp
@@ -33,7 +33,7 @@
visibility: [
"//frameworks/base/core/tests/coretests",
"//cts/hostsidetests/appsearch",
- "//cts/tests/appsearch",
+ "//cts/tests:__subpackages__",
"//vendor:__subpackages__",
],
}
diff --git a/apex/appsearch/testing/java/com/android/server/appsearch/testing/AppSearchSessionShimImpl.java b/apex/appsearch/testing/java/com/android/server/appsearch/testing/AppSearchSessionShimImpl.java
index 941cea9..71b4f36 100644
--- a/apex/appsearch/testing/java/com/android/server/appsearch/testing/AppSearchSessionShimImpl.java
+++ b/apex/appsearch/testing/java/com/android/server/appsearch/testing/AppSearchSessionShimImpl.java
@@ -17,6 +17,7 @@
package com.android.server.appsearch.testing;
import android.annotation.NonNull;
+import android.annotation.UserIdInt;
import android.app.appsearch.AppSearchBatchResult;
import android.app.appsearch.AppSearchManager;
import android.app.appsearch.AppSearchResult;
@@ -37,6 +38,7 @@
import android.app.appsearch.StorageInfo;
import android.app.appsearch.exceptions.AppSearchException;
import android.content.Context;
+import android.os.UserHandle;
import androidx.test.core.app.ApplicationProvider;
@@ -58,18 +60,29 @@
private final AppSearchSession mAppSearchSession;
private final ExecutorService mExecutor;
+ /** Creates the SearchSessionShim with given SearchContext. */
@NonNull
public static ListenableFuture<AppSearchSessionShim> createSearchSession(
@NonNull AppSearchManager.SearchContext searchContext) {
- return createSearchSession(searchContext, Executors.newCachedThreadPool());
+ Context context = ApplicationProvider.getApplicationContext();
+ return createSearchSession(context, searchContext, Executors.newCachedThreadPool());
}
- /** Creates the SearchSession with given ExecutorService. */
+ /** Creates the SearchSessionShim with given SearchContext for the given user. */
@NonNull
public static ListenableFuture<AppSearchSessionShim> createSearchSession(
+ @NonNull AppSearchManager.SearchContext searchContext, @UserIdInt int userId) {
+ Context context = ApplicationProvider.getApplicationContext()
+ .createContextAsUser(new UserHandle(userId), /*flags=*/ 0);
+ return createSearchSession(context, searchContext, Executors.newCachedThreadPool());
+ }
+
+ /** Creates the SearchSession with given Context and ExecutorService. */
+ @NonNull
+ public static ListenableFuture<AppSearchSessionShim> createSearchSession(
+ @NonNull Context context,
@NonNull AppSearchManager.SearchContext searchContext,
@NonNull ExecutorService executor) {
- Context context = ApplicationProvider.getApplicationContext();
AppSearchManager appSearchManager = context.getSystemService(AppSearchManager.class);
SettableFuture<AppSearchResult<AppSearchSession>> future = SettableFuture.create();
appSearchManager.createSearchSession(searchContext, executor, future::set);
diff --git a/apex/blobstore/service/java/com/android/server/blob/BlobStoreManagerService.java b/apex/blobstore/service/java/com/android/server/blob/BlobStoreManagerService.java
index cc5e31a..731ba92 100644
--- a/apex/blobstore/service/java/com/android/server/blob/BlobStoreManagerService.java
+++ b/apex/blobstore/service/java/com/android/server/blob/BlobStoreManagerService.java
@@ -101,14 +101,15 @@
import com.android.internal.util.Preconditions;
import com.android.internal.util.XmlUtils;
import com.android.internal.util.function.pooled.PooledLambda;
+import com.android.server.LocalManagerRegistry;
import com.android.server.LocalServices;
import com.android.server.ServiceThread;
import com.android.server.SystemService;
import com.android.server.Watchdog;
import com.android.server.blob.BlobMetadata.Committer;
import com.android.server.pm.UserManagerInternal;
-import com.android.server.usage.StorageStatsManagerInternal;
-import com.android.server.usage.StorageStatsManagerInternal.StorageStatsAugmenter;
+import com.android.server.usage.StorageStatsManagerLocal;
+import com.android.server.usage.StorageStatsManagerLocal.StorageStatsAugmenter;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlSerializer;
@@ -208,7 +209,7 @@
mPackageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
mStatsManager = getContext().getSystemService(StatsManager.class);
registerReceivers();
- LocalServices.getService(StorageStatsManagerInternal.class)
+ LocalManagerRegistry.getManager(StorageStatsManagerLocal.class)
.registerStorageStatsAugmenter(new BlobStorageStatsAugmenter(), TAG);
}
@@ -1281,17 +1282,20 @@
private class BlobStorageStatsAugmenter implements StorageStatsAugmenter {
@Override
- public void augmentStatsForPackage(@NonNull PackageStats stats, @NonNull String packageName,
- @UserIdInt int userId, boolean callerHasStatsPermission) {
+ public void augmentStatsForPackageForUser(
+ @NonNull PackageStats stats,
+ @NonNull String packageName,
+ @NonNull UserHandle userHandle,
+ boolean callerHasStatsPermission) {
final AtomicLong blobsDataSize = new AtomicLong(0);
forEachSessionInUser(session -> {
if (session.getOwnerPackageName().equals(packageName)) {
blobsDataSize.getAndAdd(session.getSize());
}
- }, userId);
+ }, userHandle.getIdentifier());
forEachBlob(blobMetadata -> {
- if (blobMetadata.shouldAttributeToLeasee(packageName, userId,
+ if (blobMetadata.shouldAttributeToLeasee(packageName, userHandle.getIdentifier(),
callerHasStatsPermission)) {
blobsDataSize.getAndAdd(blobMetadata.getSize());
}
@@ -1320,6 +1324,22 @@
stats.dataSize += blobsDataSize.get();
}
+
+ @Override
+ public void augmentStatsForUser(
+ @NonNull PackageStats stats, @NonNull UserHandle userHandle) {
+ final AtomicLong blobsDataSize = new AtomicLong(0);
+ forEachSessionInUser(session -> {
+ blobsDataSize.getAndAdd(session.getSize());
+ }, userHandle.getIdentifier());
+
+ // TODO(http://b/187460239): Update this to only include blobs available to userId.
+ forEachBlob(blobMetadata -> {
+ blobsDataSize.getAndAdd(blobMetadata.getSize());
+ });
+
+ stats.dataSize += blobsDataSize.get();
+ }
}
private void forEachSessionInUser(Consumer<BlobStoreSession> consumer, int userId) {
@@ -1900,4 +1920,4 @@
return BackgroundThread.getHandler();
}
}
-}
\ No newline at end of file
+}
diff --git a/apex/jobscheduler/framework/java/android/os/PowerExemptionManager.java b/apex/jobscheduler/framework/java/android/os/PowerExemptionManager.java
index 9dd1296..42e953b 100644
--- a/apex/jobscheduler/framework/java/android/os/PowerExemptionManager.java
+++ b/apex/jobscheduler/framework/java/android/os/PowerExemptionManager.java
@@ -344,6 +344,9 @@
*/
public static final int REASON_MEDIA_SESSION_CALLBACK = 317;
+ /** @hide The app requests out-out. */
+ public static final int REASON_OPT_OUT_REQUESTED = 1000;
+
/**
* The list of BG-FGS-Launch and temp-allow-list reason code.
* @hide
@@ -411,6 +414,7 @@
REASON_EVENT_MMS,
REASON_SHELL,
REASON_MEDIA_SESSION_CALLBACK,
+ REASON_OPT_OUT_REQUESTED,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ReasonCode {}
@@ -709,6 +713,8 @@
return "SHELL";
case REASON_MEDIA_SESSION_CALLBACK:
return "MEDIA_SESSION_CALLBACK";
+ case REASON_OPT_OUT_REQUESTED:
+ return "REASON_OPT_OUT_REQUESTED";
default:
return "(unknown:" + reasonCode + ")";
}
diff --git a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
index 452be30..96cbed7 100644
--- a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
+++ b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java
@@ -2629,8 +2629,7 @@
}
} catch (NameNotFoundException e) {
throw new IllegalArgumentException(
- "Tried to schedule job for non-existent package: "
- + service.getPackageName());
+ "Tried to schedule job for non-existent component: " + service);
}
}
diff --git a/build/boot/boot-image-profile.txt b/boot/boot-image-profile.txt
similarity index 100%
rename from build/boot/boot-image-profile.txt
rename to boot/boot-image-profile.txt
diff --git a/build/boot/preloaded-classes b/boot/preloaded-classes
similarity index 100%
rename from build/boot/preloaded-classes
rename to boot/preloaded-classes
diff --git a/core/api/current.txt b/core/api/current.txt
index 9131816..98c2d40 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -11154,6 +11154,7 @@
field public static final String ACTION_VIEW = "android.intent.action.VIEW";
field public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS";
field @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) public static final String ACTION_VIEW_PERMISSION_USAGE = "android.intent.action.VIEW_PERMISSION_USAGE";
+ field @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) public static final String ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD = "android.intent.action.VIEW_PERMISSION_USAGE_FOR_PERIOD";
field public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
field @Deprecated public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
field public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
@@ -11206,6 +11207,7 @@
field public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD = "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
field public static final String EXTRA_ASSIST_PACKAGE = "android.intent.extra.ASSIST_PACKAGE";
field public static final String EXTRA_ASSIST_UID = "android.intent.extra.ASSIST_UID";
+ field public static final String EXTRA_ATTRIBUTION_TAGS = "android.intent.extra.ATTRIBUTION_TAGS";
field public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE = "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
field public static final String EXTRA_BCC = "android.intent.extra.BCC";
field public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
@@ -11231,6 +11233,7 @@
field public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
field public static final String EXTRA_DURATION_MILLIS = "android.intent.extra.DURATION_MILLIS";
field public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
+ field public static final String EXTRA_END_TIME = "android.intent.extra.END_TIME";
field public static final String EXTRA_EXCLUDE_COMPONENTS = "android.intent.extra.EXCLUDE_COMPONENTS";
field public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
field public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
@@ -11245,6 +11248,7 @@
field public static final String EXTRA_NOT_UNKNOWN_SOURCE = "android.intent.extra.NOT_UNKNOWN_SOURCE";
field public static final String EXTRA_ORIGINATING_URI = "android.intent.extra.ORIGINATING_URI";
field public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
+ field public static final String EXTRA_PERMISSION_GROUP_NAME = "android.intent.extra.PERMISSION_GROUP_NAME";
field public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
field public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
field public static final String EXTRA_PROCESS_TEXT_READONLY = "android.intent.extra.PROCESS_TEXT_READONLY";
@@ -11267,6 +11271,7 @@
field @Deprecated public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
field public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
field public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
+ field public static final String EXTRA_START_TIME = "android.intent.extra.START_TIME";
field public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
field public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
field public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
@@ -13079,7 +13084,6 @@
method public void reportShortcutUsed(String);
method @WorkerThread public boolean requestPinShortcut(@NonNull android.content.pm.ShortcutInfo, @Nullable android.content.IntentSender);
method @WorkerThread public boolean setDynamicShortcuts(@NonNull java.util.List<android.content.pm.ShortcutInfo>);
- method public void updateShortcutVisibility(@NonNull String, @Nullable byte[], boolean);
method @WorkerThread public boolean updateShortcuts(@NonNull java.util.List<android.content.pm.ShortcutInfo>);
field public static final int FLAG_MATCH_CACHED = 8; // 0x8
field public static final int FLAG_MATCH_DYNAMIC = 2; // 0x2
@@ -46814,6 +46818,11 @@
method public void onActionProviderVisibilityChanged(boolean);
}
+ @UiThread public interface AttachedSurfaceControl {
+ method public boolean applyTransactionOnDraw(@NonNull android.view.SurfaceControl.Transaction);
+ method @Nullable public android.view.SurfaceControl.Transaction buildReparentTransaction(@NonNull android.view.SurfaceControl);
+ }
+
public final class Choreographer {
method public static android.view.Choreographer getInstance();
method public void postFrameCallback(android.view.Choreographer.FrameCallback);
@@ -48540,6 +48549,7 @@
method public android.view.WindowInsets dispatchApplyWindowInsets(android.view.WindowInsets);
method public boolean dispatchCapturedPointerEvent(android.view.MotionEvent);
method public void dispatchConfigurationChanged(android.content.res.Configuration);
+ method public void dispatchCreateViewTranslationRequest(@NonNull java.util.Map<android.view.autofill.AutofillId,long[]>, @NonNull int[], @NonNull android.view.translation.TranslationCapability, @NonNull java.util.List<android.view.translation.ViewTranslationRequest>);
method public void dispatchDisplayHint(int);
method public boolean dispatchDragEvent(android.view.DragEvent);
method protected void dispatchDraw(android.graphics.Canvas);
@@ -48561,7 +48571,6 @@
method public boolean dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
method public void dispatchProvideAutofillStructure(@NonNull android.view.ViewStructure, int);
method public void dispatchProvideStructure(android.view.ViewStructure);
- method public void dispatchRequestTranslation(@NonNull java.util.Map<android.view.autofill.AutofillId,long[]>, @NonNull int[], @NonNull android.view.translation.TranslationCapability, @NonNull java.util.List<android.view.translation.ViewTranslationRequest>);
method protected void dispatchRestoreInstanceState(android.util.SparseArray<android.os.Parcelable>);
method protected void dispatchSaveInstanceState(android.util.SparseArray<android.os.Parcelable>);
method public void dispatchScrollCaptureSearch(@NonNull android.graphics.Rect, @NonNull android.graphics.Point, @NonNull java.util.function.Consumer<android.view.ScrollCaptureTarget>);
@@ -48714,6 +48723,7 @@
method public final int getRight();
method protected float getRightFadingEdgeStrength();
method protected int getRightPaddingOffset();
+ method @Nullable public android.view.AttachedSurfaceControl getRootSurfaceControl();
method public android.view.View getRootView();
method public android.view.WindowInsets getRootWindowInsets();
method public float getRotation();
@@ -48758,7 +48768,6 @@
method @Nullable public android.graphics.drawable.Drawable getVerticalScrollbarThumbDrawable();
method @Nullable public android.graphics.drawable.Drawable getVerticalScrollbarTrackDrawable();
method public int getVerticalScrollbarWidth();
- method @Nullable public android.view.ViewRoot getViewRoot();
method @Nullable public android.view.translation.ViewTranslationResponse getViewTranslationResponse();
method public android.view.ViewTreeObserver getViewTreeObserver();
method public int getVisibility();
@@ -49834,11 +49843,6 @@
method public android.view.ViewPropertyAnimator zBy(float);
}
- @UiThread public interface ViewRoot {
- method public boolean applyTransactionOnDraw(@NonNull android.view.SurfaceControl.Transaction);
- method @Nullable public android.view.SurfaceControl.Transaction buildReparentTransaction(@NonNull android.view.SurfaceControl);
- }
-
public abstract class ViewStructure {
ctor public ViewStructure();
method public abstract int addChildCount(int);
@@ -50025,6 +50029,7 @@
method @ColorInt public int getNavigationBarDividerColor();
method public android.transition.Transition getReenterTransition();
method public android.transition.Transition getReturnTransition();
+ method @Nullable public android.view.AttachedSurfaceControl getRootSurfaceControl();
method public android.transition.Transition getSharedElementEnterTransition();
method public android.transition.Transition getSharedElementExitTransition();
method public android.transition.Transition getSharedElementReenterTransition();
@@ -50034,7 +50039,6 @@
method @NonNull public java.util.List<android.graphics.Rect> getSystemGestureExclusionRects();
method public long getTransitionBackgroundFadeDuration();
method public android.transition.TransitionManager getTransitionManager();
- method @Nullable public android.view.ViewRoot getViewRoot();
method public abstract int getVolumeControlStream();
method public android.view.WindowManager getWindowManager();
method public final android.content.res.TypedArray getWindowStyle();
@@ -52988,7 +52992,7 @@
method @NonNull public android.view.translation.TranslationRequestValue getValue(@NonNull String);
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.view.translation.ViewTranslationRequest> CREATOR;
- field public static final String ID_TEXT = "text";
+ field public static final String ID_TEXT = "android:text";
}
public static final class ViewTranslationRequest.Builder {
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 96a23b2..d30d59f 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -2399,12 +2399,9 @@
field public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
field public static final String ACTION_USER_ADDED = "android.intent.action.USER_ADDED";
field public static final String ACTION_USER_REMOVED = "android.intent.action.USER_REMOVED";
- field @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) public static final String ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD = "android.intent.action.VIEW_PERMISSION_USAGE_FOR_PERIOD";
field public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
field public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
- field public static final String EXTRA_ATTRIBUTION_TAGS = "android.intent.extra.ATTRIBUTION_TAGS";
field public static final String EXTRA_CALLING_PACKAGE = "android.intent.extra.CALLING_PACKAGE";
- field public static final String EXTRA_END_TIME = "android.intent.extra.END_TIME";
field public static final String EXTRA_FORCE_FACTORY_RESET = "android.intent.extra.FORCE_FACTORY_RESET";
field public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
field public static final String EXTRA_INSTANT_APP_BUNDLES = "android.intent.extra.INSTANT_APP_BUNDLES";
@@ -2416,13 +2413,11 @@
field public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
field public static final String EXTRA_ORIGINATING_UID = "android.intent.extra.ORIGINATING_UID";
field public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
- field public static final String EXTRA_PERMISSION_GROUP_NAME = "android.intent.extra.PERMISSION_GROUP_NAME";
field public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
field public static final String EXTRA_REASON = "android.intent.extra.REASON";
field public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
field public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
field public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME";
- field public static final String EXTRA_START_TIME = "android.intent.extra.START_TIME";
field public static final String EXTRA_UNKNOWN_INSTANT_APP = "android.intent.extra.UNKNOWN_INSTANT_APP";
field public static final String EXTRA_VERIFICATION_BUNDLE = "android.intent.extra.VERIFICATION_BUNDLE";
field public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 67108864; // 0x4000000
@@ -10473,7 +10468,7 @@
method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public int setParameter(int, int);
method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public boolean startRecognition(int);
method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public boolean startRecognition();
- method @Nullable public boolean startRecognition(@NonNull android.os.ParcelFileDescriptor, @NonNull android.media.AudioFormat, @Nullable android.os.PersistableBundle);
+ method public boolean startRecognition(@NonNull android.os.ParcelFileDescriptor, @NonNull android.media.AudioFormat, @Nullable android.os.PersistableBundle);
method @RequiresPermission(allOf={android.Manifest.permission.RECORD_AUDIO, android.Manifest.permission.CAPTURE_AUDIO_HOTWORD}) public boolean stopRecognition();
method public final void updateState(@Nullable android.os.PersistableBundle, @Nullable android.os.SharedMemory);
field public static final int AUDIO_CAPABILITY_ECHO_CANCELLATION = 1; // 0x1
@@ -10498,7 +10493,7 @@
method public abstract void onAvailabilityChanged(int);
method public void onHotwordDetectionServiceInitialized(int);
method public void onHotwordDetectionServiceRestarted();
- method public void onRejected(@Nullable android.service.voice.HotwordRejectedResult);
+ method public void onRejected(@NonNull android.service.voice.HotwordRejectedResult);
}
public static class AlwaysOnHotwordDetector.EventPayload {
@@ -10559,8 +10554,8 @@
}
public static final class HotwordDetectionService.Callback {
- method public void onDetected(@Nullable android.service.voice.HotwordDetectedResult);
- method public void onRejected(@Nullable android.service.voice.HotwordRejectedResult);
+ method public void onDetected(@NonNull android.service.voice.HotwordDetectedResult);
+ method public void onRejected(@NonNull android.service.voice.HotwordRejectedResult);
}
public interface HotwordDetector {
@@ -10581,7 +10576,7 @@
method public void onHotwordDetectionServiceRestarted();
method public void onRecognitionPaused();
method public void onRecognitionResumed();
- method public void onRejected(@Nullable android.service.voice.HotwordRejectedResult);
+ method public void onRejected(@NonNull android.service.voice.HotwordRejectedResult);
}
public final class HotwordRejectedResult implements android.os.Parcelable {
@@ -14919,6 +14914,7 @@
public static interface WebViewProvider.ViewDelegate {
method public default void autofill(android.util.SparseArray<android.view.autofill.AutofillValue>);
+ method public default void dispatchCreateViewTranslationRequest(@NonNull java.util.Map<android.view.autofill.AutofillId,long[]>, @NonNull int[], @Nullable android.view.translation.TranslationCapability, @NonNull java.util.List<android.view.translation.ViewTranslationRequest>);
method public boolean dispatchKeyEvent(android.view.KeyEvent);
method public android.view.View findFocus(android.view.View);
method public android.view.accessibility.AccessibilityNodeProvider getAccessibilityNodeProvider();
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index d366e35d..c8e365e 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -50,6 +50,10 @@
field public static final String UNDEFINED = "android.permission-group.UNDEFINED";
}
+ public static final class R.attr {
+ field public static final int requestForegroundServiceExemption;
+ }
+
public static final class R.bool {
field public static final int config_assistantOnTopOfDream = 17891333; // 0x1110005
field public static final int config_perDisplayFocusEnabled = 17891332; // 0x1110004
@@ -452,7 +456,7 @@
method @RequiresPermission(android.Manifest.permission.FORCE_DEVICE_POLICY_MANAGER_LOGS) public long forceNetworkLogs();
method @RequiresPermission("android.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS") public void forceRemoveActiveAdmin(@NonNull android.content.ComponentName, int);
method @RequiresPermission(android.Manifest.permission.FORCE_DEVICE_POLICY_MANAGER_LOGS) public long forceSecurityLogs();
- method public void forceUpdateUserSetupComplete();
+ method public void forceUpdateUserSetupComplete(int);
method @NonNull public java.util.Set<java.lang.String> getDefaultCrossProfilePackages();
method @NonNull public java.util.Set<java.lang.String> getDisallowedSystemApps(@NonNull android.content.ComponentName, int, @NonNull String);
method public long getLastBugReportRequestTime();
@@ -806,6 +810,7 @@
}
public class ApplicationInfo extends android.content.pm.PackageItemInfo implements android.os.Parcelable {
+ method public boolean hasRequestForegroundServiceExemption();
method public boolean isPrivilegedApp();
method public boolean isSystemApp();
field public static final int PRIVATE_FLAG_PRIVILEGED = 8; // 0x8
@@ -860,6 +865,10 @@
field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.ProviderInfoList> CREATOR;
}
+ public final class SharedLibraryInfo implements android.os.Parcelable {
+ method @NonNull public java.util.List<java.lang.String> getAllCodePaths();
+ }
+
public final class ShortcutInfo implements android.os.Parcelable {
method public boolean isVisibleToPublisher();
}
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index ff210e1..a667767 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -5887,7 +5887,7 @@
public final void applyConfigurationToResources(Configuration config) {
synchronized (mResourcesManager) {
- mResourcesManager.applyConfigurationToResourcesLocked(config, null);
+ mResourcesManager.applyConfigurationToResources(config, null);
}
}
@@ -5975,7 +5975,7 @@
synchronized (mResourcesManager) {
// Update all affected Resources objects to use new ResourcesImpl
- mResourcesManager.applyNewResourceDirsLocked(ai, oldResDirs);
+ mResourcesManager.applyNewResourceDirs(ai, oldResDirs);
}
}
@@ -6231,7 +6231,7 @@
synchronized (mResourcesManager) {
// Update affected Resources objects to use new ResourcesImpl
- mResourcesManager.applyNewResourceDirsLocked(aInfo, oldResDirs);
+ mResourcesManager.applyNewResourceDirs(aInfo, oldResDirs);
}
} catch (RemoteException e) {
}
@@ -6474,7 +6474,7 @@
* reflect configuration changes. The configuration object passed
* in AppBindData can be safely assumed to be up to date
*/
- mResourcesManager.applyConfigurationToResourcesLocked(data.config, data.compatInfo);
+ mResourcesManager.applyConfigurationToResources(data.config, data.compatInfo);
mCurDefaultDisplayDpi = data.config.densityDpi;
// This calls mResourcesManager so keep it within the synchronized block.
@@ -7509,7 +7509,7 @@
// We need to apply this change to the resources immediately, because upon returning
// the view hierarchy will be informed about it.
- if (mResourcesManager.applyConfigurationToResourcesLocked(globalConfig,
+ if (mResourcesManager.applyConfigurationToResources(globalConfig,
null /* compat */,
mInitialApplication.getResources().getDisplayAdjustments())) {
mConfigurationController.updateLocaleListFromAppContext(
diff --git a/core/java/android/app/ConfigurationController.java b/core/java/android/app/ConfigurationController.java
index 0dbe3ba..6d92201 100644
--- a/core/java/android/app/ConfigurationController.java
+++ b/core/java/android/app/ConfigurationController.java
@@ -107,8 +107,7 @@
mCompatConfiguration = new Configuration();
}
mCompatConfiguration.setTo(mConfiguration);
- if (mResourcesManager.applyCompatConfigurationLocked(displayDensity,
- mCompatConfiguration)) {
+ if (mResourcesManager.applyCompatConfiguration(displayDensity, mCompatConfiguration)) {
config = mCompatConfiguration;
}
return config;
@@ -199,7 +198,7 @@
// configuration also needs to set to the adjustments for consistency.
appResources.getDisplayAdjustments().getConfiguration().updateFrom(config);
}
- mResourcesManager.applyConfigurationToResourcesLocked(config, compat,
+ mResourcesManager.applyConfigurationToResources(config, compat,
appResources.getDisplayAdjustments());
updateLocaleListFromAppContext(app.getApplicationContext());
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 2dcdd07..6838289 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -174,6 +174,7 @@
*/
public static final @ServiceNotificationPolicy int FOREGROUND_SERVICE_DEFERRED = 2;
+ @ServiceNotificationPolicy
private int mFgsDeferBehavior;
/**
@@ -4614,9 +4615,9 @@
* foreground service. By default, the system can choose to defer
* visibility of the notification for a short time after the service is
* started. Pass
- * {@link Notification#FOREGROUND_SERVICE_IMMEDIATE BEHAVIOR_IMMEDIATE_DISPLAY}
+ * {@link Notification#FOREGROUND_SERVICE_IMMEDIATE FOREGROUND_SERVICE_IMMEDIATE}
* to this method in order to guarantee that visibility is never deferred. Pass
- * {@link Notification#FOREGROUND_SERVICE_DEFERRED BEHAVIOR_DEFERRED_DISPLAY}
+ * {@link Notification#FOREGROUND_SERVICE_DEFERRED FOREGROUND_SERVICE_DEFERRED}
* to request that visibility is deferred whenever possible.
*
* <p class="note">Note that deferred visibility is not guaranteed. There
@@ -4624,13 +4625,13 @@
* service's associated Notification immediately even when the app has used
* this method to explicitly request deferred display.</p>
* @param behavior One of
- * {@link Notification#FOREGROUND_SERVICE_DEFAULT BEHAVIOR_DEFAULT},
- * {@link Notification#FOREGROUND_SERVICE_IMMEDIATE BEHAVIOR_IMMEDIATE_DISPLAY},
- * or {@link Notification#FOREGROUND_SERVICE_DEFERRED BEHAVIOR_DEFERRED_DISPLAY}
+ * {@link Notification#FOREGROUND_SERVICE_DEFAULT FOREGROUND_SERVICE_DEFAULT},
+ * {@link Notification#FOREGROUND_SERVICE_IMMEDIATE FOREGROUND_SERVICE_IMMEDIATE},
+ * or {@link Notification#FOREGROUND_SERVICE_DEFERRED FOREGROUND_SERVICE_DEFERRED}
* @return
*/
@NonNull
- public Builder setForegroundServiceBehavior(int behavior) {
+ public Builder setForegroundServiceBehavior(@ServiceNotificationPolicy int behavior) {
mN.mFgsDeferBehavior = behavior;
return this;
}
@@ -5662,11 +5663,6 @@
R.dimen.call_notification_collapsible_indent);
}
big.setBoolean(R.id.actions, "setEmphasizedMode", emphazisedMode);
- if (p.mCallStyleActions) {
- // Use "wrap_content" (unlike normal emphasized mode) and allow prioritizing the
- // required actions (Answer, Decline, and Hang Up).
- big.setBoolean(R.id.actions, "setPrioritizedWrapMode", true);
- }
if (numActions > 0 && !p.mHideActions) {
big.setViewVisibility(R.id.actions_container, View.VISIBLE);
big.setViewVisibility(R.id.actions, View.VISIBLE);
@@ -5683,7 +5679,7 @@
// Clear the drawable
button.setInt(R.id.action0, "setBackgroundResource", 0);
}
- if (p.mCallStyleActions && i > 0) {
+ if (emphazisedMode && i > 0) {
// Clear start margin from non-first buttons to reduce the gap between them.
// (8dp remaining gap is from all buttons' standard 4dp inset).
button.setViewLayoutMarginDimen(R.id.action0, RemoteViews.MARGIN_START, 0);
@@ -6053,11 +6049,13 @@
.viewType(StandardTemplateParams.VIEW_TYPE_MINIMIZED)
.highlightExpander(false)
.fillTextsFrom(this);
- if (!useRegularSubtext || TextUtils.isEmpty(mParams.summaryText)) {
+ if (!useRegularSubtext || TextUtils.isEmpty(p.summaryText)) {
p.summaryText(createSummaryText());
}
RemoteViews header = makeNotificationHeader(p);
header.setBoolean(R.id.notification_header, "setAcceptAllTouches", true);
+ // The low priority header has no app name and shows the text
+ header.setBoolean(R.id.notification_header, "styleTextAsTitle", true);
return header;
}
@@ -6103,26 +6101,21 @@
// change the background bgColor
CharSequence title = action.title;
ColorStateList[] outResultColor = new ColorStateList[1];
- int background = getBackgroundColor(p);
+ int background = getSecondaryAccentColor(p);
if (isLegacy()) {
title = ContrastColorUtil.clearColorSpans(title);
} else {
title = ensureColorSpanContrast(title, background, outResultColor);
}
button.setTextViewText(R.id.action0, processTextSpans(title));
- final int textColor;
boolean hasColorOverride = outResultColor[0] != null;
if (hasColorOverride) {
// There's a span spanning the full text, let's take it and use it as the
// background color
background = outResultColor[0].getDefaultColor();
- textColor = ContrastColorUtil.resolvePrimaryColor(mContext,
- background, mInNightMode);
- } else if (mTintActionButtons && !mInNightMode && !isBackgroundColorized(p)) {
- textColor = getAccentColor(p);
- } else {
- textColor = getPrimaryTextColor(p);
}
+ final int textColor = ContrastColorUtil.resolvePrimaryColor(mContext,
+ background, mInNightMode);
button.setTextColor(R.id.action0, textColor);
// We only want about 20% alpha for the ripple
final int rippleColor = (textColor & 0x00ffffff) | 0x33000000;
@@ -6130,11 +6123,10 @@
ColorStateList.valueOf(rippleColor));
button.setColorStateList(R.id.action0, "setButtonBackground",
ColorStateList.valueOf(background));
- button.setBoolean(R.id.action0, "setHasStroke", !hasColorOverride);
if (p.mCallStyleActions) {
button.setImageViewIcon(R.id.action0, action.getIcon());
boolean priority = action.getExtras().getBoolean(CallStyle.KEY_ACTION_PRIORITY);
- button.setBoolean(R.id.action0, "setWrapModePriority", priority);
+ button.setBoolean(R.id.action0, "setIsPriority", priority);
int minWidthDimen =
priority ? R.dimen.call_notification_system_action_min_width : 0;
button.setIntDimen(R.id.action0, "setMinimumWidth", minWidthDimen);
@@ -6320,6 +6312,22 @@
}
/**
+ * Gets the secondary accent color for colored UI elements. If we're tinting with the theme
+ * accent, this is the theme accent color, otherwise this would be identical to
+ * {@link #getSmallIconColor(StandardTemplateParams)}.
+ */
+ private @ColorInt int getSecondaryAccentColor(StandardTemplateParams p) {
+ if (isBackgroundColorized(p)) {
+ return getSecondaryTextColor(p);
+ }
+ int color = obtainThemeColor(R.attr.colorAccentSecondary, COLOR_INVALID);
+ if (color != COLOR_INVALID) {
+ return color;
+ }
+ return getContrastColor(p);
+ }
+
+ /**
* Gets the "surface protection" color from the theme, or a variant of the normal background
* color when colorized, or when not using theme color tints.
*/
diff --git a/core/java/android/app/ResourcesManager.java b/core/java/android/app/ResourcesManager.java
index 74134e1..792336d 100644
--- a/core/java/android/app/ResourcesManager.java
+++ b/core/java/android/app/ResourcesManager.java
@@ -75,6 +75,11 @@
private static ResourcesManager sResourcesManager;
/**
+ * Internal lock object
+ */
+ private final Object mLock = new Object();
+
+ /**
* The global compatibility settings.
*/
private CompatibilityInfo mResCompatibilityInfo;
@@ -275,7 +280,7 @@
* try as hard as possible to release any open FDs.
*/
public void invalidatePath(String path) {
- synchronized (this) {
+ synchronized (mLock) {
int count = 0;
for (int i = mResourceImpls.size() - 1; i >= 0; i--) {
@@ -304,7 +309,7 @@
}
public Configuration getConfiguration() {
- synchronized (this) {
+ synchronized (mLock) {
return mResConfiguration;
}
}
@@ -351,13 +356,15 @@
config.compatSmallestScreenWidthDp = config.smallestScreenWidthDp;
}
- public boolean applyCompatConfigurationLocked(int displayDensity,
+ public boolean applyCompatConfiguration(int displayDensity,
@NonNull Configuration compatConfiguration) {
- if (mResCompatibilityInfo != null && !mResCompatibilityInfo.supportsScreen()) {
- mResCompatibilityInfo.applyToConfiguration(displayDensity, compatConfiguration);
- return true;
+ synchronized (mLock) {
+ if (mResCompatibilityInfo != null && !mResCompatibilityInfo.supportsScreen()) {
+ mResCompatibilityInfo.applyToConfiguration(displayDensity, compatConfiguration);
+ return true;
+ }
+ return false;
}
- return false;
}
/**
@@ -376,7 +383,7 @@
final Pair<Integer, DisplayAdjustments> key =
Pair.create(displayId, displayAdjustmentsCopy);
SoftReference<Display> sd;
- synchronized (this) {
+ synchronized (mLock) {
sd = mAdjustedDisplays.get(key);
}
if (sd != null) {
@@ -392,7 +399,7 @@
}
final Display display = dm.getCompatibleDisplay(displayId, key.second);
if (display != null) {
- synchronized (this) {
+ synchronized (mLock) {
mAdjustedDisplays.put(key, new SoftReference<>(display));
}
}
@@ -407,7 +414,7 @@
* @param resources The {@link Resources} backing the display adjustments.
*/
public Display getAdjustedDisplay(final int displayId, Resources resources) {
- synchronized (this) {
+ synchronized (mLock) {
final DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance();
if (dm == null) {
// may be null early in system startup
@@ -425,7 +432,7 @@
ApkAssets apkAssets;
// Optimistically check if this ApkAssets exists somewhere else.
- synchronized (this) {
+ synchronized (mLock) {
final WeakReference<ApkAssets> apkAssetsRef = mCachedApkAssets.get(key);
if (apkAssetsRef != null) {
apkAssets = apkAssetsRef.get();
@@ -447,7 +454,7 @@
key.sharedLib ? ApkAssets.PROPERTY_DYNAMIC : 0);
}
- synchronized (this) {
+ synchronized (mLock) {
mCachedApkAssets.put(key, new WeakReference<>(apkAssets));
}
@@ -559,7 +566,7 @@
* @hide
*/
public void dump(String prefix, PrintWriter printWriter) {
- synchronized (this) {
+ synchronized (mLock) {
IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, " ");
for (int i = 0; i < prefix.length() / 2; i++) {
pw.increaseIndent();
@@ -688,7 +695,7 @@
*/
boolean isSameResourcesOverrideConfig(@Nullable IBinder activityToken,
@Nullable Configuration overrideConfig) {
- synchronized (this) {
+ synchronized (mLock) {
final ActivityResources activityResources
= activityToken != null ? mActivityResourceReferences.get(activityToken) : null;
if (activityResources == null) {
@@ -834,7 +841,7 @@
+ " with key=" + key);
}
- synchronized (this) {
+ synchronized (mLock) {
// Force the creation of an ActivityResourcesStruct.
getOrCreateActivityResourcesStructLocked(token);
}
@@ -842,7 +849,7 @@
// Update any existing Activity Resources references.
updateResourcesForActivity(token, overrideConfig, displayId);
- synchronized (this) {
+ synchronized (mLock) {
Resources resources = findResourcesForActivityLocked(token, key,
classLoader);
if (resources != null) {
@@ -868,7 +875,7 @@
*/
private void rebaseKeyForActivity(IBinder activityToken, ResourcesKey key,
boolean overridesActivityDisplay) {
- synchronized (this) {
+ synchronized (mLock) {
final ActivityResources activityResources =
getOrCreateActivityResourcesStructLocked(activityToken);
@@ -960,7 +967,7 @@
Trace.traceBegin(Trace.TRACE_TAG_RESOURCES,
"ResourcesManager#createApkAssetsSupplierNotLocked");
try {
- if (DEBUG && Thread.holdsLock(this)) {
+ if (DEBUG && Thread.holdsLock(mLock)) {
Slog.w(TAG, "Calling thread " + Thread.currentThread().getName()
+ " is holding mLock", new Throwable());
}
@@ -994,7 +1001,7 @@
@Nullable
private Resources createResources(@NonNull ResourcesKey key, @NonNull ClassLoader classLoader,
@Nullable ApkAssetsSupplier apkSupplier) {
- synchronized (this) {
+ synchronized (mLock) {
if (DEBUG) {
Throwable here = new Throwable();
here.fillInStackTrace();
@@ -1015,7 +1022,7 @@
@NonNull ResourcesKey key, @NonNull Configuration initialOverrideConfig,
@Nullable Integer overrideDisplayId, @NonNull ClassLoader classLoader,
@Nullable ApkAssetsSupplier apkSupplier) {
- synchronized (this) {
+ synchronized (mLock) {
if (DEBUG) {
Throwable here = new Throwable();
here.fillInStackTrace();
@@ -1130,7 +1137,7 @@
if (displayId == INVALID_DISPLAY) {
throw new IllegalArgumentException("displayId can not be INVALID_DISPLAY");
}
- synchronized (this) {
+ synchronized (mLock) {
final ActivityResources activityResources =
getOrCreateActivityResourcesStructLocked(activityToken);
@@ -1269,67 +1276,64 @@
public final boolean applyConfigurationToResources(@NonNull Configuration config,
@Nullable CompatibilityInfo compat) {
- synchronized(this) {
- return applyConfigurationToResourcesLocked(config, compat, null /* adjustments */);
- }
- }
-
- public final boolean applyConfigurationToResourcesLocked(@NonNull Configuration config,
- @Nullable CompatibilityInfo compat) {
- return applyConfigurationToResourcesLocked(config, compat, null /* adjustments */);
+ return applyConfigurationToResources(config, compat, null /* adjustments */);
}
/** Applies the global configuration to the managed resources. */
- public final boolean applyConfigurationToResourcesLocked(@NonNull Configuration config,
+ public final boolean applyConfigurationToResources(@NonNull Configuration config,
@Nullable CompatibilityInfo compat, @Nullable DisplayAdjustments adjustments) {
- try {
- Trace.traceBegin(Trace.TRACE_TAG_RESOURCES,
- "ResourcesManager#applyConfigurationToResourcesLocked");
+ synchronized (mLock) {
+ try {
+ Trace.traceBegin(Trace.TRACE_TAG_RESOURCES,
+ "ResourcesManager#applyConfigurationToResources");
- if (!mResConfiguration.isOtherSeqNewer(config) && compat == null) {
- if (DEBUG || DEBUG_CONFIGURATION) Slog.v(TAG, "Skipping new config: curSeq="
- + mResConfiguration.seq + ", newSeq=" + config.seq);
- return false;
- }
-
- // Things might have changed in display manager, so clear the cached displays.
- mAdjustedDisplays.clear();
-
- int changes = mResConfiguration.updateFrom(config);
- if (compat != null && (mResCompatibilityInfo == null ||
- !mResCompatibilityInfo.equals(compat))) {
- mResCompatibilityInfo = compat;
- changes |= ActivityInfo.CONFIG_SCREEN_LAYOUT
- | ActivityInfo.CONFIG_SCREEN_SIZE
- | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
- }
-
- DisplayMetrics displayMetrics = getDisplayMetrics();
- if (adjustments != null) {
- // Currently the only case where the adjustment takes effect is to simulate placing
- // an app in a rotated display.
- adjustments.adjustGlobalAppMetrics(displayMetrics);
- }
- Resources.updateSystemConfiguration(config, displayMetrics, compat);
-
- ApplicationPackageManager.configurationChanged();
-
- Configuration tmpConfig = new Configuration();
-
- for (int i = mResourceImpls.size() - 1; i >= 0; i--) {
- ResourcesKey key = mResourceImpls.keyAt(i);
- WeakReference<ResourcesImpl> weakImplRef = mResourceImpls.valueAt(i);
- ResourcesImpl r = weakImplRef != null ? weakImplRef.get() : null;
- if (r != null) {
- applyConfigurationToResourcesLocked(config, compat, tmpConfig, key, r);
- } else {
- mResourceImpls.removeAt(i);
+ if (!mResConfiguration.isOtherSeqNewer(config) && compat == null) {
+ if (DEBUG || DEBUG_CONFIGURATION) {
+ Slog.v(TAG, "Skipping new config: curSeq="
+ + mResConfiguration.seq + ", newSeq=" + config.seq);
+ }
+ return false;
}
- }
- return changes != 0;
- } finally {
- Trace.traceEnd(Trace.TRACE_TAG_RESOURCES);
+ // Things might have changed in display manager, so clear the cached displays.
+ mAdjustedDisplays.clear();
+
+ int changes = mResConfiguration.updateFrom(config);
+ if (compat != null && (mResCompatibilityInfo == null
+ || !mResCompatibilityInfo.equals(compat))) {
+ mResCompatibilityInfo = compat;
+ changes |= ActivityInfo.CONFIG_SCREEN_LAYOUT
+ | ActivityInfo.CONFIG_SCREEN_SIZE
+ | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
+ }
+
+ DisplayMetrics displayMetrics = getDisplayMetrics();
+ if (adjustments != null) {
+ // Currently the only case where the adjustment takes effect is to simulate
+ // placing an app in a rotated display.
+ adjustments.adjustGlobalAppMetrics(displayMetrics);
+ }
+ Resources.updateSystemConfiguration(config, displayMetrics, compat);
+
+ ApplicationPackageManager.configurationChanged();
+
+ Configuration tmpConfig = new Configuration();
+
+ for (int i = mResourceImpls.size() - 1; i >= 0; i--) {
+ ResourcesKey key = mResourceImpls.keyAt(i);
+ WeakReference<ResourcesImpl> weakImplRef = mResourceImpls.valueAt(i);
+ ResourcesImpl r = weakImplRef != null ? weakImplRef.get() : null;
+ if (r != null) {
+ applyConfigurationToResourcesLocked(config, compat, tmpConfig, key, r);
+ } else {
+ mResourceImpls.removeAt(i);
+ }
+ }
+
+ return changes != 0;
+ } finally {
+ Trace.traceEnd(Trace.TRACE_TAG_RESOURCES);
+ }
}
}
@@ -1378,7 +1382,7 @@
* @param libAssets The library asset paths to add.
*/
public void appendLibAssetsForMainAssetPath(String assetPath, String[] libAssets) {
- synchronized (this) {
+ synchronized (mLock) {
// Record which ResourcesImpl need updating
// (and what ResourcesKey they should update to).
final ArrayMap<ResourcesImpl, ResourcesKey> updatedResourceKeys = new ArrayMap<>();
@@ -1414,54 +1418,56 @@
}
// TODO(adamlesinski): Make this accept more than just overlay directories.
- final void applyNewResourceDirsLocked(@NonNull final ApplicationInfo appInfo,
+ void applyNewResourceDirs(@NonNull final ApplicationInfo appInfo,
@Nullable final String[] oldPaths) {
- try {
- Trace.traceBegin(Trace.TRACE_TAG_RESOURCES,
- "ResourcesManager#applyNewResourceDirsLocked");
+ synchronized (mLock) {
+ try {
+ Trace.traceBegin(Trace.TRACE_TAG_RESOURCES,
+ "ResourcesManager#applyNewResourceDirsLocked");
- String baseCodePath = appInfo.getBaseCodePath();
+ String baseCodePath = appInfo.getBaseCodePath();
- final int myUid = Process.myUid();
- String[] newSplitDirs = appInfo.uid == myUid
- ? appInfo.splitSourceDirs
- : appInfo.splitPublicSourceDirs;
+ final int myUid = Process.myUid();
+ String[] newSplitDirs = appInfo.uid == myUid
+ ? appInfo.splitSourceDirs
+ : appInfo.splitPublicSourceDirs;
- // ApplicationInfo is mutable, so clone the arrays to prevent outside modification
- String[] copiedSplitDirs = ArrayUtils.cloneOrNull(newSplitDirs);
- String[] copiedResourceDirs = combinedOverlayPaths(appInfo.resourceDirs,
- appInfo.overlayPaths);
+ // ApplicationInfo is mutable, so clone the arrays to prevent outside modification
+ String[] copiedSplitDirs = ArrayUtils.cloneOrNull(newSplitDirs);
+ String[] copiedResourceDirs = combinedOverlayPaths(appInfo.resourceDirs,
+ appInfo.overlayPaths);
- final ArrayMap<ResourcesImpl, ResourcesKey> updatedResourceKeys = new ArrayMap<>();
- final int implCount = mResourceImpls.size();
- for (int i = 0; i < implCount; i++) {
- final ResourcesKey key = mResourceImpls.keyAt(i);
- final WeakReference<ResourcesImpl> weakImplRef = mResourceImpls.valueAt(i);
- final ResourcesImpl impl = weakImplRef != null ? weakImplRef.get() : null;
+ final ArrayMap<ResourcesImpl, ResourcesKey> updatedResourceKeys = new ArrayMap<>();
+ final int implCount = mResourceImpls.size();
+ for (int i = 0; i < implCount; i++) {
+ final ResourcesKey key = mResourceImpls.keyAt(i);
+ final WeakReference<ResourcesImpl> weakImplRef = mResourceImpls.valueAt(i);
+ final ResourcesImpl impl = weakImplRef != null ? weakImplRef.get() : null;
- if (impl == null) {
- continue;
+ if (impl == null) {
+ continue;
+ }
+
+ if (key.mResDir == null
+ || key.mResDir.equals(baseCodePath)
+ || ArrayUtils.contains(oldPaths, key.mResDir)) {
+ updatedResourceKeys.put(impl, new ResourcesKey(
+ baseCodePath,
+ copiedSplitDirs,
+ copiedResourceDirs,
+ key.mLibDirs,
+ key.mDisplayId,
+ key.mOverrideConfiguration,
+ key.mCompatInfo,
+ key.mLoaders
+ ));
+ }
}
- if (key.mResDir == null
- || key.mResDir.equals(baseCodePath)
- || ArrayUtils.contains(oldPaths, key.mResDir)) {
- updatedResourceKeys.put(impl, new ResourcesKey(
- baseCodePath,
- copiedSplitDirs,
- copiedResourceDirs,
- key.mLibDirs,
- key.mDisplayId,
- key.mOverrideConfiguration,
- key.mCompatInfo,
- key.mLoaders
- ));
- }
+ redirectResourcesToNewImplLocked(updatedResourceKeys);
+ } finally {
+ Trace.traceEnd(Trace.TRACE_TAG_RESOURCES);
}
-
- redirectResourcesToNewImplLocked(updatedResourceKeys);
- } finally {
- Trace.traceEnd(Trace.TRACE_TAG_RESOURCES);
}
}
@@ -1556,7 +1562,7 @@
public boolean overrideTokenDisplayAdjustments(IBinder token,
@Nullable Consumer<DisplayAdjustments> override) {
boolean handled = false;
- synchronized (this) {
+ synchronized (mLock) {
final ActivityResources tokenResources = mActivityResourceReferences.get(token);
if (tokenResources == null) {
return false;
@@ -1589,7 +1595,7 @@
@Override
public void onLoadersChanged(@NonNull Resources resources,
@NonNull List<ResourcesLoader> newLoader) {
- synchronized (ResourcesManager.this) {
+ synchronized (mLock) {
final ResourcesKey oldKey = findKeyForResourceImplLocked(resources.getImpl());
if (oldKey == null) {
throw new IllegalArgumentException("Cannot modify resource loaders of"
@@ -1617,7 +1623,7 @@
**/
@Override
public void onLoaderUpdated(@NonNull ResourcesLoader loader) {
- synchronized (ResourcesManager.this) {
+ synchronized (mLock) {
final ArrayMap<ResourcesImpl, ResourcesKey> updatedResourceImplKeys =
new ArrayMap<>();
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 02e64b8..38b19ae 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -11974,15 +11974,14 @@
/**
* @hide
- * Force update user setup completed status.
+ * Force update user setup completed status for the given {@code userId}.
* @throws {@link SecurityException} if the caller has no
- * {@code android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS} or the caller is
- * not {@link UserHandle#SYSTEM_USER}
+ * {@code android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS}.
*/
@TestApi
- public void forceUpdateUserSetupComplete() {
+ public void forceUpdateUserSetupComplete(@UserIdInt int userId) {
try {
- mService.forceUpdateUserSetupComplete();
+ mService.forceUpdateUserSetupComplete(userId);
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 9f76bd1..db2fc0d 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -406,7 +406,7 @@
boolean isDeviceProvisioningConfigApplied();
void setDeviceProvisioningConfigApplied();
- void forceUpdateUserSetupComplete();
+ void forceUpdateUserSetupComplete(int userId);
void setBackupServiceEnabled(in ComponentName admin, boolean enabled);
boolean isBackupServiceEnabled(in ComponentName admin);
diff --git a/core/java/android/app/admin/SecurityLog.java b/core/java/android/app/admin/SecurityLog.java
index 1cf4567..8c59982 100644
--- a/core/java/android/app/admin/SecurityLog.java
+++ b/core/java/android/app/admin/SecurityLog.java
@@ -189,6 +189,7 @@
* detected.
* <li> {@code eio} indicates that an I/O error will be returned for an attempt to read
* corrupted data blocks.
+ * <li> {@code disabled} indicates that integrity check is disabled.
* For details see Verified Boot documentation.
*/
public static final int TAG_OS_STARTUP = SecurityLogTags.SECURITY_OS_STARTUP;
@@ -344,7 +345,7 @@
public static final int TAG_WIPE_FAILURE = SecurityLogTags.SECURITY_WIPE_FAILED;
/**
- * Indicates that an authentication key was generated. The log entry contains the following
+ * Indicates that a cryptographic key was generated. The log entry contains the following
* information about the event, encapsulated in an {@link Object} array and accessible via
* {@link SecurityEvent#getData()}:
* <li> [0] result ({@code Integer}, 0 if operation failed, 1 if succeeded)
diff --git a/core/java/android/bluetooth/le/ScanFilter.java b/core/java/android/bluetooth/le/ScanFilter.java
index c5c4277..dfef47d 100644
--- a/core/java/android/bluetooth/le/ScanFilter.java
+++ b/core/java/android/bluetooth/le/ScanFilter.java
@@ -586,6 +586,10 @@
* @throws IllegalArgumentException If the {@code deviceAddress} is invalid.
*/
public Builder setDeviceAddress(String deviceAddress) {
+ if (deviceAddress == null) {
+ mDeviceAddress = deviceAddress;
+ return this;
+ }
return setDeviceAddress(deviceAddress, BluetoothDevice.ADDRESS_TYPE_PUBLIC);
}
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 7c7cfdb..bbb49fb 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -2022,12 +2022,9 @@
* <p>
* Output: Nothing.
* </p>
- *
- * @hide
*/
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
@RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE)
- @SystemApi
public static final String ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD =
"android.intent.action.VIEW_PERMISSION_USAGE_FOR_PERIOD";
@@ -2188,12 +2185,7 @@
* <p>
* Type: String
* </p>
- *
- * E.g. {@link android.Manifest.permission_group.CONTACTS}
- *
- * @hide
*/
- @SystemApi
public static final String EXTRA_PERMISSION_GROUP_NAME =
"android.intent.extra.PERMISSION_GROUP_NAME";
@@ -5342,28 +5334,19 @@
* {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD}
*
* E.g. an attribution tag could be location_provider, com.google.android.gms.*, etc.
- *
- * @hide
*/
- @SystemApi
public static final String EXTRA_ATTRIBUTION_TAGS = "android.intent.extra.ATTRIBUTION_TAGS";
/**
* A long representing the start timestamp (epoch time in millis) of the permission usage
* when used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD}
- *
- * @hide
*/
- @SystemApi
public static final String EXTRA_START_TIME = "android.intent.extra.START_TIME";
/**
* A long representing the end timestamp (epoch time in millis) of the permission usage when
* used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD}
- *
- * @hide
*/
- @SystemApi
public static final String EXTRA_END_TIME = "android.intent.extra.END_TIME";
/**
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index a3e0473..8b0e992 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -778,9 +778,18 @@
*/
public static final int PRIVATE_FLAG_EXT_PROFILEABLE = 1 << 0;
+ /**
+ * Value for {@link #privateFlagsExt}: whether this application has requested
+ * exemption from the foreground service restriction introduced in S
+ * (https://developer.android.com/about/versions/12/foreground-services).
+ * @hide
+ */
+ public static final int PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION = 1 << 1;
+
/** @hide */
@IntDef(flag = true, prefix = { "PRIVATE_FLAG_EXT_" }, value = {
PRIVATE_FLAG_EXT_PROFILEABLE,
+ PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ApplicationInfoPrivateFlagsExt {}
@@ -2445,6 +2454,17 @@
}
/**
+ * @return whether the app has requested exemption from the foreground service restrictions.
+ * This does not take any affect for now.
+ * @hide
+ */
+ @TestApi
+ public boolean hasRequestForegroundServiceExemption() {
+ return (privateFlagsExt
+ & ApplicationInfo.PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION) != 0;
+ }
+
+ /**
* @hide
*/
@Override protected ApplicationInfo getApplicationInfo() {
diff --git a/core/java/android/content/pm/IShortcutService.aidl b/core/java/android/content/pm/IShortcutService.aidl
index 9d381ef..804a06b 100644
--- a/core/java/android/content/pm/IShortcutService.aidl
+++ b/core/java/android/content/pm/IShortcutService.aidl
@@ -81,7 +81,4 @@
AndroidFuture<ParceledListSlice> getShortcuts(String packageName, int matchFlags, int userId);
AndroidFuture pushDynamicShortcut(String packageName, in ShortcutInfo shortcut, int userId);
-
- AndroidFuture updateShortcutVisibility(String callingPkg, String packageName,
- in byte[] certificate, in boolean visible, int userId);
}
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index a1d419e..edf0e57 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -4775,8 +4775,7 @@
* @param flags Additional option flags to modify the data returned.
* @return A {@link ServiceInfo} object containing information about the
* service.
- * @throws NameNotFoundException if a package with the given name cannot be
- * found on the system.
+ * @throws NameNotFoundException if the component cannot be found on the system.
*/
@NonNull
public abstract ServiceInfo getServiceInfo(@NonNull ComponentName component,
diff --git a/core/java/android/content/pm/SharedLibraryInfo.java b/core/java/android/content/pm/SharedLibraryInfo.java
index a60e642..13ff602 100644
--- a/core/java/android/content/pm/SharedLibraryInfo.java
+++ b/core/java/android/content/pm/SharedLibraryInfo.java
@@ -20,6 +20,7 @@
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.TestApi;
import android.os.Parcel;
import android.os.Parcelable;
@@ -29,6 +30,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
/**
* This class provides information for a shared library. There are
@@ -190,7 +192,8 @@
*
* @hide
*/
- public List<String> getAllCodePaths() {
+ @TestApi
+ public @NonNull List<String> getAllCodePaths() {
if (getPath() != null) {
// Builtin library.
ArrayList<String> list = new ArrayList<>();
@@ -198,7 +201,7 @@
return list;
} else {
// Static or dynamic library.
- return mCodePaths;
+ return Objects.requireNonNull(mCodePaths);
}
}
diff --git a/core/java/android/content/pm/ShortcutManager.java b/core/java/android/content/pm/ShortcutManager.java
index 2a36c11..d77fa91 100644
--- a/core/java/android/content/pm/ShortcutManager.java
+++ b/core/java/android/content/pm/ShortcutManager.java
@@ -40,7 +40,6 @@
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
-import android.os.UserHandle;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.infra.AndroidFuture;
@@ -790,23 +789,6 @@
}
}
- /**
- * Granting another app the access to the shortcuts you own. You must provide the package name
- * and their SHA256 certificate digest in order to granting the access.
- *
- * Once granted, the other app can retain a copy of all the shortcuts you own when calling
- * {@link LauncherApps#getShortcuts(LauncherApps.ShortcutQuery, UserHandle)}.
- */
- public void updateShortcutVisibility(@NonNull final String packageName,
- @Nullable final byte[] certificate, final boolean visible) {
- try {
- getFutureOrThrow(mService.updateShortcutVisibility(mContext.getPackageName(),
- packageName, certificate, visible, injectMyUserId()));
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
private static <T> T getFutureOrThrow(@NonNull AndroidFuture<T> future) {
try {
return future.get();
diff --git a/core/java/android/content/pm/TEST_MAPPING b/core/java/android/content/pm/TEST_MAPPING
index 8bc3734..aa26520 100644
--- a/core/java/android/content/pm/TEST_MAPPING
+++ b/core/java/android/content/pm/TEST_MAPPING
@@ -39,6 +39,9 @@
"include-filter": "android.incrementalinstall.cts.IncrementalFeatureTest"
}
]
+ },
+ {
+ "name": "CtsPackageManagerBootTestCases"
}
],
"postsubmit": [
diff --git a/core/java/android/content/pm/parsing/PackageInfoWithoutStateUtils.java b/core/java/android/content/pm/parsing/PackageInfoWithoutStateUtils.java
index 980f10d..a9d70c5 100644
--- a/core/java/android/content/pm/parsing/PackageInfoWithoutStateUtils.java
+++ b/core/java/android/content/pm/parsing/PackageInfoWithoutStateUtils.java
@@ -397,7 +397,7 @@
}
// CompatibilityMode is global state.
- if (!ParsingPackageUtils.sCompatibilityModeEnabled) {
+ if (!android.content.pm.PackageParser.sCompatibilityModeEnabled) {
ai.disableCompatibilityMode();
}
@@ -806,7 +806,9 @@
public static int appInfoPrivateFlagsExt(ParsingPackageRead pkg) {
// @formatter:off
int privateFlagsExt =
- flag(pkg.isProfileable(), ApplicationInfo.PRIVATE_FLAG_EXT_PROFILEABLE);
+ flag(pkg.isProfileable(), ApplicationInfo.PRIVATE_FLAG_EXT_PROFILEABLE)
+ | flag(pkg.hasRequestForegroundServiceExemption(),
+ ApplicationInfo.PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION);
// @formatter:on
return privateFlagsExt;
}
diff --git a/core/java/android/content/pm/parsing/ParsingPackage.java b/core/java/android/content/pm/parsing/ParsingPackage.java
index cea50cb..2413e6d 100644
--- a/core/java/android/content/pm/parsing/ParsingPackage.java
+++ b/core/java/android/content/pm/parsing/ParsingPackage.java
@@ -338,6 +338,8 @@
ParsingPackage setTheme(int theme);
+ ParsingPackage setRequestForegroundServiceExemption(boolean requestForegroundServiceExemption);
+
ParsingPackage setUpgradeKeySets(@NonNull Set<String> upgradeKeySets);
ParsingPackage setUse32BitAbi(boolean use32BitAbi);
diff --git a/core/java/android/content/pm/parsing/ParsingPackageImpl.java b/core/java/android/content/pm/parsing/ParsingPackageImpl.java
index 7114886..b0342aa 100644
--- a/core/java/android/content/pm/parsing/ParsingPackageImpl.java
+++ b/core/java/android/content/pm/parsing/ParsingPackageImpl.java
@@ -464,6 +464,7 @@
CROSS_PROFILE,
ENABLED,
DISALLOW_PROFILING,
+ REQUEST_FOREGROUND_SERVICE_EXEMPTION,
})
public @interface Values {}
private static final long EXTERNAL_STORAGE = 1L;
@@ -512,6 +513,7 @@
private static final long CROSS_PROFILE = 1L << 43;
private static final long ENABLED = 1L << 44;
private static final long DISALLOW_PROFILING = 1L << 45;
+ private static final long REQUEST_FOREGROUND_SERVICE_EXEMPTION = 1L << 46;
}
private ParsingPackageImpl setBoolean(@Booleans.Values long flag, boolean value) {
@@ -2199,6 +2201,11 @@
}
@Override
+ public boolean hasRequestForegroundServiceExemption() {
+ return getBoolean(Booleans.REQUEST_FOREGROUND_SERVICE_EXEMPTION);
+ }
+
+ @Override
public ParsingPackageImpl setBaseRevisionCode(int value) {
baseRevisionCode = value;
return this;
@@ -2420,6 +2427,11 @@
}
@Override
+ public ParsingPackageImpl setRequestForegroundServiceExemption(boolean value) {
+ return setBoolean(Booleans.REQUEST_FOREGROUND_SERVICE_EXEMPTION, value);
+ }
+
+ @Override
public ParsingPackageImpl setUiOptions(int value) {
uiOptions = value;
return this;
diff --git a/core/java/android/content/pm/parsing/ParsingPackageRead.java b/core/java/android/content/pm/parsing/ParsingPackageRead.java
index 1c2c59f..35a2b9a 100644
--- a/core/java/android/content/pm/parsing/ParsingPackageRead.java
+++ b/core/java/android/content/pm/parsing/ParsingPackageRead.java
@@ -906,10 +906,15 @@
*/
@ApplicationInfo.NativeHeapZeroInitialized
int getNativeHeapZeroInitialized();
-
@Nullable
Boolean hasRequestRawExternalStorageAccess();
+ /**
+ * @see ApplicationInfo#hasRequestForegroundServiceExemption()
+ * @see R.styleable#AndroidManifest_requestForegroundServiceExemption
+ */
+ boolean hasRequestForegroundServiceExemption();
+
// TODO(b/135203078): Hide and enforce going through PackageInfoUtils
ApplicationInfo toAppInfoWithoutState();
diff --git a/core/java/android/content/pm/parsing/ParsingPackageUtils.java b/core/java/android/content/pm/parsing/ParsingPackageUtils.java
index 22d75ef..5d74e74 100644
--- a/core/java/android/content/pm/parsing/ParsingPackageUtils.java
+++ b/core/java/android/content/pm/parsing/ParsingPackageUtils.java
@@ -2033,6 +2033,12 @@
.AndroidManifestApplication_requestRawExternalStorageAccess,
false));
}
+ if (sa.hasValue(
+ R.styleable.AndroidManifestApplication_requestForegroundServiceExemption)) {
+ pkg.setRequestForegroundServiceExemption(sa.getBoolean(R.styleable
+ .AndroidManifestApplication_requestForegroundServiceExemption,
+ false));
+ }
} finally {
sa.recycle();
}
diff --git a/core/java/android/hardware/camera2/CameraExtensionCharacteristics.java b/core/java/android/hardware/camera2/CameraExtensionCharacteristics.java
index 80b5078..8e3de61 100644
--- a/core/java/android/hardware/camera2/CameraExtensionCharacteristics.java
+++ b/core/java/android/hardware/camera2/CameraExtensionCharacteristics.java
@@ -21,9 +21,11 @@
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.ImageFormat;
+import android.hardware.camera2.extension.IAdvancedExtenderImpl;
import android.hardware.camera2.extension.ICameraExtensionsProxyService;
import android.hardware.camera2.extension.IImageCaptureExtenderImpl;
import android.hardware.camera2.extension.IPreviewExtenderImpl;
+import android.hardware.camera2.extension.LatencyRange;
import android.hardware.camera2.extension.SizeList;
import android.hardware.camera2.params.ExtensionSessionConfiguration;
import android.hardware.camera2.params.StreamConfigurationMap;
@@ -220,6 +222,7 @@
private InitializerFuture mInitFuture = null;
private ServiceConnection mConnection = null;
private ICameraExtensionsProxyService mProxy = null;
+ private boolean mSupportsAdvancedExtensions = false;
// Singleton, don't allow construction
private CameraExtensionManagerGlobal() {}
@@ -245,6 +248,11 @@
public void onServiceConnected(ComponentName component, IBinder binder) {
mProxy = ICameraExtensionsProxyService.Stub.asInterface(binder);
mInitFuture.setStatus(true);
+ try {
+ mSupportsAdvancedExtensions = mProxy.advancedExtensionsSupported();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Remote IPC failed!");
+ }
}
};
ctx.bindService(intent, mConnection, Context.BIND_AUTO_CREATE |
@@ -334,6 +342,10 @@
}
}
+ public boolean areAdvancedExtensionsSupported() {
+ return mSupportsAdvancedExtensions;
+ }
+
public IPreviewExtenderImpl initializePreviewExtension(int extensionType)
throws RemoteException {
synchronized (mLock) {
@@ -355,6 +367,17 @@
}
}
}
+
+ public IAdvancedExtenderImpl initializeAdvancedExtension(int extensionType)
+ throws RemoteException {
+ synchronized (mLock) {
+ if (mProxy != null) {
+ return mProxy.initializeAdvancedExtension(extensionType);
+ } else {
+ return null;
+ }
+ }
+ }
}
/**
@@ -374,23 +397,60 @@
/**
* @hide
*/
+ public static boolean areAdvancedExtensionsSupported() {
+ return CameraExtensionManagerGlobal.get().areAdvancedExtensionsSupported();
+ }
+
+ /**
+ * @hide
+ */
public static boolean isExtensionSupported(String cameraId, int extensionType,
CameraCharacteristics chars) {
- Pair<IPreviewExtenderImpl, IImageCaptureExtenderImpl> extenders;
+ if (areAdvancedExtensionsSupported()) {
+ try {
+ IAdvancedExtenderImpl extender = initializeAdvancedExtension(extensionType);
+ return extender.isExtensionAvailable(cameraId);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to query extension availability! Extension service does not"
+ + " respond!");
+ return false;
+ }
+ } else {
+ Pair<IPreviewExtenderImpl, IImageCaptureExtenderImpl> extenders;
+ try {
+ extenders = initializeExtension(extensionType);
+ } catch (IllegalArgumentException e) {
+ return false;
+ }
+
+ try {
+ return extenders.first.isExtensionAvailable(cameraId, chars.getNativeMetadata()) &&
+ extenders.second.isExtensionAvailable(cameraId, chars.getNativeMetadata());
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to query extension availability! Extension service does not"
+ + " respond!");
+ return false;
+ }
+ }
+ }
+
+ /**
+ * @hide
+ */
+ public static IAdvancedExtenderImpl initializeAdvancedExtension(@Extension int extensionType) {
+ IAdvancedExtenderImpl extender;
try {
- extenders = initializeExtension(extensionType);
- } catch (IllegalArgumentException e) {
- return false;
+ extender = CameraExtensionManagerGlobal.get().initializeAdvancedExtension(
+ extensionType);
+ } catch (RemoteException e) {
+ throw new IllegalStateException("Failed to initialize extension: " + extensionType);
}
- try {
- return extenders.first.isExtensionAvailable(cameraId, chars.getNativeMetadata()) &&
- extenders.second.isExtensionAvailable(cameraId, chars.getNativeMetadata());
- } catch (RemoteException e) {
- Log.e(TAG, "Failed to query extension availability! Extension service does not"
- + " respond!");
- return false;
+ if (extender == null) {
+ throw new IllegalArgumentException("Unknown extension: " + extensionType);
}
+
+ return extender;
}
/**
@@ -487,13 +547,21 @@
throw new IllegalArgumentException("Unsupported extension");
}
- Pair<IPreviewExtenderImpl, IImageCaptureExtenderImpl> extenders =
- initializeExtension(extension);
StreamConfigurationMap streamMap = mChars.get(
CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
- extenders.first.init(mCameraId, mChars.getNativeMetadata());
- return generateSupportedSizes(extenders.first.getSupportedResolutions(),
- ImageFormat.PRIVATE, streamMap);
+ if (areAdvancedExtensionsSupported()) {
+ IAdvancedExtenderImpl extender = initializeAdvancedExtension(extension);
+ extender.init(mCameraId);
+ return generateSupportedSizes(
+ extender.getSupportedPreviewOutputResolutions(mCameraId),
+ ImageFormat.PRIVATE, streamMap);
+ } else {
+ Pair<IPreviewExtenderImpl, IImageCaptureExtenderImpl> extenders =
+ initializeExtension(extension);
+ extenders.first.init(mCameraId, mChars.getNativeMetadata());
+ return generateSupportedSizes(extenders.first.getSupportedResolutions(),
+ ImageFormat.PRIVATE, streamMap);
+ }
} catch (RemoteException e) {
Log.e(TAG, "Failed to query the extension supported sizes! Extension service does"
+ " not respond!");
@@ -536,31 +604,47 @@
throw new IllegalArgumentException("Unsupported extension");
}
- Pair<IPreviewExtenderImpl, IImageCaptureExtenderImpl> extenders =
- initializeExtension(extension);
StreamConfigurationMap streamMap = mChars.get(
CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
- if (format == ImageFormat.YUV_420_888) {
- extenders.second.init(mCameraId, mChars.getNativeMetadata());
- if (extenders.second.getCaptureProcessor() == null) {
- // Extensions that don't implement any capture processor are limited to
- // JPEG only!
- return new ArrayList<>();
+ if (areAdvancedExtensionsSupported()) {
+ switch(format) {
+ case ImageFormat.YUV_420_888:
+ case ImageFormat.JPEG:
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported format: " + format);
}
- return generateSupportedSizes(extenders.second.getSupportedResolutions(),
- format, streamMap);
- } else if (format == ImageFormat.JPEG) {
- extenders.second.init(mCameraId, mChars.getNativeMetadata());
- if (extenders.second.getCaptureProcessor() != null) {
- // The framework will perform the additional encoding pass on the
- // processed YUV_420 buffers.
- return generateJpegSupportedSizes(
- extenders.second.getSupportedResolutions(), streamMap);
- } else {
- return generateSupportedSizes(null, format, streamMap);
- }
+ IAdvancedExtenderImpl extender = initializeAdvancedExtension(extension);
+ extender.init(mCameraId);
+ return generateSupportedSizes(extender.getSupportedCaptureOutputResolutions(
+ mCameraId), format, streamMap);
} else {
- throw new IllegalArgumentException("Unsupported format: " + format);
+ if (format == ImageFormat.YUV_420_888) {
+ Pair<IPreviewExtenderImpl, IImageCaptureExtenderImpl> extenders =
+ initializeExtension(extension);
+ extenders.second.init(mCameraId, mChars.getNativeMetadata());
+ if (extenders.second.getCaptureProcessor() == null) {
+ // Extensions that don't implement any capture processor are limited to
+ // JPEG only!
+ return new ArrayList<>();
+ }
+ return generateSupportedSizes(extenders.second.getSupportedResolutions(),
+ format, streamMap);
+ } else if (format == ImageFormat.JPEG) {
+ Pair<IPreviewExtenderImpl, IImageCaptureExtenderImpl> extenders =
+ initializeExtension(extension);
+ extenders.second.init(mCameraId, mChars.getNativeMetadata());
+ if (extenders.second.getCaptureProcessor() != null) {
+ // The framework will perform the additional encoding pass on the
+ // processed YUV_420 buffers.
+ return generateJpegSupportedSizes(
+ extenders.second.getSupportedResolutions(), streamMap);
+ } else {
+ return generateSupportedSizes(null, format, streamMap);
+ }
+ } else {
+ throw new IllegalArgumentException("Unsupported format: " + format);
+ }
}
} finally {
unregisterClient(clientId);
@@ -608,6 +692,23 @@
if (!isExtensionSupported(mCameraId, extension, mChars)) {
throw new IllegalArgumentException("Unsupported extension");
}
+
+ if (areAdvancedExtensionsSupported()) {
+ IAdvancedExtenderImpl extender = initializeAdvancedExtension(extension);
+ extender.init(mCameraId);
+ android.hardware.camera2.extension.Size sz =
+ new android.hardware.camera2.extension.Size();
+ sz.width = captureOutputSize.getWidth();
+ sz.height = captureOutputSize.getHeight();
+ LatencyRange latencyRange = extender.getEstimatedCaptureLatencyRange(mCameraId,
+ sz, format);
+ if (latencyRange != null) {
+ return new Range(latencyRange.min, latencyRange.max);
+ }
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to query the extension capture latency! Extension service does"
+ + " not respond!");
} finally {
unregisterClient(clientId);
}
diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java
index 6ff68c1..d32341f 100644
--- a/core/java/android/hardware/camera2/CaptureResult.java
+++ b/core/java/android/hardware/camera2/CaptureResult.java
@@ -230,6 +230,33 @@
}
/**
+ * Takes ownership of the passed-in properties object
+ *
+ * <p>For internal use only</p>
+ * @hide
+ */
+ public CaptureResult(String cameraId, CameraMetadataNative results, CaptureRequest parent,
+ int requestId, long frameNumber) {
+ if (results == null) {
+ throw new IllegalArgumentException("results was null");
+ }
+
+ if (parent == null) {
+ throw new IllegalArgumentException("parent was null");
+ }
+
+ mResults = CameraMetadataNative.move(results);
+ if (mResults.isEmpty()) {
+ throw new AssertionError("Results must not be empty");
+ }
+ setNativeInstance(mResults);
+ mCameraId = cameraId;
+ mRequest = parent;
+ mSequenceId = requestId;
+ mFrameNumber = frameNumber;
+ }
+
+ /**
* Returns a copy of the underlying {@link CameraMetadataNative}.
* @hide
*/
diff --git a/core/java/android/hardware/camera2/TotalCaptureResult.java b/core/java/android/hardware/camera2/TotalCaptureResult.java
index df8eecc..ac7f2ca 100644
--- a/core/java/android/hardware/camera2/TotalCaptureResult.java
+++ b/core/java/android/hardware/camera2/TotalCaptureResult.java
@@ -94,6 +94,36 @@
}
/**
+ * Takes ownership of the passed-in camera metadata and the partial results
+ *
+ * @param partials a list of partial results; {@code null} will be substituted for an empty list
+ * @hide
+ */
+ public TotalCaptureResult(String logicalCameraId, CameraMetadataNative results,
+ CaptureRequest parent, int requestId, long frameNumber, List<CaptureResult> partials,
+ int sessionId, PhysicalCaptureResultInfo[] physicalResults) {
+ super(logicalCameraId, results, parent, requestId, frameNumber);
+
+ if (partials == null) {
+ mPartialResults = new ArrayList<>();
+ } else {
+ mPartialResults = partials;
+ }
+
+ mSessionId = sessionId;
+
+ mPhysicalCaptureResults = new HashMap<String, TotalCaptureResult>();
+ for (PhysicalCaptureResultInfo onePhysicalResult : physicalResults) {
+ TotalCaptureResult physicalResult = new TotalCaptureResult(
+ onePhysicalResult.getCameraId(), onePhysicalResult.getCameraMetadata(),
+ parent, requestId, frameNumber, /*partials*/null, sessionId,
+ new PhysicalCaptureResultInfo[0]);
+ mPhysicalCaptureResults.put(onePhysicalResult.getCameraId(),
+ physicalResult);
+ }
+ }
+
+ /**
* Creates a request-less result.
*
* <p><strong>For testing only.</strong></p>
diff --git a/core/java/android/hardware/camera2/extension/CameraOutputConfig.aidl b/core/java/android/hardware/camera2/extension/CameraOutputConfig.aidl
new file mode 100644
index 0000000..a61bb33
--- /dev/null
+++ b/core/java/android/hardware/camera2/extension/CameraOutputConfig.aidl
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2021, 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.camera2.extension;
+
+import android.hardware.camera2.extension.Size;
+import android.hardware.camera2.extension.OutputConfigId;
+import android.view.Surface;
+
+/** @hide */
+parcelable CameraOutputConfig
+{
+ Size size;
+ Surface surface;
+ int imageFormat;
+ int capacity;
+
+ const int TYPE_SURFACE = 0;
+ const int TYPE_IMAGEREADER = 1;
+ const int TYPE_MULTIRES_IMAGEREADER = 2;
+ int type;
+
+ OutputConfigId outputId;
+ int surfaceGroupId;
+ String physicalCameraId;
+ List<OutputConfigId> surfaceSharingOutputConfigs;
+}
diff --git a/core/java/android/hardware/camera2/extension/CameraSessionConfig.aidl b/core/java/android/hardware/camera2/extension/CameraSessionConfig.aidl
new file mode 100644
index 0000000..97ce183
--- /dev/null
+++ b/core/java/android/hardware/camera2/extension/CameraSessionConfig.aidl
@@ -0,0 +1,27 @@
+/**
+ * Copyright (c) 2021, 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.camera2.extension;
+
+import android.hardware.camera2.extension.CameraOutputConfig;
+import android.hardware.camera2.impl.CameraMetadataNative;
+
+/** @hide */
+parcelable CameraSessionConfig
+{
+ List<CameraOutputConfig> outputConfigs;
+ CameraMetadataNative sessionParameter;
+ int sessionTemplateId;
+}
diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl b/core/java/android/hardware/camera2/extension/CaptureFailure.aidl
similarity index 62%
copy from apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl
copy to core/java/android/hardware/camera2/extension/CaptureFailure.aidl
index 37ce990..d48696c 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl
+++ b/core/java/android/hardware/camera2/extension/CaptureFailure.aidl
@@ -1,5 +1,5 @@
/**
- * Copyright 2020, The Android Open Source Project
+ * Copyright (c) 2021, 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.
@@ -13,7 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.app.appsearch;
+package android.hardware.camera2.extension;
-/** {@hide} */
-parcelable AppSearchResult<ValueType>;
\ No newline at end of file
+import android.hardware.camera2.CaptureRequest;
+
+/** @hide */
+parcelable CaptureFailure
+{
+ CaptureRequest request;
+ int reason;
+ boolean dropped;
+ int sequenceId;
+ long frameNumber;
+ String errorPhysicalCameraId;
+}
diff --git a/core/java/android/hardware/camera2/extension/IAdvancedExtenderImpl.aidl b/core/java/android/hardware/camera2/extension/IAdvancedExtenderImpl.aidl
new file mode 100644
index 0000000..f279c59
--- /dev/null
+++ b/core/java/android/hardware/camera2/extension/IAdvancedExtenderImpl.aidl
@@ -0,0 +1,33 @@
+/**
+ * Copyright (c) 2021, 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.camera2.extension;
+
+import android.hardware.camera2.extension.ISessionProcessorImpl;
+import android.hardware.camera2.extension.LatencyRange;
+import android.hardware.camera2.extension.Size;
+import android.hardware.camera2.extension.SizeList;
+
+/** @hide */
+interface IAdvancedExtenderImpl
+{
+ boolean isExtensionAvailable(in String cameraId);
+ void init(in String cameraId);
+ LatencyRange getEstimatedCaptureLatencyRange(in String cameraId, in Size outputSize,
+ int format);
+ @nullable List<SizeList> getSupportedPreviewOutputResolutions(in String cameraId);
+ @nullable List<SizeList> getSupportedCaptureOutputResolutions(in String cameraId);
+ ISessionProcessorImpl getSessionProcessor();
+}
diff --git a/core/java/android/hardware/camera2/extension/ICameraExtensionsProxyService.aidl b/core/java/android/hardware/camera2/extension/ICameraExtensionsProxyService.aidl
index 2a6d22c..bc29e9a 100644
--- a/core/java/android/hardware/camera2/extension/ICameraExtensionsProxyService.aidl
+++ b/core/java/android/hardware/camera2/extension/ICameraExtensionsProxyService.aidl
@@ -15,6 +15,7 @@
*/
package android.hardware.camera2.extension;
+import android.hardware.camera2.extension.IAdvancedExtenderImpl;
import android.hardware.camera2.extension.IPreviewExtenderImpl;
import android.hardware.camera2.extension.IImageCaptureExtenderImpl;
@@ -23,6 +24,8 @@
{
long registerClient();
void unregisterClient(long clientId);
+ boolean advancedExtensionsSupported();
@nullable IPreviewExtenderImpl initializePreviewExtension(int extensionType);
@nullable IImageCaptureExtenderImpl initializeImageExtension(int extensionType);
+ @nullable IAdvancedExtenderImpl initializeAdvancedExtension(int extensionType);
}
diff --git a/core/java/android/hardware/camera2/extension/ICaptureCallback.aidl b/core/java/android/hardware/camera2/extension/ICaptureCallback.aidl
new file mode 100644
index 0000000..6ab0ad2
--- /dev/null
+++ b/core/java/android/hardware/camera2/extension/ICaptureCallback.aidl
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2021, 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.camera2.extension;
+
+import android.hardware.camera2.extension.Request;
+
+/** @hide */
+interface ICaptureCallback
+{
+ void onCaptureStarted(int captureSequenceId, long timestamp);
+ void onCaptureProcessStarted(int captureSequenceId);
+ void onCaptureFailed(int captureSequenceId);
+ void onCaptureSequenceCompleted(int captureSequenceId);
+ void onCaptureSequenceAborted(int captureSequenceId);
+}
diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl b/core/java/android/hardware/camera2/extension/IImageProcessorImpl.aidl
similarity index 61%
copy from apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl
copy to core/java/android/hardware/camera2/extension/IImageProcessorImpl.aidl
index 37ce990..f365469 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl
+++ b/core/java/android/hardware/camera2/extension/IImageProcessorImpl.aidl
@@ -1,5 +1,5 @@
/**
- * Copyright 2020, The Android Open Source Project
+ * Copyright (c) 2021, 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.
@@ -13,7 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.app.appsearch;
+package android.hardware.camera2.extension;
-/** {@hide} */
-parcelable AppSearchResult<ValueType>;
\ No newline at end of file
+import android.hardware.camera2.extension.OutputConfigId;
+import android.hardware.camera2.extension.ParcelImage;
+
+/** @hide */
+interface IImageProcessorImpl
+{
+ void onNextImageAvailable(in OutputConfigId outputConfigId, in ParcelImage image);
+}
diff --git a/core/java/android/hardware/camera2/extension/IRequestCallback.aidl b/core/java/android/hardware/camera2/extension/IRequestCallback.aidl
new file mode 100644
index 0000000..5f308b7
--- /dev/null
+++ b/core/java/android/hardware/camera2/extension/IRequestCallback.aidl
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2021, 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.camera2.extension;
+
+import android.hardware.camera2.extension.CaptureFailure;
+import android.hardware.camera2.extension.ParcelCaptureResult;
+import android.hardware.camera2.extension.ParcelTotalCaptureResult;
+
+/** @hide */
+interface IRequestCallback
+{
+ void onCaptureStarted(int requestId, long frameNumber, long timestamp);
+ void onCaptureProgressed(int requestId, in ParcelCaptureResult partialResult);
+ void onCaptureCompleted(int requestId, in ParcelTotalCaptureResult totalCaptureResult);
+ void onCaptureFailed(int requestId, in CaptureFailure captureFailure);
+ void onCaptureBufferLost(int requestId, long frameNumber, int outputStreamId);
+ void onCaptureSequenceCompleted(int sequenceId, long frameNumber);
+ void onCaptureSequenceAborted(int sequenceId);
+}
diff --git a/core/java/android/hardware/camera2/extension/IRequestProcessorImpl.aidl b/core/java/android/hardware/camera2/extension/IRequestProcessorImpl.aidl
new file mode 100644
index 0000000..52595a8
--- /dev/null
+++ b/core/java/android/hardware/camera2/extension/IRequestProcessorImpl.aidl
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2021, 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.camera2.extension;
+
+import android.hardware.camera2.extension.IImageProcessorImpl;
+import android.hardware.camera2.extension.IRequestCallback;
+import android.hardware.camera2.extension.OutputConfigId;
+import android.hardware.camera2.extension.Request;
+
+/** @hide */
+interface IRequestProcessorImpl
+{
+ void setImageProcessor(in OutputConfigId outputConfigId, in IImageProcessorImpl imageProcessor);
+ boolean submit(in Request request, in IRequestCallback callback);
+ boolean submitBurst(in List<Request> requests, in IRequestCallback callback);
+ boolean setRepeating(in Request request, in IRequestCallback callback);
+ void abortCaptures();
+ void stopRepeating();
+}
diff --git a/core/java/android/hardware/camera2/extension/ISessionProcessorImpl.aidl b/core/java/android/hardware/camera2/extension/ISessionProcessorImpl.aidl
new file mode 100644
index 0000000..6fdf4df
--- /dev/null
+++ b/core/java/android/hardware/camera2/extension/ISessionProcessorImpl.aidl
@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) 2021, 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.camera2.extension;
+
+import android.hardware.camera2.extension.CameraSessionConfig;
+import android.hardware.camera2.extension.ICaptureCallback;
+import android.hardware.camera2.extension.IRequestProcessorImpl;
+import android.hardware.camera2.extension.OutputSurface;
+
+/** @hide */
+interface ISessionProcessorImpl
+{
+ CameraSessionConfig initSession(in String cameraId, in OutputSurface previewSurface,
+ in OutputSurface imageCaptureSurface);
+ void deInitSession();
+ void onCaptureSessionStart(IRequestProcessorImpl requestProcessor);
+ void onCaptureSessionEnd();
+ int startRepeating(in ICaptureCallback callback);
+ void stopRepeating();
+ int startCapture(in ICaptureCallback callback, int jpegRotation, int jpegQuality);
+}
diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl b/core/java/android/hardware/camera2/extension/LatencyRange.aidl
similarity index 76%
copy from apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl
copy to core/java/android/hardware/camera2/extension/LatencyRange.aidl
index 37ce990..9bedbb0 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl
+++ b/core/java/android/hardware/camera2/extension/LatencyRange.aidl
@@ -1,5 +1,5 @@
/**
- * Copyright 2020, The Android Open Source Project
+ * Copyright (c) 2021, 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.
@@ -13,7 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.app.appsearch;
+package android.hardware.camera2.extension;
-/** {@hide} */
-parcelable AppSearchResult<ValueType>;
\ No newline at end of file
+/** @hide */
+parcelable LatencyRange
+{
+ long min;
+ long max;
+}
diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl b/core/java/android/hardware/camera2/extension/OutputConfigId.aidl
similarity index 77%
copy from apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl
copy to core/java/android/hardware/camera2/extension/OutputConfigId.aidl
index 37ce990..b27f29a 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl
+++ b/core/java/android/hardware/camera2/extension/OutputConfigId.aidl
@@ -1,5 +1,5 @@
/**
- * Copyright 2020, The Android Open Source Project
+ * Copyright (c) 2021, 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.
@@ -13,7 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.app.appsearch;
+package android.hardware.camera2.extension;
-/** {@hide} */
-parcelable AppSearchResult<ValueType>;
\ No newline at end of file
+/** @hide */
+parcelable OutputConfigId
+{
+ int id;
+}
diff --git a/apex/appsearch/framework/java/android/app/appsearch/IAppSearchResultCallback.aidl b/core/java/android/hardware/camera2/extension/OutputSurface.aidl
similarity index 67%
copy from apex/appsearch/framework/java/android/app/appsearch/IAppSearchResultCallback.aidl
copy to core/java/android/hardware/camera2/extension/OutputSurface.aidl
index 299c995..8415379 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/IAppSearchResultCallback.aidl
+++ b/core/java/android/hardware/camera2/extension/OutputSurface.aidl
@@ -1,5 +1,5 @@
/**
- * Copyright 2020, The Android Open Source Project
+ * Copyright (c) 2021, 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.
@@ -13,11 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.app.appsearch;
+package android.hardware.camera2.extension;
-import android.app.appsearch.AppSearchResult;
+import android.hardware.camera2.extension.Size;
+import android.view.Surface;
-/** {@hide} */
-oneway interface IAppSearchResultCallback {
- void onResult(in AppSearchResult result);
+/** @hide */
+parcelable OutputSurface
+{
+ Surface surface;
+ Size size;
+ int imageFormat;
}
diff --git a/core/java/android/hardware/camera2/extension/ParcelCaptureResult.aidl b/core/java/android/hardware/camera2/extension/ParcelCaptureResult.aidl
new file mode 100644
index 0000000..f99b256
--- /dev/null
+++ b/core/java/android/hardware/camera2/extension/ParcelCaptureResult.aidl
@@ -0,0 +1,29 @@
+/**
+ * Copyright (c) 2021, 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.camera2.extension;
+
+import android.hardware.camera2.CaptureRequest;
+import android.hardware.camera2.impl.CameraMetadataNative;
+
+/** @hide */
+parcelable ParcelCaptureResult
+{
+ String cameraId;
+ CameraMetadataNative results;
+ CaptureRequest parent;
+ int sequenceId;
+ long frameNumber;
+}
diff --git a/core/java/android/hardware/camera2/extension/ParcelTotalCaptureResult.aidl b/core/java/android/hardware/camera2/extension/ParcelTotalCaptureResult.aidl
new file mode 100644
index 0000000..8021a57
--- /dev/null
+++ b/core/java/android/hardware/camera2/extension/ParcelTotalCaptureResult.aidl
@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) 2021, 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.camera2.extension;
+
+import android.hardware.camera2.CaptureRequest;
+import android.hardware.camera2.extension.ParcelCaptureResult;
+import android.hardware.camera2.impl.CameraMetadataNative;
+import android.hardware.camera2.impl.PhysicalCaptureResultInfo;
+
+/** @hide */
+parcelable ParcelTotalCaptureResult
+{
+ String logicalCameraId;
+ CameraMetadataNative results;
+ CaptureRequest parent;
+ int sequenceId;
+ long frameNumber;
+ List<ParcelCaptureResult> partials;
+ int sessionId;
+ List<PhysicalCaptureResultInfo> physicalResult;
+}
diff --git a/core/java/android/hardware/camera2/extension/Request.aidl b/core/java/android/hardware/camera2/extension/Request.aidl
new file mode 100644
index 0000000..d9934dc
--- /dev/null
+++ b/core/java/android/hardware/camera2/extension/Request.aidl
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2021, 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.camera2.extension;
+
+import android.hardware.camera2.extension.OutputConfigId;
+import android.hardware.camera2.impl.CameraMetadataNative;
+
+/** @hide */
+parcelable Request
+{
+ List<OutputConfigId> targetOutputConfigIds;
+ CameraMetadataNative parameters;
+ int templateId;
+ int requestId;
+}
diff --git a/core/java/android/hardware/camera2/impl/CameraAdvancedExtensionSessionImpl.java b/core/java/android/hardware/camera2/impl/CameraAdvancedExtensionSessionImpl.java
new file mode 100644
index 0000000..abc487d
--- /dev/null
+++ b/core/java/android/hardware/camera2/impl/CameraAdvancedExtensionSessionImpl.java
@@ -0,0 +1,917 @@
+/*
+ * Copyright (C) 2021 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.camera2.impl;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
+import android.content.Context;
+import android.graphics.ImageFormat;
+import android.graphics.SurfaceTexture;
+import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.CameraCaptureSession;
+import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraDevice;
+import android.hardware.camera2.CameraExtensionCharacteristics;
+import android.hardware.camera2.CameraExtensionSession;
+import android.hardware.camera2.CameraManager;
+import android.hardware.camera2.CaptureFailure;
+import android.hardware.camera2.CaptureRequest;
+import android.hardware.camera2.CaptureResult;
+import android.hardware.camera2.TotalCaptureResult;
+import android.hardware.camera2.extension.CameraOutputConfig;
+import android.hardware.camera2.extension.CameraSessionConfig;
+import android.hardware.camera2.extension.IAdvancedExtenderImpl;
+import android.hardware.camera2.extension.ICaptureCallback;
+import android.hardware.camera2.extension.IImageProcessorImpl;
+import android.hardware.camera2.extension.IRequestCallback;
+import android.hardware.camera2.extension.IRequestProcessorImpl;
+import android.hardware.camera2.extension.ISessionProcessorImpl;
+import android.hardware.camera2.extension.OutputConfigId;
+import android.hardware.camera2.extension.OutputSurface;
+import android.hardware.camera2.extension.ParcelCaptureResult;
+import android.hardware.camera2.extension.ParcelImage;
+import android.hardware.camera2.extension.ParcelTotalCaptureResult;
+import android.hardware.camera2.extension.Request;
+import android.hardware.camera2.params.ExtensionSessionConfiguration;
+import android.hardware.camera2.params.OutputConfiguration;
+import android.hardware.camera2.params.SessionConfiguration;
+import android.hardware.camera2.utils.SurfaceUtils;
+import android.media.Image;
+import android.media.ImageReader;
+import android.os.Binder;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.ParcelFileDescriptor;
+import android.os.RemoteException;
+import android.util.Log;
+import android.util.Size;
+import android.view.Surface;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executor;
+
+public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSession {
+ private static final String TAG = "CameraAdvancedExtensionSessionImpl";
+
+ private final Executor mExecutor;
+ private final CameraDevice mCameraDevice;
+ private final long mExtensionClientId;
+ private final Handler mHandler;
+ private final HandlerThread mHandlerThread;
+ private final CameraExtensionSession.StateCallback mCallbacks;
+ private final IAdvancedExtenderImpl mAdvancedExtender;
+ // maps camera outputs to extension output ids
+ private final HashMap<Surface, Integer> mSurfaceIdMap = new HashMap<>();
+ // maps camera extension output ids to camera registered image readers
+ private final HashMap<Integer, ImageReader> mReaderMap = new HashMap<>();
+ private final RequestProcessor mRequestProcessor = new RequestProcessor();
+
+ private Surface mClientRepeatingRequestSurface;
+ private Surface mClientCaptureSurface;
+ private CameraCaptureSession mCaptureSession = null;
+ private ISessionProcessorImpl mSessionProcessor = null;
+
+ private boolean mInitialized;
+
+
+ // Lock to synchronize cross-thread access to device public interface
+ final Object mInterfaceLock = new Object(); // access from this class and Session only!
+
+ /**
+ * @hide
+ */
+ @RequiresPermission(android.Manifest.permission.CAMERA)
+ public static CameraAdvancedExtensionSessionImpl createCameraAdvancedExtensionSession(
+ @NonNull CameraDevice cameraDevice, @NonNull Context ctx,
+ @NonNull ExtensionSessionConfiguration config)
+ throws CameraAccessException, RemoteException {
+ long clientId = CameraExtensionCharacteristics.registerClient(ctx);
+ if (clientId < 0) {
+ throw new UnsupportedOperationException("Unsupported extension!");
+ }
+
+ String cameraId = cameraDevice.getId();
+ CameraManager manager = ctx.getSystemService(CameraManager.class);
+ CameraCharacteristics chars = manager.getCameraCharacteristics(cameraId);
+ CameraExtensionCharacteristics extensionChars = new CameraExtensionCharacteristics(ctx,
+ cameraId, chars);
+
+ if (!CameraExtensionCharacteristics.isExtensionSupported(cameraDevice.getId(),
+ config.getExtension(), chars)) {
+ throw new UnsupportedOperationException("Unsupported extension type: " +
+ config.getExtension());
+ }
+
+ if (config.getOutputConfigurations().isEmpty() ||
+ config.getOutputConfigurations().size() > 2) {
+ throw new IllegalArgumentException("Unexpected amount of output surfaces, received: " +
+ config.getOutputConfigurations().size() + " expected <= 2");
+ }
+
+ int suitableSurfaceCount = 0;
+ List<Size> supportedPreviewSizes = extensionChars.getExtensionSupportedSizes(
+ config.getExtension(), SurfaceTexture.class);
+ Surface repeatingRequestSurface = CameraExtensionUtils.getRepeatingRequestSurface(
+ config.getOutputConfigurations(), supportedPreviewSizes);
+ if (repeatingRequestSurface != null) {
+ suitableSurfaceCount++;
+ }
+
+ HashMap<Integer, List<Size>> supportedCaptureSizes = new HashMap<>();
+ for (int format : CameraExtensionUtils.SUPPORTED_CAPTURE_OUTPUT_FORMATS) {
+ List<Size> supportedSizes = extensionChars.getExtensionSupportedSizes(
+ config.getExtension(), format);
+ if (supportedSizes != null) {
+ supportedCaptureSizes.put(format, supportedSizes);
+ }
+ }
+ Surface burstCaptureSurface = CameraExtensionUtils.getBurstCaptureSurface(
+ config.getOutputConfigurations(), supportedCaptureSizes);
+ if (burstCaptureSurface != null) {
+ suitableSurfaceCount++;
+ }
+
+ if (suitableSurfaceCount != config.getOutputConfigurations().size()) {
+ throw new IllegalArgumentException("One or more unsupported output surfaces found!");
+ }
+
+ IAdvancedExtenderImpl extender = CameraExtensionCharacteristics.initializeAdvancedExtension(
+ config.getExtension());
+ extender.init(cameraId);
+
+ CameraAdvancedExtensionSessionImpl ret = new CameraAdvancedExtensionSessionImpl(clientId,
+ extender, cameraDevice, repeatingRequestSurface, burstCaptureSurface,
+ config.getStateCallback(), config.getExecutor());
+ ret.initialize();
+
+ return ret;
+ }
+
+ private CameraAdvancedExtensionSessionImpl(long extensionClientId,
+ @NonNull IAdvancedExtenderImpl extender, @NonNull CameraDevice cameraDevice,
+ @Nullable Surface repeatingRequestSurface, @Nullable Surface burstCaptureSurface,
+ @NonNull CameraExtensionSession.StateCallback callback, @NonNull Executor executor) {
+ mExtensionClientId = extensionClientId;
+ mAdvancedExtender = extender;
+ mCameraDevice = cameraDevice;
+ mCallbacks = callback;
+ mExecutor = executor;
+ mClientRepeatingRequestSurface = repeatingRequestSurface;
+ mClientCaptureSurface = burstCaptureSurface;
+ mHandlerThread = new HandlerThread(TAG);
+ mHandlerThread.start();
+ mHandler = new Handler(mHandlerThread.getLooper());
+ mInitialized = false;
+ }
+
+ /**
+ * @hide
+ */
+ public synchronized void initialize() throws CameraAccessException, RemoteException {
+ if (mInitialized) {
+ Log.d(TAG, "Session already initialized");
+ return;
+ }
+
+ OutputSurface previewSurface = initializeParcelable(mClientRepeatingRequestSurface);
+ OutputSurface captureSurface = initializeParcelable(mClientCaptureSurface);
+ mSessionProcessor = mAdvancedExtender.getSessionProcessor();
+ CameraSessionConfig sessionConfig = mSessionProcessor.initSession(mCameraDevice.getId(),
+ previewSurface, captureSurface);
+ List<CameraOutputConfig> outputConfigs = sessionConfig.outputConfigs;
+ // map camera output ids to output configurations
+ HashMap<Integer, OutputConfiguration> cameraOutputs = new HashMap<>();
+ for (CameraOutputConfig output : outputConfigs) {
+ OutputConfiguration cameraOutput = null;
+ switch(output.type) {
+ case CameraOutputConfig.TYPE_SURFACE:
+ if (output.surface == null) {
+ Log.w(TAG, "Unsupported client output id: " + output.outputId.id +
+ ", skipping!");
+ continue;
+ }
+ cameraOutput = new OutputConfiguration(output.surfaceGroupId,
+ output.surface);
+ break;
+ case CameraOutputConfig.TYPE_IMAGEREADER:
+ if ((output.imageFormat == ImageFormat.UNKNOWN) || (output.size.width <= 0) ||
+ (output.size.height <= 0)) {
+ Log.w(TAG, "Unsupported client output id: " + output.outputId.id +
+ ", skipping!");
+ continue;
+ }
+ ImageReader reader = ImageReader.newInstance(output.size.width,
+ output.size.height, output.imageFormat, output.capacity);
+ mReaderMap.put(output.outputId.id, reader);
+ cameraOutput = new OutputConfiguration(output.surfaceGroupId,
+ reader.getSurface());
+ break;
+ case CameraOutputConfig.TYPE_MULTIRES_IMAGEREADER:
+ // TBD
+ default:
+ throw new IllegalArgumentException("Unsupported output config type: " +
+ output.type);
+ }
+ cameraOutput.setPhysicalCameraId(output.physicalCameraId);
+ cameraOutputs.put(output.outputId.id, cameraOutput);
+ }
+
+ ArrayList<OutputConfiguration> outputList = new ArrayList<>();
+ for (CameraOutputConfig output : outputConfigs) {
+ if (!cameraOutputs.containsKey(output.outputId.id)) {
+ // Shared surface already removed by a previous iteration
+ continue;
+ }
+ OutputConfiguration outConfig = cameraOutputs.get(output.outputId.id);
+ if ((output.surfaceSharingOutputConfigs != null) &&
+ !output.surfaceSharingOutputConfigs.isEmpty()) {
+ outConfig.enableSurfaceSharing();
+ for (OutputConfigId outputId : output.surfaceSharingOutputConfigs) {
+ outConfig.addSurface(cameraOutputs.get(outputId.id).getSurface());
+ cameraOutputs.remove(outputId.id);
+ }
+ }
+ outputList.add(outConfig);
+ mSurfaceIdMap.put(outConfig.getSurface(), output.outputId.id);
+ }
+
+ SessionConfiguration sessionConfiguration = new SessionConfiguration(
+ SessionConfiguration.SESSION_REGULAR, outputList,
+ new CameraExtensionUtils.HandlerExecutor(mHandler), new SessionStateHandler());
+
+ if ((sessionConfig.sessionParameter != null) &&
+ (!sessionConfig.sessionParameter.isEmpty())) {
+ CaptureRequest.Builder requestBuilder = mCameraDevice.createCaptureRequest(
+ sessionConfig.sessionTemplateId);
+ CaptureRequest sessionRequest = requestBuilder.build();
+ CameraMetadataNative.update(sessionRequest.getNativeMetadata(),
+ sessionConfig.sessionParameter);
+ sessionConfiguration.setSessionParameters(sessionRequest);
+ }
+
+ mCameraDevice.createCaptureSession(sessionConfiguration);
+ }
+
+ private static ParcelCaptureResult initializeParcelable(CaptureResult result) {
+ ParcelCaptureResult ret = new ParcelCaptureResult();
+ ret.cameraId = result.getCameraId();
+ ret.results = result.getNativeMetadata();
+ ret.parent = result.getRequest();
+ ret.sequenceId = result.getSequenceId();
+ ret.frameNumber = result.getFrameNumber();
+
+ return ret;
+ }
+
+ private static ParcelTotalCaptureResult initializeParcelable(TotalCaptureResult totalResult) {
+ ParcelTotalCaptureResult ret = new ParcelTotalCaptureResult();
+ ret.logicalCameraId = totalResult.getCameraId();
+ ret.results = totalResult.getNativeMetadata();
+ ret.parent = totalResult.getRequest();
+ ret.sequenceId = totalResult.getSequenceId();
+ ret.frameNumber = totalResult.getFrameNumber();
+ ret.sessionId = totalResult.getSessionId();
+ ret.partials = new ArrayList<>(totalResult.getPartialResults().size());
+ for (CaptureResult partial : totalResult.getPartialResults()) {
+ ret.partials.add(initializeParcelable(partial));
+ }
+ Map<String, TotalCaptureResult> physicalResults =
+ totalResult.getPhysicalCameraTotalResults();
+ ret.physicalResult = new ArrayList<>(physicalResults.size());
+ for (TotalCaptureResult physicalResult : physicalResults.values()) {
+ ret.physicalResult.add(new PhysicalCaptureResultInfo(physicalResult.getCameraId(),
+ physicalResult.getNativeMetadata()));
+ }
+
+ return ret;
+ }
+
+ private static OutputSurface initializeParcelable(Surface s) {
+ OutputSurface ret = new OutputSurface();
+ if (s != null) {
+ ret.surface = s;
+ ret.size = new android.hardware.camera2.extension.Size();
+ Size surfaceSize = SurfaceUtils.getSurfaceSize(s);
+ ret.size.width = surfaceSize.getWidth();
+ ret.size.height = surfaceSize.getHeight();
+ ret.imageFormat = SurfaceUtils.getSurfaceFormat(s);
+ } else {
+ ret.surface = null;
+ ret.size = new android.hardware.camera2.extension.Size();
+ ret.size.width = -1;
+ ret.size.height = -1;
+ ret.imageFormat = ImageFormat.UNKNOWN;
+ }
+
+ return ret;
+ }
+
+ @Override
+ public @NonNull CameraDevice getDevice() {
+ synchronized (mInterfaceLock) {
+ return mCameraDevice;
+ }
+ }
+
+ @Override
+ public int setRepeatingRequest(@NonNull CaptureRequest request, @NonNull Executor executor,
+ @NonNull ExtensionCaptureCallback listener) throws CameraAccessException {
+ int seqId = -1;
+ synchronized (mInterfaceLock) {
+ if (!mInitialized) {
+ throw new IllegalStateException("Uninitialized component");
+ }
+
+ if (mClientRepeatingRequestSurface == null) {
+ throw new IllegalArgumentException("No registered preview surface");
+ }
+
+ if (!request.containsTarget(mClientRepeatingRequestSurface) ||
+ (request.getTargets().size() != 1)) {
+ throw new IllegalArgumentException("Invalid repeating request output target!");
+ }
+
+ try {
+ seqId = mSessionProcessor.startRepeating(new RequestCallbackHandler(request,
+ executor, listener));
+ } catch (RemoteException e) {
+ throw new CameraAccessException(CameraAccessException.CAMERA_ERROR,
+ "Failed to enable repeating request, extension service failed to respond!");
+ }
+ }
+
+ return seqId;
+ }
+
+ @Override
+ public int capture(@NonNull CaptureRequest request,
+ @NonNull Executor executor,
+ @NonNull ExtensionCaptureCallback listener) throws CameraAccessException {
+ int seqId = -1;
+ synchronized (mInterfaceLock) {
+ if (!mInitialized) {
+ throw new IllegalStateException("Uninitialized component");
+ }
+
+ if (mClientCaptureSurface == null) {
+ throw new IllegalArgumentException("No output surface registered for single"
+ + " requests!");
+ }
+
+ if (!request.containsTarget(mClientCaptureSurface) ||
+ (request.getTargets().size() != 1)) {
+ throw new IllegalArgumentException("Invalid single capture output target!");
+ }
+
+ try {
+ // This will override the extension capture stage jpeg parameters with the user set
+ // jpeg quality and rotation. This will guarantee that client configured jpeg
+ // parameters always have highest priority.
+ Integer jpegRotation = request.get(CaptureRequest.JPEG_ORIENTATION);
+ if (jpegRotation == null) {
+ jpegRotation = CameraExtensionUtils.JPEG_DEFAULT_ROTATION;
+ }
+ Byte jpegQuality = request.get(CaptureRequest.JPEG_QUALITY);
+ if (jpegQuality == null) {
+ jpegQuality = CameraExtensionUtils.JPEG_DEFAULT_QUALITY;
+ }
+
+ seqId = mSessionProcessor.startCapture(new RequestCallbackHandler(request,
+ executor, listener), jpegRotation, jpegQuality);
+ } catch (RemoteException e) {
+ throw new CameraAccessException(CameraAccessException.CAMERA_ERROR,
+ "Failed to submit capture request, extension service failed to respond!");
+ }
+ }
+
+ return seqId;
+ }
+
+ @Override
+ public void stopRepeating() throws CameraAccessException {
+ synchronized (mInterfaceLock) {
+ if (!mInitialized) {
+ throw new IllegalStateException("Uninitialized component");
+ }
+
+ mCaptureSession.stopRepeating();
+
+ try {
+ mSessionProcessor.stopRepeating();
+ } catch (RemoteException e) {
+ throw new CameraAccessException(CameraAccessException.CAMERA_ERROR,
+ "Failed to notify about the end of repeating request, extension service"
+ + " failed to respond!");
+ }
+ }
+ }
+
+ @Override
+ public void close() throws CameraAccessException {
+ synchronized (mInterfaceLock) {
+ if (mInitialized) {
+ try {
+ mCaptureSession.stopRepeating();
+ mSessionProcessor.stopRepeating();
+ mSessionProcessor.onCaptureSessionEnd();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to stop the repeating request or end the session,"
+ + " , extension service does not respond!") ;
+ }
+ mCaptureSession.close();
+ }
+ }
+ }
+
+ public void release() {
+ synchronized (mInterfaceLock) {
+ mInitialized = false;
+ mHandlerThread.quitSafely();
+
+ if (mSessionProcessor != null) {
+ try {
+ mSessionProcessor.deInitSession();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to de-initialize session processor, extension service"
+ + " does not respond!") ;
+ }
+ mSessionProcessor = null;
+ }
+
+ if (mExtensionClientId >= 0) {
+ CameraExtensionCharacteristics.unregisterClient(mExtensionClientId);
+ }
+
+ for (ImageReader reader : mReaderMap.values()) {
+ reader.close();
+ }
+ mReaderMap.clear();
+
+ mClientRepeatingRequestSurface = null;
+ mClientCaptureSurface = null;
+ }
+ }
+
+ private void notifyConfigurationFailure() {
+ synchronized (mInterfaceLock) {
+ if (mInitialized) {
+ return;
+ }
+ }
+
+ release();
+
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ mExecutor.execute(
+ () -> mCallbacks.onConfigureFailed(
+ CameraAdvancedExtensionSessionImpl.this));
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ private class SessionStateHandler extends
+ android.hardware.camera2.CameraCaptureSession.StateCallback {
+ @Override
+ public void onClosed(@NonNull CameraCaptureSession session) {
+ release();
+
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ mExecutor.execute(() -> mCallbacks.onClosed(
+ CameraAdvancedExtensionSessionImpl.this));
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public void onConfigureFailed(@NonNull CameraCaptureSession session) {
+ notifyConfigurationFailure();
+ }
+
+ @Override
+ public void onConfigured(@NonNull CameraCaptureSession session) {
+ boolean status = true;
+ synchronized (mInterfaceLock) {
+ mCaptureSession = session;
+ try {
+ mSessionProcessor.onCaptureSessionStart(mRequestProcessor);
+ mInitialized = true;
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to start capture session,"
+ + " extension service does not respond!");
+ status = false;
+ session.close();
+ }
+ }
+
+ if (status) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ mExecutor.execute(
+ () -> mCallbacks.onConfigured(CameraAdvancedExtensionSessionImpl.this));
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ } else {
+ notifyConfigurationFailure();
+ }
+ }
+ }
+
+ private final class RequestCallbackHandler extends ICaptureCallback.Stub {
+ private final CaptureRequest mClientRequest;
+ private final Executor mClientExecutor;
+ private final ExtensionCaptureCallback mClientCallbacks;
+
+ private RequestCallbackHandler(@NonNull CaptureRequest clientRequest,
+ @NonNull Executor clientExecutor,
+ @NonNull ExtensionCaptureCallback clientCallbacks) {
+ mClientRequest = clientRequest;
+ mClientExecutor = clientExecutor;
+ mClientCallbacks = clientCallbacks;
+ }
+
+ @Override
+ public void onCaptureStarted(int captureSequenceId, long timestamp) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ mClientExecutor.execute(
+ () -> mClientCallbacks.onCaptureStarted(
+ CameraAdvancedExtensionSessionImpl.this, mClientRequest,
+ timestamp));
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public void onCaptureProcessStarted(int captureSequenceId) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ mClientExecutor.execute(
+ () -> mClientCallbacks.onCaptureProcessStarted(
+ CameraAdvancedExtensionSessionImpl.this, mClientRequest));
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public void onCaptureFailed(int captureSequenceId) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ mClientExecutor.execute(
+ () -> mClientCallbacks.onCaptureFailed(
+ CameraAdvancedExtensionSessionImpl.this, mClientRequest));
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public void onCaptureSequenceCompleted(int captureSequenceId) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ mClientExecutor.execute(
+ () -> mClientCallbacks.onCaptureSequenceCompleted(
+ CameraAdvancedExtensionSessionImpl.this, captureSequenceId));
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public void onCaptureSequenceAborted(int captureSequenceId) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ mClientExecutor.execute(
+ () -> mClientCallbacks.onCaptureSequenceAborted(
+ CameraAdvancedExtensionSessionImpl.this, captureSequenceId));
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+ }
+
+ private final class CaptureCallbackHandler extends CameraCaptureSession.CaptureCallback {
+ private final IRequestCallback mCallback;
+
+ public CaptureCallbackHandler(IRequestCallback callback) {
+ mCallback = callback;
+ }
+
+ @Override
+ public void onCaptureBufferLost(CameraCaptureSession session, CaptureRequest request,
+ Surface target, long frameNumber) {
+ try {
+ if (request.getTag() instanceof Integer) {
+ Integer requestId = (Integer) request.getTag();
+ mCallback.onCaptureBufferLost(requestId, frameNumber,
+ mSurfaceIdMap.get(target));
+ } else {
+ Log.e(TAG, "Invalid capture request tag!");
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to notify lost capture buffer, extension service doesn't"
+ + " respond!");
+ }
+ }
+
+ @Override
+ public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
+ TotalCaptureResult result) {
+ try {
+ if (request.getTag() instanceof Integer) {
+ Integer requestId = (Integer) request.getTag();
+ mCallback.onCaptureCompleted(requestId, initializeParcelable(result));
+ } else {
+ Log.e(TAG, "Invalid capture request tag!");
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to notify capture result, extension service doesn't"
+ + " respond!");
+ }
+ }
+
+ @Override
+ public void onCaptureFailed(CameraCaptureSession session, CaptureRequest request,
+ CaptureFailure failure) {
+ try {
+ if (request.getTag() instanceof Integer) {
+ Integer requestId = (Integer) request.getTag();
+ android.hardware.camera2.extension.CaptureFailure captureFailure =
+ new android.hardware.camera2.extension.CaptureFailure();
+ captureFailure.request = request;
+ captureFailure.reason = failure.getReason();
+ captureFailure.errorPhysicalCameraId = failure.getPhysicalCameraId();
+ captureFailure.frameNumber = failure.getFrameNumber();
+ captureFailure.sequenceId = failure.getSequenceId();
+ captureFailure.dropped = !failure.wasImageCaptured();
+ mCallback.onCaptureFailed(requestId, captureFailure);
+ } else {
+ Log.e(TAG, "Invalid capture request tag!");
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to notify capture failure, extension service doesn't"
+ + " respond!");
+ }
+ }
+
+ @Override
+ public void onCaptureProgressed(CameraCaptureSession session, CaptureRequest request,
+ CaptureResult partialResult) {
+ try {
+ if (request.getTag() instanceof Integer) {
+ Integer requestId = (Integer) request.getTag();
+ mCallback.onCaptureProgressed(requestId, initializeParcelable(partialResult));
+ } else {
+ Log.e(TAG, "Invalid capture request tag!");
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to notify capture partial result, extension service doesn't"
+ + " respond!");
+ }
+ }
+
+ @Override
+ public void onCaptureSequenceAborted(CameraCaptureSession session, int sequenceId) {
+ try {
+ mCallback.onCaptureSequenceAborted(sequenceId);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to notify aborted sequence, extension service doesn't"
+ + " respond!");
+ }
+ }
+
+ @Override
+ public void onCaptureSequenceCompleted(CameraCaptureSession session, int sequenceId,
+ long frameNumber) {
+ try {
+ mCallback.onCaptureSequenceCompleted(sequenceId, frameNumber);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to notify sequence complete, extension service doesn't"
+ + " respond!");
+ }
+ }
+
+ @Override
+ public void onCaptureStarted(CameraCaptureSession session, CaptureRequest request,
+ long timestamp, long frameNumber) {
+ try {
+ if (request.getTag() instanceof Integer) {
+ Integer requestId = (Integer) request.getTag();
+ mCallback.onCaptureStarted(requestId, frameNumber, timestamp);
+ } else {
+ Log.e(TAG, "Invalid capture request tag!");
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to notify capture started, extension service doesn't"
+ + " respond!");
+ }
+ }
+ }
+
+ private static final class ImageReaderHandler implements ImageReader.OnImageAvailableListener {
+ private final OutputConfigId mOutputConfigId;
+ private final IImageProcessorImpl mIImageProcessor;
+
+ private ImageReaderHandler(int outputConfigId,
+ IImageProcessorImpl iImageProcessor) {
+ mOutputConfigId = new OutputConfigId();
+ mOutputConfigId.id = outputConfigId;
+ mIImageProcessor = iImageProcessor;
+ }
+
+ @Override
+ public void onImageAvailable(ImageReader reader) {
+ if (mIImageProcessor == null) {
+ return;
+ }
+
+ Image img;
+ try {
+ img = reader.acquireNextImage();
+ } catch (IllegalStateException e) {
+ Log.e(TAG, "Failed to acquire image, too many images pending!");
+ return;
+ }
+ if (img == null) {
+ Log.e(TAG, "Invalid image!");
+ return;
+ }
+
+ try {
+ reader.detachImage(img);
+ } catch(Exception e) {
+ Log.e(TAG, "Failed to detach image");
+ img.close();
+ return;
+ }
+
+ ParcelImage parcelImage = new ParcelImage();
+ parcelImage.buffer = img.getHardwareBuffer();
+ if (img.getFenceFd() >= 0) {
+ try {
+ parcelImage.fence = ParcelFileDescriptor.fromFd(img.getFenceFd());
+ } catch (IOException e) {
+ Log.e(TAG,"Failed to parcel buffer fence!");
+ }
+ }
+ parcelImage.format = img.getFormat();
+ parcelImage.timestamp = img.getTimestamp();
+ parcelImage.transform = img.getTransform();
+ parcelImage.scalingMode = img.getScalingMode();
+ parcelImage.planeCount = img.getPlaneCount();
+ parcelImage.crop = img.getCropRect();
+
+ try {
+ mIImageProcessor.onNextImageAvailable(mOutputConfigId, parcelImage);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to propagate image buffer on output surface id: " +
+ mOutputConfigId + " extension service does not respond!");
+ } finally {
+ parcelImage.buffer.close();
+ img.close();
+ }
+ }
+ }
+
+ private final class RequestProcessor extends IRequestProcessorImpl.Stub {
+ @Override
+ public void setImageProcessor(OutputConfigId outputConfigId,
+ IImageProcessorImpl imageProcessor) {
+ synchronized (mInterfaceLock) {
+ if (mReaderMap.containsKey(outputConfigId.id)) {
+ mReaderMap.get(outputConfigId.id).setOnImageAvailableListener(
+ new ImageReaderHandler(outputConfigId.id, imageProcessor), mHandler);
+ } else {
+ Log.e(TAG, "ImageReader with output config id: " + outputConfigId.id +
+ " not found!");
+ }
+ }
+ }
+
+ @Override
+ public boolean submit(Request request, IRequestCallback callback) {
+ ArrayList<Request> captureList = new ArrayList<>();
+ captureList.add(request);
+ return submitBurst(captureList, callback);
+ }
+
+ @Override
+ public boolean submitBurst(List<Request> requests, IRequestCallback callback) {
+ synchronized (mInterfaceLock) {
+ try {
+ CaptureCallbackHandler captureCallback = new CaptureCallbackHandler(callback);
+ ArrayList<CaptureRequest> captureRequests = new ArrayList<>();
+ for (Request request : requests) {
+ captureRequests.add(initializeCaptureRequest(mCameraDevice, request,
+ mSurfaceIdMap));
+ }
+ mCaptureSession.captureBurstRequests(captureRequests,
+ new CameraExtensionUtils.HandlerExecutor(mHandler), captureCallback);
+ } catch (CameraAccessException e) {
+ Log.e(TAG, "Failed to submit capture requests!");
+ return false;
+ } catch (IllegalStateException e) {
+ Log.e(TAG, "Capture session closed!");
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public boolean setRepeating(Request request, IRequestCallback callback) {
+ synchronized (mInterfaceLock) {
+ try {
+ CaptureRequest repeatingRequest = initializeCaptureRequest(mCameraDevice,
+ request, mSurfaceIdMap);
+ CaptureCallbackHandler captureCallback = new CaptureCallbackHandler(callback);
+ mCaptureSession.setSingleRepeatingRequest(repeatingRequest,
+ new CameraExtensionUtils.HandlerExecutor(mHandler), captureCallback);
+ } catch (CameraAccessException e) {
+ Log.e(TAG, "Failed to enable repeating request!");
+ return false;
+ } catch (IllegalStateException e) {
+ Log.e(TAG, "Capture session closed!");
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public void abortCaptures() {
+ synchronized (mInterfaceLock) {
+ try {
+ mCaptureSession.abortCaptures();
+ } catch (CameraAccessException e) {
+ Log.e(TAG, "Failed during capture abort!");
+ } catch (IllegalStateException e) {
+ Log.e(TAG, "Capture session closed!");
+ }
+ }
+ }
+
+ @Override
+ public void stopRepeating() {
+ synchronized (mInterfaceLock) {
+ try {
+ mCaptureSession.stopRepeating();
+ } catch (CameraAccessException e) {
+ Log.e(TAG, "Failed during repeating capture stop!");
+ } catch (IllegalStateException e) {
+ Log.e(TAG, "Capture session closed!");
+ }
+ }
+ }
+ }
+
+ private static CaptureRequest initializeCaptureRequest(CameraDevice cameraDevice,
+ Request request, HashMap<Surface, Integer> surfaceIdMap) throws CameraAccessException {
+ CaptureRequest.Builder builder = cameraDevice.createCaptureRequest(request.templateId);
+ for (OutputConfigId configId : request.targetOutputConfigIds) {
+ boolean found = false;
+ for (Map.Entry<Surface, Integer> entry : surfaceIdMap.entrySet()) {
+ if (entry.getValue() == configId.id) {
+ builder.addTarget(entry.getKey());
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ Log.e(TAG, "Surface with output id: " + configId.id +
+ " not found among registered camera outputs!");
+ }
+ }
+
+ builder.setTag(request.requestId);
+ CaptureRequest ret = builder.build();
+ CameraMetadataNative.update(ret.getNativeMetadata(), request.parameters);
+ return ret;
+ }
+}
diff --git a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
index b578bf8..11b137ca 100644
--- a/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
+++ b/core/java/android/hardware/camera2/impl/CameraDeviceImpl.java
@@ -25,6 +25,7 @@
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraExtensionCharacteristics;
import android.hardware.camera2.CameraExtensionSession;
import android.hardware.camera2.CameraOfflineSession;
import android.hardware.camera2.CameraDevice;
@@ -138,6 +139,7 @@
private CameraCaptureSessionCore mCurrentSession;
private CameraExtensionSessionImpl mCurrentExtensionSession;
+ private CameraAdvancedExtensionSessionImpl mCurrentAdvancedExtensionSession;
private int mNextSessionId = 0;
private final int mAppTargetSdkVersion;
@@ -1343,6 +1345,12 @@
mCurrentExtensionSession.release();
mCurrentExtensionSession = null;
}
+
+ if (mCurrentAdvancedExtensionSession != null) {
+ mCurrentAdvancedExtensionSession.release();
+ mCurrentAdvancedExtensionSession = null;
+ }
+
// Only want to fire the onClosed callback once;
// either a normal close where the remote device is valid
// or a close after a startup error (no remote device but in error state)
@@ -2395,9 +2403,14 @@
public void createExtensionSession(ExtensionSessionConfiguration extensionConfiguration)
throws CameraAccessException {
try {
- mCurrentExtensionSession = CameraExtensionSessionImpl.createCameraExtensionSession(this,
- mContext,
- extensionConfiguration);
+ if (CameraExtensionCharacteristics.areAdvancedExtensionsSupported()) {
+ mCurrentAdvancedExtensionSession =
+ CameraAdvancedExtensionSessionImpl.createCameraAdvancedExtensionSession(
+ this, mContext, extensionConfiguration);
+ } else {
+ mCurrentExtensionSession = CameraExtensionSessionImpl.createCameraExtensionSession(
+ this, mContext, extensionConfiguration);
+ }
} catch (RemoteException e) {
throw new CameraAccessException(CameraAccessException.CAMERA_ERROR);
}
diff --git a/core/java/android/hardware/camera2/impl/CameraExtensionJpegProcessor.java b/core/java/android/hardware/camera2/impl/CameraExtensionJpegProcessor.java
index 936734b..3b1cb94 100644
--- a/core/java/android/hardware/camera2/impl/CameraExtensionJpegProcessor.java
+++ b/core/java/android/hardware/camera2/impl/CameraExtensionJpegProcessor.java
@@ -16,6 +16,9 @@
package android.hardware.camera2.impl;
+import static android.hardware.camera2.impl.CameraExtensionUtils.JPEG_DEFAULT_QUALITY;
+import static android.hardware.camera2.impl.CameraExtensionUtils.JPEG_DEFAULT_ROTATION;
+
import android.annotation.NonNull;
import android.graphics.ImageFormat;
import android.hardware.camera2.CaptureResult;
@@ -42,8 +45,6 @@
public class CameraExtensionJpegProcessor implements ICaptureProcessorImpl {
public final static String TAG = "CameraExtensionJpeg";
private final static int JPEG_QUEUE_SIZE = 1;
- private final static int JPEG_DEFAULT_QUALITY = 100;
- private final static int JPEG_DEFAULT_ROTATION = 0;
private final Handler mHandler;
private final HandlerThread mHandlerThread;
diff --git a/core/java/android/hardware/camera2/impl/CameraExtensionSessionImpl.java b/core/java/android/hardware/camera2/impl/CameraExtensionSessionImpl.java
index 3d771c0..5339f41 100644
--- a/core/java/android/hardware/camera2/impl/CameraExtensionSessionImpl.java
+++ b/core/java/android/hardware/camera2/impl/CameraExtensionSessionImpl.java
@@ -110,79 +110,10 @@
// Lock to synchronize cross-thread access to device public interface
final Object mInterfaceLock = new Object(); // access from this class and Session only!
- private static class SurfaceInfo {
- public int mWidth = 0;
- public int mHeight = 0;
- public int mFormat = PixelFormat.RGBA_8888;
- public long mUsage = 0;
- }
-
- private static final int SUPPORTED_CAPTURE_OUTPUT_FORMATS[] = {
- CameraExtensionCharacteristics.PROCESSING_INPUT_FORMAT,
- ImageFormat.JPEG
- };
-
- private static int nativeGetSurfaceWidth(Surface surface) {
- return SurfaceUtils.getSurfaceSize(surface).getWidth();
- }
-
- private static int nativeGetSurfaceHeight(Surface surface) {
- return SurfaceUtils.getSurfaceSize(surface).getHeight();
- }
-
private static int nativeGetSurfaceFormat(Surface surface) {
return SurfaceUtils.getSurfaceFormat(surface);
}
- private static Surface getBurstCaptureSurface(
- @NonNull List<OutputConfiguration> outputConfigs,
- @NonNull HashMap<Integer, List<Size>> supportedCaptureSizes) {
- for (OutputConfiguration config : outputConfigs) {
- SurfaceInfo surfaceInfo = querySurface(config.getSurface());
- for (int supportedFormat : SUPPORTED_CAPTURE_OUTPUT_FORMATS) {
- if (surfaceInfo.mFormat == supportedFormat) {
- Size captureSize = new Size(surfaceInfo.mWidth, surfaceInfo.mHeight);
- if (supportedCaptureSizes.containsKey(supportedFormat)) {
- if (supportedCaptureSizes.get(surfaceInfo.mFormat).contains(captureSize)) {
- return config.getSurface();
- } else {
- throw new IllegalArgumentException("Capture size not supported!");
- }
- }
- return config.getSurface();
- }
- }
- }
-
- return null;
- }
-
- private static @Nullable Surface getRepeatingRequestSurface(
- @NonNull List<OutputConfiguration> outputConfigs,
- @Nullable List<Size> supportedPreviewSizes) {
- for (OutputConfiguration config : outputConfigs) {
- SurfaceInfo surfaceInfo = querySurface(config.getSurface());
- if ((surfaceInfo.mFormat ==
- CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT) ||
- // The default RGBA_8888 is also implicitly supported because camera will
- // internally override it to
- // 'CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT'
- (surfaceInfo.mFormat == PixelFormat.RGBA_8888)) {
- Size repeatingRequestSurfaceSize = new Size(surfaceInfo.mWidth,
- surfaceInfo.mHeight);
- if ((supportedPreviewSizes == null) ||
- (!supportedPreviewSizes.contains(repeatingRequestSurfaceSize))) {
- throw new IllegalArgumentException("Repeating request surface size " +
- repeatingRequestSurfaceSize + " not supported!");
- }
-
- return config.getSurface();
- }
- }
-
- return null;
- }
-
/**
* @hide
*/
@@ -221,22 +152,22 @@
int suitableSurfaceCount = 0;
List<Size> supportedPreviewSizes = extensionChars.getExtensionSupportedSizes(
config.getExtension(), SurfaceTexture.class);
- Surface repeatingRequestSurface = getRepeatingRequestSurface(
+ Surface repeatingRequestSurface = CameraExtensionUtils.getRepeatingRequestSurface(
config.getOutputConfigurations(), supportedPreviewSizes);
if (repeatingRequestSurface != null) {
suitableSurfaceCount++;
}
HashMap<Integer, List<Size>> supportedCaptureSizes = new HashMap<>();
- for (int format : SUPPORTED_CAPTURE_OUTPUT_FORMATS) {
+ for (int format : CameraExtensionUtils.SUPPORTED_CAPTURE_OUTPUT_FORMATS) {
List<Size> supportedSizes = extensionChars.getExtensionSupportedSizes(
config.getExtension(), format);
if (supportedSizes != null) {
supportedCaptureSizes.put(format, supportedSizes);
}
}
- Surface burstCaptureSurface = getBurstCaptureSurface(config.getOutputConfigurations(),
- supportedCaptureSizes);
+ Surface burstCaptureSurface = CameraExtensionUtils.getBurstCaptureSurface(
+ config.getOutputConfigurations(), supportedCaptureSizes);
if (burstCaptureSurface != null) {
suitableSurfaceCount++;
}
@@ -266,15 +197,15 @@
return session;
}
- private CameraExtensionSessionImpl(@NonNull IImageCaptureExtenderImpl imageExtender,
- @NonNull IPreviewExtenderImpl previewExtender,
- @NonNull List<Size> previewSizes,
- long extensionClientId,
- @NonNull CameraDevice cameraDevice,
- @Nullable Surface repeatingRequestSurface,
- @Nullable Surface burstCaptureSurface,
- @NonNull StateCallback callback,
- @NonNull Executor executor) {
+ public CameraExtensionSessionImpl(@NonNull IImageCaptureExtenderImpl imageExtender,
+ @NonNull IPreviewExtenderImpl previewExtender,
+ @NonNull List<Size> previewSizes,
+ long extensionClientId,
+ @NonNull CameraDevice cameraDevice,
+ @Nullable Surface repeatingRequestSurface,
+ @Nullable Surface burstCaptureSurface,
+ @NonNull StateCallback callback,
+ @NonNull Executor executor) {
mExtensionClientId = extensionClientId;
mImageExtender = imageExtender;
mPreviewExtender = previewExtender;
@@ -290,57 +221,17 @@
mInitialized = false;
}
- private static @NonNull SurfaceInfo querySurface(@NonNull Surface s) {
- ImageWriter writer = null;
- Image img = null;
- SurfaceInfo surfaceInfo = new SurfaceInfo();
- int nativeFormat = nativeGetSurfaceFormat(s);
- int dataspace = SurfaceUtils.getSurfaceDataspace(s);
- // Jpeg surfaces cannot be queried for their usage and other parameters
- // in the usual way below. A buffer can only be de-queued after the
- // producer overrides the surface dimensions to (width*height) x 1.
- if ((nativeFormat == StreamConfigurationMap.HAL_PIXEL_FORMAT_BLOB) &&
- (dataspace == StreamConfigurationMap.HAL_DATASPACE_V0_JFIF)) {
- surfaceInfo.mFormat = ImageFormat.JPEG;
- surfaceInfo.mWidth = nativeGetSurfaceWidth(s);
- surfaceInfo.mHeight = nativeGetSurfaceHeight(s);
- return surfaceInfo;
- }
-
- HardwareBuffer buffer = null;
- try {
- writer = ImageWriter.newInstance(s, 1);
- img = writer.dequeueInputImage();
- buffer = img.getHardwareBuffer();
- surfaceInfo.mFormat = buffer.getFormat();
- surfaceInfo.mWidth = buffer.getWidth();
- surfaceInfo.mHeight = buffer.getHeight();
- surfaceInfo.mUsage = buffer.getUsage();
- } catch (Exception e) {
- Log.e(TAG, "Failed to query surface, returning defaults!");
- } finally {
- if (buffer != null) {
- buffer.close();
- }
- if (img != null) {
- img.close();
- }
- if (writer != null) {
- writer.close();
- }
- }
-
- return surfaceInfo;
- }
-
private void initializeRepeatingRequestPipeline() throws RemoteException {
- SurfaceInfo repeatingSurfaceInfo = new SurfaceInfo();
+ CameraExtensionUtils.SurfaceInfo repeatingSurfaceInfo =
+ new CameraExtensionUtils.SurfaceInfo();
mPreviewProcessorType = mPreviewExtender.getProcessorType();
if (mClientRepeatingRequestSurface != null) {
- repeatingSurfaceInfo = querySurface(mClientRepeatingRequestSurface);
+ repeatingSurfaceInfo = CameraExtensionUtils.querySurface(
+ mClientRepeatingRequestSurface);
} else {
// Make the intermediate surface behave as any regular 'SurfaceTexture'
- SurfaceInfo captureSurfaceInfo = querySurface(mClientCaptureSurface);
+ CameraExtensionUtils.SurfaceInfo captureSurfaceInfo = CameraExtensionUtils.querySurface(
+ mClientCaptureSurface);
Size captureSize = new Size(captureSurfaceInfo.mWidth, captureSurfaceInfo.mHeight);
Size previewSize = findSmallestAspectMatchedSize(mSupportedPreviewSizes, captureSize);
repeatingSurfaceInfo.mWidth = previewSize.getWidth();
@@ -418,7 +309,8 @@
if (mImageProcessor != null) {
if (mClientCaptureSurface != null) {
- SurfaceInfo surfaceInfo = querySurface(mClientCaptureSurface);
+ CameraExtensionUtils.SurfaceInfo surfaceInfo = CameraExtensionUtils.querySurface(
+ mClientCaptureSurface);
if (surfaceInfo.mFormat == ImageFormat.JPEG) {
mImageJpegProcessor = new CameraExtensionJpegProcessor(mImageProcessor);
mImageProcessor = mImageJpegProcessor;
@@ -501,7 +393,7 @@
SessionConfiguration sessionConfig = new SessionConfiguration(
SessionConfiguration.SESSION_REGULAR,
outputList,
- new HandlerExecutor(mHandler),
+ new CameraExtensionUtils.HandlerExecutor(mHandler),
new SessionStateHandler());
if (!sessionParamsList.isEmpty()) {
@@ -656,7 +548,8 @@
throw new UnsupportedOperationException("Failed to create still capture burst request");
}
- return mCaptureSession.captureBurstRequests(burstRequest, new HandlerExecutor(mHandler),
+ return mCaptureSession.captureBurstRequests(burstRequest,
+ new CameraExtensionUtils.HandlerExecutor(mHandler),
new BurstRequestHandler(request, executor, listener, requestMap,
mBurstCaptureImageCallback));
}
@@ -724,7 +617,7 @@
CaptureRequest repeatingRequest = createRequest(mCameraDevice,
captureStageList, mCameraRepeatingSurface, CameraDevice.TEMPLATE_PREVIEW);
return mCaptureSession.setSingleRepeatingRequest(repeatingRequest,
- new HandlerExecutor(mHandler), requestHandler);
+ new CameraExtensionUtils.HandlerExecutor(mHandler), requestHandler);
}
/** @hide */
@@ -1705,23 +1598,6 @@
return ret;
}
- private final class HandlerExecutor implements Executor {
- private final Handler mHandler;
-
- public HandlerExecutor(Handler handler) {
- mHandler = handler;
- }
-
- @Override
- public void execute(Runnable runCmd) {
- try {
- mHandler.post(runCmd);
- } catch (RejectedExecutionException e) {
- Log.w(TAG, "Handler thread unavailable, skipping message!");
- }
- }
- }
-
private static ParcelImage initializeParcelImage(Image img) {
ParcelImage parcelImage = new ParcelImage();
parcelImage.buffer = img.getHardwareBuffer();
diff --git a/core/java/android/hardware/camera2/impl/CameraExtensionUtils.java b/core/java/android/hardware/camera2/impl/CameraExtensionUtils.java
new file mode 100644
index 0000000..950d716b
--- /dev/null
+++ b/core/java/android/hardware/camera2/impl/CameraExtensionUtils.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2021 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.camera2.impl;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.graphics.ImageFormat;
+import android.graphics.PixelFormat;
+import android.hardware.HardwareBuffer;
+import android.hardware.camera2.CameraExtensionCharacteristics;
+import android.hardware.camera2.params.OutputConfiguration;
+import android.hardware.camera2.params.StreamConfigurationMap;
+import android.hardware.camera2.utils.SurfaceUtils;
+import android.media.Image;
+import android.media.ImageWriter;
+import android.os.Handler;
+import android.util.Log;
+import android.util.Size;
+import android.view.Surface;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.Executor;
+import java.util.concurrent.RejectedExecutionException;
+
+public final class CameraExtensionUtils {
+ private static final String TAG = "CameraExtensionUtils";
+
+ public final static int JPEG_DEFAULT_QUALITY = 100;
+ public final static int JPEG_DEFAULT_ROTATION = 0;
+
+ public static final int[] SUPPORTED_CAPTURE_OUTPUT_FORMATS = {
+ CameraExtensionCharacteristics.PROCESSING_INPUT_FORMAT,
+ ImageFormat.JPEG
+ };
+
+ public static class SurfaceInfo {
+ public int mWidth = 0;
+ public int mHeight = 0;
+ public int mFormat = PixelFormat.RGBA_8888;
+ public long mUsage = 0;
+ }
+
+ public static final class HandlerExecutor implements Executor {
+ private final Handler mHandler;
+
+ public HandlerExecutor(Handler handler) {
+ mHandler = handler;
+ }
+
+ @Override
+ public void execute(Runnable runCmd) {
+ try {
+ mHandler.post(runCmd);
+ } catch (RejectedExecutionException e) {
+ Log.w(TAG, "Handler thread unavailable, skipping message!");
+ }
+ }
+ }
+
+ public static @NonNull SurfaceInfo querySurface(@NonNull Surface s) {
+ ImageWriter writer = null;
+ Image img = null;
+ SurfaceInfo surfaceInfo = new SurfaceInfo();
+ int nativeFormat = SurfaceUtils.getSurfaceFormat(s);
+ int dataspace = SurfaceUtils.getSurfaceDataspace(s);
+ // Jpeg surfaces cannot be queried for their usage and other parameters
+ // in the usual way below. A buffer can only be de-queued after the
+ // producer overrides the surface dimensions to (width*height) x 1.
+ if ((nativeFormat == StreamConfigurationMap.HAL_PIXEL_FORMAT_BLOB) &&
+ (dataspace == StreamConfigurationMap.HAL_DATASPACE_V0_JFIF)) {
+ surfaceInfo.mFormat = ImageFormat.JPEG;
+ Size surfaceSize = SurfaceUtils.getSurfaceSize(s);
+ surfaceInfo.mWidth = surfaceSize.getWidth();
+ surfaceInfo.mHeight = surfaceSize.getHeight();
+ return surfaceInfo;
+ }
+
+ HardwareBuffer buffer = null;
+ try {
+ writer = ImageWriter.newInstance(s, 1);
+ img = writer.dequeueInputImage();
+ buffer = img.getHardwareBuffer();
+ surfaceInfo.mFormat = buffer.getFormat();
+ surfaceInfo.mWidth = buffer.getWidth();
+ surfaceInfo.mHeight = buffer.getHeight();
+ surfaceInfo.mUsage = buffer.getUsage();
+ } catch (Exception e) {
+ Log.e(TAG, "Failed to query surface, returning defaults!");
+ } finally {
+ if (buffer != null) {
+ buffer.close();
+ }
+ if (img != null) {
+ img.close();
+ }
+ if (writer != null) {
+ writer.close();
+ }
+ }
+
+ return surfaceInfo;
+ }
+
+ public static Surface getBurstCaptureSurface(
+ @NonNull List<OutputConfiguration> outputConfigs,
+ @NonNull HashMap<Integer, List<Size>> supportedCaptureSizes) {
+ for (OutputConfiguration config : outputConfigs) {
+ SurfaceInfo surfaceInfo = querySurface(config.getSurface());
+ for (int supportedFormat : SUPPORTED_CAPTURE_OUTPUT_FORMATS) {
+ if (surfaceInfo.mFormat == supportedFormat) {
+ Size captureSize = new Size(surfaceInfo.mWidth, surfaceInfo.mHeight);
+ if (supportedCaptureSizes.containsKey(supportedFormat)) {
+ if (supportedCaptureSizes.get(surfaceInfo.mFormat).contains(captureSize)) {
+ return config.getSurface();
+ } else {
+ throw new IllegalArgumentException("Capture size not supported!");
+ }
+ }
+ return config.getSurface();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public static @Nullable Surface getRepeatingRequestSurface(
+ @NonNull List<OutputConfiguration> outputConfigs,
+ @Nullable List<Size> supportedPreviewSizes) {
+ for (OutputConfiguration config : outputConfigs) {
+ SurfaceInfo surfaceInfo = querySurface(config.getSurface());
+ if ((surfaceInfo.mFormat ==
+ CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT) ||
+ // The default RGBA_8888 is also implicitly supported because camera will
+ // internally override it to
+ // 'CameraExtensionCharacteristics.NON_PROCESSING_INPUT_FORMAT'
+ (surfaceInfo.mFormat == PixelFormat.RGBA_8888)) {
+ Size repeatingRequestSurfaceSize = new Size(surfaceInfo.mWidth,
+ surfaceInfo.mHeight);
+ if ((supportedPreviewSizes == null) ||
+ (!supportedPreviewSizes.contains(repeatingRequestSurfaceSize))) {
+ throw new IllegalArgumentException("Repeating request surface size " +
+ repeatingRequestSurfaceSize + " not supported!");
+ }
+
+ return config.getSurface();
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/core/java/android/hardware/face/FaceManager.java b/core/java/android/hardware/face/FaceManager.java
index 9a27a99..55c90ce 100644
--- a/core/java/android/hardware/face/FaceManager.java
+++ b/core/java/android/hardware/face/FaceManager.java
@@ -69,8 +69,6 @@
private static final int MSG_SET_FEATURE_COMPLETED = 107;
private static final int MSG_CHALLENGE_GENERATED = 108;
private static final int MSG_FACE_DETECTED = 109;
- private static final int MSG_CHALLENGE_INTERRUPTED = 110;
- private static final int MSG_CHALLENGE_INTERRUPT_FINISHED = 111;
private static final int MSG_AUTHENTICATION_FRAME = 112;
private static final int MSG_ENROLLMENT_FRAME = 113;
@@ -102,8 +100,8 @@
@Override // binder call
public void onAuthenticationSucceeded(Face face, int userId, boolean isStrongBiometric) {
- mHandler.obtainMessage(MSG_AUTHENTICATION_SUCCEEDED, userId, isStrongBiometric ? 1 : 0,
- face).sendToTarget();
+ mHandler.obtainMessage(MSG_AUTHENTICATION_SUCCEEDED, userId,
+ isStrongBiometric ? 1 : 0, face).sendToTarget();
}
@Override // binder call
@@ -142,22 +140,12 @@
}
@Override
- public void onChallengeGenerated(int sensorId, long challenge) {
- mHandler.obtainMessage(MSG_CHALLENGE_GENERATED, sensorId, 0, challenge)
+ public void onChallengeGenerated(int sensorId, int userId, long challenge) {
+ mHandler.obtainMessage(MSG_CHALLENGE_GENERATED, sensorId, userId, challenge)
.sendToTarget();
}
@Override
- public void onChallengeInterrupted(int sensorId) {
- mHandler.obtainMessage(MSG_CHALLENGE_INTERRUPTED, sensorId).sendToTarget();
- }
-
- @Override
- public void onChallengeInterruptFinished(int sensorId) {
- mHandler.obtainMessage(MSG_CHALLENGE_INTERRUPT_FINISHED, sensorId).sendToTarget();
- }
-
- @Override
public void onAuthenticationFrame(FaceAuthenticationFrame frame) {
mHandler.obtainMessage(MSG_AUTHENTICATION_FRAME, frame).sendToTarget();
}
@@ -434,16 +422,14 @@
*
* @see com.android.server.locksettings.LockSettingsService
*
- * TODO(b/171335732): should take userId
- *
* @hide
*/
@RequiresPermission(MANAGE_BIOMETRIC)
- public void generateChallenge(int sensorId, GenerateChallengeCallback callback) {
+ public void generateChallenge(int sensorId, int userId, GenerateChallengeCallback callback) {
if (mService != null) {
try {
mGenerateChallengeCallback = callback;
- mService.generateChallenge(mToken, sensorId, 0 /* userId */, mServiceReceiver,
+ mService.generateChallenge(mToken, sensorId, userId, mServiceReceiver,
mContext.getOpPackageName());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
@@ -452,12 +438,13 @@
}
/**
- * Same as {@link #generateChallenge(int, GenerateChallengeCallback)}, but assumes the first
- * enumerated sensor.
+ * Same as {@link #generateChallenge(int, int, GenerateChallengeCallback)}, but assumes the
+ * first enumerated sensor.
+ *
* @hide
*/
@RequiresPermission(MANAGE_BIOMETRIC)
- public void generateChallenge(GenerateChallengeCallback callback) {
+ public void generateChallenge(int userId, GenerateChallengeCallback callback) {
final List<FaceSensorPropertiesInternal> faceSensorProperties =
getSensorPropertiesInternal();
if (faceSensorProperties.isEmpty()) {
@@ -466,7 +453,7 @@
}
final int sensorId = faceSensorProperties.get(0).sensorId;
- generateChallenge(sensorId, callback);
+ generateChallenge(sensorId, userId, callback);
}
/**
@@ -1120,25 +1107,16 @@
}
/**
- * Callback structure provided to {@link #generateChallenge(int, GenerateChallengeCallback)}.
+ * Callback structure provided to {@link #generateChallenge(int, int,
+ * GenerateChallengeCallback)}.
+ *
* @hide
*/
public interface GenerateChallengeCallback {
/**
* Invoked when a challenge has been generated.
*/
- void onGenerateChallengeResult(int sensorId, long challenge);
-
- /**
- * Invoked if the challenge has not been revoked and a subsequent caller/owner invokes
- * {@link #generateChallenge(int, GenerateChallengeCallback)}, but
- */
- default void onChallengeInterrupted(int sensorId) {}
-
- /**
- * Invoked when the interrupting client has finished (e.g. revoked its challenge).
- */
- default void onChallengeInterruptFinished(int sensorId) {}
+ void onGenerateChallengeResult(int sensorId, int userId, long challenge);
}
private class OnEnrollCancelListener implements OnCancelListener {
@@ -1212,18 +1190,13 @@
args.recycle();
break;
case MSG_CHALLENGE_GENERATED:
- sendChallengeGenerated(msg.arg1 /* sensorId */, (long) msg.obj /* challenge */);
+ sendChallengeGenerated(msg.arg1 /* sensorId */, msg.arg2 /* userId */,
+ (long) msg.obj /* challenge */);
break;
case MSG_FACE_DETECTED:
sendFaceDetected(msg.arg1 /* sensorId */, msg.arg2 /* userId */,
(boolean) msg.obj /* isStrongBiometric */);
break;
- case MSG_CHALLENGE_INTERRUPTED:
- sendChallengeInterrupted((int) msg.obj /* sensorId */);
- break;
- case MSG_CHALLENGE_INTERRUPT_FINISHED:
- sendChallengeInterruptFinished((int) msg.obj /* sensorId */);
- break;
case MSG_AUTHENTICATION_FRAME:
sendAuthenticationFrame((FaceAuthenticationFrame) msg.obj /* frame */);
break;
@@ -1251,11 +1224,11 @@
mGetFeatureCallback.onCompleted(success, features, featureState);
}
- private void sendChallengeGenerated(int sensorId, long challenge) {
+ private void sendChallengeGenerated(int sensorId, int userId, long challenge) {
if (mGenerateChallengeCallback == null) {
return;
}
- mGenerateChallengeCallback.onGenerateChallengeResult(sensorId, challenge);
+ mGenerateChallengeCallback.onGenerateChallengeResult(sensorId, userId, challenge);
}
private void sendFaceDetected(int sensorId, int userId, boolean isStrongBiometric) {
@@ -1266,22 +1239,6 @@
mFaceDetectionCallback.onFaceDetected(sensorId, userId, isStrongBiometric);
}
- private void sendChallengeInterrupted(int sensorId) {
- if (mGenerateChallengeCallback == null) {
- Slog.e(TAG, "sendChallengeInterrupted, callback null");
- return;
- }
- mGenerateChallengeCallback.onChallengeInterrupted(sensorId);
- }
-
- private void sendChallengeInterruptFinished(int sensorId) {
- if (mGenerateChallengeCallback == null) {
- Slog.e(TAG, "sendChallengeInterruptFinished, callback null");
- return;
- }
- mGenerateChallengeCallback.onChallengeInterruptFinished(sensorId);
- }
-
private void sendRemovedResult(Face face, int remaining) {
if (mRemovalCallback == null) {
return;
diff --git a/core/java/android/hardware/face/FaceServiceReceiver.java b/core/java/android/hardware/face/FaceServiceReceiver.java
index 9e62ca5..9e78592 100644
--- a/core/java/android/hardware/face/FaceServiceReceiver.java
+++ b/core/java/android/hardware/face/FaceServiceReceiver.java
@@ -72,17 +72,8 @@
}
@Override
- public void onChallengeGenerated(int sensorId, long challenge) throws RemoteException {
-
- }
-
- @Override
- public void onChallengeInterrupted(int sensorId) throws RemoteException {
-
- }
-
- @Override
- public void onChallengeInterruptFinished(int sensorId) throws RemoteException {
+ public void onChallengeGenerated(int sensorId, int userId, long challenge)
+ throws RemoteException {
}
diff --git a/core/java/android/hardware/face/IFaceServiceReceiver.aidl b/core/java/android/hardware/face/IFaceServiceReceiver.aidl
index 0ccb395..c4d9bf2 100644
--- a/core/java/android/hardware/face/IFaceServiceReceiver.aidl
+++ b/core/java/android/hardware/face/IFaceServiceReceiver.aidl
@@ -33,9 +33,7 @@
void onRemoved(in Face face, int remaining);
void onFeatureSet(boolean success, int feature);
void onFeatureGet(boolean success, in int[] features, in boolean[] featureState);
- void onChallengeGenerated(int sensorId, long challenge);
- void onChallengeInterrupted(int sensorId);
- void onChallengeInterruptFinished(int sensorId);
+ void onChallengeGenerated(int sensorId, int userId, long challenge);
void onAuthenticationFrame(in FaceAuthenticationFrame frame);
void onEnrollmentFrame(in FaceEnrollFrame frame);
}
diff --git a/core/java/android/hardware/fingerprint/FingerprintManager.java b/core/java/android/hardware/fingerprint/FingerprintManager.java
index b52955d..8aeb5cd 100644
--- a/core/java/android/hardware/fingerprint/FingerprintManager.java
+++ b/core/java/android/hardware/fingerprint/FingerprintManager.java
@@ -475,10 +475,13 @@
}
/**
+ * Callbacks for generate challenge operations.
+ *
* @hide
*/
public interface GenerateChallengeCallback {
- void onChallengeGenerated(int sensorId, long challenge);
+ /** Called when a challenged has been generated. */
+ void onChallengeGenerated(int sensorId, int userId, long challenge);
}
/**
@@ -1124,7 +1127,8 @@
sendRemovedResult((Fingerprint) msg.obj, msg.arg1 /* remaining */);
break;
case MSG_CHALLENGE_GENERATED:
- sendChallengeGenerated(msg.arg1 /* sensorId */, (long) msg.obj /* challenge */);
+ sendChallengeGenerated(msg.arg1 /* sensorId */, msg.arg2 /* userId */,
+ (long) msg.obj /* challenge */);
break;
case MSG_FINGERPRINT_DETECTED:
sendFingerprintDetected(msg.arg1 /* sensorId */, msg.arg2 /* userId */,
@@ -1233,12 +1237,12 @@
}
}
- private void sendChallengeGenerated(int sensorId, long challenge) {
+ private void sendChallengeGenerated(int sensorId, int userId, long challenge) {
if (mGenerateChallengeCallback == null) {
Slog.e(TAG, "sendChallengeGenerated, callback null");
return;
}
- mGenerateChallengeCallback.onChallengeGenerated(sensorId, challenge);
+ mGenerateChallengeCallback.onChallengeGenerated(sensorId, userId, challenge);
}
private void sendFingerprintDetected(int sensorId, int userId, boolean isStrongBiometric) {
@@ -1454,8 +1458,8 @@
}
@Override // binder call
- public void onChallengeGenerated(int sensorId, long challenge) {
- mHandler.obtainMessage(MSG_CHALLENGE_GENERATED, sensorId, 0, challenge)
+ public void onChallengeGenerated(int sensorId, int userId, long challenge) {
+ mHandler.obtainMessage(MSG_CHALLENGE_GENERATED, sensorId, userId, challenge)
.sendToTarget();
}
diff --git a/core/java/android/hardware/fingerprint/FingerprintServiceReceiver.java b/core/java/android/hardware/fingerprint/FingerprintServiceReceiver.java
index 798e87b..a9779b5 100644
--- a/core/java/android/hardware/fingerprint/FingerprintServiceReceiver.java
+++ b/core/java/android/hardware/fingerprint/FingerprintServiceReceiver.java
@@ -61,7 +61,8 @@
}
@Override
- public void onChallengeGenerated(int sensorId, long challenge) throws RemoteException {
+ public void onChallengeGenerated(int sensorId, int userId, long challenge)
+ throws RemoteException {
}
diff --git a/core/java/android/hardware/fingerprint/IFingerprintServiceReceiver.aidl b/core/java/android/hardware/fingerprint/IFingerprintServiceReceiver.aidl
index 1bd284d..9cea1fe 100644
--- a/core/java/android/hardware/fingerprint/IFingerprintServiceReceiver.aidl
+++ b/core/java/android/hardware/fingerprint/IFingerprintServiceReceiver.aidl
@@ -29,7 +29,7 @@
void onAuthenticationFailed();
void onError(int error, int vendorCode);
void onRemoved(in Fingerprint fp, int remaining);
- void onChallengeGenerated(int sensorId, long challenge);
+ void onChallengeGenerated(int sensorId, int userId, long challenge);
void onUdfpsPointerDown(int sensorId);
void onUdfpsPointerUp(int sensorId);
}
diff --git a/core/java/android/hardware/fingerprint/IUdfpsHbmListener.aidl b/core/java/android/hardware/fingerprint/IUdfpsHbmListener.aidl
index 1551e07..f4d22da 100644
--- a/core/java/android/hardware/fingerprint/IUdfpsHbmListener.aidl
+++ b/core/java/android/hardware/fingerprint/IUdfpsHbmListener.aidl
@@ -35,7 +35,7 @@
* UdfpsController will call this method when the HBM is enabled.
*
* @param hbmType The type of HBM that was enabled. See
- * {@link com.android.systemui.biometrics.HbmTypes}.
+ * {@link com.android.systemui.biometrics.UdfpsHbmTypes}.
* @param displayId The displayId for which the HBM is enabled. See
* {@link android.view.Display#getDisplayId()}.
*/
@@ -45,7 +45,7 @@
* UdfpsController will call this method when the HBM is disabled.
*
* @param hbmType The type of HBM that was disabled. See
- * {@link com.android.systemui.biometrics.HbmTypes}.
+ * {@link com.android.systemui.biometrics.UdfpsHbmTypes}.
* @param displayId The displayId for which the HBM is disabled. See
* {@link android.view.Display#getDisplayId()}.
*/
diff --git a/core/java/android/hardware/hdmi/OWNERS b/core/java/android/hardware/hdmi/OWNERS
index 16c15e3..60d43fd 100644
--- a/core/java/android/hardware/hdmi/OWNERS
+++ b/core/java/android/hardware/hdmi/OWNERS
@@ -4,3 +4,4 @@
marvinramin@google.com
nchalko@google.com
+lcnathalie@google.com
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index d7b96df..f0d410f 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -1329,6 +1329,7 @@
WindowManager.LayoutParams.TYPE_INPUT_METHOD, Gravity.BOTTOM, false);
mWindow.getWindow().getAttributes().setFitInsetsTypes(statusBars() | navigationBars());
mWindow.getWindow().getAttributes().setFitInsetsSides(Side.all() & ~Side.BOTTOM);
+ mWindow.getWindow().getAttributes().receiveInsetsIgnoringZOrder = true;
// Automotive devices may request the navigation bar to be hidden when the IME shows up
// (controlled via config_automotiveHideNavBarForKeyboard) in order to maximize the visible
diff --git a/core/java/android/net/NetworkStateSnapshot.java b/core/java/android/net/NetworkStateSnapshot.java
index 9df861a..3915634 100644
--- a/core/java/android/net/NetworkStateSnapshot.java
+++ b/core/java/android/net/NetworkStateSnapshot.java
@@ -104,7 +104,10 @@
return mSubscriberId;
}
- /** Get the legacy type of the network associated with this snapshot. */
+ /**
+ * Get the legacy type of the network associated with this snapshot.
+ * @return the legacy network type. See {@code ConnectivityManager#TYPE_*}.
+ */
public int getLegacyType() {
return mLegacyType;
}
diff --git a/core/java/android/net/vcn/VcnConfig.java b/core/java/android/net/vcn/VcnConfig.java
index d41c0b4..caab152 100644
--- a/core/java/android/net/vcn/VcnConfig.java
+++ b/core/java/android/net/vcn/VcnConfig.java
@@ -52,12 +52,17 @@
private static final String GATEWAY_CONNECTION_CONFIGS_KEY = "mGatewayConnectionConfigs";
@NonNull private final Set<VcnGatewayConnectionConfig> mGatewayConnectionConfigs;
+ private static final String IS_TEST_MODE_PROFILE_KEY = "mIsTestModeProfile";
+ private final boolean mIsTestModeProfile;
+
private VcnConfig(
@NonNull String packageName,
- @NonNull Set<VcnGatewayConnectionConfig> gatewayConnectionConfigs) {
+ @NonNull Set<VcnGatewayConnectionConfig> gatewayConnectionConfigs,
+ boolean isTestModeProfile) {
mPackageName = packageName;
mGatewayConnectionConfigs =
Collections.unmodifiableSet(new ArraySet<>(gatewayConnectionConfigs));
+ mIsTestModeProfile = isTestModeProfile;
validate();
}
@@ -77,6 +82,7 @@
new ArraySet<>(
PersistableBundleUtils.toList(
gatewayConnectionConfigsBundle, VcnGatewayConnectionConfig::new));
+ mIsTestModeProfile = in.getBoolean(IS_TEST_MODE_PROFILE_KEY);
validate();
}
@@ -104,6 +110,15 @@
}
/**
+ * Returns whether or not this VcnConfig is restricted to test networks.
+ *
+ * @hide
+ */
+ public boolean isTestModeProfile() {
+ return mIsTestModeProfile;
+ }
+
+ /**
* Serializes this object to a PersistableBundle.
*
* @hide
@@ -119,13 +134,14 @@
new ArrayList<>(mGatewayConnectionConfigs),
VcnGatewayConnectionConfig::toPersistableBundle);
result.putPersistableBundle(GATEWAY_CONNECTION_CONFIGS_KEY, gatewayConnectionConfigsBundle);
+ result.putBoolean(IS_TEST_MODE_PROFILE_KEY, mIsTestModeProfile);
return result;
}
@Override
public int hashCode() {
- return Objects.hash(mPackageName, mGatewayConnectionConfigs);
+ return Objects.hash(mPackageName, mGatewayConnectionConfigs, mIsTestModeProfile);
}
@Override
@@ -136,7 +152,8 @@
final VcnConfig rhs = (VcnConfig) other;
return mPackageName.equals(rhs.mPackageName)
- && mGatewayConnectionConfigs.equals(rhs.mGatewayConnectionConfigs);
+ && mGatewayConnectionConfigs.equals(rhs.mGatewayConnectionConfigs)
+ && mIsTestModeProfile == rhs.mIsTestModeProfile;
}
// Parcelable methods
@@ -172,6 +189,8 @@
@NonNull
private final Set<VcnGatewayConnectionConfig> mGatewayConnectionConfigs = new ArraySet<>();
+ private boolean mIsTestModeProfile = false;
+
public Builder(@NonNull Context context) {
Objects.requireNonNull(context, "context was null");
@@ -207,13 +226,29 @@
}
/**
+ * Restricts this VcnConfig to matching with test networks (only).
+ *
+ * <p>This method is for testing only, and must not be used by apps. Calling {@link
+ * VcnManager#setVcnConfig(ParcelUuid, VcnConfig)} with a VcnConfig where test-network usage
+ * is enabled will require the MANAGE_TEST_NETWORKS permission.
+ *
+ * @return this {@link Builder} instance, for chaining
+ * @hide
+ */
+ @NonNull
+ public Builder setIsTestModeProfile() {
+ mIsTestModeProfile = true;
+ return this;
+ }
+
+ /**
* Builds and validates the VcnConfig.
*
* @return an immutable VcnConfig instance
*/
@NonNull
public VcnConfig build() {
- return new VcnConfig(mPackageName, mGatewayConnectionConfigs);
+ return new VcnConfig(mPackageName, mGatewayConnectionConfigs, mIsTestModeProfile);
}
}
}
diff --git a/core/java/android/net/vcn/VcnGatewayConnectionConfig.java b/core/java/android/net/vcn/VcnGatewayConnectionConfig.java
index f02346b..7eea0b1 100644
--- a/core/java/android/net/vcn/VcnGatewayConnectionConfig.java
+++ b/core/java/android/net/vcn/VcnGatewayConnectionConfig.java
@@ -15,6 +15,8 @@
*/
package android.net.vcn;
+import static android.net.ipsec.ike.IkeSessionParams.IKE_OPTION_MOBIKE;
+
import static com.android.internal.annotations.VisibleForTesting.Visibility;
import android.annotation.IntDef;
@@ -438,6 +440,8 @@
* distinguish between VcnGatewayConnectionConfigs configured on a single {@link
* VcnConfig}. This will be used as the identifier in VcnStatusCallback invocations.
* @param tunnelConnectionParams the IKE tunnel connection configuration
+ * @throws IllegalArgumentException if the provided IkeTunnelConnectionParams is not
+ * configured to support MOBIKE
* @see IkeTunnelConnectionParams
* @see VcnManager.VcnStatusCallback#onGatewayConnectionError
*/
@@ -446,6 +450,10 @@
@NonNull IkeTunnelConnectionParams tunnelConnectionParams) {
Objects.requireNonNull(gatewayConnectionName, "gatewayConnectionName was null");
Objects.requireNonNull(tunnelConnectionParams, "tunnelConnectionParams was null");
+ if (!tunnelConnectionParams.getIkeSessionParams().hasIkeOption(IKE_OPTION_MOBIKE)) {
+ throw new IllegalArgumentException(
+ "MOBIKE must be configured for the provided IkeSessionParams");
+ }
mGatewayConnectionName = gatewayConnectionName;
mTunnelConnectionParams = tunnelConnectionParams;
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index c97d1f8..4c8297a 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -3931,7 +3931,6 @@
getStartClockTime(),
whichBatteryScreenOffRealtime / 1000, whichBatteryScreenOffUptime / 1000,
getEstimatedBatteryCapacity(),
- getLearnedBatteryCapacity(),
getMinLearnedBatteryCapacity(),
getMaxLearnedBatteryCapacity(),
screenDozeTime / 1000);
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 5b3bc26..900659b 100755
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -309,7 +309,7 @@
* booted, but it may increase when the hardware manufacturer provides an OTA update.
* <p>
* Possible non-zero values are defined in {@link Build.VERSION_CODES} starting with
- * {@link Build.VERSION_CODES#S}.
+ * {@link Build.VERSION_CODES#R}.
*/
public static final int MEDIA_PERFORMANCE_CLASS =
DeviceProperties.media_performance_class().orElse(0);
@@ -437,7 +437,8 @@
* Magic version number for a current development build, which has
* not yet turned into an official release.
*/
- public static final int CUR_DEVELOPMENT = VMRuntime.SDK_VERSION_CUR_DEVELOPMENT;
+ // This must match VMRuntime.SDK_VERSION_CUR_DEVELOPMENT.
+ public static final int CUR_DEVELOPMENT = 10000;
/**
* October 2008: The original, first, version of Android. Yay!
@@ -1324,6 +1325,7 @@
* selinux into "permissive" mode in particular.
* @hide
*/
+ @UnsupportedAppUsage
public static final boolean IS_DEBUGGABLE =
SystemProperties.getInt("ro.debuggable", 0) == 1;
diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java
index b8bb353..d90e129 100644
--- a/core/java/android/os/Debug.java
+++ b/core/java/android/os/Debug.java
@@ -74,8 +74,9 @@
*
* @deprecated Accurate counting is a burden on the runtime and may be removed.
*/
+ // This must match VMDebug.TRACE_COUNT_ALLOCS.
@Deprecated
- public static final int TRACE_COUNT_ALLOCS = VMDebug.TRACE_COUNT_ALLOCS;
+ public static final int TRACE_COUNT_ALLOCS = 1;
/**
* Flags for printLoadedClasses(). Default behavior is to only show
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java
index f9e4f73..6bca336 100644
--- a/core/java/android/os/Process.java
+++ b/core/java/android/os/Process.java
@@ -250,6 +250,12 @@
public static final int EXT_OBB_RW_GID = 1079;
/**
+ * Defines the UID/GID for the Uwb service process.
+ * @hide
+ */
+ public static final int UWB_UID = 1083;
+
+ /**
* GID that corresponds to the INTERNET permission.
* Must match the value of AID_INET.
* @hide
diff --git a/core/java/android/provider/DeviceConfig.java b/core/java/android/provider/DeviceConfig.java
index d7d1902..1092adf 100644
--- a/core/java/android/provider/DeviceConfig.java
+++ b/core/java/android/provider/DeviceConfig.java
@@ -580,6 +580,13 @@
*/
public static final String NAMESPACE_GAME_OVERLAY = "game_overlay";
+ /**
+ * Namespace for Constrain Display APIs related features.
+ *
+ * @hide
+ */
+ public static final String NAMESPACE_CONSTRAIN_DISPLAY_APIS = "constrain_display_apis";
+
private static final Object sLock = new Object();
@GuardedBy("sLock")
private static ArrayMap<OnPropertiesChangedListener, Pair<String, Executor>> sListeners =
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 3bdc546..e410e50 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -8636,7 +8636,6 @@
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
@TestApi
- @Readable
public static final String NFC_PAYMENT_DEFAULT_COMPONENT = "nfc_payment_default_component";
/**
@@ -9921,6 +9920,18 @@
"accessibility_floating_menu_opacity";
/**
+ * Prompts the user to the Accessibility button is replaced with the floating menu.
+ * <ul>
+ * <li> 0 = disabled </li>
+ * <li> 1 = enabled </li>
+ * </ul>
+ *
+ * @hide
+ */
+ public static final String ACCESSIBILITY_FLOATING_MENU_MIGRATION_TOOLTIP_PROMPT =
+ "accessibility_floating_menu_migration_tooltip_prompt";
+
+ /**
* Whether the Adaptive connectivity option is enabled.
*
* @hide
diff --git a/core/java/android/service/voice/AbstractHotwordDetector.java b/core/java/android/service/voice/AbstractHotwordDetector.java
index 4896748..54ccf30 100644
--- a/core/java/android/service/voice/AbstractHotwordDetector.java
+++ b/core/java/android/service/voice/AbstractHotwordDetector.java
@@ -55,10 +55,8 @@
/**
* Detect hotword from an externally supplied stream of data.
*
- * @return a writeable file descriptor that clients can start writing data in the given format.
- * In order to stop detection, clients can close the given stream.
+ * @return true if the request to start recognition succeeded
*/
- @Nullable
@Override
public boolean startRecognition(
@NonNull ParcelFileDescriptor audioStream,
diff --git a/core/java/android/service/voice/AlwaysOnHotwordDetector.java b/core/java/android/service/voice/AlwaysOnHotwordDetector.java
index bacc6ec..e813017 100644
--- a/core/java/android/service/voice/AlwaysOnHotwordDetector.java
+++ b/core/java/android/service/voice/AlwaysOnHotwordDetector.java
@@ -524,7 +524,7 @@
* @param result Info about the second stage detection result, provided by the
* {@link HotwordDetectionService}.
*/
- public void onRejected(@Nullable HotwordRejectedResult result) {
+ public void onRejected(@NonNull HotwordRejectedResult result) {
}
/**
@@ -1164,7 +1164,7 @@
}
@Override
- public void onRejected(HotwordRejectedResult result) {
+ public void onRejected(@NonNull HotwordRejectedResult result) {
if (DBG) {
Slog.d(TAG, "onRejected(" + result + ")");
} else {
diff --git a/core/java/android/service/voice/HotwordDetectionService.java b/core/java/android/service/voice/HotwordDetectionService.java
index 5f41174..ea01e09 100644
--- a/core/java/android/service/voice/HotwordDetectionService.java
+++ b/core/java/android/service/voice/HotwordDetectionService.java
@@ -16,9 +16,8 @@
package android.service.voice;
-import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage;
+import static java.util.Objects.requireNonNull;
-import android.annotation.CallSuper;
import android.annotation.DurationMillisLong;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -33,10 +32,8 @@
import android.hardware.soundtrigger.SoundTrigger;
import android.media.AudioFormat;
import android.os.Bundle;
-import android.os.Handler;
import android.os.IBinder;
import android.os.IRemoteCallback;
-import android.os.Looper;
import android.os.ParcelFileDescriptor;
import android.os.PersistableBundle;
import android.os.RemoteException;
@@ -67,6 +64,8 @@
* to inform the system that a keyphrase was not detected. The system then relays this result to
* the {@link VoiceInteractionService} through {@link HotwordDetector.Callback}.
*
+ * Note: Methods in this class may be called concurrently
+ *
* @hide
*/
@SystemApi
@@ -138,8 +137,6 @@
public static final String SERVICE_INTERFACE =
"android.service.voice.HotwordDetectionService";
- private Handler mHandler;
-
@Nullable
private ContentCaptureManager mContentCaptureManager;
@@ -154,13 +151,12 @@
if (DBG) {
Log.d(TAG, "#detectFromDspSource");
}
- mHandler.sendMessage(obtainMessage(HotwordDetectionService::onDetect,
- HotwordDetectionService.this,
+ HotwordDetectionService.this.onDetect(
new AlwaysOnHotwordDetector.EventPayload(
event.triggerInData, event.captureAvailable,
event.captureFormat, event.captureSession, event.data),
timeoutMillis,
- new Callback(callback)));
+ new Callback(callback));
}
@Override
@@ -169,11 +165,10 @@
if (DBG) {
Log.d(TAG, "#updateState");
}
- mHandler.sendMessage(obtainMessage(HotwordDetectionService::onUpdateStateInternal,
- HotwordDetectionService.this,
+ HotwordDetectionService.this.onUpdateStateInternal(
options,
sharedMemory,
- callback));
+ callback);
}
@Override
@@ -189,19 +184,15 @@
}
switch (audioSource) {
case AUDIO_SOURCE_MICROPHONE:
- mHandler.sendMessage(obtainMessage(
- HotwordDetectionService::onDetect,
- HotwordDetectionService.this,
- new Callback(callback)));
+ HotwordDetectionService.this.onDetect(
+ new Callback(callback));
break;
case AUDIO_SOURCE_EXTERNAL:
- mHandler.sendMessage(obtainMessage(
- HotwordDetectionService::onDetect,
- HotwordDetectionService.this,
+ HotwordDetectionService.this.onDetect(
audioStream,
audioFormat,
options,
- new Callback(callback)));
+ new Callback(callback));
break;
default:
Log.i(TAG, "Unsupported audio source " + audioSource);
@@ -216,13 +207,6 @@
}
};
- @CallSuper
- @Override
- public void onCreate() {
- super.onCreate();
- mHandler = Handler.createAsync(Looper.getMainLooper());
- }
-
@Override
@Nullable
public final IBinder onBind(@NonNull Intent intent) {
@@ -432,11 +416,15 @@
}
/**
- * Called when the detected result is valid.
+ * Informs the {@link HotwordDetector} that the keyphrase was detected.
+ *
+ * @param result Info about the detection result. This is provided to the
+ * {@link HotwordDetector}.
*/
- public void onDetected(@Nullable HotwordDetectedResult hotwordDetectedResult) {
+ public void onDetected(@NonNull HotwordDetectedResult result) {
+ requireNonNull(result);
try {
- mRemoteCallback.onDetected(hotwordDetectedResult);
+ mRemoteCallback.onDetected(result);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -451,7 +439,8 @@
* @param result Info about the second stage detection result. This is provided to
* the {@link HotwordDetector}.
*/
- public void onRejected(@Nullable HotwordRejectedResult result) {
+ public void onRejected(@NonNull HotwordRejectedResult result) {
+ requireNonNull(result);
try {
mRemoteCallback.onRejected(result);
} catch (RemoteException e) {
diff --git a/core/java/android/service/voice/HotwordDetector.java b/core/java/android/service/voice/HotwordDetector.java
index 2fb4dbc..d3c10ea 100644
--- a/core/java/android/service/voice/HotwordDetector.java
+++ b/core/java/android/service/voice/HotwordDetector.java
@@ -160,7 +160,7 @@
* @param result Info about the second stage detection result, provided by the
* {@link HotwordDetectionService}.
*/
- void onRejected(@Nullable HotwordRejectedResult result);
+ void onRejected(@NonNull HotwordRejectedResult result);
/**
* Called when the {@link HotwordDetectionService} is created by the system and given a
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index 53bde36..324d1ab 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -21,6 +21,7 @@
import static android.graphics.Matrix.MSKEW_X;
import static android.graphics.Matrix.MSKEW_Y;
import static android.view.View.SYSTEM_UI_FLAG_VISIBLE;
+import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import android.annotation.FloatRange;
import android.annotation.NonNull;
@@ -1218,7 +1219,9 @@
mIWallpaperEngine.mDisplayManager.registerDisplayListener(mDisplayListener,
mCaller.getHandler());
mDisplay = mIWallpaperEngine.mDisplay;
- mDisplayContext = createDisplayContext(mDisplay);
+ // Use window context of TYPE_WALLPAPER so client can access UI resources correctly.
+ mDisplayContext = createDisplayContext(mDisplay)
+ .createWindowContext(TYPE_WALLPAPER, null /* options */);
mDisplayState = mDisplay.getState();
if (DEBUG) Log.v(TAG, "onCreate(): " + this);
diff --git a/core/java/android/text/method/TranslationTransformationMethod.java b/core/java/android/text/method/TranslationTransformationMethod.java
index 54c0ffc..80387aa 100644
--- a/core/java/android/text/method/TranslationTransformationMethod.java
+++ b/core/java/android/text/method/TranslationTransformationMethod.java
@@ -22,6 +22,7 @@
import android.util.Log;
import android.view.View;
import android.view.translation.TranslationResponseValue;
+import android.view.translation.ViewTranslationRequest;
import android.view.translation.ViewTranslationResponse;
import android.widget.TextView;
@@ -67,7 +68,8 @@
Log.w(TAG, "Caller did not enable length changes; not transforming to translated text");
return source;
}
- TranslationResponseValue value = mTranslationResponse.getValue("text");
+ TranslationResponseValue value = mTranslationResponse.getValue(
+ ViewTranslationRequest.ID_TEXT);
CharSequence translatedText;
if (value.getStatusCode() == TranslationResponseValue.STATUS_SUCCESS) {
translatedText = value.getText();
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/AttachedSurfaceControl.java
similarity index 70%
rename from core/java/android/view/ViewRoot.java
rename to core/java/android/view/AttachedSurfaceControl.java
index 3c75598..bcc5b56 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/AttachedSurfaceControl.java
@@ -22,16 +22,19 @@
/**
* Provides an interface to the root-Surface of a View Hierarchy or Window. This
* is used in combination with the {@link android.view.SurfaceControl} API to enable
- * attaching app created SurfaceControl to the ViewRoot's surface hierarchy, and enable
- * SurfaceTransactions to be performed in sync with the ViewRoot drawing. This object
- * is obtained from {@link android.view.View#getViewRoot} and
- * {@link android.view.Window#getViewRoot}. It must be used from the UI thread of
+ * attaching app created SurfaceControl to the SurfaceControl hierarchy used
+ * by the app, and enable SurfaceTransactions to be performed in sync with the
+ * View hierarchy drawing.
+ *
+ * This object is obtained from {@link android.view.View#getRootSurfaceControl} and
+ * {@link android.view.Window#getRootSurfaceControl}. It must be used from the UI thread of
* the object it was obtained from.
*/
@UiThread
-public interface ViewRoot {
+public interface AttachedSurfaceControl {
/**
- * Create a transaction which will reparent {@param child} to the ViewRoot. See
+ * Create a transaction which will reparent {@param child} to the View hierarchy
+ * root SurfaceControl. See
* {@link SurfaceControl.Transaction#reparent}. This transacton must be applied
* or merged in to another transaction by the caller, otherwise it will have
* no effect.
@@ -42,9 +45,9 @@
@Nullable SurfaceControl.Transaction buildReparentTransaction(@NonNull SurfaceControl child);
/**
- * Consume the passed in transaction, and request the ViewRoot to apply it with the
- * next draw. This transaction will be merged with the buffer transaction from the ViewRoot
- * and they will show up on-screen atomically synced.
+ * Consume the passed in transaction, and request the View hierarchy to apply it atomically
+ * with the next draw. This transaction will be merged with the buffer transaction from the
+ * ViewRoot and they will show up on-screen atomically synced.
*
* This will not cause a draw to be scheduled, and if there are no other changes
* to the View hierarchy you may need to call {@link android.view.View#invalidate}
diff --git a/core/java/android/view/NotificationHeaderView.java b/core/java/android/view/NotificationHeaderView.java
index 6c8753b..000c685 100644
--- a/core/java/android/view/NotificationHeaderView.java
+++ b/core/java/android/view/NotificationHeaderView.java
@@ -29,6 +29,7 @@
import android.util.AttributeSet;
import android.widget.RelativeLayout;
import android.widget.RemoteViews;
+import android.widget.TextView;
import com.android.internal.R;
import com.android.internal.widget.CachingIconView;
@@ -175,6 +176,28 @@
}
/**
+ * This is used to make the low-priority header show the bolded text of a title.
+ *
+ * @param styleTextAsTitle true if this header's text is to have the style of a title
+ */
+ @RemotableViewMethod
+ public void styleTextAsTitle(boolean styleTextAsTitle) {
+ int styleResId = styleTextAsTitle
+ ? R.style.TextAppearance_DeviceDefault_Notification_Title
+ : R.style.TextAppearance_DeviceDefault_Notification_Info;
+ // Most of the time, we're showing text in the minimized state
+ View headerText = findViewById(R.id.header_text);
+ if (headerText instanceof TextView) {
+ ((TextView) headerText).setTextAppearance(styleResId);
+ }
+ // If there's no summary or text, we show the app name instead of nothing
+ View appNameText = findViewById(R.id.app_name_text);
+ if (appNameText instanceof TextView) {
+ ((TextView) appNameText).setTextAppearance(styleResId);
+ }
+ }
+
+ /**
* Get the current margin end value for the header text.
* Add this to {@link #getTopLineBaseMarginEnd()} to get the total margin of the top line.
*
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index c1c892c..acc0fc1 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -29599,7 +29599,7 @@
return mScrollCaptureInternal;
}
- ViewRoot getViewRoot() {
+ AttachedSurfaceControl getRootSurfaceControl() {
return mViewRootImpl;
}
@@ -30876,7 +30876,9 @@
/**
* Called when the content from {@link View#onCreateViewTranslationRequest} had been translated
- * by the TranslationService.
+ * by the TranslationService. The {@link ViewTranslationResponse} should be saved here so that
+ * the {@link ViewTranslationResponse} can be used to display the translation when the system
+ * calls {@link ViewTranslationCallback#onShowTranslation}.
*
* <p> The default implementation will set the ViewTranslationResponse that can be get from
* {@link View#getViewTranslationResponse}. </p>
@@ -30929,7 +30931,7 @@
* information, e.g. source spec, target spec.
* @param requests fill in with {@link ViewTranslationRequest}s for translation purpose.
*/
- public void dispatchRequestTranslation(@NonNull Map<AutofillId, long[]> viewIds,
+ public void dispatchCreateViewTranslationRequest(@NonNull Map<AutofillId, long[]> viewIds,
@NonNull @DataFormat int[] supportedFormats,
@NonNull TranslationCapability capability,
@NonNull List<ViewTranslationRequest> requests) {
@@ -31043,17 +31045,17 @@
}
/**
- * @return The {@link android.view.ViewRoot} interface for this View. This will only
- * return a non-null value when called between {@link #onAttachedToWindow} and
- * {@link #onDetachedFromWindow}.
- *
- * The ViewRoot itself is not a View, it is just the interface to the windowing-system
- * object that contains the entire view hierarchy. For the root View of a given hierarchy
- * see {@link #getRootView}.
+ * The AttachedSurfaceControl itself is not a View, it is just the interface to the
+ * windowing-system object that contains the entire view hierarchy.
+ * For the root View of a given hierarchy see {@link #getRootView}.
+
+ * @return The {@link android.view.AttachedSurfaceControl} interface for this View.
+ * This will only return a non-null value when called between {@link #onAttachedToWindow}
+ * and {@link #onDetachedFromWindow}.
*/
- public @Nullable ViewRoot getViewRoot() {
+ public @Nullable AttachedSurfaceControl getRootSurfaceControl() {
if (mAttachInfo != null) {
- return mAttachInfo.getViewRoot();
+ return mAttachInfo.getRootSurfaceControl();
}
return null;
}
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index a02281b..4647f47 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -9275,21 +9275,23 @@
/**
* {@inheritDoc}
*
- * The implementation calls {@link #dispatchRequestTranslation} for all the child views.
+ * The implementation calls {@link #dispatchCreateViewTranslationRequest} for all the child
+ * views.
*/
@Override
- public void dispatchRequestTranslation(@NonNull Map<AutofillId, long[]> viewIds,
+ public void dispatchCreateViewTranslationRequest(@NonNull Map<AutofillId, long[]> viewIds,
@NonNull @DataFormat int[] supportedFormats,
@Nullable TranslationCapability capability,
@NonNull List<ViewTranslationRequest> requests) {
- super.dispatchRequestTranslation(viewIds, supportedFormats, capability, requests);
+ super.dispatchCreateViewTranslationRequest(viewIds, supportedFormats, capability, requests);
final int childCount = getChildCount();
if (childCount == 0) {
return;
}
for (int i = 0; i < childCount; ++i) {
final View child = getChildAt(i);
- child.dispatchRequestTranslation(viewIds, supportedFormats, capability, requests);
+ child.dispatchCreateViewTranslationRequest(viewIds, supportedFormats, capability,
+ requests);
}
}
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index a06f193..4d1c666 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -224,7 +224,8 @@
*/
@SuppressWarnings({"EmptyCatchBlock", "PointlessBooleanExpression"})
public final class ViewRootImpl implements ViewParent,
- View.AttachInfo.Callbacks, ThreadedRenderer.DrawCallbacks, ViewRoot {
+ View.AttachInfo.Callbacks, ThreadedRenderer.DrawCallbacks,
+ AttachedSurfaceControl {
private static final String TAG = "ViewRootImpl";
private static final boolean DBG = false;
private static final boolean LOCAL_LOGV = false;
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index 52a09701..5fb4e70 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -2722,11 +2722,12 @@
/**
* This will be null before a content view is added, e.g. via
- * {@link #setContentView} or {@link #addContentView}.
+ * {@link #setContentView} or {@link #addContentView}. See
+ * {@link android.view.View#getRootSurfaceControl}.
*
- * @return The {@link android.view.ViewRoot} interface for this Window
+ * @return The {@link android.view.AttachedSurfaceControl} interface for this Window
*/
- public @Nullable ViewRoot getViewRoot() {
+ public @Nullable AttachedSurfaceControl getRootSurfaceControl() {
return null;
}
}
diff --git a/core/java/android/view/translation/UiTranslationController.java b/core/java/android/view/translation/UiTranslationController.java
index 8a2b629..e0526f8 100644
--- a/core/java/android/view/translation/UiTranslationController.java
+++ b/core/java/android/view/translation/UiTranslationController.java
@@ -466,8 +466,8 @@
// traverse the hierarchy to collect ViewTranslationRequests
for (int rootNum = 0; rootNum < roots.size(); rootNum++) {
View rootView = roots.get(rootNum).getView();
- rootView.dispatchRequestTranslation(viewIds, supportedFormats, capability,
- requests);
+ rootView.dispatchCreateViewTranslationRequest(viewIds, supportedFormats,
+ capability, requests);
}
mWorkerHandler.sendMessage(PooledLambda.obtainMessage(
UiTranslationController::sendTranslationRequest,
diff --git a/core/java/android/view/translation/UiTranslationSpec.java b/core/java/android/view/translation/UiTranslationSpec.java
index b43dbce..3d1ebfd 100644
--- a/core/java/android/view/translation/UiTranslationSpec.java
+++ b/core/java/android/view/translation/UiTranslationSpec.java
@@ -20,6 +20,7 @@
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
+import android.widget.TextView;
import com.android.internal.util.DataClass;
@@ -35,36 +36,38 @@
public final class UiTranslationSpec implements Parcelable {
/**
- * Whether the original content of the view should be directly modified to include padding that
- * makes it the same size as the translated content. Defaults to {@code false}.
+ * Whether the original content of the view should be made to appear as if it is the same size
+ * as the translated content. Defaults to {@code false}.
* <p>
- * For {@link android.widget.TextView}, the system does not directly modify the original text,
- * rather changes the displayed content using a
- * {@link android.text.method.TransformationMethod}.
- * This can cause issues in apps that do not account for TransformationMethods. For example, an
- * app using DynamicLayout may use the calculated text offsets to operate on the original text,
- * but this can be problematic when the layout was calculated on translated text with a
- * different length.
+ * For {@link TextView}, the system does not directly modify the original text, rather
+ * changes the displayed content using a {@link android.text.method.TransformationMethod}. This
+ * can cause issues in apps that do not account for length-changing TransformationMethods. For
+ * example, an app using DynamicLayout may use the calculated line-offsets to operate on the
+ * original text, but this can cause crashes when the layout was calculated on translated text
+ * with a different length.
* <p>
- * If this is {@code true}, for a TextView the default implementation will append spaces to the
- * text to make the length the same as the translated text.
+ * If this is {@code true}, for a TextView the default implementation appends spaces to the
+ * result of {@link TextView#getText()} to make the length the same as the translated text.
+ * <p>
+ * This only affects apps with target SDK R or lower.
*/
private boolean mShouldPadContentForCompat = false;
/**
- * Whether the original content of the view should be directly modified to include padding that
- * makes it the same size as the translated content.
+ * Whether the original content of the view should be made to appear as if it is the same size
+ * as the translated content.
* <p>
- * For {@link android.widget.TextView}, the system does not directly modify the original text,
- * rather changes the displayed content using a
- * {@link android.text.method.TransformationMethod}.
- * This can cause issues in apps that do not account for TransformationMethods. For example, an
- * app using DynamicLayout may use the calculated text offsets to operate on the original text,
- * but this can be problematic when the layout was calculated on translated text with a
- * different length.
+ * For {@link TextView}, the system does not directly modify the original text, rather
+ * changes the displayed content using a {@link android.text.method.TransformationMethod}. This
+ * can cause issues in apps that do not account for length-changing TransformationMethods. For
+ * example, an app using DynamicLayout may use the calculated line-offsets to operate on the
+ * original text, but this can cause crashes when the layout was calculated on translated text
+ * with a different length.
* <p>
- * If this is {@code true}, for a TextView the default implementation will append spaces to the
- * text to make the length the same as the translated text.
+ * If this is {@code true}, for a TextView the default implementation appends spaces to the
+ * result of {@link TextView#getText()} to make the length the same as the translated text.
+ * <p>
+ * This only affects apps with target SDK R or lower.
*/
public boolean shouldPadContentForCompat() {
return mShouldPadContentForCompat;
@@ -190,19 +193,20 @@
}
/**
- * Whether the original content of the view should be directly modified to include padding that
- * makes it the same size as the translated content. Defaults to {@code false}.
+ * Whether the original content of the view should be made to appear as if it is the same size
+ * as the translated content. Defaults to {@code false}.
* <p>
- * For {@link android.widget.TextView}, the system does not directly modify the original text,
- * rather changes the displayed content using a
- * {@link android.text.method.TransformationMethod}.
- * This can cause issues in apps that do not account for TransformationMethods. For example, an
- * app using DynamicLayout may use the calculated text offsets to operate on the original text,
- * but this can be problematic when the layout was calculated on translated text with a
- * different length.
+ * For {@link TextView}, the system does not directly modify the original text, rather
+ * changes the displayed content using a {@link android.text.method.TransformationMethod}. This
+ * can cause issues in apps that do not account for length-changing TransformationMethods. For
+ * example, an app using DynamicLayout may use the calculated line-offsets to operate on the
+ * original text, but this can cause crashes when the layout was calculated on translated text
+ * with a different length.
* <p>
- * If this is {@code true}, for a TextView the default implementation will append spaces to the
- * text to make the length the same as the translated text.
+ * If this is {@code true}, for a TextView the default implementation appends spaces to the
+ * result of {@link TextView#getText()} to make the length the same as the translated text.
+ * <p>
+ * This only affects apps with target SDK R or lower.
*/
@DataClass.Generated.Member
public @NonNull Builder setShouldPadContentForCompat(boolean value) {
@@ -234,7 +238,7 @@
}
@DataClass.Generated(
- time = 1619034161701L,
+ time = 1620790033058L,
codegenVersion = "1.0.23",
sourceFile = "frameworks/base/core/java/android/view/translation/UiTranslationSpec.java",
inputSignatures = "private boolean mShouldPadContentForCompat\npublic boolean shouldPadContentForCompat()\nclass UiTranslationSpec extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true, genHiddenConstDefs=true, genToString=true)")
diff --git a/core/java/android/view/translation/ViewTranslationRequest.java b/core/java/android/view/translation/ViewTranslationRequest.java
index 2913dfa..00f6ef2 100644
--- a/core/java/android/view/translation/ViewTranslationRequest.java
+++ b/core/java/android/view/translation/ViewTranslationRequest.java
@@ -43,7 +43,7 @@
* Constant id for the default view text to be translated. This is used by
* {@link Builder#setValue(String, TranslationRequestValue)}.
*/
- public static final String ID_TEXT = "text";
+ public static final String ID_TEXT = "android:text";
/**
* The {@link AutofillId} of the view associated with this request.
@@ -303,7 +303,7 @@
};
@DataClass.Generated(
- time = 1617119791798L,
+ time = 1620259482911L,
codegenVersion = "1.0.23",
sourceFile = "frameworks/base/core/java/android/view/translation/ViewTranslationRequest.java",
inputSignatures = "public static final java.lang.String ID_TEXT\nprivate final @android.annotation.NonNull android.view.autofill.AutofillId mAutofillId\nprivate final @android.annotation.NonNull @com.android.internal.util.DataClass.PluralOf(\"translationRequestValue\") java.util.Map<java.lang.String,android.view.translation.TranslationRequestValue> mTranslationRequestValues\npublic @android.annotation.NonNull android.view.translation.TranslationRequestValue getValue(java.lang.String)\npublic @android.annotation.NonNull java.util.Set<java.lang.String> getKeys()\npublic @android.annotation.NonNull android.view.autofill.AutofillId getAutofillId()\nprivate static java.util.Map<java.lang.String,android.view.translation.TranslationRequestValue> defaultTranslationRequestValues()\nclass ViewTranslationRequest extends java.lang.Object implements [android.os.Parcelable]\nprivate @android.annotation.NonNull android.view.autofill.AutofillId mAutofillId\nprivate @android.annotation.NonNull java.util.Map<java.lang.String,android.view.translation.TranslationRequestValue> mTranslationRequestValues\nprivate long mBuilderFieldsSet\npublic @android.annotation.SuppressLint @android.annotation.NonNull android.view.translation.ViewTranslationRequest.Builder setValue(java.lang.String,android.view.translation.TranslationRequestValue)\npublic @android.annotation.NonNull android.view.translation.ViewTranslationRequest build()\n android.view.translation.ViewTranslationRequest.Builder setTranslationRequestValues(java.util.Map<java.lang.String,android.view.translation.TranslationRequestValue>)\nprivate void checkNotUsed()\nclass Builder extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genBuilder=false, genToString=true, genEqualsHashCode=true, genGetters=false, genHiddenConstructor=true)")
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index a1d4822..0bbaac0f 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -60,11 +60,13 @@
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider;
+import android.view.autofill.AutofillId;
import android.view.autofill.AutofillValue;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inspector.InspectableProperty;
import android.view.textclassifier.TextClassifier;
+import android.view.translation.TranslationCapability;
import android.view.translation.TranslationSpec.DataFormat;
import android.view.translation.ViewTranslationRequest;
import android.view.translation.ViewTranslationResponse;
@@ -2869,6 +2871,16 @@
}
@Override
+ public void dispatchCreateViewTranslationRequest(@NonNull Map<AutofillId, long[]> viewIds,
+ @NonNull @DataFormat int[] supportedFormats,
+ @Nullable TranslationCapability capability,
+ @NonNull List<ViewTranslationRequest> requests) {
+ super.dispatchCreateViewTranslationRequest(viewIds, supportedFormats, capability, requests);
+ mProvider.getViewDelegate().dispatchCreateViewTranslationRequest(viewIds, supportedFormats,
+ capability, requests);
+ }
+
+ @Override
public void onVirtualViewTranslationResponses(
@NonNull LongSparseArray<ViewTranslationResponse> response) {
mProvider.getViewDelegate().onVirtualViewTranslationResponses(response);
diff --git a/core/java/android/webkit/WebViewProvider.java b/core/java/android/webkit/WebViewProvider.java
index 8d996ee..f9f823b 100644
--- a/core/java/android/webkit/WebViewProvider.java
+++ b/core/java/android/webkit/WebViewProvider.java
@@ -45,10 +45,12 @@
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider;
+import android.view.autofill.AutofillId;
import android.view.autofill.AutofillValue;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.textclassifier.TextClassifier;
+import android.view.translation.TranslationCapability;
import android.view.translation.TranslationSpec.DataFormat;
import android.view.translation.ViewTranslationRequest;
import android.view.translation.ViewTranslationResponse;
@@ -59,6 +61,7 @@
import java.io.BufferedWriter;
import java.io.File;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
@@ -377,6 +380,14 @@
LongSparseArray<ViewTranslationResponse> response) {
}
+ default void dispatchCreateViewTranslationRequest(
+ @NonNull @SuppressWarnings("unused") Map<AutofillId, long[]> viewIds,
+ @NonNull @SuppressWarnings("unused") @DataFormat int[] supportedFormats,
+ @Nullable @SuppressWarnings("unused") TranslationCapability capability,
+ @NonNull @SuppressWarnings("unused") List<ViewTranslationRequest> requests) {
+
+ }
+
public AccessibilityNodeProvider getAccessibilityNodeProvider();
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info);
diff --git a/core/java/android/widget/AnalogClock.java b/core/java/android/widget/AnalogClock.java
index 9eebf06..786e6fc 100644
--- a/core/java/android/widget/AnalogClock.java
+++ b/core/java/android/widget/AnalogClock.java
@@ -24,7 +24,6 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.ColorStateList;
-import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.BlendMode;
import android.graphics.Canvas;
@@ -40,8 +39,9 @@
import java.time.Clock;
import java.time.DateTimeException;
+import java.time.Duration;
import java.time.Instant;
-import java.time.LocalDateTime;
+import java.time.LocalTime;
import java.time.ZoneId;
import java.util.Formatter;
import java.util.Locale;
@@ -61,8 +61,8 @@
@Deprecated
public class AnalogClock extends View {
private static final String LOG_TAG = "AnalogClock";
- /** How often the clock should refresh to make the seconds hand advance at ~15 FPS. */
- private static final long SECONDS_TICK_FREQUENCY_MS = 1000 / 15;
+ /** How many times per second that the seconds hand advances. */
+ private static final long SECONDS_HAND_FPS = 30;
private Clock mClock;
@Nullable
@@ -106,7 +106,6 @@
public AnalogClock(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
- final Resources r = context.getResources();
final TypedArray a = context.obtainStyledAttributes(
attrs, com.android.internal.R.styleable.AnalogClock, defStyleAttr, defStyleRes);
saveAttributeDataForStyleable(context, com.android.internal.R.styleable.AnalogClock,
@@ -716,25 +715,34 @@
}
private void onTimeChanged() {
- long nowMillis = mClock.millis();
- LocalDateTime localDateTime = toLocalDateTime(nowMillis, mClock.getZone());
+ Instant now = mClock.instant();
+ onTimeChanged(now.atZone(mClock.getZone()).toLocalTime(), now.toEpochMilli());
+ }
- int hour = localDateTime.getHour();
- int minute = localDateTime.getMinute();
- int second = localDateTime.getSecond();
+ private void onTimeChanged(LocalTime localTime, long nowMillis) {
+ float previousHour = mHour;
+ float previousMinutes = mMinutes;
- mSeconds = second + localDateTime.getNano() / 1_000_000_000f;
- mMinutes = minute + second / 60.0f;
- mHour = hour + mMinutes / 60.0f;
+ float rawSeconds = localTime.getSecond() + localTime.getNano() / 1_000_000_000f;
+ // We round the fraction of the second so that the seconds hand always occupies the same
+ // n positions between two given numbers, where n is the number of ticks per second. This
+ // ensures the second hand advances by a consistent distance despite our handler callbacks
+ // occurring at inconsistent frequencies.
+ mSeconds = Math.round(rawSeconds * SECONDS_HAND_FPS) / (float) SECONDS_HAND_FPS;
+ mMinutes = localTime.getMinute() + mSeconds / 60.0f;
+ mHour = localTime.getHour() + mMinutes / 60.0f;
mChanged = true;
- updateContentDescription(nowMillis);
+ // Update the content description only if the announced hours and minutes have changed.
+ if ((int) previousHour != (int) mHour || (int) previousMinutes != (int) mMinutes) {
+ updateContentDescription(nowMillis);
+ }
}
private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- if (intent.getAction().equals(Intent.ACTION_TIMEZONE_CHANGED)) {
+ if (Intent.ACTION_TIMEZONE_CHANGED.equals(intent.getAction())) {
createClock();
}
@@ -747,15 +755,32 @@
private final Runnable mSecondsTick = new Runnable() {
@Override
public void run() {
+ removeCallbacks(this);
if (!mVisible || mSecondHand == null) {
return;
}
- onTimeChanged();
+ Instant now = mClock.instant();
+ LocalTime localTime = now.atZone(mClock.getZone()).toLocalTime();
+ // How many milliseconds through the second we currently are.
+ long millisOfSecond = Duration.ofNanos(localTime.getNano()).toMillis();
+ // How many milliseconds there are between tick positions for the seconds hand.
+ double millisPerTick = 1000 / (double) SECONDS_HAND_FPS;
+ // How many milliseconds we are past the last tick position.
+ long millisPastLastTick = Math.round(millisOfSecond % millisPerTick);
+ // How many milliseconds there are until the next tick position.
+ long millisUntilNextTick = Math.round(millisPerTick - millisPastLastTick);
+ // If we are exactly at the tick position, this could be 0 milliseconds due to rounding.
+ // In this case, advance by the full amount of millis to the next position.
+ if (millisUntilNextTick <= 0) {
+ millisUntilNextTick = Math.round(millisPerTick);
+ }
+ // Schedule a callback for when the next tick should occur.
+ postDelayed(this, millisUntilNextTick);
+
+ onTimeChanged(localTime, now.toEpochMilli());
invalidate();
-
- postDelayed(this, SECONDS_TICK_FREQUENCY_MS);
}
};
@@ -782,14 +807,6 @@
setContentDescription(contentDescription);
}
- private static LocalDateTime toLocalDateTime(long timeMillis, ZoneId zoneId) {
- // java.time types like LocalDateTime / Instant can support the full range of "long millis"
- // with room to spare so we do not need to worry about overflow / underflow and the
- // resulting exceptions while the input to this class is a long.
- Instant instant = Instant.ofEpochMilli(timeMillis);
- return LocalDateTime.ofInstant(instant, zoneId);
- }
-
/**
* Tries to parse a {@link ZoneId} from {@code timeZone}, returning null if it is null or there
* is an error parsing.
diff --git a/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java b/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java
index 49a3e29..14fd4c2 100644
--- a/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java
+++ b/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java
@@ -86,6 +86,11 @@
public static final ComponentName REDUCE_BRIGHT_COLORS_COMPONENT_NAME =
new ComponentName("com.android.server.accessibility", "ReduceBrightColors");
+ // The component name for the sub setting of Accessibility button in Accessibility settings
+ public static final ComponentName ACCESSIBILITY_BUTTON_COMPONENT_NAME =
+ new ComponentName("com.android.server.accessibility", "AccessibilityButton");
+
+
private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY)
diff --git a/core/java/com/android/internal/jank/FrameTracker.java b/core/java/com/android/internal/jank/FrameTracker.java
index 4d5b90a..4126801 100644
--- a/core/java/com/android/internal/jank/FrameTracker.java
+++ b/core/java/com/android/internal/jank/FrameTracker.java
@@ -401,8 +401,9 @@
int totalFramesCount = 0;
long maxFrameTimeNanos = 0;
+ int missedFramesCount = 0;
int missedAppFramesCount = 0;
- int missedSfFramesCounts = 0;
+ int missedSfFramesCount = 0;
for (int i = 0; i <= indexOnOrAfterEnd; i++) {
JankInfo info = mJankInfos.valueAt(i);
@@ -411,17 +412,23 @@
}
if (info.surfaceControlCallbackFired) {
totalFramesCount++;
+ boolean missedFrame = false;
if ((info.jankType & PREDICTION_ERROR) != 0
|| ((info.jankType & JANK_APP_DEADLINE_MISSED) != 0)) {
Log.w(TAG, "Missed App frame:" + info.jankType);
missedAppFramesCount++;
+ missedFrame = true;
}
if ((info.jankType & DISPLAY_HAL) != 0
|| (info.jankType & JANK_SURFACEFLINGER_DEADLINE_MISSED) != 0
|| (info.jankType & JANK_SURFACEFLINGER_GPU_DEADLINE_MISSED) != 0
|| (info.jankType & SURFACE_FLINGER_SCHEDULING) != 0) {
Log.w(TAG, "Missed SF frame:" + info.jankType);
- missedSfFramesCounts++;
+ missedSfFramesCount++;
+ missedFrame = true;
+ }
+ if (missedFrame) {
+ missedFramesCount++;
}
// TODO (b/174755489): Early latch currently gets fired way too often, so we have
// to ignore it for now.
@@ -438,10 +445,12 @@
}
// Log the frame stats as counters to make them easily accessible in traces.
+ Trace.traceCounter(Trace.TRACE_TAG_APP, mSession.getName() + "#missedFrames",
+ missedFramesCount);
Trace.traceCounter(Trace.TRACE_TAG_APP, mSession.getName() + "#missedAppFrames",
missedAppFramesCount);
Trace.traceCounter(Trace.TRACE_TAG_APP, mSession.getName() + "#missedSfFrames",
- missedSfFramesCounts);
+ missedSfFramesCount);
Trace.traceCounter(Trace.TRACE_TAG_APP, mSession.getName() + "#totalFrames",
totalFramesCount);
Trace.traceCounter(Trace.TRACE_TAG_APP, mSession.getName() + "#maxFrameTimeMillis",
@@ -449,7 +458,7 @@
// Trigger perfetto if necessary.
boolean overMissedFramesThreshold = mTraceThresholdMissedFrames != -1
- && missedAppFramesCount + missedSfFramesCounts >= mTraceThresholdMissedFrames;
+ && missedFramesCount >= mTraceThresholdMissedFrames;
boolean overFrameTimeThreshold = mTraceThresholdFrameTimeMillis != -1
&& maxFrameTimeNanos >= mTraceThresholdFrameTimeMillis * NANOS_IN_MILLISECOND;
if (overMissedFramesThreshold || overFrameTimeThreshold) {
@@ -460,9 +469,10 @@
FrameworkStatsLog.UI_INTERACTION_FRAME_INFO_REPORTED,
mSession.getStatsdInteractionType(),
totalFramesCount,
- missedAppFramesCount + missedSfFramesCounts,
+ missedFramesCount,
maxFrameTimeNanos,
- missedSfFramesCounts);
+ missedSfFramesCount,
+ missedAppFramesCount);
if (mListener != null) {
mListener.onCujEvents(mSession, ACTION_METRICS_LOGGED);
}
@@ -472,7 +482,8 @@
+ " (" + mBeginVsyncId + "," + mEndVsyncId + ")"
+ " totalFrames=" + totalFramesCount
+ " missedAppFrames=" + missedAppFramesCount
- + " missedSfFrames=" + missedSfFramesCounts
+ + " missedSfFrames=" + missedSfFramesCount
+ + " missedFrames=" + missedFramesCount
+ " maxFrameTimeMillis=" + maxFrameTimeNanos / NANOS_IN_MILLISECOND);
}
}
diff --git a/core/java/com/android/internal/os/KernelCpuUidTimeReader.java b/core/java/com/android/internal/os/KernelCpuUidTimeReader.java
index e670178..50df166 100644
--- a/core/java/com/android/internal/os/KernelCpuUidTimeReader.java
+++ b/core/java/com/android/internal/os/KernelCpuUidTimeReader.java
@@ -477,18 +477,17 @@
}
copyToCurTimes();
boolean notify = false;
- boolean valid = true;
for (int i = 0; i < mFreqCount; i++) {
// Unit is 10ms.
mDeltaTimes[i] = mCurTimes[i] - lastTimes[i];
if (mDeltaTimes[i] < 0) {
Slog.e(mTag, "Negative delta from freq time for uid: " + uid
+ ", delta: " + mDeltaTimes[i]);
- valid = false;
+ return;
}
notify |= mDeltaTimes[i] > 0;
}
- if (notify && valid) {
+ if (notify) {
System.arraycopy(mCurTimes, 0, lastTimes, 0, mFreqCount);
if (cb != null) {
cb.onUidCpuTime(uid, mDeltaTimes);
@@ -826,11 +825,11 @@
if (mDeltaTime[i] < 0) {
Slog.e(mTag, "Negative delta from cluster time for uid: " + uid
+ ", delta: " + mDeltaTime[i]);
- valid = false;
+ return;
}
notify |= mDeltaTime[i] > 0;
}
- if (notify && valid) {
+ if (notify) {
System.arraycopy(mCurTime, 0, lastTimes, 0, mNumClusters);
if (cb != null) {
cb.onUidCpuTime(uid, mDeltaTime);
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java
index a6dc4e0..0ea299d 100644
--- a/core/java/com/android/internal/policy/PhoneWindow.java
+++ b/core/java/com/android/internal/policy/PhoneWindow.java
@@ -70,12 +70,12 @@
import android.transition.TransitionManager;
import android.transition.TransitionSet;
import android.util.AndroidRuntimeException;
+import android.view.AttachedSurfaceControl;
import android.util.EventLog;
import android.util.Log;
import android.util.Pair;
import android.util.SparseArray;
import android.util.TypedValue;
-import android.view.ViewRoot;
import android.view.ContextThemeWrapper;
import android.view.CrossWindowBlurListeners;
import android.view.Gravity;
@@ -3984,7 +3984,7 @@
}
@Override
- public ViewRoot getViewRoot() {
+ public AttachedSurfaceControl getRootSurfaceControl() {
return getViewRootImplOrNull();
}
}
diff --git a/core/java/com/android/internal/power/MeasuredEnergyStats.java b/core/java/com/android/internal/power/MeasuredEnergyStats.java
index 42fb3f4..72b57ab 100644
--- a/core/java/com/android/internal/power/MeasuredEnergyStats.java
+++ b/core/java/com/android/internal/power/MeasuredEnergyStats.java
@@ -33,6 +33,7 @@
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.Arrays;
/**
* Tracks the measured charge consumption of various subsystems according to their
@@ -96,8 +97,10 @@
* supportedStandardBuckets must be of size {@link #NUMBER_STANDARD_POWER_BUCKETS}.
* numCustomBuckets >= 0 is the number of (non-standard) custom power buckets on the device.
*/
- public MeasuredEnergyStats(boolean[] supportedStandardBuckets, String[] customBucketNames) {
- final int numTotalBuckets = NUMBER_STANDARD_POWER_BUCKETS + customBucketNames.length;
+ public MeasuredEnergyStats(@NonNull boolean[] supportedStandardBuckets,
+ @Nullable String[] customBucketNames) {
+ mCustomBucketNames = customBucketNames == null ? new String[0] : customBucketNames;
+ final int numTotalBuckets = NUMBER_STANDARD_POWER_BUCKETS + mCustomBucketNames.length;
mAccumulatedChargeMicroCoulomb = new long[numTotalBuckets];
// Initialize to all zeros where supported, otherwise POWER_DATA_UNAVAILABLE.
// All custom buckets are, by definition, supported, so their values stay at 0.
@@ -106,7 +109,6 @@
mAccumulatedChargeMicroCoulomb[stdBucket] = POWER_DATA_UNAVAILABLE;
}
}
- mCustomBucketNames = customBucketNames;
}
/**
@@ -431,14 +433,22 @@
/** Check if the supported power buckets are precisely those given. */
public boolean isSupportEqualTo(
- @NonNull boolean[] queriedStandardBuckets, String[] customBucketNames) {
+ @NonNull boolean[] queriedStandardBuckets, @Nullable String[] customBucketNames) {
+ if (customBucketNames == null) {
+ //In practice customBucketNames should never be null, but sanitize it just to be sure.
+ customBucketNames = new String[0];
+ }
final int numBuckets = getNumberOfIndices();
- // TODO(b/178504428): Detect whether custom buckets have changed qualitatively, not just
- // quantitatively, and treat as mismatch if so.
- if (numBuckets != NUMBER_STANDARD_POWER_BUCKETS + customBucketNames.length) {
+ final int numCustomBuckets = customBucketNames == null ? 0 : customBucketNames.length;
+ if (numBuckets != NUMBER_STANDARD_POWER_BUCKETS + numCustomBuckets) {
return false;
}
+
+ if (!Arrays.equals(mCustomBucketNames, customBucketNames)) {
+ return false;
+ }
+
for (int stdBucket = 0; stdBucket < NUMBER_STANDARD_POWER_BUCKETS; stdBucket++) {
if (isStandardBucketSupported(stdBucket) != queriedStandardBuckets[stdBucket]) {
return false;
diff --git a/core/java/com/android/internal/widget/EmphasizedNotificationButton.java b/core/java/com/android/internal/widget/EmphasizedNotificationButton.java
index 058a921..4460e4a 100644
--- a/core/java/com/android/internal/widget/EmphasizedNotificationButton.java
+++ b/core/java/com/android/internal/widget/EmphasizedNotificationButton.java
@@ -27,9 +27,7 @@
import android.graphics.drawable.RippleDrawable;
import android.util.AttributeSet;
import android.view.RemotableViewMethod;
-import android.view.ViewGroup;
import android.widget.Button;
-import android.widget.LinearLayout;
import android.widget.RemoteViews;
import com.android.internal.R;
@@ -42,8 +40,6 @@
@RemoteViews.RemoteView
public class EmphasizedNotificationButton extends Button {
private final RippleDrawable mRipple;
- private final int mStrokeWidth;
- private final int mStrokeColor;
private boolean mPriority;
public EmphasizedNotificationButton(Context context) {
@@ -63,9 +59,6 @@
super(context, attrs, defStyleAttr, defStyleRes);
DrawableWrapper background = (DrawableWrapper) getBackground().mutate();
mRipple = (RippleDrawable) background.getDrawable();
- mStrokeWidth = getResources().getDimensionPixelSize(
- com.android.internal.R.dimen.emphasized_button_stroke_width);
- mStrokeColor = getContext().getColor(com.android.internal.R.color.material_grey_300);
mRipple.mutate();
}
@@ -82,13 +75,6 @@
invalidate();
}
- @RemotableViewMethod
- public void setHasStroke(boolean hasStroke) {
- GradientDrawable inner = (GradientDrawable) mRipple.getDrawable(0);
- inner.setStroke(hasStroke ? mStrokeWidth : 0, mStrokeColor);
- invalidate();
- }
-
/**
* Sets an image icon which will have its size constrained and will be set to the same color as
* the text. Must be called after {@link #setTextColor(int)} for the latter to work.
@@ -121,18 +107,13 @@
}
/**
- * Changes the LayoutParams.width to WRAP_CONTENT, with the argument representing if this view
- * is a priority over its peers (which affects weight).
+ * Sets whether this view is a priority over its peers (which affects width).
+ * Specifically, this is used by {@link NotificationActionListLayout} to give this view width
+ * priority ahead of user-defined buttons when allocating horizontal space.
*/
@RemotableViewMethod
- public void setWrapModePriority(boolean priority) {
+ public void setIsPriority(boolean priority) {
mPriority = priority;
- ViewGroup.LayoutParams layoutParams = getLayoutParams();
- layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
- if (layoutParams instanceof LinearLayout.LayoutParams) {
- ((LinearLayout.LayoutParams) layoutParams).weight = 0;
- }
- setLayoutParams(layoutParams);
}
/**
diff --git a/core/java/com/android/internal/widget/NotificationActionListLayout.java b/core/java/com/android/internal/widget/NotificationActionListLayout.java
index 8e6497b..a4d6a60 100644
--- a/core/java/com/android/internal/widget/NotificationActionListLayout.java
+++ b/core/java/com/android/internal/widget/NotificationActionListLayout.java
@@ -17,11 +17,11 @@
package com.android.internal.widget;
import android.annotation.DimenRes;
+import android.app.Notification;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.RippleDrawable;
import android.util.AttributeSet;
-import android.util.Pair;
import android.view.Gravity;
import android.view.RemotableViewMethod;
import android.view.View;
@@ -43,10 +43,9 @@
private final int mGravity;
private int mTotalWidth = 0;
private int mExtraStartPadding = 0;
- private ArrayList<Pair<Integer, TextView>> mMeasureOrderTextViews = new ArrayList<>();
+ private ArrayList<TextViewInfo> mMeasureOrderTextViews = new ArrayList<>();
private ArrayList<View> mMeasureOrderOther = new ArrayList<>();
private boolean mEmphasizedMode;
- private boolean mPrioritizedWrapMode;
private int mDefaultPaddingBottom;
private int mDefaultPaddingTop;
private int mEmphasizedHeight;
@@ -70,16 +69,18 @@
ta.recycle();
}
+ private static boolean isPriority(View actionView) {
+ return actionView instanceof EmphasizedNotificationButton
+ && ((EmphasizedNotificationButton) actionView).isPriority();
+ }
+
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- if (mEmphasizedMode && !mPrioritizedWrapMode) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- return;
- }
final int N = getChildCount();
int textViews = 0;
int otherViews = 0;
int notGoneChildren = 0;
+ int priorityChildren = 0;
for (int i = 0; i < N; i++) {
View c = getChildAt(i);
@@ -90,6 +91,9 @@
}
if (c.getVisibility() != GONE) {
notGoneChildren++;
+ if (isPriority(c)) {
+ priorityChildren++;
+ }
}
}
@@ -103,9 +107,9 @@
if (!needRebuild) {
final int size = mMeasureOrderTextViews.size();
for (int i = 0; i < size; i++) {
- Pair<Integer, TextView> pair = mMeasureOrderTextViews.get(i);
- if (pair.first != pair.second.getText().length()) {
+ if (mMeasureOrderTextViews.get(i).needsRebuild()) {
needRebuild = true;
+ break;
}
}
}
@@ -122,14 +126,19 @@
int usedWidth = 0;
int measuredChildren = 0;
+ int measuredPriorityChildren = 0;
for (int i = 0; i < N; i++) {
// Measure shortest children first. To avoid measuring twice, we approximate by looking
// at the text length.
- View c;
+ final boolean isPriority;
+ final View c;
if (i < otherSize) {
c = mMeasureOrderOther.get(i);
+ isPriority = false;
} else {
- c = mMeasureOrderTextViews.get(i - otherSize).second;
+ TextViewInfo info = mMeasureOrderTextViews.get(i - otherSize);
+ c = info.mTextView;
+ isPriority = info.mIsPriority;
}
if (c.getVisibility() == GONE) {
continue;
@@ -143,7 +152,18 @@
// measure in the order of (approx.) size, a large view can still take more than its
// share if the others are small.
int availableWidth = innerWidth - usedWidth;
- int maxWidthForChild = availableWidth / (notGoneChildren - measuredChildren);
+ int unmeasuredChildren = notGoneChildren - measuredChildren;
+ int maxWidthForChild = availableWidth / unmeasuredChildren;
+ if (isPriority) {
+ // Priority children get a larger maximum share of the total space:
+ // maximum priority share = (nPriority + 1) / (MAX + 1)
+ int unmeasuredPriorityChildren = priorityChildren - measuredPriorityChildren;
+ int unmeasuredOtherChildren = unmeasuredChildren - unmeasuredPriorityChildren;
+ int widthReservedForOtherChildren = innerWidth * unmeasuredOtherChildren
+ / (Notification.MAX_ACTION_BUTTONS + 1);
+ int widthAvailableForPriority = availableWidth - widthReservedForOtherChildren;
+ maxWidthForChild = widthAvailableForPriority / unmeasuredPriorityChildren;
+ }
usedWidthForChild = innerWidth - maxWidthForChild;
}
@@ -153,6 +173,9 @@
usedWidth += c.getMeasuredWidth() + lp.rightMargin + lp.leftMargin;
measuredChildren++;
+ if (isPriority) {
+ measuredPriorityChildren++;
+ }
}
int collapsibleIndent = mCollapsibleIndentDimen == 0 ? 0
@@ -175,13 +198,8 @@
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View c = getChildAt(i);
- if (c instanceof EmphasizedNotificationButton
- && ((EmphasizedNotificationButton) c).isPriority()) {
- // add with 0 length to ensure that this view is measured before others.
- mMeasureOrderTextViews.add(Pair.create(0, (TextView) c));
- } else if (c instanceof TextView && ((TextView) c).getText().length() > 0) {
- mMeasureOrderTextViews.add(Pair.create(((TextView) c).getText().length(),
- (TextView)c));
+ if (c instanceof TextView && ((TextView) c).getText().length() > 0) {
+ mMeasureOrderTextViews.add(new TextViewInfo((TextView) c));
} else {
mMeasureOrderOther.add(c);
}
@@ -213,10 +231,6 @@
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- if (mEmphasizedMode && !mPrioritizedWrapMode) {
- super.onLayout(changed, left, top, right, bottom);
- return;
- }
final boolean isLayoutRtl = isLayoutRtl();
final int paddingTop = mPaddingTop;
final boolean centerAligned = (mGravity & Gravity.CENTER_HORIZONTAL) != 0;
@@ -293,16 +307,6 @@
}
/**
- * When used with emphasizedMode, changes the button sizing behavior to prioritize certain
- * buttons (which are system generated) to not scrunch, and leave the remaining space for
- * custom actions.
- */
- @RemotableViewMethod
- public void setPrioritizedWrapMode(boolean prioritizedWrapMode) {
- mPrioritizedWrapMode = prioritizedWrapMode;
- }
-
- /**
* When buttons are in wrap mode, this is a padding that will be applied at the start of the
* layout of the actions, but only when those actions would fit with the entire padding
* visible. Otherwise, this padding will be omitted entirely.
@@ -353,6 +357,28 @@
return 0;
}
- public static final Comparator<Pair<Integer, TextView>> MEASURE_ORDER_COMPARATOR
- = (a, b) -> a.first.compareTo(b.first);
+ public static final Comparator<TextViewInfo> MEASURE_ORDER_COMPARATOR = (a, b) -> {
+ int priorityComparison = -Boolean.compare(a.mIsPriority, b.mIsPriority);
+ return priorityComparison != 0
+ ? priorityComparison
+ : Integer.compare(a.mTextLength, b.mTextLength);
+ };
+
+ private static final class TextViewInfo {
+ final boolean mIsPriority;
+ final int mTextLength;
+ final TextView mTextView;
+
+ TextViewInfo(TextView textView) {
+ this.mIsPriority = isPriority(textView);
+ this.mTextLength = textView.getText().length();
+ this.mTextView = textView;
+ }
+
+ boolean needsRebuild() {
+ return mTextView.getText().length() != mTextLength
+ || isPriority(mTextView) != mIsPriority;
+ }
+ }
+
}
diff --git a/core/jni/android_hardware_camera2_CameraMetadata.cpp b/core/jni/android_hardware_camera2_CameraMetadata.cpp
index 315ca2e..5c9999d 100644
--- a/core/jni/android_hardware_camera2_CameraMetadata.cpp
+++ b/core/jni/android_hardware_camera2_CameraMetadata.cpp
@@ -270,7 +270,28 @@
metadataSrc->unlock(metaBuffer);
return;
}
- metadataDst->update(entry.tag, entry.data.u8, entry.count);
+ switch (entry.type) {
+ case TYPE_BYTE:
+ metadataDst->update(entry.tag, entry.data.u8, entry.count);
+ break;
+ case TYPE_INT32:
+ metadataDst->update(entry.tag, entry.data.i32, entry.count);
+ break;
+ case TYPE_FLOAT:
+ metadataDst->update(entry.tag, entry.data.f, entry.count);
+ break;
+ case TYPE_INT64:
+ metadataDst->update(entry.tag, entry.data.i64, entry.count);
+ break;
+ case TYPE_DOUBLE:
+ metadataDst->update(entry.tag, entry.data.d, entry.count);
+ break;
+ case TYPE_RATIONAL:
+ metadataDst->update(entry.tag, entry.data.r, entry.count);
+ break;
+ default:
+ ALOGE("%s: Unsupported tag type: %d!", __func__, entry.type);
+ }
}
metadataSrc->unlock(metaBuffer);
}
diff --git a/core/jni/com_android_internal_net_NetworkUtilsInternal.cpp b/core/jni/com_android_internal_net_NetworkUtilsInternal.cpp
index 980e12d..83e2f2b 100644
--- a/core/jni/com_android_internal_net_NetworkUtilsInternal.cpp
+++ b/core/jni/com_android_internal_net_NetworkUtilsInternal.cpp
@@ -31,7 +31,7 @@
}
static jboolean android_net_utils_protectFromVpnWithFd(JNIEnv *env, jobject thiz, jobject javaFd) {
- return android_net_utils_protectFromVpn(env, thiz, AFileDescriptor_getFD(env, javaFd));
+ return android_net_utils_protectFromVpn(env, thiz, AFileDescriptor_getFd(env, javaFd));
}
static const JNINativeMethod gNetworkUtilMethods[] = {
diff --git a/core/res/Android.bp b/core/res/Android.bp
index b988b5a..6063062 100644
--- a/core/res/Android.bp
+++ b/core/res/Android.bp
@@ -100,8 +100,7 @@
+ "RES_DIR=$$(dirname $$(dirname $${INPUTS[0]})) && "
+ "mkdir -p $$RES_DIR/values && "
+ "cp $${INPUTS[1]} $$RES_DIR/values && "
- + "$(location soong_zip) -o $(out) -C $$RES_DIR -D $$RES_DIR && "
- + "cp $(out) ."
+ + "$(location soong_zip) -o $(out) -C $$RES_DIR -D $$RES_DIR"
}
android_app {
diff --git a/core/res/res/drawable/btn_notification_emphasized.xml b/core/res/res/drawable/btn_notification_emphasized.xml
index ad68054..63707ab 100644
--- a/core/res/res/drawable/btn_notification_emphasized.xml
+++ b/core/res/res/drawable/btn_notification_emphasized.xml
@@ -24,13 +24,11 @@
<item>
<shape android:shape="rectangle">
<corners android:radius="@dimen/notification_action_button_radius" />
- <padding android:left="@dimen/button_padding_horizontal_material"
+ <padding android:left="12dp"
android:top="@dimen/button_padding_vertical_material"
- android:right="@dimen/button_padding_horizontal_material"
+ android:right="12dp"
android:bottom="@dimen/button_padding_vertical_material" />
<solid android:color="@color/white" />
- <stroke android:width="@dimen/emphasized_button_stroke_width"
- android:color="@color/material_grey_300"/>
</shape>
</item>
</ripple>
diff --git a/core/res/res/layout/notification_material_action_emphasized.xml b/core/res/res/layout/notification_material_action_emphasized.xml
index cd1f1ab..ea84185 100644
--- a/core/res/res/layout/notification_material_action_emphasized.xml
+++ b/core/res/res/layout/notification_material_action_emphasized.xml
@@ -18,10 +18,9 @@
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/NotificationEmphasizedAction"
android:id="@+id/action0"
- android:layout_width="match_parent"
+ android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="12dp"
- android:layout_weight="1"
android:drawablePadding="6dp"
android:gravity="center"
android:textColor="@color/notification_default_color"
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index c5f4fd1..6386274 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -1954,6 +1954,13 @@
See the <a href="{@docRoot}about/versions/12/backup-restore">Changes in backup and restore</a>
document for the format of the XML file.-->
<attr name="dataExtractionRules" format="reference"/>
+
+ <!-- @hide Request exemption from the foreground service restrictions introduced in S
+ (https://developer.android.com/about/versions/12/foreground-services)
+ Note the framework <b>ignores</b> this attribute at this time. Once apps target S or above,
+ there's no way to be exempted (without using a privileged permission).
+ -->
+ <attr name="requestForegroundServiceExemption" format="boolean" />
</declare-styleable>
<!-- An attribution is a logical part of an app and is identified by a tag.
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 4f90a17..d334306 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -224,14 +224,14 @@
<!-- The margin on the end of the top-line content views (accommodates the expander) -->
<dimen name="notification_heading_margin_end">56dp</dimen>
- <!-- The height of the notification action list -->
+ <!-- The total height of the notification action list -->
<dimen name="notification_action_list_height">60dp</dimen>
<!-- The margin of the notification action list at the top -->
<dimen name="notification_action_list_margin_top">0dp</dimen>
- <!-- The height of the notification action list -->
- <dimen name="notification_action_emphasized_height">48dp</dimen>
+ <!-- The visual height of the emphasized notification action -->
+ <dimen name="notification_action_emphasized_height">36dp</dimen>
<!-- The padding of the actions in non-conversation layout. For conversations, the analogous
value is calculated in ConversationLayout#updateActionListPadding() -->
@@ -252,7 +252,7 @@
<dimen name="notification_actions_icon_drawable_size">20dp</dimen>
<!-- The corner radius if the emphasized action buttons in a notification -->
- <dimen name="notification_action_button_radius">8dp</dimen>
+ <dimen name="notification_action_button_radius">18dp</dimen>
<!-- Size of the stroke with for the emphasized notification button style -->
<dimen name="emphasized_button_stroke_width">1dp</dimen>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 500a9da..f7a9930 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -3099,6 +3099,8 @@
<public name="durationBetweenRequestsMillis" />
<public name="showInInputMethodPicker" />
<public name="effectColor" />
+ <!-- @hide @TestApi -->
+ <public name="requestForegroundServiceExemption" />
</staging-public-group>
<staging-public-group type="drawable" first-id="0x010800b5">
diff --git a/core/tests/coretests/src/android/app/appsearch/external/app/SearchSpecTest.java b/core/tests/coretests/src/android/app/appsearch/external/app/SearchSpecTest.java
index 9e88373..a613e77 100644
--- a/core/tests/coretests/src/android/app/appsearch/external/app/SearchSpecTest.java
+++ b/core/tests/coretests/src/android/app/appsearch/external/app/SearchSpecTest.java
@@ -16,18 +16,12 @@
package android.app.appsearch;
-
import static com.google.common.truth.Truth.assertThat;
import android.os.Bundle;
-import com.google.common.collect.ImmutableList;
-
import org.junit.Test;
-import java.util.List;
-import java.util.Map;
-
public class SearchSpecTest {
@Test
@@ -63,32 +57,4 @@
assertThat(bundle.getInt(SearchSpec.RANKING_STRATEGY_FIELD))
.isEqualTo(SearchSpec.RANKING_STRATEGY_DOCUMENT_SCORE);
}
-
- @Test
- public void testGetProjectionTypePropertyMasks() {
- SearchSpec searchSpec =
- new SearchSpec.Builder()
- .setTermMatch(SearchSpec.TERM_MATCH_PREFIX)
- .addProjection("TypeA", ImmutableList.of("field1", "field2.subfield2"))
- .addProjection("TypeB", ImmutableList.of("field7"))
- .addProjection("TypeC", ImmutableList.of())
- .build();
-
- Map<String, List<String>> typePropertyPathMap = searchSpec.getProjections();
- assertThat(typePropertyPathMap.keySet()).containsExactly("TypeA", "TypeB", "TypeC");
- assertThat(typePropertyPathMap.get("TypeA")).containsExactly("field1", "field2.subfield2");
- assertThat(typePropertyPathMap.get("TypeB")).containsExactly("field7");
- assertThat(typePropertyPathMap.get("TypeC")).isEmpty();
- }
-
- @Test
- public void testGetRankingStrategy() {
- SearchSpec searchSpec =
- new SearchSpec.Builder()
- .setTermMatch(SearchSpec.TERM_MATCH_PREFIX)
- .setRankingStrategy(SearchSpec.RANKING_STRATEGY_RELEVANCE_SCORE)
- .build();
- assertThat(searchSpec.getRankingStrategy())
- .isEqualTo(SearchSpec.RANKING_STRATEGY_RELEVANCE_SCORE);
- }
}
diff --git a/core/tests/coretests/src/android/content/res/ResourcesManagerTest.java b/core/tests/coretests/src/android/content/res/ResourcesManagerTest.java
index 46dbe0f..e7ee9dc 100644
--- a/core/tests/coretests/src/android/content/res/ResourcesManagerTest.java
+++ b/core/tests/coretests/src/android/content/res/ResourcesManagerTest.java
@@ -166,7 +166,7 @@
Configuration newConfig = new Configuration();
newConfig.orientation = Configuration.ORIENTATION_LANDSCAPE;
- mResourcesManager.applyConfigurationToResourcesLocked(newConfig, null);
+ mResourcesManager.applyConfigurationToResources(newConfig, null);
final Configuration expectedConfig = new Configuration();
expectedConfig.setToDefaults();
diff --git a/core/tests/coretests/src/com/android/internal/power/MeasuredEnergyStatsTest.java b/core/tests/coretests/src/com/android/internal/power/MeasuredEnergyStatsTest.java
index 2d894f5..a70033b 100644
--- a/core/tests/coretests/src/com/android/internal/power/MeasuredEnergyStatsTest.java
+++ b/core/tests/coretests/src/com/android/internal/power/MeasuredEnergyStatsTest.java
@@ -499,4 +499,84 @@
assertEquals(exp, MeasuredEnergyStats.getDisplayPowerBucket(Display.STATE_DOZE));
assertEquals(exp, MeasuredEnergyStats.getDisplayPowerBucket(Display.STATE_DOZE_SUSPEND));
}
+
+ /** Test MeasuredEnergyStats#isSupportEqualTo */
+ @Test
+ public void testIsSupportEqualTo() {
+ final boolean[] supportedStandardBuckets = new boolean[NUMBER_STANDARD_POWER_BUCKETS];
+ Arrays.fill(supportedStandardBuckets, true);
+ final String[] customBucketNames = {"A", "B"};
+
+ final MeasuredEnergyStats stats =
+ new MeasuredEnergyStats(supportedStandardBuckets.clone(),
+ customBucketNames.clone());
+
+ assertTrue(
+ "All standard and custom bucket supports match",
+ stats.isSupportEqualTo(supportedStandardBuckets, customBucketNames));
+
+ boolean[] differentSupportedStandardBuckets = supportedStandardBuckets.clone();
+ differentSupportedStandardBuckets[0] = !differentSupportedStandardBuckets[0];
+ assertFalse(
+ "Standard bucket support mismatch",
+ stats.isSupportEqualTo(differentSupportedStandardBuckets, customBucketNames));
+
+ assertFalse(
+ "Custom bucket support mismatch",
+ stats.isSupportEqualTo(supportedStandardBuckets, new String[]{"C", "B"}));
+
+ assertFalse(
+ "Fewer custom buckets supported",
+ stats.isSupportEqualTo(supportedStandardBuckets, new String[]{"A"}));
+
+ assertFalse(
+ "More custom bucket supported",
+ stats.isSupportEqualTo(supportedStandardBuckets, new String[]{"A", "B", "C"}));
+
+ assertFalse(
+ "Custom bucket support order changed",
+ stats.isSupportEqualTo(supportedStandardBuckets, new String[]{"B", "A"}));
+ }
+
+ /** Test MeasuredEnergyStats#isSupportEqualTo when holding a null array of custom buckets */
+ @Test
+ public void testIsSupportEqualTo_nullCustomBuckets() {
+ final boolean[] supportedStandardBuckets = new boolean[NUMBER_STANDARD_POWER_BUCKETS];
+
+ final MeasuredEnergyStats stats =
+ new MeasuredEnergyStats(supportedStandardBuckets.clone(), null);
+
+ assertTrue(
+ "Null custom bucket name lists should match",
+ stats.isSupportEqualTo(supportedStandardBuckets, null));
+
+ assertTrue(
+ "Null and empty custom buckets should match",
+ stats.isSupportEqualTo(supportedStandardBuckets, new String[0]));
+
+ assertFalse(
+ "Null custom buckets should not match populated list",
+ stats.isSupportEqualTo(supportedStandardBuckets, new String[]{"A", "B"}));
+ }
+
+ /** Test MeasuredEnergyStats#isSupportEqualTo when holding an empty array of custom buckets */
+ @Test
+ public void testIsSupportEqualTo_emptyCustomBuckets() {
+ final boolean[] supportedStandardBuckets = new boolean[NUMBER_STANDARD_POWER_BUCKETS];
+
+ final MeasuredEnergyStats stats =
+ new MeasuredEnergyStats(supportedStandardBuckets.clone(), new String[0]);
+
+ assertTrue(
+ "Empty custom buckets should match",
+ stats.isSupportEqualTo(supportedStandardBuckets, new String[0]));
+
+ assertTrue(
+ "Empty and null custom buckets should match",
+ stats.isSupportEqualTo(supportedStandardBuckets, null));
+
+ assertFalse(
+ "Empty custom buckets should not match populated list",
+ stats.isSupportEqualTo(supportedStandardBuckets, new String[]{"A", "B"}));
+ }
}
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index e222570..51bf6d53 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -255,6 +255,12 @@
| FILTER_BITMAP_FLAG;
/**
+ * These flags are always set on a reset paint or a new paint instantiated using
+ * {@link #Paint()}.
+ */
+ private static final int DEFAULT_PAINT_FLAGS = ANTI_ALIAS_FLAG | DITHER_FLAG;
+
+ /**
* Font hinter option that disables font hinting.
*
* @see #setHinting(int)
@@ -570,10 +576,13 @@
* accelerated drawing always acts as if {@link #FILTER_BITMAP_FLAG} is set.
* On devices running {@link Build.VERSION_CODES#Q} and above,
* {@code FILTER_BITMAP_FLAG} is set by this constructor, and it can be
- * cleared with {@link #setFlags} or {@link #setFilterBitmap}.</p>
+ * cleared with {@link #setFlags} or {@link #setFilterBitmap}.
+ * On devices running {@link Build.VERSION_CODES#S} and above, {@code ANTI_ALIAS_FLAG} and
+ * {@code DITHER_FLAG} are set by this constructor, and they can be cleared with
+ * {@link #setFlags} or {@link #setAntiAlias} and {@link #setDither}, respectively.</p>
*/
public Paint() {
- this(0);
+ this(DEFAULT_PAINT_FLAGS);
}
/**
@@ -618,7 +627,7 @@
/** Restores the paint to its default settings. */
public void reset() {
nReset(mNativePaint);
- setFlags(HIDDEN_DEFAULT_PAINT_FLAGS);
+ setFlags(HIDDEN_DEFAULT_PAINT_FLAGS | DEFAULT_PAINT_FLAGS);
// TODO: Turning off hinting has undesirable side effects, we need to
// revisit hinting once we add support for subpixel positioning
diff --git a/graphics/java/android/graphics/drawable/RippleShader.java b/graphics/java/android/graphics/drawable/RippleShader.java
index d00492c..6c0981a 100644
--- a/graphics/java/android/graphics/drawable/RippleShader.java
+++ b/graphics/java/android/graphics/drawable/RippleShader.java
@@ -43,10 +43,10 @@
+ "uniform shader in_shader;\n";
private static final String SHADER_LIB =
"float triangleNoise(vec2 n) {\n"
- + " n = fract(n * vec2(5.3987, 5.4421));\n"
- + " n += dot(n.yx, n.xy + vec2(21.5351, 14.3137));\n"
- + " float xy = n.x * n.y;\n"
- + " return fract(xy * 95.4307) + fract(xy * 75.04961) - 1.0;\n"
+ + " n = fract(n * vec2(5.3987, 5.4421));\n"
+ + " n += dot(n.yx, n.xy + vec2(21.5351, 14.3137));\n"
+ + " float xy = n.x * n.y;\n"
+ + " return fract(xy * 95.4307) + fract(xy * 75.04961) - 1.0;\n"
+ "}"
+ "const float PI = 3.1415926535897932384626;\n"
+ "\n"
@@ -110,14 +110,16 @@
+ " vec2 uv = p * in_resolutionScale;\n"
+ " vec2 densityUv = uv - mod(uv, in_noiseScale);\n"
+ " float turbulence = turbulence(uv, in_turbulencePhase);\n"
- + " float sparkle = sparkles(densityUv, in_noisePhase) * ring * alpha "
+ + " float sparkleAlpha = sparkles(densityUv, in_noisePhase) * ring * alpha "
+ "* turbulence;\n"
+ " float fade = min(fadeIn, 1. - fadeOutRipple);\n"
- + " float circleAlpha = softCircle(p, center, in_maxRadius * scaleIn, 0.2) * fade;\n"
- + " vec3 color = mix(in_color.rgb, in_sparkleColor.rgb, sparkle);\n"
+ + " float waveAlpha = softCircle(p, center, in_maxRadius * scaleIn, 0.2) * fade "
+ + "* in_color.a;\n"
+ + " vec4 waveColor = vec4(in_color.rgb * waveAlpha, waveAlpha);\n"
+ + " vec4 sparkleColor = vec4(in_sparkleColor.rgb * in_sparkleColor.a, "
+ + "in_sparkleColor.a);\n"
+ " float mask = in_hasMask == 1. ? sample(in_shader, p).a > 0. ? 1. : 0. : 1.;\n"
- + " float a = (in_color.a * circleAlpha + in_sparkleColor.a * sparkle) * mask;\n"
- + " return vec4(color * a, a);\n"
+ + " return mix(waveColor, sparkleColor, sparkleAlpha) * mask;\n"
+ "}";
private static final String SHADER = SHADER_UNIFORMS + SHADER_LIB + SHADER_MAIN;
private static final double PI_ROTATE_RIGHT = Math.PI * 0.0078125;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedAnimationController.java
index 180cceb..7e5fd92 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedAnimationController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/onehanded/OneHandedAnimationController.java
@@ -113,20 +113,18 @@
/**
* Animator for OneHanded transition animation which supports both alpha and bounds animation.
- *
- * @param <T> Type of property to animate, either offset (float)
*/
// TODO: Refactoring to use SpringAnimation and DynamicAnimation instead of using ValueAnimator
// to implement One-Handed transition animation. (b/185129031)
- public abstract static class OneHandedTransitionAnimator<T> extends ValueAnimator implements
+ public abstract static class OneHandedTransitionAnimator extends ValueAnimator implements
ValueAnimator.AnimatorUpdateListener,
ValueAnimator.AnimatorListener {
private final SurfaceControl mLeash;
private final WindowContainerToken mToken;
- private T mStartValue;
- private T mEndValue;
- private T mCurrentValue;
+ private float mStartValue;
+ private float mEndValue;
+ private float mCurrentValue;
private final List<OneHandedAnimationCallback> mOneHandedAnimationCallbacks =
new ArrayList<>();
@@ -137,7 +135,7 @@
private @TransitionDirection int mTransitionDirection;
private OneHandedTransitionAnimator(WindowContainerToken token, SurfaceControl leash,
- T startValue, T endValue) {
+ float startValue, float endValue) {
mLeash = leash;
mToken = token;
mStartValue = startValue;
@@ -204,7 +202,7 @@
mSurfaceTransactionHelper = helper;
}
- OneHandedTransitionAnimator<T> addOneHandedAnimationCallback(
+ OneHandedTransitionAnimator addOneHandedAnimationCallback(
OneHandedAnimationCallback callback) {
mOneHandedAnimationCallbacks.add(callback);
return this;
@@ -223,27 +221,27 @@
return mTransitionDirection;
}
- OneHandedTransitionAnimator<T> setTransitionDirection(int direction) {
+ OneHandedTransitionAnimator setTransitionDirection(int direction) {
mTransitionDirection = direction;
return this;
}
- T getStartValue() {
+ float getStartValue() {
return mStartValue;
}
- T getEndValue() {
+ float getEndValue() {
return mEndValue;
}
- void setCurrentValue(T value) {
+ void setCurrentValue(float value) {
mCurrentValue = value;
}
/**
* Updates the {@link #mEndValue}.
*/
- void updateEndValue(T endValue) {
+ void updateEndValue(float endValue) {
mEndValue = endValue;
}
@@ -252,10 +250,10 @@
}
@VisibleForTesting
- static OneHandedTransitionAnimator<Float> ofYOffset(WindowContainerToken token,
+ static OneHandedTransitionAnimator ofYOffset(WindowContainerToken token,
SurfaceControl leash, float startValue, float endValue, Rect displayBounds) {
- return new OneHandedTransitionAnimator<Float>(token, leash, startValue, endValue) {
+ return new OneHandedTransitionAnimator(token, leash, startValue, endValue) {
private final Rect mTmpRect = new Rect(displayBounds);
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java
index ca05ff4..17e0d1b 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java
@@ -208,6 +208,24 @@
}
/**
+ * A handler class that could register itself to apply the transaction instead of the
+ * animation controller doing it. For example, the menu controller can be one such handler.
+ */
+ public static class PipTransactionHandler {
+
+ /**
+ * Called when the animation controller is about to apply a transaction. Allow a registered
+ * handler to apply the transaction instead.
+ *
+ * @return true if handled by the handler, false otherwise.
+ */
+ public boolean handlePipTransaction(SurfaceControl leash, SurfaceControl.Transaction tx,
+ Rect destinationBounds) {
+ return false;
+ }
+ }
+
+ /**
* Animator for PiP transition animation which supports both alpha and bounds animation.
* @param <T> Type of property to animate, either alpha (float) or bounds (Rect)
*/
@@ -225,6 +243,7 @@
private T mEndValue;
private float mStartingAngle;
private PipAnimationCallback mPipAnimationCallback;
+ private PipTransactionHandler mPipTransactionHandler;
private PipSurfaceTransactionHelper.SurfaceControlTransactionFactory
mSurfaceControlTransactionFactory;
private PipSurfaceTransactionHelper mSurfaceTransactionHelper;
@@ -293,6 +312,20 @@
mPipAnimationCallback = callback;
return this;
}
+
+ PipTransitionAnimator<T> setPipTransactionHandler(PipTransactionHandler handler) {
+ mPipTransactionHandler = handler;
+ return this;
+ }
+
+ boolean handlePipTransaction(SurfaceControl leash, SurfaceControl.Transaction tx,
+ Rect destinationBounds) {
+ if (mPipTransactionHandler != null) {
+ return mPipTransactionHandler.handlePipTransaction(leash, tx, destinationBounds);
+ }
+ return false;
+ }
+
@VisibleForTesting
@TransitionDirection public int getTransitionDirection() {
return mTransitionDirection;
@@ -499,7 +532,9 @@
getSurfaceTransactionHelper().scaleAndCrop(tx, leash,
initialSourceValue, bounds, insets);
}
- tx.apply();
+ if (!handlePipTransaction(leash, tx, bounds)) {
+ tx.apply();
+ }
}
private void applyRotation(SurfaceControl.Transaction tx, SurfaceControl leash,
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java
index 319d57a..48a15d8 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java
@@ -20,7 +20,6 @@
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
-import android.os.SystemProperties;
import android.view.SurfaceControl;
import com.android.wm.shell.R;
@@ -44,10 +43,7 @@
* @param context the current context
*/
public void onDensityOrFontScaleChanged(Context context) {
- final boolean enableCornerRadius =
- SystemProperties.getBoolean("debug.sf.enable_hole_punch_pip", false);
- mCornerRadius = enableCornerRadius
- ? context.getResources().getDimensionPixelSize(R.dimen.pip_corner_radius) : 0;
+ mCornerRadius = context.getResources().getDimensionPixelSize(R.dimen.pip_corner_radius);
}
/**
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java
index 4ce6c9e..0633330 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java
@@ -200,6 +200,19 @@
}
};
+ private final PipAnimationController.PipTransactionHandler mPipTransactionHandler =
+ new PipAnimationController.PipTransactionHandler() {
+ @Override
+ public boolean handlePipTransaction(SurfaceControl leash,
+ SurfaceControl.Transaction tx, Rect destinationBounds) {
+ if (mPipMenuController.isMenuVisible()) {
+ mPipMenuController.movePipMenu(leash, tx, destinationBounds);
+ return true;
+ }
+ return false;
+ }
+ };
+
private ActivityManager.RunningTaskInfo mTaskInfo;
// To handle the edge case that onTaskInfoChanged callback is received during the entering
// PiP transition, where we do not want to intercept the transition but still want to apply the
@@ -433,8 +446,10 @@
// removePipImmediately is expected when the following animation finishes.
ValueAnimator animator = mPipAnimationController
- .getAnimator(mTaskInfo, mLeash, mPipBoundsState.getBounds(), 1f, 0f)
+ .getAnimator(mTaskInfo, mLeash, mPipBoundsState.getBounds(),
+ 1f /* alphaStart */, 0f /* alphaEnd */)
.setTransitionDirection(TRANSITION_DIRECTION_REMOVE_STACK)
+ .setPipTransactionHandler(mPipTransactionHandler)
.setPipAnimationCallback(mPipAnimationCallback);
animator.setDuration(mExitAnimationDuration);
animator.setInterpolator(Interpolators.ALPHA_OUT);
@@ -573,6 +588,7 @@
.getAnimator(mTaskInfo, mLeash, destinationBounds, 0f, 1f)
.setTransitionDirection(TRANSITION_DIRECTION_TO_PIP)
.setPipAnimationCallback(mPipAnimationCallback)
+ .setPipTransactionHandler(mPipTransactionHandler)
.setDuration(durationMs)
.start();
// mState is set right after the animation is kicked off to block any resize
@@ -749,6 +765,7 @@
mPipAnimationController
.getAnimator(mTaskInfo, mLeash, mPipBoundsState.getBounds(), alphaStart, alphaEnd)
.setTransitionDirection(TRANSITION_DIRECTION_SAME)
+ .setPipTransactionHandler(mPipTransactionHandler)
.setDuration(show ? mEnterAnimationDuration : mExitAnimationDuration)
.start();
mHasFadeOut = !show;
@@ -1226,6 +1243,7 @@
sourceHintRect, direction, startingAngle, rotationDelta);
animator.setTransitionDirection(direction)
.setPipAnimationCallback(mPipAnimationCallback)
+ .setPipTransactionHandler(mPipTransactionHandler)
.setDuration(durationMs)
.start();
if (rotationDelta != Surface.ROTATION_0 && direction == TRANSITION_DIRECTION_TO_PIP) {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java
index 9b6909b..4759550 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java
@@ -111,14 +111,14 @@
final Rect sourceHintRect =
PipBoundsAlgorithm.getValidSourceHintRect(
taskInfo.pictureInPictureParams, currentBounds);
- animator = mPipAnimationController.getAnimator(taskInfo, leash,
- currentBounds, currentBounds, destinationBounds, sourceHintRect,
- TRANSITION_DIRECTION_TO_PIP, 0 /* startingAngle */, Surface.ROTATION_0);
+ animator = mPipAnimationController.getAnimator(taskInfo, leash, currentBounds,
+ currentBounds, destinationBounds, sourceHintRect, TRANSITION_DIRECTION_TO_PIP,
+ 0 /* startingAngle */, Surface.ROTATION_0);
} else if (mOneShotAnimationType == ANIM_TYPE_ALPHA) {
t.setAlpha(leash, 0f);
t.apply();
- animator = mPipAnimationController.getAnimator(taskInfo, leash,
- destinationBounds, 0f, 1f);
+ animator = mPipAnimationController.getAnimator(taskInfo, leash, destinationBounds,
+ 0f, 1f);
mOneShotAnimationType = ANIM_TYPE_BOUNDS;
} else {
throw new RuntimeException("Unrecognized animation type: "
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java
index 9cf0b72..052653e 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java
@@ -70,12 +70,19 @@
*/
public interface Listener {
/**
- * Called when the PIP menu visibility changes.
+ * Called when the PIP menu visibility change has started.
*
- * @param menuState the current state of the menu
+ * @param menuState the new, about-to-change state of the menu
* @param resize whether or not to resize the PiP with the state change
*/
- void onPipMenuStateChanged(int menuState, boolean resize, Runnable callback);
+ void onPipMenuStateChangeStart(int menuState, boolean resize, Runnable callback);
+
+ /**
+ * Called when the PIP menu state has finished changing/animating.
+ *
+ * @param menuState the new state of the menu.
+ */
+ void onPipMenuStateChangeFinish(int menuState);
/**
* Called when the PIP requested to be expanded.
@@ -485,15 +492,15 @@
/**
* Handles changes in menu visibility.
*/
- void onMenuStateChanged(int menuState, boolean resize, Runnable callback) {
+ void onMenuStateChangeStart(int menuState, boolean resize, Runnable callback) {
if (DEBUG) {
- Log.d(TAG, "onMenuStateChanged() mMenuState=" + mMenuState
+ Log.d(TAG, "onMenuStateChangeStart() mMenuState=" + mMenuState
+ " menuState=" + menuState + " resize=" + resize
+ " callers=\n" + Debug.getCallers(5, " "));
}
if (menuState != mMenuState) {
- mListeners.forEach(l -> l.onPipMenuStateChanged(menuState, resize, callback));
+ mListeners.forEach(l -> l.onPipMenuStateChangeStart(menuState, resize, callback));
if (menuState == MENU_STATE_FULL) {
// Once visible, start listening for media action changes. This call will trigger
// the menu actions to be updated again.
@@ -511,6 +518,12 @@
Log.e(TAG, "Unable to update focus as menu appears/disappears", e);
}
}
+ }
+
+ void onMenuStateChangeFinish(int menuState) {
+ if (menuState != mMenuState) {
+ mListeners.forEach(l -> l.onPipMenuStateChangeFinish(menuState));
+ }
mMenuState = menuState;
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java
index 29a483b..91e3887 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java
@@ -535,10 +535,8 @@
private void onPipCornerRadiusChanged() {
if (mPinnedStackAnimationRecentsCallback != null) {
- final boolean enableCornerRadius =
- SystemProperties.getBoolean("debug.sf.enable_hole_punch_pip", false);
- final int cornerRadius = enableCornerRadius
- ? mContext.getResources().getDimensionPixelSize(R.dimen.pip_corner_radius) : 0;
+ final int cornerRadius =
+ mContext.getResources().getDimensionPixelSize(R.dimen.pip_corner_radius);
try {
mPinnedStackAnimationRecentsCallback.onPipCornerRadiusChanged(cornerRadius);
} catch (RemoteException e) {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java
index ecbf0f1..7b17fe4 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java
@@ -45,7 +45,6 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
-import android.os.SystemProperties;
import android.os.UserHandle;
import android.util.Log;
import android.util.Pair;
@@ -152,11 +151,7 @@
mAccessibilityManager = context.getSystemService(AccessibilityManager.class);
inflate(context, R.layout.pip_menu, this);
- final boolean enableCornerRadius =
- SystemProperties.getBoolean("debug.sf.enable_hole_punch_pip", false);
- mBackgroundDrawable = enableCornerRadius
- ? mContext.getDrawable(R.drawable.pip_menu_background)
- : new ColorDrawable(Color.BLACK);
+ mBackgroundDrawable = mContext.getDrawable(R.drawable.pip_menu_background);
mBackgroundDrawable.setAlpha(0);
mViewRoot = findViewById(R.id.background);
mViewRoot.setBackground(mBackgroundDrawable);
@@ -281,17 +276,18 @@
}
mMenuContainerAnimator.setInterpolator(Interpolators.ALPHA_IN);
mMenuContainerAnimator.setDuration(ANIMATION_HIDE_DURATION_MS);
- if (allowMenuTimeout) {
- mMenuContainerAnimator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
+ mMenuContainerAnimator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ notifyMenuStateChangeFinish(menuState);
+ if (allowMenuTimeout) {
repostDelayedHide(INITIAL_DISMISS_DELAY);
}
- });
- }
+ }
+ });
if (withDelay) {
// starts the menu container animation after window expansion is completed
- notifyMenuStateChange(menuState, resizeMenuOnShow, () -> {
+ notifyMenuStateChangeStart(menuState, resizeMenuOnShow, () -> {
if (mMenuContainerAnimator == null) {
return;
}
@@ -300,11 +296,11 @@
mMenuContainerAnimator.start();
});
} else {
- notifyMenuStateChange(menuState, resizeMenuOnShow, null);
+ notifyMenuStateChangeStart(menuState, resizeMenuOnShow, null);
setVisibility(VISIBLE);
mMenuContainerAnimator.start();
}
- updateActionViews(stackBounds);
+ updateActionViews(menuState, stackBounds);
} else {
// If we are already visible, then just start the delayed dismiss and unregister any
// existing input consumers from the previous drag
@@ -357,7 +353,7 @@
if (mMenuState != MENU_STATE_NONE) {
cancelDelayedHide();
if (notifyMenuVisibility) {
- notifyMenuStateChange(MENU_STATE_NONE, resize, null);
+ notifyMenuStateChangeStart(MENU_STATE_NONE, resize, null);
}
mMenuContainerAnimator = new AnimatorSet();
ObjectAnimator menuAnim = ObjectAnimator.ofFloat(mMenuContainer, View.ALPHA,
@@ -376,6 +372,9 @@
@Override
public void onAnimationEnd(Animator animation) {
setVisibility(GONE);
+ if (notifyMenuVisibility) {
+ notifyMenuStateChangeFinish(MENU_STATE_NONE);
+ }
if (animationFinishedRunnable != null) {
animationFinishedRunnable.run();
}
@@ -404,11 +403,11 @@
mActions.clear();
mActions.addAll(actions);
if (mMenuState == MENU_STATE_FULL) {
- updateActionViews(stackBounds);
+ updateActionViews(mMenuState, stackBounds);
}
}
- private void updateActionViews(Rect stackBounds) {
+ private void updateActionViews(int menuState, Rect stackBounds) {
ViewGroup expandContainer = findViewById(R.id.expand_container);
ViewGroup actionsContainer = findViewById(R.id.actions_container);
actionsContainer.setOnTouchListener((v, ev) -> {
@@ -417,13 +416,13 @@
});
// Update the expand button only if it should show with the menu
- expandContainer.setVisibility(mMenuState == MENU_STATE_FULL
+ expandContainer.setVisibility(menuState == MENU_STATE_FULL
? View.VISIBLE
: View.INVISIBLE);
FrameLayout.LayoutParams expandedLp =
(FrameLayout.LayoutParams) expandContainer.getLayoutParams();
- if (mActions.isEmpty() || mMenuState == MENU_STATE_CLOSE || mMenuState == MENU_STATE_NONE) {
+ if (mActions.isEmpty() || menuState == MENU_STATE_CLOSE || menuState == MENU_STATE_NONE) {
actionsContainer.setVisibility(View.INVISIBLE);
// Update the expand container margin to adjust the center of the expand button to
@@ -493,9 +492,13 @@
expandContainer.requestLayout();
}
- private void notifyMenuStateChange(int menuState, boolean resize, Runnable callback) {
+ private void notifyMenuStateChangeStart(int menuState, boolean resize, Runnable callback) {
+ mController.onMenuStateChangeStart(menuState, resize, callback);
+ }
+
+ private void notifyMenuStateChangeFinish(int menuState) {
mMenuState = menuState;
- mController.onMenuStateChanged(menuState, resize, callback);
+ mController.onMenuStateChangeFinish(menuState);
}
private void expandPip() {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java
index 8726ee7..0878f54 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java
@@ -419,13 +419,13 @@
// Reset the down to begin resizing from this point
mDownPoint.set(mLastPoint);
mDownSecondPoint.set(mLastSecondPoint);
- }
- if (mThresholdCrossed) {
if (mPhonePipMenuController.isMenuVisible()) {
mPhonePipMenuController.hideMenu();
}
+ }
+ if (mThresholdCrossed) {
mAngle = mPinchResizingAlgorithm.calculateBoundsAndAngle(mDownPoint,
mDownSecondPoint, mLastPoint, mLastSecondPoint, mMinSize, mMaxSize,
mDownBounds, mLastResizeBounds);
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java
index 0a0798e..8f9dcef 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java
@@ -129,8 +129,13 @@
*/
private class PipMenuListener implements PhonePipMenuController.Listener {
@Override
- public void onPipMenuStateChanged(int menuState, boolean resize, Runnable callback) {
- setMenuState(menuState, resize, callback);
+ public void onPipMenuStateChangeStart(int menuState, boolean resize, Runnable callback) {
+ PipTouchHandler.this.onPipMenuStateChangeStart(menuState, resize, callback);
+ }
+
+ @Override
+ public void onPipMenuStateChangeFinish(int menuState) {
+ setMenuState(menuState);
}
@Override
@@ -614,7 +619,7 @@
}
}
- shouldDeliverToMenu |= !mPipBoundsState.isStashed();
+ shouldDeliverToMenu &= !mPipBoundsState.isStashed();
// Deliver the event to PipMenuActivity to handle button click if the menu has shown.
if (shouldDeliverToMenu) {
@@ -646,9 +651,9 @@
}
/**
- * Sets the menu visibility.
+ * Called when the PiP menu state is in the process of animating/changing from one to another.
*/
- private void setMenuState(int menuState, boolean resize, Runnable callback) {
+ private void onPipMenuStateChangeStart(int menuState, boolean resize, Runnable callback) {
if (mMenuState == menuState && !resize) {
return;
}
@@ -686,6 +691,9 @@
mSavedSnapFraction = -1f;
}
}
+ }
+
+ private void setMenuState(int menuState) {
mMenuState = menuState;
updateMovementBounds();
// If pip menu has dismissed, we should register the A11y ActionReplacingConnection for pip
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java
index fd6f0ad9..1f098c2 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenContentDrawer.java
@@ -66,7 +66,7 @@
// For example, an icon with the foreground 108*108 opaque pixels and it's background
// also 108*108 pixels, then do not enlarge this icon if only need to show foreground icon.
private static final float ENLARGE_FOREGROUND_ICON_THRESHOLD = (72f * 72f) / (108f * 108f);
- private static final float NO_BACKGROUND_SCALE = 1.3f;
+ private static final float NO_BACKGROUND_SCALE = 192f / 160;
private final Context mContext;
private final IconProvider mIconProvider;
@@ -283,7 +283,8 @@
} else {
final float iconScale = (float) mIconSize / (float) mDefaultIconSize;
final int densityDpi = mContext.getResources().getDisplayMetrics().densityDpi;
- final int scaledIconDpi = (int) (0.5f + iconScale * densityDpi);
+ final int scaledIconDpi =
+ (int) (0.5f + iconScale * densityDpi * NO_BACKGROUND_SCALE);
iconDrawable = mIconProvider.getIcon(mActivityInfo, scaledIconDpi);
if (iconDrawable == null) {
iconDrawable = mContext.getPackageManager().getDefaultActivityIcon();
@@ -356,7 +357,7 @@
Slog.d(TAG, "makeSplashScreenContentView: choose fg icon");
}
// Reference AdaptiveIcon description, outer is 108 and inner is 72, so we
- // should enlarge the size 108/72 if we only draw adaptiveIcon's foreground.
+ // scale by 192/160 if we only draw adaptiveIcon's foreground.
final float noBgScale =
foreIconTester.nonTransparentRatio() < ENLARGE_FOREGROUND_ICON_THRESHOLD
? NO_BACKGROUND_SCALE : 1f;
diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp
index 7e45f95..320106a 100644
--- a/libs/androidfw/AssetManager2.cpp
+++ b/libs/androidfw/AssetManager2.cpp
@@ -221,6 +221,16 @@
for (auto iter2 = package_groups_.begin(); iter2 != package_groups_end; ++iter2) {
iter2->dynamic_ref_table->addMapping(String16(package_name.c_str(), package_name.size()),
iter->dynamic_ref_table->mAssignedPackageId);
+
+ // Add the alias resources to the dynamic reference table of every package group. Since
+ // staging aliases can only be defined by the framework package (which is not a shared
+ // library), the compile-time package id of the framework is the same across all packages
+ // that compile against the framework.
+ for (const auto& package : iter->packages_) {
+ for (const auto& entry : package.loaded_package_->GetAliasResourceIdMap()) {
+ iter2->dynamic_ref_table->addAlias(entry.first, entry.second);
+ }
+ }
}
}
}
diff --git a/libs/androidfw/LoadedArsc.cpp b/libs/androidfw/LoadedArsc.cpp
index cb620cc..d17c328 100644
--- a/libs/androidfw/LoadedArsc.cpp
+++ b/libs/androidfw/LoadedArsc.cpp
@@ -41,6 +41,7 @@
namespace android {
+constexpr const static int kFrameworkPackageId = 0x01;
constexpr const static int kAppPackageId = 0x7f;
namespace {
@@ -675,6 +676,42 @@
}
} break;
+ case RES_TABLE_STAGED_ALIAS_TYPE: {
+ if (loaded_package->package_id_ != kFrameworkPackageId) {
+ LOG(WARNING) << "Alias chunk ignored for non-framework package '"
+ << loaded_package->package_name_ << "'";
+ break;
+ }
+
+ std::unordered_set<uint32_t> finalized_ids;
+ const auto lib_alias = child_chunk.header<ResTable_staged_alias_header>();
+ if (!lib_alias) {
+ return {};
+ }
+ const auto entry_begin = child_chunk.data_ptr().convert<ResTable_staged_alias_entry>();
+ const auto entry_end = entry_begin + dtohl(lib_alias->count);
+ for (auto entry_iter = entry_begin; entry_iter != entry_end; ++entry_iter) {
+ if (!entry_iter) {
+ return {};
+ }
+ auto finalized_id = dtohl(entry_iter->finalizedResId);
+ if (!finalized_ids.insert(finalized_id).second) {
+ LOG(ERROR) << StringPrintf("Repeated finalized resource id '%08x' in staged aliases.",
+ finalized_id);
+ return {};
+ }
+
+ auto staged_id = dtohl(entry_iter->stagedResId);
+ auto [_, success] = loaded_package->alias_id_map_.insert(std::make_pair(staged_id,
+ finalized_id));
+ if (!success) {
+ LOG(ERROR) << StringPrintf("Repeated staged resource id '%08x' in staged aliases.",
+ staged_id);
+ return {};
+ }
+ }
+ } break;
+
default:
LOG(WARNING) << StringPrintf("Unknown chunk type '%02x'.", chunk.type());
break;
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp
index 30500ab..cae2d0b 100644
--- a/libs/androidfw/ResourceTypes.cpp
+++ b/libs/androidfw/ResourceTypes.cpp
@@ -7079,6 +7079,10 @@
mLookupTable[buildPackageId] = runtimePackageId;
}
+void DynamicRefTable::addAlias(uint32_t stagedId, uint32_t finalizedId) {
+ mAliasId[stagedId] = finalizedId;
+}
+
status_t DynamicRefTable::lookupResourceId(uint32_t* resId) const {
uint32_t res = *resId;
size_t packageId = Res_GETPACKAGE(res) + 1;
@@ -7088,8 +7092,16 @@
return NO_ERROR;
}
- if (packageId == APP_PACKAGE_ID && !mAppAsLib) {
- // No lookup needs to be done, app package IDs are absolute.
+ auto alias_id = mAliasId.find(res);
+ if (alias_id != mAliasId.end()) {
+ // Rewrite the resource id to its alias resource id. Since the alias resource id is a
+ // compile-time id, it still needs to be resolved further.
+ res = alias_id->second;
+ }
+
+ if (packageId == SYS_PACKAGE_ID || (packageId == APP_PACKAGE_ID && !mAppAsLib)) {
+ // No lookup needs to be done, app and framework package IDs are absolute.
+ *resId = res;
return NO_ERROR;
}
diff --git a/libs/androidfw/include/androidfw/LoadedArsc.h b/libs/androidfw/include/androidfw/LoadedArsc.h
index 3b222c5..9bbdede 100644
--- a/libs/androidfw/include/androidfw/LoadedArsc.h
+++ b/libs/androidfw/include/androidfw/LoadedArsc.h
@@ -17,6 +17,7 @@
#ifndef LOADEDARSC_H_
#define LOADEDARSC_H_
+#include <map>
#include <memory>
#include <set>
#include <vector>
@@ -171,51 +172,51 @@
incfs::verified_map_ptr<ResTable_type> type_chunk, uint32_t offset);
// Returns the string pool where type names are stored.
- inline const ResStringPool* GetTypeStringPool() const {
+ const ResStringPool* GetTypeStringPool() const {
return &type_string_pool_;
}
// Returns the string pool where the names of resource entries are stored.
- inline const ResStringPool* GetKeyStringPool() const {
+ const ResStringPool* GetKeyStringPool() const {
return &key_string_pool_;
}
- inline const std::string& GetPackageName() const {
+ const std::string& GetPackageName() const {
return package_name_;
}
- inline int GetPackageId() const {
+ int GetPackageId() const {
return package_id_;
}
// Returns true if this package is dynamic (shared library) and needs to have an ID assigned.
- inline bool IsDynamic() const {
+ bool IsDynamic() const {
return (property_flags_ & PROPERTY_DYNAMIC) != 0;
}
// Returns true if this package is a Runtime Resource Overlay.
- inline bool IsOverlay() const {
+ bool IsOverlay() const {
return (property_flags_ & PROPERTY_OVERLAY) != 0;
}
// Returns true if this package originates from a system provided resource.
- inline bool IsSystem() const {
+ bool IsSystem() const {
return (property_flags_ & PROPERTY_SYSTEM) != 0;
}
// Returns true if this package is a custom loader and should behave like an overlay.
- inline bool IsCustomLoader() const {
+ bool IsCustomLoader() const {
return (property_flags_ & PROPERTY_LOADER) != 0;
}
- inline package_property_t GetPropertyFlags() const {
+ package_property_t GetPropertyFlags() const {
return property_flags_;
}
// Returns the map of package name to package ID used in this LoadedPackage. At runtime, a
// package could have been assigned a different package ID than what this LoadedPackage was
// compiled with. AssetManager rewrites the package IDs so that they are compatible at runtime.
- inline const std::vector<DynamicPackageEntry>& GetDynamicPackageMap() const {
+ const std::vector<DynamicPackageEntry>& GetDynamicPackageMap() const {
return dynamic_package_map_;
}
@@ -270,6 +271,10 @@
return overlayable_map_;
}
+ const std::map<uint32_t, uint32_t>& GetAliasResourceIdMap() const {
+ return alias_id_map_;
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(LoadedPackage);
@@ -287,6 +292,7 @@
ByteBucketArray<uint32_t> resource_ids_;
std::vector<DynamicPackageEntry> dynamic_package_map_;
std::vector<const std::pair<OverlayableInfo, std::unordered_set<uint32_t>>> overlayable_infos_;
+ std::map<uint32_t, uint32_t> alias_id_map_;
// A map of overlayable name to actor
std::unordered_map<std::string, std::string> overlayable_map_;
diff --git a/libs/androidfw/include/androidfw/ResourceTypes.h b/libs/androidfw/include/androidfw/ResourceTypes.h
index 17c1404..3d66244 100644
--- a/libs/androidfw/include/androidfw/ResourceTypes.h
+++ b/libs/androidfw/include/androidfw/ResourceTypes.h
@@ -39,6 +39,7 @@
#include <android/configuration.h>
#include <array>
+#include <map>
#include <memory>
namespace android {
@@ -229,30 +230,31 @@
};
enum {
- RES_NULL_TYPE = 0x0000,
- RES_STRING_POOL_TYPE = 0x0001,
- RES_TABLE_TYPE = 0x0002,
- RES_XML_TYPE = 0x0003,
+ RES_NULL_TYPE = 0x0000,
+ RES_STRING_POOL_TYPE = 0x0001,
+ RES_TABLE_TYPE = 0x0002,
+ RES_XML_TYPE = 0x0003,
// Chunk types in RES_XML_TYPE
- RES_XML_FIRST_CHUNK_TYPE = 0x0100,
- RES_XML_START_NAMESPACE_TYPE= 0x0100,
- RES_XML_END_NAMESPACE_TYPE = 0x0101,
- RES_XML_START_ELEMENT_TYPE = 0x0102,
- RES_XML_END_ELEMENT_TYPE = 0x0103,
- RES_XML_CDATA_TYPE = 0x0104,
- RES_XML_LAST_CHUNK_TYPE = 0x017f,
+ RES_XML_FIRST_CHUNK_TYPE = 0x0100,
+ RES_XML_START_NAMESPACE_TYPE = 0x0100,
+ RES_XML_END_NAMESPACE_TYPE = 0x0101,
+ RES_XML_START_ELEMENT_TYPE = 0x0102,
+ RES_XML_END_ELEMENT_TYPE = 0x0103,
+ RES_XML_CDATA_TYPE = 0x0104,
+ RES_XML_LAST_CHUNK_TYPE = 0x017f,
// This contains a uint32_t array mapping strings in the string
// pool back to resource identifiers. It is optional.
- RES_XML_RESOURCE_MAP_TYPE = 0x0180,
+ RES_XML_RESOURCE_MAP_TYPE = 0x0180,
// Chunk types in RES_TABLE_TYPE
- RES_TABLE_PACKAGE_TYPE = 0x0200,
- RES_TABLE_TYPE_TYPE = 0x0201,
- RES_TABLE_TYPE_SPEC_TYPE = 0x0202,
- RES_TABLE_LIBRARY_TYPE = 0x0203,
- RES_TABLE_OVERLAYABLE_TYPE = 0x0204,
+ RES_TABLE_PACKAGE_TYPE = 0x0200,
+ RES_TABLE_TYPE_TYPE = 0x0201,
+ RES_TABLE_TYPE_SPEC_TYPE = 0x0202,
+ RES_TABLE_LIBRARY_TYPE = 0x0203,
+ RES_TABLE_OVERLAYABLE_TYPE = 0x0204,
RES_TABLE_OVERLAYABLE_POLICY_TYPE = 0x0205,
+ RES_TABLE_STAGED_ALIAS_TYPE = 0x0206,
};
/**
@@ -1639,6 +1641,29 @@
};
/**
+ * A map that allows rewriting staged (non-finalized) resource ids to their finalized counterparts.
+ */
+struct ResTable_staged_alias_header
+{
+ struct ResChunk_header header;
+
+ // The number of ResTable_staged_alias_entry that follow this header.
+ uint32_t count;
+};
+
+/**
+ * Maps the staged (non-finalized) resource id to its finalized resource id.
+ */
+struct ResTable_staged_alias_entry
+{
+ // The compile-time staged resource id to rewrite.
+ uint32_t stagedResId;
+
+ // The compile-time finalized resource id to which the staged resource id should be rewritten.
+ uint32_t finalizedResId;
+};
+
+/**
* Specifies the set of resources that are explicitly allowed to be overlaid by RROs.
*/
struct ResTable_overlayable_header
@@ -1751,6 +1776,8 @@
void addMapping(uint8_t buildPackageId, uint8_t runtimePackageId);
+ void addAlias(uint32_t stagedId, uint32_t finalizedId);
+
// Returns whether or not the value must be looked up.
bool requiresLookup(const Res_value* value) const;
@@ -1768,6 +1795,7 @@
uint8_t mLookupTable[256];
KeyedVector<String16, uint8_t> mEntries;
bool mAppAsLib;
+ std::map<uint32_t, uint32_t> mAliasId;
};
bool U16StringToInt(const char16_t* s, size_t len, Res_value* outValue);
diff --git a/libs/hwui/Android.bp b/libs/hwui/Android.bp
index 0212309..c6ab8a2 100644
--- a/libs/hwui/Android.bp
+++ b/libs/hwui/Android.bp
@@ -583,6 +583,7 @@
"libhwui_defaults",
"android_graphics_apex",
"android_graphics_jni",
+ "linker_hugepage_aligned",
],
export_header_lib_headers: ["android_graphics_apex_headers"],
target: {
diff --git a/libs/hwui/DamageAccumulator.cpp b/libs/hwui/DamageAccumulator.cpp
index a164233..0adc0f6 100644
--- a/libs/hwui/DamageAccumulator.cpp
+++ b/libs/hwui/DamageAccumulator.cpp
@@ -157,7 +157,7 @@
static inline void mapRect(const RenderProperties& props, const SkRect& in, SkRect* out) {
if (in.isEmpty()) return;
SkRect temp(in);
- if (Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale) {
+ if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
const StretchEffect& stretch = props.layerProperties().getStretchEffect();
if (!stretch.isEmpty()) {
applyMatrix(stretch.makeLinearStretch(props.getWidth(), props.getHeight()), &temp);
diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp
index 9ed801b..a4614a9 100644
--- a/libs/hwui/Properties.cpp
+++ b/libs/hwui/Properties.cpp
@@ -138,7 +138,7 @@
if (targetCpuTimePercentage <= 0 || targetCpuTimePercentage > 100) targetCpuTimePercentage = 70;
int stretchType = base::GetIntProperty(PROPERTY_STRETCH_EFFECT_TYPE, 0);
- stretchType = std::clamp(stretchType, 0, static_cast<int>(StretchEffectBehavior::LinearScale));
+ stretchType = std::clamp(stretchType, 0, static_cast<int>(StretchEffectBehavior::UniformScale));
stretchEffectBehavior = static_cast<StretchEffectBehavior>(stretchType);
return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw);
diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h
index 9d2b617..9964254 100644
--- a/libs/hwui/Properties.h
+++ b/libs/hwui/Properties.h
@@ -200,9 +200,9 @@
enum class RenderPipelineType { SkiaGL, SkiaVulkan, NotInitialized = 128 };
enum class StretchEffectBehavior {
- ShaderHWUI, // Stretch shader in HWUI only, matrix scale in SF
- Shader, // Stretch shader in both HWUI and SF
- LinearScale // Linear stretch everywhere
+ ShaderHWUI, // Stretch shader in HWUI only, matrix scale in SF
+ Shader, // Stretch shader in both HWUI and SF
+ UniformScale // Uniform scale stretch everywhere
};
/**
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index 64abd94..ad2cd8c 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -478,7 +478,7 @@
}
}
- if (Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale) {
+ if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
const StretchEffect& stretch = properties().layerProperties().getStretchEffect();
if (!stretch.isEmpty()) {
matrix.multiply(
diff --git a/libs/hwui/RenderProperties.h b/libs/hwui/RenderProperties.h
index 5540e2d..cd622eb 100644
--- a/libs/hwui/RenderProperties.h
+++ b/libs/hwui/RenderProperties.h
@@ -553,7 +553,7 @@
bool promotedToLayer() const {
return mLayerProperties.mType == LayerType::None && fitsOnLayer() &&
(mComputedFields.mNeedLayerForFunctors || mLayerProperties.mImageFilter != nullptr ||
- !mLayerProperties.getStretchEffect().isEmpty() ||
+ mLayerProperties.getStretchEffect().requiresLayer() ||
(!MathUtils::isZero(mPrimitiveFields.mAlpha) && mPrimitiveFields.mAlpha < 1 &&
mPrimitiveFields.mHasOverlappingRendering));
}
diff --git a/libs/hwui/effects/StretchEffect.h b/libs/hwui/effects/StretchEffect.h
index c49d53a..0e1a654 100644
--- a/libs/hwui/effects/StretchEffect.h
+++ b/libs/hwui/effects/StretchEffect.h
@@ -16,6 +16,7 @@
#pragma once
+#include "Properties.h"
#include "utils/MathUtils.h"
#include <SkImage.h>
@@ -108,6 +109,11 @@
return matrix;
}
+ bool requiresLayer() const {
+ return !(isEmpty() ||
+ Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale);
+ }
+
private:
static sk_sp<SkRuntimeEffect> getStretchEffect();
mutable SkVector mStretchDirection{0, 0};
diff --git a/libs/hwui/jni/android_graphics_RenderNode.cpp b/libs/hwui/jni/android_graphics_RenderNode.cpp
index cd0783f..a096ed0 100644
--- a/libs/hwui/jni/android_graphics_RenderNode.cpp
+++ b/libs/hwui/jni/android_graphics_RenderNode.cpp
@@ -573,8 +573,8 @@
const RenderProperties& props = node.properties();
uirenderer::Rect bounds(props.getWidth(), props.getHeight());
- bool useStretchShader = Properties::stretchEffectBehavior !=
- StretchEffectBehavior::LinearScale;
+ bool useStretchShader =
+ Properties::stretchEffectBehavior != StretchEffectBehavior::UniformScale;
if (useStretchShader && info.stretchEffectCount) {
handleStretchEffect(info, bounds);
}
diff --git a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
index 57cdde2..1c5515c7d 100644
--- a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
+++ b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
@@ -171,16 +171,11 @@
displayList->mProjectedOutline = nullptr;
}
-static bool stretchNeedsLayer(const LayerProperties& properties) {
- return Properties::stretchEffectBehavior != StretchEffectBehavior::LinearScale &&
- !properties.getStretchEffect().isEmpty();
-}
-
static bool layerNeedsPaint(const sk_sp<SkImage>& snapshotImage, const LayerProperties& properties,
float alphaMultiplier, SkPaint* paint) {
if (alphaMultiplier < 1.0f || properties.alpha() < 255 ||
properties.xferMode() != SkBlendMode::kSrcOver || properties.getColorFilter() != nullptr ||
- properties.getImageFilter() != nullptr || stretchNeedsLayer(properties)) {
+ properties.getImageFilter() != nullptr || properties.getStretchEffect().requiresLayer()) {
paint->setAlpha(properties.alpha() * alphaMultiplier);
paint->setBlendMode(properties.xferMode());
paint->setColorFilter(sk_ref_sp(properties.getColorFilter()));
@@ -253,7 +248,7 @@
const StretchEffect& stretch = properties.layerProperties().getStretchEffect();
if (stretch.isEmpty() ||
- Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale) {
+ Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
// If we don't have any stretch effects, issue the filtered
// canvas draw calls to make sure we still punch a hole
// with the same canvas transformation + clip into the target
@@ -332,7 +327,7 @@
canvas->concat(*properties.getTransformMatrix());
}
}
- if (Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale) {
+ if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
const StretchEffect& stretch = properties.layerProperties().getStretchEffect();
if (!stretch.isEmpty()) {
canvas->concat(
diff --git a/libs/hwui/pipeline/skia/SkiaMemoryTracer.cpp b/libs/hwui/pipeline/skia/SkiaMemoryTracer.cpp
index e48ecf4..0b995bc 100644
--- a/libs/hwui/pipeline/skia/SkiaMemoryTracer.cpp
+++ b/libs/hwui/pipeline/skia/SkiaMemoryTracer.cpp
@@ -126,6 +126,12 @@
mCurrentValues.insert({valueName, {units, value}});
}
+bool SkiaMemoryTracer::hasOutput() {
+ // process any remaining elements
+ processElement();
+ return mResults.size() > 0;
+}
+
void SkiaMemoryTracer::logOutput(String8& log) {
// process any remaining elements
processElement();
diff --git a/libs/hwui/pipeline/skia/SkiaMemoryTracer.h b/libs/hwui/pipeline/skia/SkiaMemoryTracer.h
index e9a7981..b393b07 100644
--- a/libs/hwui/pipeline/skia/SkiaMemoryTracer.h
+++ b/libs/hwui/pipeline/skia/SkiaMemoryTracer.h
@@ -34,6 +34,7 @@
SkiaMemoryTracer(const char* categoryKey, bool itemizeType);
~SkiaMemoryTracer() override {}
+ bool hasOutput();
void logOutput(String8& log);
void logTotals(String8& log);
diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.h b/libs/hwui/pipeline/skia/SkiaPipeline.h
index 100bfb6..4658035 100644
--- a/libs/hwui/pipeline/skia/SkiaPipeline.h
+++ b/libs/hwui/pipeline/skia/SkiaPipeline.h
@@ -137,9 +137,10 @@
int mCaptureSequence = 0;
// Multi frame serialization stream and writer used when serializing more than one frame.
+ std::unique_ptr<SkSharingSerialContext> mSerialContext; // Must be declared before any other
+ // serializing member
std::unique_ptr<SkFILEWStream> mOpenMultiPicStream;
sk_sp<SkDocument> mMultiPic;
- std::unique_ptr<SkSharingSerialContext> mSerialContext;
/**
* mRecorder holds the current picture recorder when serializing in either SingleFrameSKP or
diff --git a/libs/hwui/pipeline/skia/StretchMask.cpp b/libs/hwui/pipeline/skia/StretchMask.cpp
index 2bbd8a4..1c58c6a 100644
--- a/libs/hwui/pipeline/skia/StretchMask.cpp
+++ b/libs/hwui/pipeline/skia/StretchMask.cpp
@@ -46,9 +46,16 @@
if (mIsDirty) {
SkCanvas* maskCanvas = mMaskSurface->getCanvas();
+ // Make sure to apply target transformation to the mask canvas
+ // to ensure the replayed drawing commands generate the same result
+ auto previousMatrix = displayList->mParentMatrix;
+ displayList->mParentMatrix = maskCanvas->getTotalMatrix();
+ maskCanvas->save();
maskCanvas->drawColor(0, SkBlendMode::kClear);
TransformCanvas transformCanvas(maskCanvas, SkBlendMode::kSrcOver);
displayList->draw(&transformCanvas);
+ maskCanvas->restore();
+ displayList->mParentMatrix = previousMatrix;
}
sk_sp<SkImage> maskImage = mMaskSurface->makeImageSnapshot();
diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp
index d998e50..5047be9 100644
--- a/libs/hwui/renderthread/CacheManager.cpp
+++ b/libs/hwui/renderthread/CacheManager.cpp
@@ -140,7 +140,6 @@
log.appendFormat(" Size: %.2f kB \n", SkGraphics::GetFontCacheUsed() / 1024.0f);
log.appendFormat(" Glyph Count: %d \n", SkGraphics::GetFontCacheCountUsed());
- log.appendFormat("CPU Caches:\n");
std::vector<skiapipeline::ResourcePair> cpuResourceMap = {
{"skia/sk_resource_cache/bitmap_", "Bitmaps"},
{"skia/sk_resource_cache/rrect-blur_", "Masks"},
@@ -149,20 +148,20 @@
};
skiapipeline::SkiaMemoryTracer cpuTracer(cpuResourceMap, false);
SkGraphics::DumpMemoryStatistics(&cpuTracer);
- cpuTracer.logOutput(log);
+ if (cpuTracer.hasOutput()) {
+ log.appendFormat("CPU Caches:\n");
+ cpuTracer.logOutput(log);
+ }
- log.appendFormat("GPU Caches:\n");
skiapipeline::SkiaMemoryTracer gpuTracer("category", true);
mGrContext->dumpMemoryStatistics(&gpuTracer);
- gpuTracer.logOutput(log);
+ if (gpuTracer.hasOutput()) {
+ log.appendFormat("GPU Caches:\n");
+ gpuTracer.logOutput(log);
+ }
- log.appendFormat("Other Caches:\n");
- log.appendFormat(" Current / Maximum\n");
-
- if (renderState) {
- if (renderState->mActiveLayers.size() > 0) {
- log.appendFormat(" Layer Info:\n");
- }
+ if (renderState && renderState->mActiveLayers.size() > 0) {
+ log.appendFormat("Layer Info:\n");
const char* layerType = Properties::getRenderPipelineType() == RenderPipelineType::SkiaGL
? "GlLayer"
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index bba2207..bae1ab5 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -467,11 +467,11 @@
mRenderThread.pushBackFrameCallback(this);
}
-void CanvasContext::draw() {
+nsecs_t CanvasContext::draw() {
if (auto grContext = getGrContext()) {
if (grContext->abandoned()) {
LOG_ALWAYS_FATAL("GrContext is abandoned/device lost at start of CanvasContext::draw");
- return;
+ return 0;
}
}
SkRect dirty;
@@ -486,7 +486,7 @@
std::invoke(func, mFrameNumber);
}
mFrameCompleteCallbacks.clear();
- return;
+ return 0;
}
ScopedActiveContext activeContext(this);
@@ -616,6 +616,7 @@
}
mRenderThread.cacheManager().onFrameCompleted();
+ return mCurrentFrameInfo->get(FrameInfoIndex::DequeueBufferDuration);
}
void CanvasContext::reportMetricsWithPresentTime() {
diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h
index af1ebb2..4f8e4ca 100644
--- a/libs/hwui/renderthread/CanvasContext.h
+++ b/libs/hwui/renderthread/CanvasContext.h
@@ -127,7 +127,8 @@
void setColorMode(ColorMode mode);
bool makeCurrent();
void prepareTree(TreeInfo& info, int64_t* uiFrameInfo, int64_t syncQueued, RenderNode* target);
- void draw();
+ // Returns the DequeueBufferDuration.
+ nsecs_t draw();
void destroy();
// IFrameCallback, Choreographer-driven frame callback entry point
diff --git a/libs/hwui/renderthread/DrawFrameTask.cpp b/libs/hwui/renderthread/DrawFrameTask.cpp
index cb92aa1..8448b87 100644
--- a/libs/hwui/renderthread/DrawFrameTask.cpp
+++ b/libs/hwui/renderthread/DrawFrameTask.cpp
@@ -18,6 +18,7 @@
#include <utils/Log.h>
#include <utils/TraceUtils.h>
+#include <algorithm>
#include "../DeferredLayerUpdater.h"
#include "../DisplayList.h"
@@ -91,6 +92,7 @@
void DrawFrameTask::run() {
const int64_t vsyncId = mFrameInfo[static_cast<int>(FrameInfoIndex::FrameTimelineVsyncId)];
ATRACE_FORMAT("DrawFrames %" PRId64, vsyncId);
+ nsecs_t syncDelayDuration = systemTime(SYSTEM_TIME_MONOTONIC) - mSyncQueued;
bool canUnblockUiThread;
bool canDrawThisFrame;
@@ -124,8 +126,9 @@
[callback, frameNr = context->getFrameNumber()]() { callback(frameNr); });
}
+ nsecs_t dequeueBufferDuration = 0;
if (CC_LIKELY(canDrawThisFrame)) {
- context->draw();
+ dequeueBufferDuration = context->draw();
} else {
// wait on fences so tasks don't overlap next frame
context->waitOnFences();
@@ -149,10 +152,14 @@
mUpdateTargetWorkDuration(targetWorkDuration);
}
int64_t frameDuration = systemTime(SYSTEM_TIME_MONOTONIC) - frameStartTime;
- if (frameDuration > kSanityCheckLowerBound && frameDuration < kSanityCheckUpperBound) {
- mReportActualWorkDuration(frameDuration);
+ int64_t actualDuration = frameDuration -
+ (std::min(syncDelayDuration, mLastDequeueBufferDuration)) -
+ dequeueBufferDuration;
+ if (actualDuration > kSanityCheckLowerBound && actualDuration < kSanityCheckUpperBound) {
+ mReportActualWorkDuration(actualDuration);
}
}
+ mLastDequeueBufferDuration = dequeueBufferDuration;
}
bool DrawFrameTask::syncFrameState(TreeInfo& info) {
diff --git a/libs/hwui/renderthread/DrawFrameTask.h b/libs/hwui/renderthread/DrawFrameTask.h
index 3bb574a..2455ea8 100644
--- a/libs/hwui/renderthread/DrawFrameTask.h
+++ b/libs/hwui/renderthread/DrawFrameTask.h
@@ -110,6 +110,7 @@
std::function<void(int64_t)> mFrameCallback;
std::function<void(int64_t)> mFrameCompleteCallback;
+ nsecs_t mLastDequeueBufferDuration = 0;
nsecs_t mLastTargetWorkDuration = 0;
std::function<void(int64_t)> mUpdateTargetWorkDuration;
std::function<void(int64_t)> mReportActualWorkDuration;
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index 1b4b4b9..ad325cf 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -249,10 +249,10 @@
});
}
-void RenderProxy::dumpGraphicsMemory(int fd) {
+void RenderProxy::dumpGraphicsMemory(int fd, bool includeProfileData) {
if (RenderThread::hasInstance()) {
auto& thread = RenderThread::getInstance();
- thread.queue().runSync([&]() { thread.dumpGraphicsMemory(fd); });
+ thread.queue().runSync([&]() { thread.dumpGraphicsMemory(fd, includeProfileData); });
}
}
diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h
index 288f555..662b445 100644
--- a/libs/hwui/renderthread/RenderProxy.h
+++ b/libs/hwui/renderthread/RenderProxy.h
@@ -109,7 +109,7 @@
// Not exported, only used for testing
void resetProfileInfo();
uint32_t frameTimePercentile(int p);
- static void dumpGraphicsMemory(int fd);
+ static void dumpGraphicsMemory(int fd, bool includeProfileData = true);
static void rotateProcessStatsBuffer();
static void setProcessStatsBuffer(int fd);
diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp
index 3421e01..308352d 100644
--- a/libs/hwui/renderthread/RenderThread.cpp
+++ b/libs/hwui/renderthread/RenderThread.cpp
@@ -302,30 +302,25 @@
return *mVkManager.get();
}
-void RenderThread::dumpGraphicsMemory(int fd) {
- globalProfileData()->dump(fd);
-
- String8 cachesOutput;
- String8 pipeline;
- auto renderType = Properties::getRenderPipelineType();
- switch (renderType) {
- case RenderPipelineType::SkiaGL: {
- mCacheManager->dumpMemoryUsage(cachesOutput, mRenderState);
- pipeline.appendFormat("Skia (OpenGL)");
- break;
- }
- case RenderPipelineType::SkiaVulkan: {
- mCacheManager->dumpMemoryUsage(cachesOutput, mRenderState);
- pipeline.appendFormat("Skia (Vulkan)");
- break;
- }
+static const char* pipelineToString() {
+ switch (auto renderType = Properties::getRenderPipelineType()) {
+ case RenderPipelineType::SkiaGL:
+ return "Skia (OpenGL)";
+ case RenderPipelineType::SkiaVulkan:
+ return "Skia (Vulkan)";
default:
LOG_ALWAYS_FATAL("canvas context type %d not supported", (int32_t)renderType);
- break;
+ }
+}
+
+void RenderThread::dumpGraphicsMemory(int fd, bool includeProfileData) {
+ if (includeProfileData) {
+ globalProfileData()->dump(fd);
}
- dprintf(fd, "\n%s\n", cachesOutput.string());
- dprintf(fd, "\nPipeline=%s\n", pipeline.string());
+ String8 cachesOutput;
+ mCacheManager->dumpMemoryUsage(cachesOutput, mRenderState);
+ dprintf(fd, "\nPipeline=%s\n%s\n", pipelineToString(), cachesOutput.string());
}
Readback& RenderThread::readback() {
diff --git a/libs/hwui/renderthread/RenderThread.h b/libs/hwui/renderthread/RenderThread.h
index cd9b923..afd5750 100644
--- a/libs/hwui/renderthread/RenderThread.h
+++ b/libs/hwui/renderthread/RenderThread.h
@@ -150,7 +150,7 @@
VulkanManager& vulkanManager();
sk_sp<Bitmap> allocateHardwareBitmap(SkBitmap& skBitmap);
- void dumpGraphicsMemory(int fd);
+ void dumpGraphicsMemory(int fd, bool includeProfileData);
void requireGlContext();
void requireVkContext();
diff --git a/libs/hwui/tests/common/TestScene.cpp b/libs/hwui/tests/common/TestScene.cpp
index 02bcd47..2c532b0 100644
--- a/libs/hwui/tests/common/TestScene.cpp
+++ b/libs/hwui/tests/common/TestScene.cpp
@@ -22,8 +22,9 @@
// Not a static global because we need to force the map to be constructed
// before we try to add things to it.
-std::unordered_map<std::string, TestScene::Info>& TestScene::testMap() {
- static std::unordered_map<std::string, TestScene::Info> testMap;
+// std::map because tests sorted by name is a prettier output
+std::map<std::string, TestScene::Info>& TestScene::testMap() {
+ static std::map<std::string, TestScene::Info> testMap;
return testMap;
}
diff --git a/libs/hwui/tests/common/TestScene.h b/libs/hwui/tests/common/TestScene.h
index 91022cf..781884a 100644
--- a/libs/hwui/tests/common/TestScene.h
+++ b/libs/hwui/tests/common/TestScene.h
@@ -19,8 +19,8 @@
#include <gui/Surface.h>
#include <utils/StrongPointer.h>
+#include <map>
#include <string>
-#include <unordered_map>
namespace android {
@@ -35,9 +35,11 @@
class TestScene {
public:
struct Options {
- int count = 0;
+ int frameCount = 150;
+ int repeatCount = 1;
int reportFrametimeWeight = 0;
bool renderOffscreen = true;
+ bool reportGpuMemoryUsage = false;
};
template <class T>
@@ -67,7 +69,7 @@
virtual void createContent(int width, int height, Canvas& renderer) = 0;
virtual void doFrame(int frameNr) = 0;
- static std::unordered_map<std::string, Info>& testMap();
+ static std::map<std::string, Info>& testMap();
static void registerScene(const Info& info);
sp<Surface> renderTarget;
diff --git a/libs/hwui/tests/common/scenes/StretchyListViewAnimation.cpp b/libs/hwui/tests/common/scenes/StretchyListViewAnimation.cpp
new file mode 100644
index 0000000..c451112
--- /dev/null
+++ b/libs/hwui/tests/common/scenes/StretchyListViewAnimation.cpp
@@ -0,0 +1,230 @@
+/*
+ * Copyright (C) 2021 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 <SkFont.h>
+#include <cstdio>
+#include "TestSceneBase.h"
+#include "hwui/Paint.h"
+#include "tests/common/TestUtils.h"
+
+class StretchyListViewAnimation;
+class StretchyListViewHolePunch;
+class StretchyUniformListView;
+class StretchyUniformListViewHolePunch;
+class StretchyUniformLayerListView;
+class StretchyUniformLayerListViewHolePunch;
+
+static TestScene::Registrar _StretchyListViewAnimation(TestScene::Info{
+ "stretchylistview",
+ "A mock ListView of scrolling content that's stretching. Doesn't re-bind/re-record views "
+ "as they are recycled, so won't upload much content (either glyphs, or bitmaps).",
+ TestScene::simpleCreateScene<StretchyListViewAnimation>});
+
+static TestScene::Registrar _StretchyListViewHolePunch(TestScene::Info{
+ "stretchylistview_holepunch",
+ "A mock ListView of scrolling content that's stretching. Includes a hole punch",
+ TestScene::simpleCreateScene<StretchyListViewHolePunch>});
+
+static TestScene::Registrar _StretchyUniformListView(TestScene::Info{
+ "stretchylistview_uniform",
+ "A mock ListView of scrolling content that's stretching using a uniform stretch effect.",
+ TestScene::simpleCreateScene<StretchyUniformListView>});
+
+static TestScene::Registrar _StretchyUniformListViewHolePunch(TestScene::Info{
+ "stretchylistview_uniform_holepunch",
+ "A mock ListView of scrolling content that's stretching using a uniform stretch effect. "
+ "Includes a hole punch",
+ TestScene::simpleCreateScene<StretchyUniformListViewHolePunch>});
+
+static TestScene::Registrar _StretchyUniformLayerListView(TestScene::Info{
+ "stretchylistview_uniform_layer",
+ "A mock ListView of scrolling content that's stretching using a uniform stretch effect. "
+ "Uses a layer",
+ TestScene::simpleCreateScene<StretchyUniformLayerListView>});
+
+static TestScene::Registrar _StretchyUniformLayerListViewHolePunch(TestScene::Info{
+ "stretchylistview_uniform_layer_holepunch",
+ "A mock ListView of scrolling content that's stretching using a uniform stretch effect. "
+ "Uses a layer & includes a hole punch",
+ TestScene::simpleCreateScene<StretchyUniformLayerListViewHolePunch>});
+
+class StretchyListViewAnimation : public TestScene {
+protected:
+ virtual StretchEffectBehavior stretchBehavior() { return StretchEffectBehavior::Shader; }
+ virtual bool haveHolePunch() { return false; }
+ virtual bool forceLayer() { return false; }
+
+private:
+ int mItemHeight;
+ int mItemSpacing;
+ int mItemWidth;
+ int mItemLeft;
+ sp<RenderNode> mListView;
+ std::vector<sp<RenderNode> > mListItems;
+
+ sk_sp<Bitmap> createRandomCharIcon(int cardHeight) {
+ SkBitmap skBitmap;
+ int size = cardHeight - (dp(10) * 2);
+ sk_sp<Bitmap> bitmap(TestUtils::createBitmap(size, size, &skBitmap));
+ SkCanvas canvas(skBitmap);
+ canvas.clear(0);
+
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkColor randomColor = BrightColors[rand() % BrightColorsCount];
+ paint.setColor(randomColor);
+ canvas.drawCircle(size / 2, size / 2, size / 2, paint);
+
+ bool bgDark =
+ SkColorGetR(randomColor) + SkColorGetG(randomColor) + SkColorGetB(randomColor) <
+ 128 * 3;
+ paint.setColor(bgDark ? Color::White : Color::Grey_700);
+
+ SkFont font;
+ font.setSize(size / 2);
+ char charToShow = 'A' + (rand() % 26);
+ const SkPoint pos = {SkIntToScalar(size / 2),
+ /*approximate centering*/ SkFloatToScalar(size * 0.7f)};
+ canvas.drawSimpleText(&charToShow, 1, SkTextEncoding::kUTF8, pos.fX, pos.fY, font, paint);
+ return bitmap;
+ }
+
+ static sk_sp<Bitmap> createBoxBitmap(bool filled) {
+ int size = dp(20);
+ int stroke = dp(2);
+ SkBitmap skBitmap;
+ auto bitmap = TestUtils::createBitmap(size, size, &skBitmap);
+ SkCanvas canvas(skBitmap);
+ canvas.clear(Color::Transparent);
+
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setColor(filled ? Color::Yellow_500 : Color::Grey_700);
+ paint.setStyle(filled ? SkPaint::kStrokeAndFill_Style : SkPaint::kStroke_Style);
+ paint.setStrokeWidth(stroke);
+ canvas.drawRect(SkRect::MakeLTRB(stroke, stroke, size - stroke, size - stroke), paint);
+ return bitmap;
+ }
+
+ void createListItem(RenderProperties& props, Canvas& canvas, int cardId, int itemWidth,
+ int itemHeight) {
+ static sk_sp<Bitmap> filledBox(createBoxBitmap(true));
+ static sk_sp<Bitmap> strokedBox(createBoxBitmap(false));
+ const bool addHolePunch = cardId == 2 && haveHolePunch();
+ // TODO: switch to using round rect clipping, once merging correctly handles that
+ Paint roundRectPaint;
+ roundRectPaint.setAntiAlias(true);
+ roundRectPaint.setColor(Color::White);
+ if (addHolePunch) {
+ // Punch a hole but then cover it up, we don't want to actually see it
+ canvas.punchHole(SkRRect::MakeRect(SkRect::MakeWH(itemWidth, itemHeight)));
+ }
+ canvas.drawRoundRect(0, 0, itemWidth, itemHeight, dp(6), dp(6), roundRectPaint);
+
+ Paint textPaint;
+ textPaint.setColor(rand() % 2 ? Color::Black : Color::Grey_500);
+ textPaint.getSkFont().setSize(dp(20));
+ textPaint.setAntiAlias(true);
+ char buf[256];
+ snprintf(buf, sizeof(buf), "This card is #%d", cardId);
+ TestUtils::drawUtf8ToCanvas(&canvas, buf, textPaint, itemHeight, dp(25));
+ textPaint.getSkFont().setSize(dp(15));
+ if (addHolePunch) {
+ TestUtils::drawUtf8ToCanvas(&canvas, "I have a hole punch", textPaint, itemHeight,
+ dp(45));
+ } else {
+ TestUtils::drawUtf8ToCanvas(&canvas, "This is some more text on the card", textPaint,
+ itemHeight, dp(45));
+ }
+
+ auto randomIcon = createRandomCharIcon(itemHeight);
+ canvas.drawBitmap(*randomIcon, dp(10), dp(10), nullptr);
+
+ auto box = rand() % 2 ? filledBox : strokedBox;
+ canvas.drawBitmap(*box, itemWidth - dp(10) - box->width(), dp(10), nullptr);
+ }
+
+ void createContent(int width, int height, Canvas& canvas) override {
+ srand(0);
+ mItemHeight = dp(60);
+ mItemSpacing = dp(16);
+ mItemWidth = std::min((height - mItemSpacing * 2), (int)dp(300));
+ mItemLeft = (width - mItemWidth) / 2;
+ int heightWithSpacing = mItemHeight + mItemSpacing;
+ for (int y = 0; y < height + (heightWithSpacing - 1); y += heightWithSpacing) {
+ int id = mListItems.size();
+ auto node = TestUtils::createNode(mItemLeft, y, mItemLeft + mItemWidth, y + mItemHeight,
+ [this, id](RenderProperties& props, Canvas& canvas) {
+ createListItem(props, canvas, id, mItemWidth,
+ mItemHeight);
+ });
+ mListItems.push_back(node);
+ }
+ mListView = TestUtils::createNode(0, 0, width, height,
+ [this](RenderProperties& props, Canvas& canvas) {
+ for (size_t ci = 0; ci < mListItems.size(); ci++) {
+ canvas.drawRenderNode(mListItems[ci].get());
+ }
+ });
+
+ canvas.drawColor(Color::Grey_500, SkBlendMode::kSrcOver);
+ canvas.drawRenderNode(mListView.get());
+ }
+
+ void doFrame(int frameNr) override {
+ if (frameNr == 0) {
+ Properties::stretchEffectBehavior = stretchBehavior();
+ if (forceLayer()) {
+ mListView->mutateStagingProperties().mutateLayerProperties().setType(
+ LayerType::RenderLayer);
+ }
+ }
+ auto& props = mListView->mutateStagingProperties();
+ auto& stretch = props.mutateLayerProperties().mutableStretchEffect();
+ stretch.setEmpty();
+ frameNr = frameNr % 150;
+ // Animate from 0f to .1f
+ const float sY = (frameNr > 75 ? 150 - frameNr : frameNr) / 1500.f;
+ stretch.mergeWith({{.fX = 0, .fY = sY},
+ static_cast<float>(props.getWidth()),
+ static_cast<float>(props.getHeight())});
+ mListView->setPropertyFieldsDirty(RenderNode::GENERIC);
+ }
+};
+
+class StretchyListViewHolePunch : public StretchyListViewAnimation {
+ bool haveHolePunch() override { return true; }
+};
+
+class StretchyUniformListView : public StretchyListViewAnimation {
+ StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::UniformScale; }
+};
+
+class StretchyUniformListViewHolePunch : public StretchyListViewAnimation {
+ StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::UniformScale; }
+ bool haveHolePunch() override { return true; }
+};
+
+class StretchyUniformLayerListView : public StretchyListViewAnimation {
+ StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::UniformScale; }
+ bool forceLayer() override { return true; }
+};
+
+class StretchyUniformLayerListViewHolePunch : public StretchyListViewAnimation {
+ StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::UniformScale; }
+ bool haveHolePunch() override { return true; }
+ bool forceLayer() override { return true; }
+};
\ No newline at end of file
diff --git a/libs/hwui/tests/macrobench/TestSceneRunner.cpp b/libs/hwui/tests/macrobench/TestSceneRunner.cpp
index 13ac367..9d3b732 100644
--- a/libs/hwui/tests/macrobench/TestSceneRunner.cpp
+++ b/libs/hwui/tests/macrobench/TestSceneRunner.cpp
@@ -62,53 +62,23 @@
T mAverage;
};
+using BenchmarkResults = std::vector<benchmark::BenchmarkReporter::Run>;
+
void outputBenchmarkReport(const TestScene::Info& info, const TestScene::Options& opts,
- benchmark::BenchmarkReporter* reporter, RenderProxy* proxy,
- double durationInS) {
- using namespace benchmark;
-
- struct ReportInfo {
- int percentile;
- const char* suffix;
- };
-
- static std::array<ReportInfo, 4> REPORTS = {
- ReportInfo{50, "_50th"}, ReportInfo{90, "_90th"}, ReportInfo{95, "_95th"},
- ReportInfo{99, "_99th"},
- };
-
- // Although a vector is used, it must stay with only a single element
- // otherwise the BenchmarkReporter will automatically compute
- // mean and stddev which doesn't make sense for our usage
- std::vector<BenchmarkReporter::Run> reports;
- BenchmarkReporter::Run report;
+ double durationInS, int repetationIndex, BenchmarkResults* reports) {
+ benchmark::BenchmarkReporter::Run report;
+ report.repetitions = opts.repeatCount;
+ report.repetition_index = repetationIndex;
report.run_name.function_name = info.name;
- report.iterations = static_cast<int64_t>(opts.count);
+ report.iterations = static_cast<int64_t>(opts.frameCount);
report.real_accumulated_time = durationInS;
report.cpu_accumulated_time = durationInS;
- report.counters["items_per_second"] = opts.count / durationInS;
- reports.push_back(report);
- reporter->ReportRuns(reports);
-
- // Pretend the percentiles are single-iteration runs of the test
- // If rendering offscreen skip this as it's fps that's more interesting
- // in that test case than percentiles.
- if (!opts.renderOffscreen) {
- for (auto& ri : REPORTS) {
- reports[0].run_name.function_name = info.name;
- reports[0].run_name.function_name += ri.suffix;
- durationInS = proxy->frameTimePercentile(ri.percentile) / 1000.0;
- reports[0].real_accumulated_time = durationInS;
- reports[0].cpu_accumulated_time = durationInS;
- reports[0].iterations = 1;
- reports[0].counters["items_per_second"] = 0;
- reporter->ReportRuns(reports);
- }
- }
+ report.counters["items_per_second"] = opts.frameCount / durationInS;
+ reports->push_back(report);
}
-void run(const TestScene::Info& info, const TestScene::Options& opts,
- benchmark::BenchmarkReporter* reporter) {
+static void doRun(const TestScene::Info& info, const TestScene::Options& opts, int repetitionIndex,
+ BenchmarkResults* reports) {
Properties::forceDrawFrame = true;
TestContext testContext;
testContext.setRenderOffscreen(opts.renderOffscreen);
@@ -158,7 +128,7 @@
ModifiedMovingAverage<double> avgMs(opts.reportFrametimeWeight);
nsecs_t start = systemTime(SYSTEM_TIME_MONOTONIC);
- for (int i = 0; i < opts.count; i++) {
+ for (int i = 0; i < opts.frameCount; i++) {
testContext.waitForVsync();
nsecs_t vsync = systemTime(SYSTEM_TIME_MONOTONIC);
{
@@ -182,9 +152,32 @@
proxy->fence();
nsecs_t end = systemTime(SYSTEM_TIME_MONOTONIC);
- if (reporter) {
- outputBenchmarkReport(info, opts, reporter, proxy.get(), (end - start) / (double)s2ns(1));
+ if (reports) {
+ outputBenchmarkReport(info, opts, (end - start) / (double)s2ns(1), repetitionIndex,
+ reports);
} else {
proxy->dumpProfileInfo(STDOUT_FILENO, DumpFlags::JankStats);
}
}
+
+void run(const TestScene::Info& info, const TestScene::Options& opts,
+ benchmark::BenchmarkReporter* reporter) {
+ if (opts.reportGpuMemoryUsage) {
+ // If we're reporting GPU memory usage we need to first start with a clean slate
+ // All repetitions of the same test will share a single memory usage report
+ RenderProxy::trimMemory(100);
+ }
+ BenchmarkResults results;
+ for (int i = 0; i < opts.repeatCount; i++) {
+ doRun(info, opts, i, reporter ? &results : nullptr);
+ }
+ if (reporter) {
+ reporter->ReportRuns(results);
+ if (results.size() > 1) {
+ // TODO: Report summary
+ }
+ }
+ if (opts.reportGpuMemoryUsage) {
+ RenderProxy::dumpGraphicsMemory(STDOUT_FILENO, false);
+ }
+}
diff --git a/libs/hwui/tests/macrobench/main.cpp b/libs/hwui/tests/macrobench/main.cpp
index 174a140..e9e962a 100644
--- a/libs/hwui/tests/macrobench/main.cpp
+++ b/libs/hwui/tests/macrobench/main.cpp
@@ -23,6 +23,7 @@
#include "renderthread/RenderProxy.h"
#include <benchmark/benchmark.h>
+#include <fnmatch.h>
#include <getopt.h>
#include <pthread.h>
#include <stdio.h>
@@ -40,9 +41,9 @@
using namespace android::uirenderer;
using namespace android::uirenderer::test;
-static int gRepeatCount = 1;
static std::vector<TestScene::Info> gRunTests;
static TestScene::Options gOpts;
+static bool gRunLeakCheck = true;
std::unique_ptr<benchmark::BenchmarkReporter> gBenchmarkReporter;
void run(const TestScene::Info& info, const TestScene::Options& opts,
@@ -69,6 +70,8 @@
are offscreen rendered
--benchmark_format Set output format. Possible values are tabular, json, csv
--renderer=TYPE Sets the render pipeline to use. May be skiagl or skiavk
+ --skip-leak-check Skips the memory leak check
+ --report-gpu-memory Dumps the GPU memory usage after each test run
)");
}
@@ -170,6 +173,8 @@
Onscreen,
Offscreen,
Renderer,
+ SkipLeakCheck,
+ ReportGpuMemory,
};
}
@@ -185,6 +190,8 @@
{"onscreen", no_argument, nullptr, LongOpts::Onscreen},
{"offscreen", no_argument, nullptr, LongOpts::Offscreen},
{"renderer", required_argument, nullptr, LongOpts::Renderer},
+ {"skip-leak-check", no_argument, nullptr, LongOpts::SkipLeakCheck},
+ {"report-gpu-memory", no_argument, nullptr, LongOpts::ReportGpuMemory},
{0, 0, 0, 0}};
static const char* SHORT_OPTIONS = "c:r:h";
@@ -214,20 +221,20 @@
break;
case 'c':
- gOpts.count = atoi(optarg);
- if (!gOpts.count) {
+ gOpts.frameCount = atoi(optarg);
+ if (!gOpts.frameCount) {
fprintf(stderr, "Invalid frames argument '%s'\n", optarg);
error = true;
}
break;
case 'r':
- gRepeatCount = atoi(optarg);
- if (!gRepeatCount) {
+ gOpts.repeatCount = atoi(optarg);
+ if (!gOpts.repeatCount) {
fprintf(stderr, "Invalid repeat argument '%s'\n", optarg);
error = true;
} else {
- gRepeatCount = (gRepeatCount > 0 ? gRepeatCount : INT_MAX);
+ gOpts.repeatCount = (gOpts.repeatCount > 0 ? gOpts.repeatCount : INT_MAX);
}
break;
@@ -283,6 +290,14 @@
gOpts.renderOffscreen = true;
break;
+ case LongOpts::SkipLeakCheck:
+ gRunLeakCheck = false;
+ break;
+
+ case LongOpts::ReportGpuMemory:
+ gOpts.reportGpuMemoryUsage = true;
+ break;
+
case 'h':
printHelp();
exit(EXIT_SUCCESS);
@@ -306,12 +321,21 @@
if (optind < argc) {
do {
const char* test = argv[optind++];
- auto pos = TestScene::testMap().find(test);
- if (pos == TestScene::testMap().end()) {
- fprintf(stderr, "Unknown test '%s'\n", test);
- exit(EXIT_FAILURE);
+ if (strchr(test, '*')) {
+ // Glob match
+ for (auto& iter : TestScene::testMap()) {
+ if (!fnmatch(test, iter.first.c_str(), 0)) {
+ gRunTests.push_back(iter.second);
+ }
+ }
} else {
- gRunTests.push_back(pos->second);
+ auto pos = TestScene::testMap().find(test);
+ if (pos == TestScene::testMap().end()) {
+ fprintf(stderr, "Unknown test '%s'\n", test);
+ exit(EXIT_FAILURE);
+ } else {
+ gRunTests.push_back(pos->second);
+ }
}
} while (optind < argc);
} else {
@@ -322,9 +346,6 @@
}
int main(int argc, char* argv[]) {
- // set defaults
- gOpts.count = 150;
-
Typeface::setRobotoTypefaceForTest();
parseOptions(argc, argv);
@@ -345,10 +366,8 @@
gBenchmarkReporter->ReportContext(context);
}
- for (int i = 0; i < gRepeatCount; i++) {
- for (auto&& test : gRunTests) {
- run(test, gOpts, gBenchmarkReporter.get());
- }
+ for (auto&& test : gRunTests) {
+ run(test, gOpts, gBenchmarkReporter.get());
}
if (gBenchmarkReporter) {
@@ -358,6 +377,8 @@
renderthread::RenderProxy::trimMemory(100);
HardwareBitmapUploader::terminate();
- LeakChecker::checkForLeaks();
+ if (gRunLeakCheck) {
+ LeakChecker::checkForLeaks();
+ }
return 0;
}
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index f2f9a26..14d4937 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -7068,15 +7068,7 @@
/**
* Set a certain surround format as enabled or not.
- * @param audioFormat a surround format, the value is one of
- * {@link AudioFormat#ENCODING_AC3}, {@link AudioFormat#ENCODING_E_AC3},
- * {@link AudioFormat#ENCODING_DTS}, {@link AudioFormat#ENCODING_DTS_HD},
- * {@link AudioFormat#ENCODING_AAC_LC}, {@link AudioFormat#ENCODING_DOLBY_TRUEHD},
- * {@link AudioFormat#ENCODING_E_AC3_JOC}. Once {@link AudioFormat#ENCODING_AAC_LC} is
- * set as enabled, {@link AudioFormat#ENCODING_AAC_LC},
- * {@link AudioFormat#ENCODING_AAC_HE_V1}, {@link AudioFormat#ENCODING_AAC_HE_V2},
- * {@link AudioFormat#ENCODING_AAC_ELD}, {@link AudioFormat#ENCODING_AAC_XHE} are
- * all enabled.
+ *
* @param enabled the required surround format state, true for enabled, false for disabled
* @return true if successful, otherwise false
*/
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index 39b7922..5f6fc17 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -131,6 +131,9 @@
public static final int SAMPLE_RATE_HZ_MIN = native_getMinSampleRate();
private static native int native_getMinSampleRate();
+ /** @hide */
+ public static final int FCC_24 = 24; // fixed channel count 24; do not change.
+
// Expose only the getter method publicly so we can change it in the future
private static final int NUM_STREAM_TYPES = 12;
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index b2b2f8e..23d9532 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -1720,9 +1720,10 @@
mChannelCount = 0;
break; // channel index configuration only
}
- if (!isMultichannelConfigSupported(channelConfig)) {
- // input channel configuration features unsupported channels
- throw new IllegalArgumentException("Unsupported channel configuration.");
+ if (!isMultichannelConfigSupported(channelConfig, audioFormat)) {
+ throw new IllegalArgumentException(
+ "Unsupported channel mask configuration " + channelConfig
+ + " for encoding " + audioFormat);
}
mChannelMask = channelConfig;
mChannelCount = AudioFormat.channelCountFromOutChannelMask(channelConfig);
@@ -1730,13 +1731,17 @@
// check the channel index configuration (if present)
mChannelIndexMask = channelIndexMask;
if (mChannelIndexMask != 0) {
- // restrictive: indexMask could allow up to AUDIO_CHANNEL_BITS_LOG2
- final int indexMask = (1 << AudioSystem.OUT_CHANNEL_COUNT_MAX) - 1;
- if ((channelIndexMask & ~indexMask) != 0) {
- throw new IllegalArgumentException("Unsupported channel index configuration "
- + channelIndexMask);
+ // As of S, we accept up to 24 channel index mask.
+ final int fullIndexMask = (1 << AudioSystem.FCC_24) - 1;
+ final int channelIndexCount = Integer.bitCount(channelIndexMask);
+ final boolean accepted = (channelIndexMask & ~fullIndexMask) == 0
+ && (!AudioFormat.isEncodingLinearFrames(audioFormat) // compressed OK
+ || channelIndexCount <= AudioSystem.OUT_CHANNEL_COUNT_MAX); // PCM
+ if (!accepted) {
+ throw new IllegalArgumentException(
+ "Unsupported channel index mask configuration " + channelIndexMask
+ + " for encoding " + audioFormat);
}
- int channelIndexCount = Integer.bitCount(channelIndexMask);
if (mChannelCount == 0) {
mChannelCount = channelIndexCount;
} else if (mChannelCount != channelIndexCount) {
@@ -1789,16 +1794,19 @@
* @param channelConfig the mask to validate
* @return false if the AudioTrack can't be used with such a mask
*/
- private static boolean isMultichannelConfigSupported(int channelConfig) {
+ private static boolean isMultichannelConfigSupported(int channelConfig, int encoding) {
// check for unsupported channels
if ((channelConfig & SUPPORTED_OUT_CHANNELS) != channelConfig) {
loge("Channel configuration features unsupported channels");
return false;
}
final int channelCount = AudioFormat.channelCountFromOutChannelMask(channelConfig);
- if (channelCount > AudioSystem.OUT_CHANNEL_COUNT_MAX) {
- loge("Channel configuration contains too many channels " +
- channelCount + ">" + AudioSystem.OUT_CHANNEL_COUNT_MAX);
+ final int channelCountLimit = AudioFormat.isEncodingLinearFrames(encoding)
+ ? AudioSystem.OUT_CHANNEL_COUNT_MAX // PCM limited to OUT_CHANNEL_COUNT_MAX
+ : AudioSystem.FCC_24; // Compressed limited to 24 channels
+ if (channelCount > channelCountLimit) {
+ loge("Channel configuration contains too many channels for encoding "
+ + encoding + "(" + channelCount + " > " + channelCountLimit + ")");
return false;
}
// check for unsupported multichannel combinations:
@@ -2310,7 +2318,7 @@
channelCount = 2;
break;
default:
- if (!isMultichannelConfigSupported(channelConfig)) {
+ if (!isMultichannelConfigSupported(channelConfig, audioFormat)) {
loge("getMinBufferSize(): Invalid channel configuration.");
return ERROR_BAD_VALUE;
} else {
diff --git a/native/android/surface_control.cpp b/native/android/surface_control.cpp
index a8c2ea5..93a5444 100644
--- a/native/android/surface_control.cpp
+++ b/native/android/surface_control.cpp
@@ -454,28 +454,7 @@
sourceRect.makeInvalid();
}
transaction->setBufferCrop(surfaceControl, sourceRect);
-
- int destW = destRect.width();
- int destH = destRect.height();
- if (destRect.left < 0) {
- destRect.left = 0;
- destRect.right = destW;
- }
- if (destRect.top < 0) {
- destRect.top = 0;
- destRect.bottom = destH;
- }
-
- if (!sourceRect.isEmpty()) {
- float sx = destW / static_cast<float>(sourceRect.width());
- float sy = destH / static_cast<float>(sourceRect.height());
- transaction->setPosition(surfaceControl, destRect.left - (sourceRect.left * sx),
- destRect.top - (sourceRect.top * sy));
- transaction->setMatrix(surfaceControl, sx, 0, 0, sy);
- } else {
- transaction->setPosition(surfaceControl, destRect.left, destRect.top);
- }
-
+ transaction->setDestinationFrame(surfaceControl, destRect);
transaction->setTransform(surfaceControl, transform);
bool transformToInverseDisplay = (NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY & transform) ==
NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY;
diff --git a/native/android/system_fonts.cpp b/native/android/system_fonts.cpp
index 60b0f1e..9fe7929 100644
--- a/native/android/system_fonts.cpp
+++ b/native/android/system_fonts.cpp
@@ -329,7 +329,9 @@
static_cast<minikin::FamilyVariant>(matcher->mFamilyVariant),
1 /* maxRun */);
- const std::shared_ptr<minikin::Font>& font = runs[0].fakedFont.font;
+ const std::shared_ptr<minikin::Font>& font =
+ fc->getBestFont(minikin::U16StringPiece(text, textLength), runs[0], matcher->mFontStyle)
+ .font;
std::unique_ptr<AFont> result = std::make_unique<AFont>();
const android::MinikinFontSkia* minikinFontSkia =
reinterpret_cast<android::MinikinFontSkia*>(font->typeface().get());
diff --git a/packages/Connectivity/framework/jni/android_net_NetworkUtils.cpp b/packages/Connectivity/framework/jni/android_net_NetworkUtils.cpp
index 9bf910b..7478b3e 100644
--- a/packages/Connectivity/framework/jni/android_net_NetworkUtils.cpp
+++ b/packages/Connectivity/framework/jni/android_net_NetworkUtils.cpp
@@ -64,7 +64,7 @@
filter_code,
};
- int fd = AFileDescriptor_getFD(env, javaFd);
+ int fd = AFileDescriptor_getFd(env, javaFd);
if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter, sizeof(filter)) != 0) {
jniThrowExceptionFmt(env, "java/net/SocketException",
"setsockopt(SO_ATTACH_FILTER): %s", strerror(errno));
@@ -74,7 +74,7 @@
static void android_net_utils_detachBPFFilter(JNIEnv *env, jobject clazz, jobject javaFd)
{
int optval_ignored = 0;
- int fd = AFileDescriptor_getFD(env, javaFd);
+ int fd = AFileDescriptor_getFd(env, javaFd);
if (setsockopt(fd, SOL_SOCKET, SO_DETACH_FILTER, &optval_ignored, sizeof(optval_ignored)) !=
0) {
jniThrowExceptionFmt(env, "java/net/SocketException",
@@ -107,7 +107,7 @@
static jint android_net_utils_bindSocketToNetworkHandle(JNIEnv *env, jobject thiz, jobject javaFd,
jlong netHandle) {
- return android_setsocknetwork(netHandle, AFileDescriptor_getFD(env, javaFd));
+ return android_setsocknetwork(netHandle, AFileDescriptor_getFd(env, javaFd));
}
static bool checkLenAndCopy(JNIEnv* env, const jbyteArray& addr, int len, void* dst)
@@ -156,7 +156,7 @@
}
static jobject android_net_utils_resNetworkResult(JNIEnv *env, jobject thiz, jobject javaFd) {
- int fd = AFileDescriptor_getFD(env, javaFd);
+ int fd = AFileDescriptor_getFd(env, javaFd);
int rcode;
uint8_t buf[MAXPACKETSIZE] = {0};
@@ -182,7 +182,7 @@
}
static void android_net_utils_resNetworkCancel(JNIEnv *env, jobject thiz, jobject javaFd) {
- int fd = AFileDescriptor_getFD(env, javaFd);
+ int fd = AFileDescriptor_getFd(env, javaFd);
android_res_cancel(fd);
jniSetFileDescriptorOfFD(env, javaFd, -1);
}
@@ -210,7 +210,7 @@
return NULL;
}
- int fd = AFileDescriptor_getFD(env, javaFd);
+ int fd = AFileDescriptor_getFd(env, javaFd);
struct tcp_repair_window trw = {};
socklen_t size = sizeof(trw);
diff --git a/packages/Connectivity/framework/src/android/net/NetworkCapabilities.java b/packages/Connectivity/framework/src/android/net/NetworkCapabilities.java
index 0bafd5b..614dfc1 100644
--- a/packages/Connectivity/framework/src/android/net/NetworkCapabilities.java
+++ b/packages/Connectivity/framework/src/android/net/NetworkCapabilities.java
@@ -839,8 +839,17 @@
final int[] originalAdministratorUids = getAdministratorUids();
final TransportInfo originalTransportInfo = getTransportInfo();
clearAll();
- mTransportTypes = (originalTransportTypes & TEST_NETWORKS_ALLOWED_TRANSPORTS)
- | (1 << TRANSPORT_TEST);
+ if (0 != (originalCapabilities & NET_CAPABILITY_NOT_RESTRICTED)) {
+ // If the test network is not restricted, then it is only allowed to declare some
+ // specific transports. This is to minimize impact on running apps in case an app
+ // run from the shell creates a test a network.
+ mTransportTypes =
+ (originalTransportTypes & UNRESTRICTED_TEST_NETWORKS_ALLOWED_TRANSPORTS)
+ | (1 << TRANSPORT_TEST);
+ } else {
+ // If the test transport is restricted, then it may declare any transport.
+ mTransportTypes = (originalTransportTypes | (1 << TRANSPORT_TEST));
+ }
mNetworkCapabilities = originalCapabilities & TEST_NETWORKS_ALLOWED_CAPABILITIES;
mNetworkSpecifier = originalSpecifier;
mSignalStrength = originalSignalStrength;
@@ -951,9 +960,10 @@
};
/**
- * Allowed transports on a test network, in addition to TRANSPORT_TEST.
+ * Allowed transports on an unrestricted test network (in addition to TRANSPORT_TEST).
*/
- private static final int TEST_NETWORKS_ALLOWED_TRANSPORTS = 1 << TRANSPORT_TEST
+ private static final int UNRESTRICTED_TEST_NETWORKS_ALLOWED_TRANSPORTS =
+ 1 << TRANSPORT_TEST
// Test ethernet networks can be created with EthernetManager#setIncludeTestInterfaces
| 1 << TRANSPORT_ETHERNET
// Test VPN networks can be created but their UID ranges must be empty.
@@ -2461,7 +2471,8 @@
* For example {@code TRANSPORT_WIFI} and {@code TRANSPORT_ETHERNET} added to a
* {@code NetworkCapabilities} would cause either a Wi-Fi network or an Ethernet network
* to be selected. This is logically different than
- * {@code NetworkCapabilities.NET_CAPABILITY_*}.
+ * {@code NetworkCapabilities.NET_CAPABILITY_*}. Also note that multiple networks with the
+ * same transport type may be active concurrently.
*
* @param transportType the transport type to be added or removed.
* @return this builder
diff --git a/packages/CtsShim/apk/arm/CtsShim.apk b/packages/CtsShim/apk/arm/CtsShim.apk
index 784a747..ca69a28 100644
--- a/packages/CtsShim/apk/arm/CtsShim.apk
+++ b/packages/CtsShim/apk/arm/CtsShim.apk
Binary files differ
diff --git a/packages/CtsShim/apk/arm/CtsShimPriv.apk b/packages/CtsShim/apk/arm/CtsShimPriv.apk
index 5b7bda4..d7cfb96 100644
--- a/packages/CtsShim/apk/arm/CtsShimPriv.apk
+++ b/packages/CtsShim/apk/arm/CtsShimPriv.apk
Binary files differ
diff --git a/packages/CtsShim/apk/x86/CtsShim.apk b/packages/CtsShim/apk/x86/CtsShim.apk
index 784a747..ca69a28 100644
--- a/packages/CtsShim/apk/x86/CtsShim.apk
+++ b/packages/CtsShim/apk/x86/CtsShim.apk
Binary files differ
diff --git a/packages/CtsShim/apk/x86/CtsShimPriv.apk b/packages/CtsShim/apk/x86/CtsShimPriv.apk
index 780cb8a..84c3401 100644
--- a/packages/CtsShim/apk/x86/CtsShimPriv.apk
+++ b/packages/CtsShim/apk/x86/CtsShimPriv.apk
Binary files differ
diff --git a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java
index 16a946d..f8cb5d3 100644
--- a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java
+++ b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java
@@ -561,7 +561,20 @@
break;
}
- Log.d(TAG, "status=" + statusString + ", cause=" + causeString + ", detail=" + detail);
+ StringBuilder msg = new StringBuilder();
+ msg.append("status: " + statusString + ", cause: " + causeString);
+ if (status == STATUS_IN_PROGRESS) {
+ msg.append(
+ String.format(
+ ", partition name: %s, progress: %d/%d",
+ mCurrentPartitionName,
+ mCurrentPartitionInstalledSize,
+ mCurrentPartitionSize));
+ }
+ if (detail != null) {
+ msg.append(", detail: " + detail);
+ }
+ Log.d(TAG, msg.toString());
if (notifyOnNotificationBar) {
mNM.notify(NOTIFICATION_ID, buildNotification(status, cause, detail));
diff --git a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java
index 59ea9f0..f18d426 100644
--- a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java
+++ b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java
@@ -320,20 +320,21 @@
}
}
- private void installScratch() throws IOException {
- final long scratchSize = mDynSystem.suggestScratchSize();
+ private void installWritablePartition(final String partitionName, final long partitionSize)
+ throws IOException {
+ Log.d(TAG, "Creating writable partition: " + partitionName + ", size: " + partitionSize);
+
Thread thread = new Thread() {
@Override
public void run() {
mInstallationSession =
- mDynSystem.createPartition("scratch", scratchSize, /* readOnly= */ false);
+ mDynSystem.createPartition(
+ partitionName, partitionSize, /* readOnly= */ false);
}
};
- Log.d(TAG, "Creating partition: scratch, size = " + scratchSize);
thread.start();
-
- Progress progress = new Progress("scratch", scratchSize, mNumInstalledPartitions++);
+ Progress progress = new Progress(partitionName, partitionSize, mNumInstalledPartitions++);
while (thread.isAlive()) {
if (isCancelled()) {
@@ -356,53 +357,22 @@
if (mInstallationSession == null) {
throw new IOException(
- "Failed to start installation with requested size: " + scratchSize);
+ "Failed to start installation with requested size: " + partitionSize);
}
+
// Reset installation session and verify that installation completes successfully.
mInstallationSession = null;
if (!mDynSystem.closePartition()) {
- throw new IOException("Failed to complete partition installation: scratch");
+ throw new IOException("Failed to complete partition installation: " + partitionName);
}
}
+ private void installScratch() throws IOException {
+ installWritablePartition("scratch", mDynSystem.suggestScratchSize());
+ }
+
private void installUserdata() throws IOException {
- Thread thread = new Thread(() -> {
- mInstallationSession = mDynSystem.createPartition("userdata", mUserdataSize, false);
- });
-
- Log.d(TAG, "Creating partition: userdata, size = " + mUserdataSize);
- thread.start();
-
- Progress progress = new Progress("userdata", mUserdataSize, mNumInstalledPartitions++);
-
- while (thread.isAlive()) {
- if (isCancelled()) {
- return;
- }
-
- final long installedSize = mDynSystem.getInstallationProgress().bytes_processed;
-
- if (installedSize > progress.installedSize + MIN_PROGRESS_TO_PUBLISH) {
- progress.installedSize = installedSize;
- publishProgress(progress);
- }
-
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- // Ignore the error.
- }
- }
-
- if (mInstallationSession == null) {
- throw new IOException(
- "Failed to start installation with requested size: " + mUserdataSize);
- }
- // Reset installation session and verify that installation completes successfully.
- mInstallationSession = null;
- if (!mDynSystem.closePartition()) {
- throw new IOException("Failed to complete partition installation: userdata");
- }
+ installWritablePartition("userdata", mUserdataSize);
}
private void installImages() throws IOException, ImageValidationException {
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java b/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java
index 0210079..9c6113c 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java
@@ -86,7 +86,7 @@
private int mOriginatingUid = PackageInstaller.SessionParams.UID_UNKNOWN;
private String mOriginatingPackage; // The package name corresponding to #mOriginatingUid
- private boolean localLOGV = false;
+ private final boolean mLocalLOGV = false;
PackageManager mPm;
IPackageManager mIpm;
AppOpsManager mAppOpsManager;
@@ -104,7 +104,7 @@
private List<UnknownSourcesListener> mActiveUnknownSourcesListeners = new ArrayList<>(1);
// ApplicationInfo object primarily used for already existing applications
- private ApplicationInfo mAppInfo = null;
+ private ApplicationInfo mAppInfo;
// Buttons to indicate user acceptance
private Button mOk;
@@ -154,6 +154,7 @@
* @param id The dialog type to add
*/
private void showDialogInner(int id) {
+ if (mLocalLOGV) Log.i(TAG, "showDialogInner(" + id + ")");
DialogFragment currentDialog =
(DialogFragment) getFragmentManager().findFragmentByTag("dialog");
if (currentDialog != null) {
@@ -174,6 +175,7 @@
* @return The dialog
*/
private DialogFragment createDialog(int id) {
+ if (mLocalLOGV) Log.i(TAG, "createDialog(" + id + ")");
switch (id) {
case DLG_PACKAGE_ERROR:
return SimpleErrorDialog.newInstance(R.string.Parse_error_dlg_text);
@@ -294,6 +296,7 @@
@Override
protected void onCreate(Bundle icicle) {
+ if (mLocalLOGV) Log.i(TAG, "creating for user " + getUserId());
getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
super.onCreate(null);
@@ -354,6 +357,8 @@
}
boolean wasSetUp = processPackageUri(packageUri);
+ if (mLocalLOGV) Log.i(TAG, "wasSetUp: " + wasSetUp);
+
if (!wasSetUp) {
return;
}
@@ -363,6 +368,8 @@
protected void onResume() {
super.onResume();
+ if (mLocalLOGV) Log.i(TAG, "onResume(): mAppSnippet=" + mAppSnippet);
+
if (mAppSnippet != null) {
// load dummy layout with OK button disabled until we override this layout in
// startInstallConfirm
@@ -443,15 +450,21 @@
final int installAppsRestrictionSource = mUserManager.getUserRestrictionSource(
UserManager.DISALLOW_INSTALL_APPS, Process.myUserHandle());
if ((installAppsRestrictionSource & UserManager.RESTRICTION_SOURCE_SYSTEM) != 0) {
+ if (mLocalLOGV) Log.i(TAG, "install not allowed: " + UserManager.DISALLOW_INSTALL_APPS);
showDialogInner(DLG_INSTALL_APPS_RESTRICTED_FOR_USER);
return;
} else if (installAppsRestrictionSource != UserManager.RESTRICTION_NOT_SET) {
+ if (mLocalLOGV) {
+ Log.i(TAG, "install not allowed by admin; showing "
+ + Settings.ACTION_SHOW_ADMIN_SUPPORT_DETAILS);
+ }
startActivity(new Intent(Settings.ACTION_SHOW_ADMIN_SUPPORT_DETAILS));
finish();
return;
}
if (mAllowUnknownSources || !isInstallRequestFromUnknownSource(getIntent())) {
+ if (mLocalLOGV) Log.i(TAG, "install allowed");
initiateInstall();
} else {
// Check for unknown sources restrictions.
@@ -462,6 +475,7 @@
final int systemRestriction = UserManager.RESTRICTION_SOURCE_SYSTEM
& (unknownSourcesRestrictionSource | unknownSourcesGlobalRestrictionSource);
if (systemRestriction != 0) {
+ if (mLocalLOGV) Log.i(TAG, "Showing DLG_UNKNOWN_SOURCES_RESTRICTED_FOR_USER");
showDialogInner(DLG_UNKNOWN_SOURCES_RESTRICTED_FOR_USER);
} else if (unknownSourcesRestrictionSource != UserManager.RESTRICTION_NOT_SET) {
startAdminSupportDetailsActivity(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES);
@@ -475,13 +489,19 @@
}
private void startAdminSupportDetailsActivity(String restriction) {
+ if (mLocalLOGV) Log.i(TAG, "startAdminSupportDetailsActivity(): " + restriction);
+
// If the given restriction is set by an admin, display information about the
// admin enforcing the restriction for the affected user.
final DevicePolicyManager dpm = getSystemService(DevicePolicyManager.class);
final Intent showAdminSupportDetailsIntent = dpm.createAdminSupportIntent(restriction);
if (showAdminSupportDetailsIntent != null) {
+ if (mLocalLOGV) Log.i(TAG, "starting " + showAdminSupportDetailsIntent);
startActivity(showAdminSupportDetailsIntent);
+ } else {
+ if (mLocalLOGV) Log.w(TAG, "not intent for " + restriction);
}
+
finish();
}
@@ -497,6 +517,7 @@
final int appOpMode = mAppOpsManager.noteOpNoThrow(appOpCode, mOriginatingUid,
mOriginatingPackage, mCallingAttributionTag,
"Started package installation activity");
+ if (mLocalLOGV) Log.i(TAG, "handleUnknownSources(): appMode=" + appOpMode);
switch (appOpMode) {
case AppOpsManager.MODE_DEFAULT:
mAppOpsManager.setMode(appOpCode, mOriginatingUid,
@@ -527,6 +548,7 @@
mPackageURI = packageUri;
final String scheme = packageUri.getScheme();
+ if (mLocalLOGV) Log.i(TAG, "processPackageUri(): uri=" + packageUri + ", scheme=" + scheme);
switch (scheme) {
case SCHEME_PACKAGE: {
@@ -543,7 +565,9 @@
setPmResult(PackageManager.INSTALL_FAILED_INVALID_APK);
return false;
}
- mAppSnippet = new PackageUtil.AppSnippet(mPm.getApplicationLabel(mPkgInfo.applicationInfo),
+ CharSequence label = mPm.getApplicationLabel(mPkgInfo.applicationInfo);
+ if (mLocalLOGV) Log.i(TAG, "creating snippet for " + label);
+ mAppSnippet = new PackageUtil.AppSnippet(label,
mPm.getApplicationIcon(mPkgInfo.applicationInfo));
} break;
@@ -559,6 +583,7 @@
setPmResult(PackageManager.INSTALL_FAILED_INVALID_APK);
return false;
}
+ if (mLocalLOGV) Log.i(TAG, "creating snippet for local file " + sourceFile);
mAppSnippet = PackageUtil.getAppSnippet(this, mPkgInfo.applicationInfo, sourceFile);
} break;
@@ -604,7 +629,7 @@
newIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true);
}
newIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
- if(localLOGV) Log.i(TAG, "downloaded app uri="+mPackageURI);
+ if (mLocalLOGV) Log.i(TAG, "downloaded app uri=" + mPackageURI);
startActivity(newIntent);
finish();
}
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/PackageUtil.java b/packages/PackageInstaller/src/com/android/packageinstaller/PackageUtil.java
index d3a9f8f..f5570df 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/PackageUtil.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/PackageUtil.java
@@ -107,13 +107,18 @@
icon);
}
- static public class AppSnippet {
+ static final class AppSnippet {
@NonNull public CharSequence label;
@Nullable public Drawable icon;
public AppSnippet(@NonNull CharSequence label, @Nullable Drawable icon) {
this.label = label;
this.icon = icon;
}
+
+ @Override
+ public String toString() {
+ return "AppSnippet[" + label + (icon != null ? "(has" : "(no ") + " icon)]";
+ }
}
/**
diff --git a/packages/SettingsLib/Android.bp b/packages/SettingsLib/Android.bp
index 69cee00..a65bf41 100644
--- a/packages/SettingsLib/Android.bp
+++ b/packages/SettingsLib/Android.bp
@@ -54,6 +54,7 @@
"SettingsLibAppPreference",
"SettingsLibSearchWidget",
"SettingsLibSettingsSpinner",
+ "SettingsLibIllustrationPreference",
"SettingsLibLayoutPreference",
"SettingsLibMainSwitchPreference",
"SettingsLibActionButtonsPreference",
diff --git a/packages/SettingsLib/FooterPreference/Android.bp b/packages/SettingsLib/FooterPreference/Android.bp
index 11f39e7..0929706 100644
--- a/packages/SettingsLib/FooterPreference/Android.bp
+++ b/packages/SettingsLib/FooterPreference/Android.bp
@@ -20,4 +20,8 @@
],
sdk_version: "system_current",
min_sdk_version: "21",
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.permission",
+ ],
}
diff --git a/packages/SettingsLib/IllustrationPreference/Android.bp b/packages/SettingsLib/IllustrationPreference/Android.bp
new file mode 100644
index 0000000..f8dd384
--- /dev/null
+++ b/packages/SettingsLib/IllustrationPreference/Android.bp
@@ -0,0 +1,23 @@
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "frameworks_base_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["frameworks_base_license"],
+}
+
+android_library {
+ name: "SettingsLibIllustrationPreference",
+
+ srcs: ["src/**/*.java"],
+ resource_dirs: ["res"],
+
+ static_libs: [
+ "androidx.preference_preference",
+ "lottie",
+ ],
+
+ sdk_version: "system_current",
+ min_sdk_version: "21",
+}
diff --git a/packages/SettingsLib/IllustrationPreference/AndroidManifest.xml b/packages/SettingsLib/IllustrationPreference/AndroidManifest.xml
new file mode 100644
index 0000000..120b085
--- /dev/null
+++ b/packages/SettingsLib/IllustrationPreference/AndroidManifest.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 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.settingslib.widget">
+
+ <uses-sdk android:minSdkVersion="21" />
+
+</manifest>
diff --git a/packages/SettingsLib/IllustrationPreference/res/drawable/ic_gesture_play_button.xml b/packages/SettingsLib/IllustrationPreference/res/drawable/ic_gesture_play_button.xml
new file mode 100644
index 0000000..55b3115
--- /dev/null
+++ b/packages/SettingsLib/IllustrationPreference/res/drawable/ic_gesture_play_button.xml
@@ -0,0 +1,24 @@
+<!--
+ Copyright (C) 2021 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 xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="48.0"
+ android:viewportHeight="48.0">
+ <path android:fillColor="#FFFFFF" android:pathData="M24,24m-19,0a19,19 0,1 1,38 0a19,19 0,1 1,-38 0"/>
+ <path android:fillColor="#1A73E8" android:pathData="M20,33l12,-9l-12,-9z"/>
+ <path android:fillColor="#1A73E8" android:pathData="M24,4C12.96,4 4,12.96 4,24s8.96,20 20,20s20,-8.96 20,-20S35.04,4 24,4zM24,40c-8.82,0 -16,-7.18 -16,-16S15.18,8 24,8s16,7.18 16,16S32.82,40 24,40z"/>
+</vector>
diff --git a/packages/SettingsLib/IllustrationPreference/res/drawable/protection_background.xml b/packages/SettingsLib/IllustrationPreference/res/drawable/protection_background.xml
new file mode 100644
index 0000000..dd2fa5e
--- /dev/null
+++ b/packages/SettingsLib/IllustrationPreference/res/drawable/protection_background.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 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.
+-->
+
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <item
+ android:top="@dimen/settingslib_illustration_padding"
+ android:left="@dimen/settingslib_illustration_padding"
+ android:right="@dimen/settingslib_illustration_padding"
+ android:bottom="@dimen/settingslib_illustration_padding">
+ <shape android:shape="rectangle">
+ <solid android:color="@color/settingslib_protection_color"/>
+ <corners android:radius="28dp"/>
+ </shape>
+ </item>
+</layer-list>
diff --git a/packages/SettingsLib/IllustrationPreference/res/layout/illustration_preference.xml b/packages/SettingsLib/IllustrationPreference/res/layout/illustration_preference.xml
new file mode 100644
index 0000000..2cbb888
--- /dev/null
+++ b/packages/SettingsLib/IllustrationPreference/res/layout/illustration_preference.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 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_height="wrap_content"
+ android:layout_width="match_parent"
+ android:background="?android:attr/colorBackground"
+ android:gravity="center"
+ android:orientation="horizontal">
+
+ <View
+ android:id="@+id/protection_layer"
+ android:layout_width="412dp"
+ android:layout_height="300dp"
+ android:layout_gravity="center"
+ android:padding="@dimen/settingslib_illustration_padding"
+ android:background="@drawable/protection_background"/>
+
+ <com.airbnb.lottie.LottieAnimationView
+ android:id="@+id/lottie_view"
+ android:layout_width="412dp"
+ android:layout_height="300dp"
+ android:layout_gravity="center"
+ android:padding="@dimen/settingslib_illustration_padding"
+ android:importantForAccessibility="no"/>
+
+ <ImageView
+ android:id="@+id/video_play_button"
+ android:layout_width="36dp"
+ android:layout_height="36dp"
+ android:layout_gravity="center"
+ android:visibility="gone"
+ android:src="@drawable/ic_gesture_play_button"/>
+
+</FrameLayout>
+
diff --git a/packages/SettingsLib/IllustrationPreference/res/values-night/colors.xml b/packages/SettingsLib/IllustrationPreference/res/values-night/colors.xml
new file mode 100644
index 0000000..71b18a8
--- /dev/null
+++ b/packages/SettingsLib/IllustrationPreference/res/values-night/colors.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 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>
+ <color name="settingslib_protection_color">@android:color/black</color>
+</resources>
diff --git a/packages/SettingsLib/IllustrationPreference/res/values/colors.xml b/packages/SettingsLib/IllustrationPreference/res/values/colors.xml
new file mode 100644
index 0000000..e53a43e
--- /dev/null
+++ b/packages/SettingsLib/IllustrationPreference/res/values/colors.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 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>
+ <color name="settingslib_protection_color">@android:color/white</color>
+</resources>
diff --git a/packages/SettingsLib/IllustrationPreference/res/values/dimens.xml b/packages/SettingsLib/IllustrationPreference/res/values/dimens.xml
new file mode 100644
index 0000000..79562b9
--- /dev/null
+++ b/packages/SettingsLib/IllustrationPreference/res/values/dimens.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 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>
+ <!-- Padding of illustration -->
+ <dimen name="settingslib_illustration_padding">16dp</dimen>
+</resources>
diff --git a/packages/SettingsLib/IllustrationPreference/src/com/android/settingslib/widget/IllustrationPreference.java b/packages/SettingsLib/IllustrationPreference/src/com/android/settingslib/widget/IllustrationPreference.java
new file mode 100644
index 0000000..90b8a32
--- /dev/null
+++ b/packages/SettingsLib/IllustrationPreference/src/com/android/settingslib/widget/IllustrationPreference.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2021 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.settingslib.widget;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+import android.widget.ImageView;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.Preference.OnPreferenceClickListener;
+import androidx.preference.PreferenceViewHolder;
+
+import com.airbnb.lottie.LottieAnimationView;
+
+/**
+ * IllustrationPreference is a preference that can play lottie format animation
+ */
+public class IllustrationPreference extends Preference implements OnPreferenceClickListener {
+
+ static final String TAG = "IllustrationPreference";
+ private int mAnimationId;
+ private boolean mIsAnimating;
+ private ImageView mPlayButton;
+ private LottieAnimationView mIllustrationView;
+
+ public IllustrationPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init(context, attrs);
+ }
+
+ public IllustrationPreference(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init(context, attrs);
+ }
+
+ public IllustrationPreference(Context context, AttributeSet attrs, int defStyleAttr,
+ int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ init(context, attrs);
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+ if (mAnimationId == 0) {
+ Log.w(TAG, "Invalid illustration resource id.");
+ return;
+ }
+ mPlayButton = (ImageView) holder.findViewById(R.id.video_play_button);
+ mIllustrationView = (LottieAnimationView) holder.findViewById(R.id.lottie_view);
+ mIllustrationView.setAnimation(mAnimationId);
+ mIllustrationView.loop(true);
+ mIllustrationView.playAnimation();
+ updateAnimationStatus(mIsAnimating);
+ setOnPreferenceClickListener(this);
+ }
+
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ mIsAnimating = !isAnimating();
+ updateAnimationStatus(mIsAnimating);
+ return true;
+ }
+
+ @Override
+ protected Parcelable onSaveInstanceState() {
+ Parcelable superState = super.onSaveInstanceState();
+ SavedState ss = new SavedState(superState);
+ ss.mIsAnimating = mIsAnimating;
+ return ss;
+ }
+
+ @Override
+ protected void onRestoreInstanceState(Parcelable state) {
+ SavedState ss = (SavedState) state;
+ super.onRestoreInstanceState(ss.getSuperState());
+ mIsAnimating = ss.mIsAnimating;
+ }
+
+ @VisibleForTesting
+ boolean isAnimating() {
+ return mIllustrationView.isAnimating();
+ }
+
+ private void init(Context context, AttributeSet attrs) {
+ setLayoutResource(R.layout.illustration_preference);
+
+ mIsAnimating = true;
+ if (attrs != null) {
+ final TypedArray a = context.obtainStyledAttributes(attrs,
+ R.styleable.LottieAnimationView, 0 /*defStyleAttr*/, 0 /*defStyleRes*/);
+ mAnimationId = a.getResourceId(R.styleable.LottieAnimationView_lottie_rawRes, 0);
+ a.recycle();
+ }
+ }
+
+ private void updateAnimationStatus(boolean playAnimation) {
+ if (playAnimation) {
+ mIllustrationView.resumeAnimation();
+ mPlayButton.setVisibility(View.INVISIBLE);
+ } else {
+ mIllustrationView.pauseAnimation();
+ mPlayButton.setVisibility(View.VISIBLE);
+ }
+ }
+
+ static class SavedState extends BaseSavedState {
+ boolean mIsAnimating;
+
+ SavedState(Parcelable superState) {
+ super(superState);
+ }
+
+ /**
+ * Constructor called from {@link #CREATOR}
+ */
+ private SavedState(Parcel in) {
+ super(in);
+ mIsAnimating = (Boolean) in.readValue(null);
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ super.writeToParcel(out, flags);
+ out.writeValue(mIsAnimating);
+ }
+
+ @Override
+ public String toString() {
+ return "IllustrationPreference.SavedState{"
+ + Integer.toHexString(System.identityHashCode(this))
+ + " mIsAnimating=" + mIsAnimating + "}";
+ }
+
+ public static final Parcelable.Creator<SavedState> CREATOR =
+ new Parcelable.Creator<SavedState>() {
+ public SavedState createFromParcel(Parcel in) {
+ return new SavedState(in);
+ }
+
+ public SavedState[] newArray(int size) {
+ return new SavedState[size];
+ }
+ };
+ }
+}
diff --git a/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java b/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java
index 0748acd..123c477 100644
--- a/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java
+++ b/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java
@@ -72,9 +72,7 @@
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
- LayoutInflater.from(context).inflate(
- resourceId(context, "layout", "settingslib_main_switch_bar"),
- this);
+ LayoutInflater.from(context).inflate(R.layout.settingslib_main_switch_bar, this);
if (!BuildCompat.isAtLeastS()) {
final TypedArray a = context.obtainStyledAttributes(
@@ -90,12 +88,10 @@
mFrameView = findViewById(R.id.frame);
mTextView = (TextView) findViewById(R.id.switch_text);
mSwitch = (Switch) findViewById(android.R.id.switch_widget);
- mBackgroundOn = getContext().getDrawable(
- resourceId(context, "drawable", "settingslib_switch_bar_bg_on"));
- mBackgroundOff = getContext().getDrawable(
- resourceId(context, "drawable", "settingslib_switch_bar_bg_off"));
+ mBackgroundOn = getContext().getDrawable(R.drawable.settingslib_switch_bar_bg_on);
+ mBackgroundOff = getContext().getDrawable(R.drawable.settingslib_switch_bar_bg_off);
mBackgroundDisabled = getContext().getDrawable(
- resourceId(context, "drawable", "settingslib_switch_bar_bg_disabled"));
+ R.drawable.settingslib_switch_bar_bg_disabled);
addOnSwitchChangeListener((switchView, isChecked) -> setChecked(isChecked));
@@ -302,8 +298,4 @@
requestLayout();
}
-
- private int resourceId(Context context, String type, String name) {
- return context.getResources().getIdentifier(name, type, context.getPackageName());
- }
}
diff --git a/packages/SettingsLib/RadioButtonPreference/Android.bp b/packages/SettingsLib/RadioButtonPreference/Android.bp
index b309c01..28ff71f 100644
--- a/packages/SettingsLib/RadioButtonPreference/Android.bp
+++ b/packages/SettingsLib/RadioButtonPreference/Android.bp
@@ -20,4 +20,8 @@
sdk_version: "system_current",
min_sdk_version: "21",
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.permission",
+ ],
}
diff --git a/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/SettingsSpinnerPreference.java b/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/SettingsSpinnerPreference.java
index 154a0f4..304c343 100644
--- a/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/SettingsSpinnerPreference.java
+++ b/packages/SettingsLib/SettingsSpinner/src/com/android/settingslib/widget/SettingsSpinnerPreference.java
@@ -36,6 +36,7 @@
private SettingsSpinnerAdapter mAdapter;
private AdapterView.OnItemSelectedListener mListener;
private int mPosition; //Default 0 for internal shard storage.
+ private boolean mIsClickable = true;
/**
* Perform inflation from XML and apply a class-specific base style.
@@ -50,6 +51,7 @@
public SettingsSpinnerPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setLayoutResource(R.layout.settings_spinner_preference);
+ setSelectable(false);
}
/**
@@ -62,6 +64,7 @@
public SettingsSpinnerPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setLayoutResource(R.layout.settings_spinner_preference);
+ setSelectable(false);
}
/**
@@ -98,10 +101,21 @@
notifyChanged();
}
+ /** Set clickable of the spinner. */
+ public void setClickable(boolean isClickable) {
+ if (mIsClickable == isClickable) {
+ return;
+ }
+ mIsClickable = isClickable;
+ notifyChanged();
+ }
+
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
final SettingsSpinner spinner = (SettingsSpinner) holder.findViewById(R.id.spinner);
+ spinner.setEnabled(mIsClickable);
+ spinner.setClickable(mIsClickable);
spinner.setAdapter(mAdapter);
spinner.setSelection(mPosition);
spinner.setOnItemSelectedListener(mOnSelectedListener);
diff --git a/packages/SettingsLib/TwoTargetPreference/Android.bp b/packages/SettingsLib/TwoTargetPreference/Android.bp
index 078e8c3..b32d5b4 100644
--- a/packages/SettingsLib/TwoTargetPreference/Android.bp
+++ b/packages/SettingsLib/TwoTargetPreference/Android.bp
@@ -19,4 +19,8 @@
],
sdk_version: "system_current",
min_sdk_version: "21",
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.permission",
+ ],
}
diff --git a/packages/SettingsLib/TwoTargetPreference/src/com/android/settingslib/widget/TwoTargetPreference.java b/packages/SettingsLib/TwoTargetPreference/src/com/android/settingslib/widget/TwoTargetPreference.java
index 17f257d..9130662 100644
--- a/packages/SettingsLib/TwoTargetPreference/src/com/android/settingslib/widget/TwoTargetPreference.java
+++ b/packages/SettingsLib/TwoTargetPreference/src/com/android/settingslib/widget/TwoTargetPreference.java
@@ -72,9 +72,9 @@
private void init(Context context) {
setLayoutResource(R.layout.preference_two_target);
mSmallIconSize = context.getResources().getDimensionPixelSize(
- resourceId(context, "dimen", "two_target_pref_small_icon_size"));
+ R.dimen.two_target_pref_small_icon_size);
mMediumIconSize = context.getResources().getDimensionPixelSize(
- resourceId(context, "dimen", "two_target_pref_medium_icon_size"));
+ R.dimen.two_target_pref_medium_icon_size);
final int secondTargetResId = getSecondTargetResId();
if (secondTargetResId != 0) {
setWidgetLayoutResource(secondTargetResId);
@@ -116,8 +116,4 @@
protected int getSecondTargetResId() {
return 0;
}
-
- private int resourceId(Context context, String type, String name) {
- return context.getResources().getIdentifier(name, type, context.getPackageName());
- }
}
diff --git a/packages/SettingsLib/UsageProgressBarPreference/res/layout/preference_usage_progress_bar.xml b/packages/SettingsLib/UsageProgressBarPreference/res/layout/preference_usage_progress_bar.xml
index 8c20e02..ea033a3 100644
--- a/packages/SettingsLib/UsageProgressBarPreference/res/layout/preference_usage_progress_bar.xml
+++ b/packages/SettingsLib/UsageProgressBarPreference/res/layout/preference_usage_progress_bar.xml
@@ -22,8 +22,8 @@
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical"
- android:layout_marginStart="16dp"
- android:layout_marginEnd="16dp"
+ android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
+ android:layout_marginEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingBottom="16dp">
<androidx.constraintlayout.widget.ConstraintLayout
@@ -70,6 +70,7 @@
android:id="@+id/bottom_summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
android:visibility="gone"
android:ellipsize="marquee"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
diff --git a/packages/SettingsLib/res/drawable/ic_no_internet_wifi_signal_0.xml b/packages/SettingsLib/res/drawable/ic_no_internet_wifi_signal_0.xml
new file mode 100644
index 0000000..efae569
--- /dev/null
+++ b/packages/SettingsLib/res/drawable/ic_no_internet_wifi_signal_0.xml
@@ -0,0 +1,30 @@
+<!--
+ Copyright (C) 2021 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 xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M20.66,7C18.19,5.07 15.14,4 12,4C8.58,4 5.27,5.27 2.7,7.53L12,18.85l6,-7.3v3.15L12,22L0,7.39C2.97,4.08 7.25,2 12,2c4.56,0 8.69,1.92 11.64,5H20.66z"/>
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M22,10h-2v8h2V10z"/>
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M22,20h-2v2h2V20z"/>
+</vector>
diff --git a/packages/SettingsLib/res/drawable/ic_no_internet_wifi_signal_1.xml b/packages/SettingsLib/res/drawable/ic_no_internet_wifi_signal_1.xml
new file mode 100644
index 0000000..d50e734
--- /dev/null
+++ b/packages/SettingsLib/res/drawable/ic_no_internet_wifi_signal_1.xml
@@ -0,0 +1,30 @@
+<!--
+ Copyright (C) 2021 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 xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M23.62,7C20.65,3.93 16.6,2 12,2C7.2,2 3,4.1 0,7.4L12,22l6,-7.3v-3.19l-2.13,2.59C14.74,13.4 13.39,13 12,13s-2.74,0.4 -3.87,1.1L2.7,7.5C5.3,5.3 8.6,4 12,4c3.13,0 6.18,1.1 8.68,3H23.62z"/>
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M22,10h-2v8h2V10z"/>
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M22,20h-2v2h2V20z"/>
+</vector>
diff --git a/packages/SettingsLib/res/drawable/ic_no_internet_wifi_signal_2.xml b/packages/SettingsLib/res/drawable/ic_no_internet_wifi_signal_2.xml
new file mode 100644
index 0000000..1be297e
--- /dev/null
+++ b/packages/SettingsLib/res/drawable/ic_no_internet_wifi_signal_2.xml
@@ -0,0 +1,30 @@
+<!--
+ Copyright (C) 2021 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 xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M23.62,7C20.65,3.93 16.6,2 12,2C7.2,2 3,4.1 0,7.4L12,22l6,-7.3v-3.19l-0.27,0.33C16.12,10.67 14.09,10 12,10c-2.09,0 -4.12,0.67 -5.73,1.84L2.7,7.5C5.3,5.3 8.6,4 12,4c3.13,0 6.18,1.1 8.68,3H23.62z"/>
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M22,10h-2v8h2V10z"/>
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M22,20h-2v2h2V20z"/>
+</vector>
diff --git a/packages/SettingsLib/res/drawable/ic_no_internet_wifi_signal_3.xml b/packages/SettingsLib/res/drawable/ic_no_internet_wifi_signal_3.xml
new file mode 100644
index 0000000..738bd5a
--- /dev/null
+++ b/packages/SettingsLib/res/drawable/ic_no_internet_wifi_signal_3.xml
@@ -0,0 +1,30 @@
+<!--
+ Copyright (C) 2021 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 xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M0,7.4L12,22l6,-7.3V8.57C16.21,7.56 14.14,7 12,7C9.2,7 6.53,7.96 4.45,9.62L2.7,7.5C5.3,5.3 8.6,4 12,4c3.13,0 6.18,1.1 8.68,3h2.95C20.65,3.93 16.6,2 12,2C7.2,2 3,4.1 0,7.4z"/>
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M22,10h-2v8h2V10z"/>
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M22,20h-2v2h2V20z"/>
+</vector>
diff --git a/packages/SettingsLib/res/drawable/ic_no_internet_wifi_signal_4.xml b/packages/SettingsLib/res/drawable/ic_no_internet_wifi_signal_4.xml
new file mode 100644
index 0000000..14d020b
--- /dev/null
+++ b/packages/SettingsLib/res/drawable/ic_no_internet_wifi_signal_4.xml
@@ -0,0 +1,30 @@
+<!--
+ Copyright (C) 2021 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 xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M0,7.4C3,4.1 7.2,2 12,2c4.6,0 8.65,1.93 11.62,5H18v7.7L12,22L0,7.4z"/>
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M22,10h-2v8h2V10z"/>
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M22,20h-2v2h2V20z"/>
+</vector>
diff --git a/packages/SettingsLib/res/values-mn/strings.xml b/packages/SettingsLib/res/values-mn/strings.xml
index b96a4f5..e8da28f 100644
--- a/packages/SettingsLib/res/values-mn/strings.xml
+++ b/packages/SettingsLib/res/values-mn/strings.xml
@@ -118,7 +118,7 @@
<string name="bluetooth_pairing_decline" msgid="6483118841204885890">"Цуцлах"</string>
<string name="bluetooth_pairing_will_share_phonebook" msgid="3064334458659165176">"Хослуулснаар холбогдсон үед таны харилцагчид болон дуудлагын түүхэд хандах боломжтой."</string>
<string name="bluetooth_pairing_error_message" msgid="6626399020672335565">"<xliff:g id="DEVICE_NAME">%1$s</xliff:g>-тай хослуулж чадсангүй."</string>
- <string name="bluetooth_pairing_pin_error_message" msgid="264422127613704940">"Буруу PIN эсхүл дамжих түлхүүрээс шалтгаалан <xliff:g id="DEVICE_NAME">%1$s</xliff:g>-тай хослуулж чадсангүй."</string>
+ <string name="bluetooth_pairing_pin_error_message" msgid="264422127613704940">"Буруу ПИН эсхүл дамжих түлхүүрээс шалтгаалан <xliff:g id="DEVICE_NAME">%1$s</xliff:g>-тай хослуулж чадсангүй."</string>
<string name="bluetooth_pairing_device_down_error_message" msgid="2554424863101358857">"<xliff:g id="DEVICE_NAME">%1$s</xliff:g>-тай холбоо барих боломжгүй."</string>
<string name="bluetooth_pairing_rejected_error_message" msgid="5943444352777314442">"Хослуулахаас <xliff:g id="DEVICE_NAME">%1$s</xliff:g> татгалзсан."</string>
<string name="bluetooth_talkback_computer" msgid="3736623135703893773">"Компьютер"</string>
diff --git a/packages/SettingsLib/res/values-ne/strings.xml b/packages/SettingsLib/res/values-ne/strings.xml
index ca185e2..645248c 100644
--- a/packages/SettingsLib/res/values-ne/strings.xml
+++ b/packages/SettingsLib/res/values-ne/strings.xml
@@ -504,7 +504,7 @@
<string name="cancel" msgid="5665114069455378395">"रद्द गर्नुहोस्"</string>
<string name="okay" msgid="949938843324579502">"ठिक छ"</string>
<string name="alarms_and_reminders_label" msgid="6918395649731424294">"अलार्म र रिमाइन्डरहरू"</string>
- <string name="alarms_and_reminders_switch_title" msgid="4939393911531826222">"अलार्म तथा रिमाइन्डर सेट गर्न दिनुहोस्"</string>
+ <string name="alarms_and_reminders_switch_title" msgid="4939393911531826222">"अलार्म तथा रिमाइन्डर सेट गर्न दिइयोस्"</string>
<string name="alarms_and_reminders_title" msgid="8819933264635406032">"घडी तथा रिमाइन्डरहरू"</string>
<string name="alarms_and_reminders_footer_title" product="default" msgid="1122213569699233612">"यो एपलाई अलार्म सेट गर्न तथा अन्य कार्यको समयतालिका तोक्न दिनुहोस्। तपाईंले आफ्नो फोन नचलाएका बेला पनि यो एप प्रयोग गरिन सक्छ। यसले गर्दा थप ब्याट्री खपत हुन सक्छ। यो अनुमति नदिइएका खण्डमा यो एप राम्ररी नचल्न सक्छ र यो एपका अलार्म पनि तोकिएको समयमा बज्ने छैनन्।"</string>
<string name="alarms_and_reminders_footer_title" product="tablet" msgid="4596201244991057839">"यो एपलाई अलार्म सेट गर्न तथा अन्य कार्यको समयतालिका तोक्न दिनुहोस्। तपाईंले आफ्नो ट्याब्लेट नचलाएका बेला पनि यो एप प्रयोग गरिन सक्छ। यसले गर्दा थप ब्याट्री खपत हुन सक्छ। यो अनुमति नदिइएका खण्डमा यो एप राम्ररी नचल्न सक्छ र यो एपका अलार्म पनि तोकिएको समयमा बज्ने छैनन्।"</string>
diff --git a/packages/SettingsLib/res/values/strings.xml b/packages/SettingsLib/res/values/strings.xml
index 08d87df..404299a 100644
--- a/packages/SettingsLib/res/values/strings.xml
+++ b/packages/SettingsLib/res/values/strings.xml
@@ -1147,8 +1147,8 @@
<string name="battery_info_status_charging_wireless">Charging wirelessly</string>
<!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="battery_info_status_discharging">Not charging</string>
- <!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
- <string name="battery_info_status_not_charging">Plugged in, can\'t charge right now</string>
+ <!-- Battery Info screen. Value for a status item. A state which device is connected with any charger(e.g. USB, Adapter or Wireless) but not charging yet. Used for diagnostic info screens, precise translation isn't needed -->
+ <string name="battery_info_status_not_charging">Connected, not charging</string>
<!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="battery_info_status_full">Charged</string>
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiEntryPreference.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiEntryPreference.java
index 9889419..4dd3ff1 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiEntryPreference.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiEntryPreference.java
@@ -187,8 +187,9 @@
}
protected int getIconColorAttr() {
- return (mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED)
- ? android.R.attr.colorAccent : android.R.attr.colorControlNormal;
+ final boolean accent = (mWifiEntry.hasInternetAccess()
+ && mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED);
+ return accent ? android.R.attr.colorAccent : android.R.attr.colorControlNormal;
}
private void updateIcon(boolean showX, int level) {
@@ -267,7 +268,7 @@
}
public Drawable getIcon(boolean showX, int level) {
- return mContext.getDrawable(Utils.getWifiIconResource(showX, level));
+ return mContext.getDrawable(WifiUtils.getInternetIconResource(level, showX));
}
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiUtils.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiUtils.java
index 15b146d..6100615 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiUtils.java
@@ -36,6 +36,22 @@
private static final int INVALID_RSSI = -127;
+ static final int[] WIFI_PIE = {
+ com.android.internal.R.drawable.ic_wifi_signal_0,
+ com.android.internal.R.drawable.ic_wifi_signal_1,
+ com.android.internal.R.drawable.ic_wifi_signal_2,
+ com.android.internal.R.drawable.ic_wifi_signal_3,
+ com.android.internal.R.drawable.ic_wifi_signal_4
+ };
+
+ static final int[] NO_INTERNET_WIFI_PIE = {
+ R.drawable.ic_no_internet_wifi_signal_0,
+ R.drawable.ic_no_internet_wifi_signal_1,
+ R.drawable.ic_no_internet_wifi_signal_2,
+ R.drawable.ic_no_internet_wifi_signal_3,
+ R.drawable.ic_no_internet_wifi_signal_4
+ };
+
public static String buildLoggingSummary(AccessPoint accessPoint, WifiConfiguration config) {
final StringBuilder summary = new StringBuilder();
final WifiInfo info = accessPoint.getInfo();
@@ -245,6 +261,20 @@
return context.getString(R.string.wifi_unmetered_label);
}
+ /**
+ * Returns the Internet icon resource for a given RSSI level.
+ *
+ * @param level The number of bars to show (0-4)
+ * @param noInternet True if a connected Wi-Fi network cannot access the Internet
+ * @throws IllegalArgumentException if an invalid RSSI level is given.
+ */
+ public static int getInternetIconResource(int level, boolean noInternet) {
+ if (level < 0 || level >= WIFI_PIE.length) {
+ throw new IllegalArgumentException("No Wifi icon found for level: " + level);
+ }
+ return noInternet ? NO_INTERNET_WIFI_PIE[level] : WIFI_PIE[level];
+ }
+
public static boolean isMeteredOverridden(WifiConfiguration config) {
return config.meteredOverride != WifiConfiguration.METERED_OVERRIDE_NONE;
}
diff --git a/packages/SettingsLib/tests/integ/src/com/android/settingslib/widget/SettingsSpinnerPreferenceTest.java b/packages/SettingsLib/tests/integ/src/com/android/settingslib/widget/SettingsSpinnerPreferenceTest.java
index 53a382a..b0c5314 100644
--- a/packages/SettingsLib/tests/integ/src/com/android/settingslib/widget/SettingsSpinnerPreferenceTest.java
+++ b/packages/SettingsLib/tests/integ/src/com/android/settingslib/widget/SettingsSpinnerPreferenceTest.java
@@ -89,4 +89,24 @@
assertThat(mSpinnerPreference.getSelectedItem())
.isEqualTo(mSpinner.getAdapter().getItem(1));
}
+
+ @Test
+ public void onBindViewHolder_setClickableTrue_isClickableTrue() {
+ mSpinnerPreference.setClickable(true);
+
+ mSpinnerPreference.onBindViewHolder(mViewHolder);
+
+ assertThat(mSpinner.isClickable()).isTrue();
+ assertThat(mSpinner.isEnabled()).isTrue();
+ }
+
+ @Test
+ public void onBindViewHolder_setClickableFalse_isClickableFalse() {
+ mSpinnerPreference.setClickable(false);
+
+ mSpinnerPreference.onBindViewHolder(mViewHolder);
+
+ assertThat(mSpinner.isClickable()).isFalse();
+ assertThat(mSpinner.isEnabled()).isFalse();
+ }
}
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/IllustrationPreferenceTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/IllustrationPreferenceTest.java
new file mode 100644
index 0000000..4a14403
--- /dev/null
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/IllustrationPreferenceTest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2021 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.settingslib.widget;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.util.AttributeSet;
+
+import com.airbnb.lottie.LottieAnimationView;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(RobolectricTestRunner.class)
+public class IllustrationPreferenceTest {
+
+ @Mock
+ LottieAnimationView mAnimationView;
+
+ private IllustrationPreference mPreference;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ final Context context = RuntimeEnvironment.application;
+ final AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
+ mPreference = new IllustrationPreference(context, attributeSet);
+ ReflectionHelpers.setField(mPreference, "mIllustrationView", mAnimationView);
+ }
+
+ @Test
+ public void isAnimating_lottieAnimationViewIsNotAnimating_shouldReturnFalse() {
+ when(mAnimationView.isAnimating()).thenReturn(false);
+
+ assertThat(mPreference.isAnimating()).isFalse();
+ }
+
+ @Test
+ public void isAnimating_lottieAnimationViewIsAnimating_shouldReturnTrue() {
+ when(mAnimationView.isAnimating()).thenReturn(true);
+
+ assertThat(mPreference.isAnimating()).isTrue();
+ }
+}
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 941f47f..3219b2b 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -34,8 +34,11 @@
import android.app.ActivityManager;
import android.app.AppGlobals;
import android.app.backup.BackupManager;
+import android.app.compat.CompatChanges;
import android.app.job.JobInfo;
import android.app.job.JobScheduler;
+import android.compat.annotation.ChangeId;
+import android.compat.annotation.EnabledSince;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentProvider;
@@ -350,6 +353,9 @@
public static String keyToString(int key) {
return SettingsState.keyToString(key);
}
+ @ChangeId
+ @EnabledSince(targetSdkVersion=android.os.Build.VERSION_CODES.S)
+ private static final long ENFORCE_READ_PERMISSION_FOR_MULTI_SIM_DATA_CALL = 172670679L;
@Override
public boolean onCreate() {
@@ -1950,6 +1956,25 @@
// Skip checking readable annotations for test_only apps
checkReadableAnnotation(settingsType, settingName);
}
+ /**
+ * some settings need additional permission check, this is to have a matching security
+ * control from other API alternatives returning the same settings values.
+ * note, the permission enforcement should be based on app's targetSDKlevel to better handle
+ * app-compat.
+ */
+ switch (settingName) {
+ // missing READ_PRIVILEGED_PHONE_STATE permission protection
+ // see alternative API {@link SubscriptionManager#getPreferredDataSubscriptionId()
+ case Settings.Global.MULTI_SIM_DATA_CALL_SUBSCRIPTION:
+ // app-compat handling, not break apps targeting on previous SDKs.
+ if (CompatChanges.isChangeEnabled(
+ ENFORCE_READ_PERMISSION_FOR_MULTI_SIM_DATA_CALL)) {
+ getContext().enforceCallingOrSelfPermission(
+ Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
+ "access global settings MULTI_SIM_DATA_CALL_SUBSCRIPTION");
+ }
+ break;
+ }
if (!ai.isInstantApp()) {
return;
}
@@ -4919,6 +4944,15 @@
String.valueOf(defAccessibilityButtonMode), /* tag= */
null, /* makeDefault= */ true,
SettingsState.SYSTEM_PACKAGE_NAME);
+
+ if (hasValueInA11yButtonTargets(secureSettings)) {
+ secureSettings.insertSettingLocked(
+ Secure.ACCESSIBILITY_FLOATING_MENU_MIGRATION_TOOLTIP_PROMPT,
+ /* enabled */ "1",
+ /* tag= */ null,
+ /* makeDefault= */ false,
+ SettingsState.SYSTEM_PACKAGE_NAME);
+ }
}
}
@@ -5145,13 +5179,21 @@
}
private boolean isAccessibilityButtonInNavigationBarOn(SettingsState secureSettings) {
- final boolean hasValueInA11yBtnTargets = !TextUtils.isEmpty(
- secureSettings.getSettingLocked(
- Secure.ACCESSIBILITY_BUTTON_TARGETS).getValue());
+ return hasValueInA11yButtonTargets(secureSettings) && !isGestureNavigateEnabled();
+ }
+
+ private boolean isGestureNavigateEnabled() {
final int navigationMode = getContext().getResources().getInteger(
com.android.internal.R.integer.config_navBarInteractionMode);
+ return navigationMode == NAV_BAR_MODE_GESTURAL;
+ }
- return hasValueInA11yBtnTargets && (navigationMode != NAV_BAR_MODE_GESTURAL);
+ private boolean hasValueInA11yButtonTargets(SettingsState secureSettings) {
+ final Setting a11yButtonTargetsSettings =
+ secureSettings.getSettingLocked(Secure.ACCESSIBILITY_BUTTON_TARGETS);
+
+ return !a11yButtonTargetsSettings.isNull()
+ && !TextUtils.isEmpty(a11yButtonTargetsSettings.getValue());
}
}
}
diff --git a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
index 22e38f4..3a82434 100644
--- a/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
+++ b/packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java
@@ -752,6 +752,7 @@
Settings.Secure.SUPPRESS_DOZE,
Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED,
Settings.Secure.ACCESSIBILITY_SHOW_WINDOW_MAGNIFICATION_PROMPT,
+ Settings.Secure.ACCESSIBILITY_FLOATING_MENU_MIGRATION_TOOLTIP_PROMPT,
Settings.Secure.UI_TRANSLATION_ENABLED);
@Test
diff --git a/packages/SystemUI/res/drawable/accessibility_floating_tooltip_background.xml b/packages/SystemUI/res/drawable/accessibility_floating_tooltip_background.xml
new file mode 100644
index 0000000..46e7dcc
--- /dev/null
+++ b/packages/SystemUI/res/drawable/accessibility_floating_tooltip_background.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 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.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ android:shape="rectangle">
+ <solid android:color="?androidprv:attr/colorAccentPrimary" />
+ <corners android:radius="@dimen/accessibility_floating_tooltip_text_corner_radius" />
+</shape>
diff --git a/packages/SystemUI/res/drawable/ic_conversation_icon.xml b/packages/SystemUI/res/drawable/ic_conversation_icon.xml
new file mode 100644
index 0000000..0e3533b
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_conversation_icon.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 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 xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48dp"
+ android:height="48dp"
+ android:viewportWidth="48"
+ android:viewportHeight="48">
+ <path
+ android:pathData="M24,24m-24,0a24,24 0,1 1,48 0a24,24 0,1 1,-48 0"
+ android:fillColor="#81C995"/>
+ <path
+ android:pathData="M27,34C23.134,34 20,30.866 20,27C20,23.134 23.134,20 27,20C30.866,20 34,23.134 34,27C34,28.4872 33.5362,29.8662 32.7453,31"
+ android:strokeWidth="2"
+ android:fillColor="#00000000"
+ android:strokeColor="#3C4043"/>
+ <path
+ android:pathData="M35,33l-8,0l-0,2l8,0z"
+ android:fillColor="#3C4043"/>
+ <path
+ android:pathData="M21,21m-6,0a6,6 0,1 1,12 0a6,6 0,1 1,-12 0"
+ android:fillColor="#81C995"/>
+ <path
+ android:pathData="M16,25h5v2h-5z"
+ android:fillColor="#81C995"/>
+ <path
+ android:pathData="M21,28C24.866,28 28,24.866 28,21C28,17.134 24.866,14 21,14C17.134,14 14,17.134 14,21C14,22.4872 14.4638,23.8662 15.2547,25"
+ android:strokeWidth="2"
+ android:fillColor="#00000000"
+ android:strokeColor="#ffffff"/>
+ <path
+ android:pathData="M13,27h8v2h-8z"
+ android:fillColor="#ffffff"/>
+</vector>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/ic_corp_badge_off.xml b/packages/SystemUI/res/drawable/ic_corp_badge_off.xml
new file mode 100644
index 0000000..a441fb2
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_corp_badge_off.xml
@@ -0,0 +1,28 @@
+<!--
+ ~ Copyright (C) 2021 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 xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="20dp"
+ android:height="20dp"
+ android:viewportWidth="20.0"
+ android:viewportHeight="20.0">
+ <path
+ android:pathData="M10,10m-10,0a10,10 0,1 1,20 0a10,10 0,1 1,-20 0"
+ android:fillColor="#607D8B"/>
+ <path
+ android:pathData="M16.42,15.68l-0.85,-0.85L7.21,6.47L4.9,4.16L4.16,4.9l1.57,1.57H5.36c-0.65,0 -1.16,0.52 -1.16,1.17L4.2,14.05c0,0.65 0.52,1.17 1.17,1.17h9.12l1.2,1.2L16.42,15.68zM15.83,7.64c0.03,-0.65 -0.49,-1.17 -1.14,-1.14h-2.33V5.3c0,-0.65 -0.52,-1.17 -1.17,-1.14H8.86C8.22,4.14 7.7,4.66 7.7,5.3v0.19l8.14,8.17V7.64zM11.2,6.5H8.83V5.3h2.36V6.5z"
+ android:fillColor="#FFFFFF"/>
+</vector>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/people_tile_empty_background.xml b/packages/SystemUI/res/drawable/people_tile_empty_background.xml
new file mode 100644
index 0000000..2dac740
--- /dev/null
+++ b/packages/SystemUI/res/drawable/people_tile_empty_background.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 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.
+ -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
+ <solid android:color="?androidprv:attr/colorSurface" />
+ <corners android:radius="@dimen/people_space_widget_radius" />
+</shape>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/people_tile_status_scrim.xml b/packages/SystemUI/res/drawable/people_tile_status_scrim.xml
new file mode 100644
index 0000000..cf16f1c
--- /dev/null
+++ b/packages/SystemUI/res/drawable/people_tile_status_scrim.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2021 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.
+ -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
+ <gradient
+ android:type="linear"
+ android:angle="90"
+ android:endColor="@android:color/transparent"
+ android:startColor="?androidprv:attr/colorSurfaceHeader" />
+</shape>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/people_tile_suppressed_background.xml b/packages/SystemUI/res/drawable/people_tile_suppressed_background.xml
new file mode 100644
index 0000000..e0c111d
--- /dev/null
+++ b/packages/SystemUI/res/drawable/people_tile_suppressed_background.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 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.
+ -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
+ <solid android:color="?androidprv:attr/colorSurfaceVariant" />
+ <corners android:radius="@dimen/people_space_widget_radius" />
+</shape>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/wallet_action_button_bg.xml b/packages/SystemUI/res/drawable/wallet_action_button_bg.xml
index bf7625f..925ab67 100644
--- a/packages/SystemUI/res/drawable/wallet_action_button_bg.xml
+++ b/packages/SystemUI/res/drawable/wallet_action_button_bg.xml
@@ -14,13 +14,14 @@
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
<item>
<shape android:shape="rectangle">
<stroke
android:width="1dp"
- android:color="@color/GM2_blue_600"/>
- <solid android:color="@color/GM2_blue_600"/>
+ android:color="?androidprv:attr/colorAccentPrimary"/>
+ <solid android:color="?androidprv:attr/colorAccentPrimary"/>
<corners android:radius="24dp"/>
</shape>
</item>
diff --git a/packages/SystemUI/res/drawable/wallet_empty_state_bg.xml b/packages/SystemUI/res/drawable/wallet_empty_state_bg.xml
index f52889a..b203228 100644
--- a/packages/SystemUI/res/drawable/wallet_empty_state_bg.xml
+++ b/packages/SystemUI/res/drawable/wallet_empty_state_bg.xml
@@ -15,7 +15,7 @@
~ limitations under the License.
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="?android:attr/colorControlHighlight">
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="#DADCE0" />
@@ -26,7 +26,7 @@
<shape>
<stroke
android:width="1dp"
- android:color="@color/GM2_grey_900" />
+ android:color="?androidprv:attr/colorAccentPrimary" />
<corners android:radius="@dimen/wallet_empty_state_corner_radius" />
</shape>
</item>
diff --git a/packages/SystemUI/res/layout/accessibility_floating_menu_tooltip.xml b/packages/SystemUI/res/layout/accessibility_floating_menu_tooltip.xml
new file mode 100644
index 0000000..5e7b7e1
--- /dev/null
+++ b/packages/SystemUI/res/layout/accessibility_floating_menu_tooltip.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/tooltip"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <View
+ android:id="@+id/arrow_left"
+ android:layout_width="@dimen/accessibility_floating_tooltip_arrow_width"
+ android:layout_height="@dimen/accessibility_floating_tooltip_arrow_height"
+ android:layout_marginRight="@dimen/accessibility_floating_tooltip_arrow_margin"
+ android:visibility="gone"
+ android:layout_gravity="center_vertical"/>
+
+ <TextView
+ android:id="@+id/text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:padding="@dimen/accessibility_floating_tooltip_padding"
+ android:background="@drawable/accessibility_floating_tooltip_background"
+ android:textColor="@android:color/black"
+ android:textColorLink="@android:color/black"
+ android:text="@string/accessibility_floating_button_migration_tooltip"
+ android:textSize="@dimen/accessibility_floating_tooltip_font_size"/>
+
+ <View
+ android:id="@+id/arrow_right"
+ android:layout_width="@dimen/accessibility_floating_tooltip_arrow_width"
+ android:layout_height="@dimen/accessibility_floating_tooltip_arrow_height"
+ android:layout_marginLeft="@dimen/accessibility_floating_tooltip_arrow_margin"
+ android:visibility="gone"
+ android:layout_gravity="center_vertical"/>
+</LinearLayout>
diff --git a/packages/SystemUI/res/layout/long_screenshot.xml b/packages/SystemUI/res/layout/long_screenshot.xml
index ceba4e3..b99c86f 100644
--- a/packages/SystemUI/res/layout/long_screenshot.xml
+++ b/packages/SystemUI/res/layout/long_screenshot.xml
@@ -126,8 +126,8 @@
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/save"
app:layout_constraintStart_toStartOf="parent"
- android:scaleType="matrix"
- android:visibility="gone"
+ android:scaleType="centerCrop"
+ android:visibility="invisible"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/packages/SystemUI/res/layout/media_smartspace_recommendations.xml b/packages/SystemUI/res/layout/media_smartspace_recommendations.xml
index 8c54e2c..9e67258 100644
--- a/packages/SystemUI/res/layout/media_smartspace_recommendations.xml
+++ b/packages/SystemUI/res/layout/media_smartspace_recommendations.xml
@@ -75,7 +75,7 @@
android:id="@+id/media_logo1"
android:layout_width="@dimen/qs_media_icon_size"
android:layout_height="@dimen/qs_media_icon_size"
- style="@style/MediaPlayer.AppIcon" />
+ style="@style/MediaPlayer.AppIcon.Recommendation" />
<ImageView
android:id="@+id/media_cover2"
@@ -91,7 +91,7 @@
android:id="@+id/media_logo2"
android:layout_width="@dimen/qs_media_icon_size"
android:layout_height="@dimen/qs_media_icon_size"
- style="@style/MediaPlayer.AppIcon" />
+ style="@style/MediaPlayer.AppIcon.Recommendation" />
<ImageView
android:id="@+id/media_cover3"
@@ -107,7 +107,7 @@
android:id="@+id/media_logo3"
android:layout_width="@dimen/qs_media_icon_size"
android:layout_height="@dimen/qs_media_icon_size"
- style="@style/MediaPlayer.AppIcon" />
+ style="@style/MediaPlayer.AppIcon.Recommendation" />
<ImageView
android:id="@+id/media_cover4"
@@ -123,7 +123,7 @@
android:id="@+id/media_logo4"
android:layout_width="@dimen/qs_media_icon_size"
android:layout_height="@dimen/qs_media_icon_size"
- style="@style/MediaPlayer.AppIcon" />
+ style="@style/MediaPlayer.AppIcon.Recommendation" />
<ImageView
android:id="@+id/media_cover5"
@@ -139,7 +139,7 @@
android:id="@+id/media_logo5"
android:layout_width="@dimen/qs_media_icon_size"
android:layout_height="@dimen/qs_media_icon_size"
- style="@style/MediaPlayer.AppIcon" />
+ style="@style/MediaPlayer.AppIcon.Recommendation" />
<ImageView
android:id="@+id/media_cover6"
@@ -155,7 +155,7 @@
android:id="@+id/media_logo6"
android:layout_width="@dimen/qs_media_icon_size"
android:layout_height="@dimen/qs_media_icon_size"
- style="@style/MediaPlayer.AppIcon" />
+ style="@style/MediaPlayer.AppIcon.Recommendation" />
<!-- Long press menu -->
<TextView
diff --git a/packages/SystemUI/res/layout/ongoing_call_chip.xml b/packages/SystemUI/res/layout/ongoing_call_chip.xml
index a146547..90214b7 100644
--- a/packages/SystemUI/res/layout/ongoing_call_chip.xml
+++ b/packages/SystemUI/res/layout/ongoing_call_chip.xml
@@ -23,6 +23,7 @@
android:background="@drawable/ongoing_call_chip_bg"
android:paddingStart="@dimen/ongoing_call_chip_side_padding"
android:paddingEnd="@dimen/ongoing_call_chip_side_padding"
+ android:contentDescription="@string/ongoing_phone_call_content_description"
>
<ImageView
diff --git a/packages/SystemUI/res/layout/people_status_scrim_layout.xml b/packages/SystemUI/res/layout/people_status_scrim_layout.xml
new file mode 100644
index 0000000..9808f74
--- /dev/null
+++ b/packages/SystemUI/res/layout/people_status_scrim_layout.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+~ Copyright (C) 2021 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.
+-->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/scrim_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <ImageView
+ android:id="@+id/status_icon"
+ android:scaleType="centerCrop"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:weightSum="1"
+ android:orientation="vertical">
+ <ImageView
+ android:layout_weight=".2"
+ android:layout_width="match_parent"
+ android:layout_height="0dp" />
+ <ImageView
+ android:background="@drawable/people_tile_status_scrim"
+ android:layout_weight=".8"
+ android:scaleType="centerCrop"
+ android:layout_width="match_parent"
+ android:layout_height="0dp" />
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:weightSum="1"
+ android:orientation="vertical">
+ <ImageView
+ android:layout_weight=".66"
+ android:layout_width="match_parent"
+ android:layout_height="0dp" />
+ <ImageView
+ android:background="@drawable/people_tile_status_scrim"
+ android:layout_weight=".33"
+ android:layout_width="match_parent"
+ android:layout_height="0dp" />
+ </LinearLayout>
+</RelativeLayout>
diff --git a/packages/SystemUI/res/layout/people_tile_empty_layout.xml b/packages/SystemUI/res/layout/people_tile_empty_layout.xml
index 7d3b919..8e9ebc6 100644
--- a/packages/SystemUI/res/layout/people_tile_empty_layout.xml
+++ b/packages/SystemUI/res/layout/people_tile_empty_layout.xml
@@ -14,16 +14,17 @@
~ limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/item"
android:theme="@android:style/Theme.DeviceDefault.DayNight"
- android:background="@drawable/people_space_tile_view_card"
+ android:background="@drawable/people_tile_empty_background"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
- android:id="@+id/item"
+ android:id="@+id/icon"
+ android:src="@drawable/ic_conversation_icon"
android:gravity="center"
android:layout_gravity="center"
- android:padding="8dp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
+ android:layout_width="48dp"
+ android:layout_height="48dp"/>
</FrameLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/people_tile_large_with_content.xml b/packages/SystemUI/res/layout/people_tile_large_with_content.xml
index 6f8de3b..b77670e 100644
--- a/packages/SystemUI/res/layout/people_tile_large_with_content.xml
+++ b/packages/SystemUI/res/layout/people_tile_large_with_content.xml
@@ -1,145 +1,159 @@
<?xml version="1.0" encoding="utf-8"?><!--
- ~ Copyright (C) 2021 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.
- -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:theme="@android:style/Theme.DeviceDefault.DayNight"
- android:id="@+id/item"
+~ Copyright (C) 2021 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.
+-->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/people_space_tile_view_card"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:id="@+id/item"
+ android:clipToOutline="true"
+ android:theme="@android:style/Theme.DeviceDefault.DayNight"
android:layout_gravity="center"
- android:padding="16dp"
- android:orientation="vertical">
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
- <RelativeLayout
+ <include layout="@layout/people_status_scrim_layout" />
+
+ <LinearLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="start|top">
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:padding="16dp"
+ android:orientation="vertical">
- <LinearLayout
- android:layout_width="wrap_content"
+ <RelativeLayout
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_alignParentStart="true"
- android:gravity="start|top"
- android:orientation="horizontal">
+ android:gravity="start|top">
- <ImageView
- android:id="@+id/person_icon"
- android:layout_marginStart="-2dp"
- android:layout_marginTop="-2dp"
+ <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_weight="1" />
+ android:layout_alignParentStart="true"
+ android:gravity="start|top"
+ android:orientation="horizontal">
- <ImageView
- android:id="@+id/availability"
- android:layout_marginStart="-2dp"
- android:layout_width="10dp"
- android:layout_height="10dp"
- android:background="@drawable/circle_green_10dp" />
- </LinearLayout>
+ <ImageView
+ android:id="@+id/person_icon"
+ android:layout_marginStart="-2dp"
+ android:layout_marginTop="-2dp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" />
- <TextView
- android:id="@+id/messages_count"
- android:layout_alignParentEnd="true"
- android:paddingStart="8dp"
- android:paddingEnd="8dp"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
- android:textColor="?android:attr/textColorPrimary"
- android:background="@drawable/people_space_messages_count_background"
- android:textSize="14sp"
- android:maxLines="1"
- android:ellipsize="end"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:visibility="gone"
- />
- </RelativeLayout>
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <include layout="@layout/people_tile_punctuation_background_large" />
- <include layout="@layout/people_tile_emoji_background_large" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <TextView
- android:layout_gravity="center"
- android:id="@+id/name"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingBottom="12dp"
- android:gravity="start"
- android:singleLine="true"
- android:ellipsize="end"
- android:text="@string/empty_user_name"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
- android:textColor="?android:attr/textColorPrimary"
- android:textSize="14sp" />
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingBottom="4dp"
- android:gravity="center_vertical"
- android:orientation="horizontal">
-
- <ImageView
- android:id="@+id/predefined_icon"
- android:tint="?android:attr/colorAccent"
- android:gravity="start|center_vertical"
- android:paddingEnd="6dp"
- android:layout_width="24dp"
- android:layout_height="18dp" />
+ <ImageView
+ android:id="@+id/availability"
+ android:layout_marginStart="-2dp"
+ android:layout_width="10dp"
+ android:layout_height="10dp"
+ android:background="@drawable/circle_green_10dp" />
+ </LinearLayout>
<TextView
- android:layout_gravity="center"
- android:id="@+id/subtext"
- android:gravity="center_vertical"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ellipsize="end"
- android:singleLine="true"
- android:text="@string/empty_user_name"
+ android:id="@+id/messages_count"
+ android:layout_alignParentEnd="true"
+ android:paddingStart="8dp"
+ android:paddingEnd="8dp"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
- android:textColor="?android:attr/textColorSecondary"
- android:textSize="12sp" />
- </LinearLayout>
+ android:textColor="?android:attr/textColorPrimary"
+ android:background="@drawable/people_space_messages_count_background"
+ android:textSize="14sp"
+ android:maxLines="1"
+ android:ellipsize="end"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:visibility="gone" />
+ </RelativeLayout>
- <ImageView
- android:id="@+id/image"
+ <RelativeLayout
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/people_space_content_background"
- android:gravity="center"
- android:scaleType="centerCrop" />
+ android:layout_height="match_parent">
- <TextView
- android:layout_gravity="center"
- android:id="@+id/text_content"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ellipsize="end"
- android:maxLines="2"
- android:singleLine="false"
- android:text="@string/empty_status"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
- android:textColor="?android:attr/textColorPrimary"
- android:textSize="12sp" />
- </LinearLayout>
- </RelativeLayout>
-</LinearLayout>
+ <include layout="@layout/people_tile_punctuation_background_large" />
+
+ <include layout="@layout/people_tile_emoji_background_large" />
+
+ <LinearLayout
+ android:id="@+id/content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_gravity="center"
+ android:id="@+id/name"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingBottom="12dp"
+ android:gravity="start"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:text="@string/empty_user_name"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textSize="14sp" />
+
+ <LinearLayout
+ android:id="@+id/status_icon_and_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingBottom="4dp"
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/predefined_icon"
+ android:tint="?android:attr/colorAccent"
+ android:gravity="start|center_vertical"
+ android:paddingEnd="6dp"
+ android:layout_width="24dp"
+ android:layout_height="18dp" />
+
+ <TextView
+ android:layout_gravity="center"
+ android:id="@+id/subtext"
+ android:gravity="center_vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:text="@string/empty_user_name"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
+ android:textColor="?android:attr/textColorSecondary"
+ android:textSize="12sp" />
+ </LinearLayout>
+
+ <ImageView
+ android:id="@+id/image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@drawable/people_space_content_background"
+ android:gravity="center"
+ android:scaleType="centerCrop" />
+
+ <TextView
+ android:layout_gravity="center"
+ android:id="@+id/text_content"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="2"
+ android:singleLine="false"
+ android:text="@string/empty_status"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textSize="@dimen/content_text_size_for_large" />
+ </LinearLayout>
+ </RelativeLayout>
+ </LinearLayout>
+</RelativeLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/people_tile_medium_with_content.xml b/packages/SystemUI/res/layout/people_tile_medium_with_content.xml
index a8c15ab..8df0bf8 100644
--- a/packages/SystemUI/res/layout/people_tile_medium_with_content.xml
+++ b/packages/SystemUI/res/layout/people_tile_medium_with_content.xml
@@ -17,18 +17,20 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:theme="@android:style/Theme.DeviceDefault.DayNight"
+ android:id="@+id/item"
+ android:background="@drawable/people_space_tile_view_card"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
- android:background="@drawable/people_space_tile_view_card"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/people_tile_punctuation_background_medium" />
- <include layout="@layout/people_tile_emoji_background_medium" />
+ <include layout="@layout/people_tile_punctuation_background_medium" />
+ <include layout="@layout/people_status_scrim_layout" />
<LinearLayout
- android:id="@+id/item"
+ android:id="@+id/content"
android:orientation="vertical"
android:layout_gravity="center"
android:padding="8dp"
@@ -89,7 +91,7 @@
android:text="@string/empty_status"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
android:textColor="?android:attr/textColorPrimary"
- android:textSize="12sp"
+ android:textSize="@dimen/content_text_size_for_medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="2"
diff --git a/packages/SystemUI/res/layout/people_tile_suppressed_layout.xml b/packages/SystemUI/res/layout/people_tile_suppressed_layout.xml
new file mode 100644
index 0000000..b151c60
--- /dev/null
+++ b/packages/SystemUI/res/layout/people_tile_suppressed_layout.xml
@@ -0,0 +1,29 @@
+<!--
+ ~ Copyright (C) 2021 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/item"
+ android:theme="@android:style/Theme.DeviceDefault.DayNight"
+ android:background="@drawable/people_tile_suppressed_background"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <ImageView
+ android:id="@+id/icon"
+ android:gravity="center"
+ android:layout_gravity="center"
+ android:layout_width="48dp"
+ android:layout_height="48dp"/>
+</FrameLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/people_tile_work_profile_quiet_layout.xml b/packages/SystemUI/res/layout/people_tile_work_profile_quiet_layout.xml
new file mode 100644
index 0000000..25ab5a6
--- /dev/null
+++ b/packages/SystemUI/res/layout/people_tile_work_profile_quiet_layout.xml
@@ -0,0 +1,39 @@
+<!--
+ ~ Copyright (C) 2021 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"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ android:id="@+id/item"
+ android:theme="@android:style/Theme.DeviceDefault.DayNight"
+ android:background="@drawable/people_tile_suppressed_background"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <ImageView
+ android:id="@+id/icon"
+ android:gravity="center"
+ android:layout_gravity="center"
+ android:layout_width="48dp"
+ android:layout_height="48dp"/>
+
+ <ImageView android:id="@+id/work_widget_badge_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|right"
+ android:layout_marginBottom="12dp"
+ android:layout_marginRight="12dp"
+ android:src="@drawable/ic_corp_badge_off"
+ android:clickable="false" />
+</FrameLayout>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/qs_detail.xml b/packages/SystemUI/res/layout/qs_detail.xml
index f056402..59e1a75 100644
--- a/packages/SystemUI/res/layout/qs_detail.xml
+++ b/packages/SystemUI/res/layout/qs_detail.xml
@@ -23,7 +23,6 @@
android:clickable="true"
android:orientation="vertical"
android:layout_marginTop="@*android:dimen/quick_qs_offset_height"
- android:layout_marginBottom="@dimen/qs_container_bottom_padding"
android:paddingBottom="8dp"
android:visibility="invisible"
android:elevation="4dp"
diff --git a/packages/SystemUI/res/layout/qs_panel.xml b/packages/SystemUI/res/layout/qs_panel.xml
index 4607e5f..4c6418a 100644
--- a/packages/SystemUI/res/layout/qs_panel.xml
+++ b/packages/SystemUI/res/layout/qs_panel.xml
@@ -17,7 +17,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/quick_settings_container"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
android:clipToPadding="false"
android:clipChildren="false" >
@@ -25,7 +25,6 @@
android:id="@+id/expanded_qs_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingBottom="@dimen/qs_container_bottom_padding"
android:elevation="4dp"
android:importantForAccessibility="no"
android:scrollbars="none"
diff --git a/packages/SystemUI/res/layout/qs_tile_side_icon.xml b/packages/SystemUI/res/layout/qs_tile_side_icon.xml
index 9f9af9d..1ae0a1c 100644
--- a/packages/SystemUI/res/layout/qs_tile_side_icon.xml
+++ b/packages/SystemUI/res/layout/qs_tile_side_icon.xml
@@ -35,6 +35,7 @@
android:layout_width="@dimen/qs_icon_size"
android:layout_height="@dimen/qs_icon_size"
android:src="@*android:drawable/ic_chevron_end"
+ android:autoMirrored="true"
android:visibility="gone"
android:importantForAccessibility="no"
/>
diff --git a/packages/SystemUI/res/layout/quick_qs_status_icons.xml b/packages/SystemUI/res/layout/quick_qs_status_icons.xml
index f0229a6..c88703d 100644
--- a/packages/SystemUI/res/layout/quick_qs_status_icons.xml
+++ b/packages/SystemUI/res/layout/quick_qs_status_icons.xml
@@ -49,17 +49,35 @@
android:layout_gravity="end|center_vertical"
android:focusable="false"/>
- <com.android.systemui.statusbar.phone.StatusIconContainer
- android:id="@+id/statusIcons"
+ <View
+ android:id="@+id/separator"
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:layout_marginStart="8dp"
+ android:layout_marginEnd="8dp"
+ android:visibility="gone"
+ />
+
+ <LinearLayout
+ android:id="@+id/rightLayout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:paddingEnd="@dimen/signal_cluster_battery_padding" />
+ android:gravity="center_vertical|end"
+ >
+ <com.android.systemui.statusbar.phone.StatusIconContainer
+ android:id="@+id/statusIcons"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:paddingEnd="@dimen/signal_cluster_battery_padding" />
- <com.android.systemui.BatteryMeterView
- android:id="@+id/batteryRemainingIcon"
- android:layout_height="match_parent"
- android:layout_width="wrap_content"
- systemui:textAppearance="@style/TextAppearance.QS.Status"
- android:paddingEnd="2dp" />
+ <com.android.systemui.BatteryMeterView
+ android:id="@+id/batteryRemainingIcon"
+ android:layout_height="match_parent"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ systemui:textAppearance="@style/TextAppearance.QS.Status"
+ android:paddingEnd="2dp" />
+ </LinearLayout>
</LinearLayout>
diff --git a/packages/SystemUI/res/layout/quick_settings_security_footer.xml b/packages/SystemUI/res/layout/quick_settings_security_footer.xml
index ce7f827..08bd71c 100644
--- a/packages/SystemUI/res/layout/quick_settings_security_footer.xml
+++ b/packages/SystemUI/res/layout/quick_settings_security_footer.xml
@@ -55,6 +55,7 @@
android:layout_marginStart="8dp"
android:contentDescription="@null"
android:src="@*android:drawable/ic_chevron_end"
+ android:autoMirrored="true"
android:tint="?android:attr/textColorSecondary" />
</com.android.systemui.util.DualHeightHorizontalLinearLayout>
diff --git a/packages/SystemUI/res/layout/smart_action_button.xml b/packages/SystemUI/res/layout/smart_action_button.xml
index 2716034..488be3a 100644
--- a/packages/SystemUI/res/layout/smart_action_button.xml
+++ b/packages/SystemUI/res/layout/smart_action_button.xml
@@ -29,6 +29,8 @@
android:textSize="@dimen/smart_reply_button_font_size"
android:lineSpacingExtra="@dimen/smart_reply_button_line_spacing_extra"
android:textColor="@color/smart_reply_button_text"
+ android:paddingLeft="@dimen/smart_reply_button_action_padding_left"
+ android:paddingRight="@dimen/smart_reply_button_padding_horizontal"
android:drawablePadding="@dimen/smart_action_button_icon_padding"
android:textStyle="normal"
android:ellipsize="none"/>
diff --git a/packages/SystemUI/res/layout/smart_reply_button.xml b/packages/SystemUI/res/layout/smart_reply_button.xml
index 9faed18..ddf16e0 100644
--- a/packages/SystemUI/res/layout/smart_reply_button.xml
+++ b/packages/SystemUI/res/layout/smart_reply_button.xml
@@ -31,5 +31,7 @@
android:textSize="@dimen/smart_reply_button_font_size"
android:lineSpacingExtra="@dimen/smart_reply_button_line_spacing_extra"
android:textColor="@color/smart_reply_button_text"
+ android:paddingLeft="@dimen/smart_reply_button_padding_horizontal"
+ android:paddingRight="@dimen/smart_reply_button_padding_horizontal"
android:textStyle="normal"
android:ellipsize="none"/>
diff --git a/packages/SystemUI/res/layout/smart_reply_view.xml b/packages/SystemUI/res/layout/smart_reply_view.xml
index 9fffc72..9d4d1db 100644
--- a/packages/SystemUI/res/layout/smart_reply_view.xml
+++ b/packages/SystemUI/res/layout/smart_reply_view.xml
@@ -24,8 +24,6 @@
android:layout_height="wrap_content"
android:layout_width="wrap_content"
systemui:spacing="@dimen/smart_reply_button_spacing"
- systemui:singleLineButtonPaddingHorizontal="@dimen/smart_reply_button_padding_horizontal_single_line"
- systemui:doubleLineButtonPaddingHorizontal="@dimen/smart_reply_button_padding_horizontal_double_line"
systemui:buttonStrokeWidth="@dimen/smart_reply_button_stroke_width">
<!-- smart_reply_button(s) will be added here. -->
</com.android.systemui.statusbar.policy.SmartReplyView>
diff --git a/packages/SystemUI/res/layout/status_bar_notification_footer.xml b/packages/SystemUI/res/layout/status_bar_notification_footer.xml
index c3c291b..412276d 100644
--- a/packages/SystemUI/res/layout/status_bar_notification_footer.xml
+++ b/packages/SystemUI/res/layout/status_bar_notification_footer.xml
@@ -19,8 +19,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingStart="4dp"
- android:paddingEnd="4dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
android:visibility="gone">
<com.android.systemui.statusbar.AlphaOptimizedFrameLayout
android:id="@+id/content"
diff --git a/packages/SystemUI/res/layout/wallet_empty_state.xml b/packages/SystemUI/res/layout/wallet_empty_state.xml
index 3ca0f73..cc2e781 100644
--- a/packages/SystemUI/res/layout/wallet_empty_state.xml
+++ b/packages/SystemUI/res/layout/wallet_empty_state.xml
@@ -16,7 +16,8 @@
** limitations under the License.
*/
-->
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
+<merge xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
<LinearLayout
android:id="@+id/wallet_empty_state"
android:layout_width="match_parent"
@@ -35,6 +36,7 @@
android:layout_height="28dp"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
+ android:tint="?androidprv:attr/colorAccentPrimary"
android:contentDescription="@null"
android:scaleType="fitCenter"/>
<TextView
diff --git a/packages/SystemUI/res/layout/wallet_fullscreen.xml b/packages/SystemUI/res/layout/wallet_fullscreen.xml
index bbb180f..d365aa3 100644
--- a/packages/SystemUI/res/layout/wallet_fullscreen.xml
+++ b/packages/SystemUI/res/layout/wallet_fullscreen.xml
@@ -16,6 +16,8 @@
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false">
@@ -34,8 +36,8 @@
android:orientation="vertical">
<ImageView
android:id="@+id/icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_width="@dimen/wallet_screen_header_view_size"
+ android:layout_height="@dimen/wallet_screen_header_view_size"
android:layout_gravity="center_horizontal"
android:layout_marginVertical="10dp"
android:scaleType="center"
@@ -65,7 +67,7 @@
android:paddingVertical="@dimen/wallet_button_vertical_padding"
android:paddingHorizontal="@dimen/wallet_button_horizontal_padding"
android:background="@drawable/wallet_action_button_bg"
- android:textColor="@color/wallet_white"
+ android:textColor="?androidprv:attr/textColorPrimaryInverse"
android:textAlignment="center"
android:visibility="gone"/>
@@ -83,7 +85,7 @@
android:paddingHorizontal="@dimen/wallet_button_horizontal_padding"
android:background="@drawable/wallet_app_button_bg"
android:text="@string/wallet_app_button_label"
- android:textColor="@color/GM2_blue_600"
+ android:textColor="?androidprv:attr/colorAccentPrimary"
android:textAlignment="center"
android:layout_marginVertical="24dp"/>
diff --git a/packages/SystemUI/res/values-af/strings.xml b/packages/SystemUI/res/values-af/strings.xml
index d3ab5b3..e000ff4 100644
--- a/packages/SystemUI/res/values-af/strings.xml
+++ b/packages/SystemUI/res/values-af/strings.xml
@@ -289,11 +289,9 @@
<string name="accessibility_quick_settings_hotspot_changed_off" msgid="7002061268910095176">"Mobiele warmkol afgeskakel."</string>
<string name="accessibility_quick_settings_hotspot_changed_on" msgid="2576895346762408840">"Mobiele warmkol aangeskakel."</string>
<string name="accessibility_casting_turned_off" msgid="1387906158563374962">"Uitsaai van skerm gestaak."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_off (9106217884005620744) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_off" msgid="9106217884005620744">"Werkmodus is onderbreek."</string>
<string name="accessibility_quick_settings_work_mode_on" msgid="2779253456042059110">"Werkmodus is aan."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_changed_off (2653550342355027441) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_changed_off" msgid="2653550342355027441">"Werkmodus is verander na onderbreek."</string>
<string name="accessibility_quick_settings_work_mode_changed_on" msgid="1105258550138313384">"Werkmodus is aangeskakel."</string>
<string name="accessibility_quick_settings_data_saver_changed_off" msgid="4910847127871603832">"Databespaarder is afgeskakel."</string>
<string name="accessibility_quick_settings_data_saver_changed_on" msgid="6370606590802623078">"Databespaarder is aangeskakel."</string>
@@ -412,8 +410,7 @@
<string name="quick_settings_cellular_detail_data_limit" msgid="1791389609409211628">"<xliff:g id="DATA_LIMIT">%s</xliff:g>-limiet"</string>
<string name="quick_settings_cellular_detail_data_warning" msgid="7957253810481086455">"<xliff:g id="DATA_LIMIT">%s</xliff:g> waarskuwing"</string>
<string name="quick_settings_work_mode_label" msgid="2754212289804324685">"Werkprofiel"</string>
- <!-- no translation found for quick_settings_work_mode_paused (4841109346916998613) -->
- <skip />
+ <string name="quick_settings_work_mode_paused" msgid="4841109346916998613">"Onderbreek"</string>
<string name="quick_settings_night_display_label" msgid="8180030659141778180">"Aandbeligting"</string>
<string name="quick_settings_night_secondary_label_on_at_sunset" msgid="3358706312129866626">"Aan by sonsondergang"</string>
<string name="quick_settings_night_secondary_label_until_sunrise" msgid="4063448287758262485">"Tot sonsopkoms"</string>
@@ -473,14 +470,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Volkome\nstilte"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Net\nprioriteit"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Net\nwekkers"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Laai tans draadloos • Vol oor <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Laai tans • Vol oor <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Laai tans vinnig • Vol oor <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Laai tans stadig • Vol oor <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Wissel gebruiker"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Wissel gebruiker, huidige gebruiker <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Huidige gebruiker <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
@@ -676,12 +669,10 @@
<string name="wallet_title" msgid="5369767670735827105">"Beursie"</string>
<string name="wallet_app_button_label" msgid="7123784239111190992">"Wys alles"</string>
<string name="wallet_action_button_label_unlock" msgid="8663239748726774487">"Ontsluit om te betaal"</string>
- <!-- no translation found for wallet_secondary_label_no_card (1282609666895946317) -->
- <skip />
+ <string name="wallet_secondary_label_no_card" msgid="1282609666895946317">"Nie opgestel nie"</string>
<string name="wallet_secondary_label_device_locked" msgid="5175862019125370506">"Ontsluit om te gebruik"</string>
<string name="wallet_error_generic" msgid="257704570182963611">"Kon nie jou kaarte kry nie; probeer later weer"</string>
- <!-- no translation found for wallet_lockscreen_settings_label (3539105300870383570) -->
- <skip />
+ <string name="wallet_lockscreen_settings_label" msgid="3539105300870383570">"Sluitskerminstellings"</string>
<string name="status_bar_work" msgid="5238641949837091056">"Werkprofiel"</string>
<string name="status_bar_airplane" msgid="4848702508684541009">"Vliegtuigmodus"</string>
<string name="add_tile" msgid="6239678623873086686">"Voeg teël by"</string>
@@ -871,8 +862,7 @@
<string name="switch_bar_on" msgid="1770868129120096114">"Aan"</string>
<string name="switch_bar_off" msgid="5669805115416379556">"Af"</string>
<string name="tile_unavailable" msgid="3095879009136616920">"Onbeskikbaar"</string>
- <!-- no translation found for tile_disabled (373212051546573069) -->
- <skip />
+ <string name="tile_disabled" msgid="373212051546573069">"Gedeaktiveer"</string>
<string name="nav_bar" msgid="4642708685386136807">"Navigasiebalk"</string>
<string name="nav_bar_layout" msgid="4716392484772899544">"Uitleg"</string>
<string name="left_nav_bar_button_type" msgid="2634852842345192790">"Ekstra linksknoppie-tipe"</string>
diff --git a/packages/SystemUI/res/values-am/strings.xml b/packages/SystemUI/res/values-am/strings.xml
index 4dee085..e69ab3f 100644
--- a/packages/SystemUI/res/values-am/strings.xml
+++ b/packages/SystemUI/res/values-am/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"ሙሉ ለሙሉ\nጸጥታ"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"ቅድሚያ ተሰጪ\nብቻ"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"ማንቂያዎች\nብቻ"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • በገመድ-አልባ ኃይል በመሙላት ላይ • በ<xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> ውስጥ ይሞላል"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • ኃይል በመሙላት ላይ • በ<xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> ውስጥ ይሞላል"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • በፍጥነት ኃይልን በመሙላት ላይ • በ<xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> ውስጥ ይሞላል"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • በዝግታ ኃይልን በመሙላት ላይ • በ<xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> ውስጥ ይሞላል"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"ተጠቃሚ ቀይር"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"ተጠቃሚ ይለውጡ፣ የአሁን ተጠቃሚ <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"የአሁን ተጠቃሚ <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-b+sr+Latn/strings.xml b/packages/SystemUI/res/values-b+sr+Latn/strings.xml
index dd342ff..7c8d105 100644
--- a/packages/SystemUI/res/values-b+sr+Latn/strings.xml
+++ b/packages/SystemUI/res/values-b+sr+Latn/strings.xml
@@ -475,14 +475,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Potpuna\ntišina"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Samo\npriorit. prekidi"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Samo\nalarmi"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Bežično se puni • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> do kraja punjenja"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Puni se • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> do kraja punjenja"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Brzo se puni • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> do kraja punjenja"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Sporo se puni • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> do kraja punjenja"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Zameni korisnika"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Promenite korisnika, aktuelni korisnik je <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Aktuelni korisnik <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-bn/strings.xml b/packages/SystemUI/res/values-bn/strings.xml
index adbef20..73efaed 100644
--- a/packages/SystemUI/res/values-bn/strings.xml
+++ b/packages/SystemUI/res/values-bn/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"একদম\nনিরব"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"শুধুমাত্র\nঅগ্রাধিকার"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"শুধুমাত্র\nঅ্যালার্মগুলি"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • ওয়্যারলেস পদ্ধতিতে চার্জ হচ্ছে • পুরো চার্জ হতে <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> লাগবে"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • চার্জিং • পুরো চার্জ হতে <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> লাগবে"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • দ্রুত চার্জ হচ্ছে • পুরো চার্জ হতে <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> লাগবে"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • ধীরে চার্জ হচ্ছে • পুরো চার্জ হতে <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> লাগবে"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"ব্যবহারকারী পাল্টে দিন"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"ব্যবহারকারী পাল্টান, বর্তমান ব্যবহারকারী <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"<xliff:g id="CURRENT_USER_NAME">%s</xliff:g> হল বর্তমান ব্যবহারকারী"</string>
@@ -750,14 +746,10 @@
<string name="notification_channel_summary_automatic_silenced" msgid="7403004439649872047">"<b>স্ট্যাটাস:</b> লেভেল কমিয়ে সাইলেন্ করা হয়েছে"</string>
<string name="notification_channel_summary_automatic_promoted" msgid="1301710305149590426">"<b>স্ট্যাটাস:</b> র্যাঙ্ক বেড়ে গেছে"</string>
<string name="notification_channel_summary_automatic_demoted" msgid="1831303964660807700">"<b>স্ট্যাটাস:</b> র্যাঙ্ক কমে গেছে"</string>
- <!-- no translation found for notification_channel_summary_priority_baseline (46674690072551234) -->
- <skip />
- <!-- no translation found for notification_channel_summary_priority_bubble (1275413109619074576) -->
- <skip />
- <!-- no translation found for notification_channel_summary_priority_dnd (6665395023264154361) -->
- <skip />
- <!-- no translation found for notification_channel_summary_priority_all (7151752959650048285) -->
- <skip />
+ <string name="notification_channel_summary_priority_baseline" msgid="46674690072551234">"কথোপকথনের বিজ্ঞপ্তির উপরের দিকে এবং প্রোফাইল ছবি হিসেবে লক স্ক্রিনে দেখানো হয়"</string>
+ <string name="notification_channel_summary_priority_bubble" msgid="1275413109619074576">"কথোপকথনের বিজ্ঞপ্তির উপরের দিকে এবং প্রোফাইল ছবি হিসেবে লক স্ক্রিনে দেখানো হয়, বাবল হিসেবেও এটি দেখা যায়"</string>
+ <string name="notification_channel_summary_priority_dnd" msgid="6665395023264154361">"কথোপকথনের বিজ্ঞপ্তির উপরের দিকে এবং প্রোফাইল ছবি হিসেবে লক স্ক্রিনে দেখানো হয় এবং এর ফলে \'বিরক্ত করবে না\' মোডে কাজ করতে অসুবিধা হয়"</string>
+ <string name="notification_channel_summary_priority_all" msgid="7151752959650048285">"কথোপকথনের বিজ্ঞপ্তির উপরের দিকে এবং প্রোফাইল ছবি হিসেবে লক স্ক্রিনে দেখানো হয়, বাবল হিসেবেও এটি দেখা যায় এবং এর ফলে \'বিরক্ত করবে না\' মোডে কাজ করতে অসুবিধা হয়"</string>
<string name="notification_conversation_channel_settings" msgid="2409977688430606835">"সেটিংস"</string>
<string name="notification_priority_title" msgid="2079708866333537093">"অগ্রাধিকার"</string>
<string name="no_shortcut" msgid="8257177117568230126">"<xliff:g id="APP_NAME">%1$s</xliff:g>-এ কথোপকথন ফিচার কাজ করে না"</string>
diff --git a/packages/SystemUI/res/values-bs/strings.xml b/packages/SystemUI/res/values-bs/strings.xml
index a54dffe..5c9ec89 100644
--- a/packages/SystemUI/res/values-bs/strings.xml
+++ b/packages/SystemUI/res/values-bs/strings.xml
@@ -475,14 +475,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Potpuna\ntišina"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Samo\nprioritetni prekidi"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Samo\nalarmi"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Bežično punjenje • Potpuna napunjenost za <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Punjenje • Potpuna napunjenost za <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Brzo punjenje • Potpuna napunjenost za <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Sporo punjenje • Potpuna napunjenost za <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Zamijeni korisnika"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Zamijeni korisnika. Trenutni korisnik je <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Trenutni korisnik <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-ca/strings.xml b/packages/SystemUI/res/values-ca/strings.xml
index 803bbd1..fc3b2f5 100644
--- a/packages/SystemUI/res/values-ca/strings.xml
+++ b/packages/SystemUI/res/values-ca/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Silenci\ntotal"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Només\ninterr. prior."</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Només\nalarmes"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Carregant sense fil • Es completarà d\'aquí a <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • S\'està carregant • Es completarà d\'aquí a <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Carregant ràpidament • Es completarà d\'aquí a <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Carregant lentament • Es completarà d\'aquí a <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Canvia d\'usuari"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Canvia d\'usuari. Usuari actual: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Usuari actual: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-cs/strings.xml b/packages/SystemUI/res/values-cs/strings.xml
index 8ed760a..4560cad 100644
--- a/packages/SystemUI/res/values-cs/strings.xml
+++ b/packages/SystemUI/res/values-cs/strings.xml
@@ -477,14 +477,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Úplné\nticho"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Pouze\nprioritní"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Pouze\nbudíky"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Bezdrátové nabíjení • Plně nabito za <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Nabíjení • Plně nabito za <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Rychlé nabíjení • Plně nabito za <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Pomalé nabíjení • Plně nabito za <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Přepnout uživatele"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Přepnout uživatele, aktuální uživatel: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Aktuální uživatel <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-da/strings.xml b/packages/SystemUI/res/values-da/strings.xml
index c76ebc3..a30e0636 100644
--- a/packages/SystemUI/res/values-da/strings.xml
+++ b/packages/SystemUI/res/values-da/strings.xml
@@ -289,11 +289,9 @@
<string name="accessibility_quick_settings_hotspot_changed_off" msgid="7002061268910095176">"Mobilhotspot er slået fra."</string>
<string name="accessibility_quick_settings_hotspot_changed_on" msgid="2576895346762408840">"Mobilhotspot er slået til."</string>
<string name="accessibility_casting_turned_off" msgid="1387906158563374962">"Casting af din skærm er stoppet."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_off (9106217884005620744) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_off" msgid="9106217884005620744">"Arbejdstilstand er på pause."</string>
<string name="accessibility_quick_settings_work_mode_on" msgid="2779253456042059110">"Arbejdstilstand er slået til."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_changed_off (2653550342355027441) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_changed_off" msgid="2653550342355027441">"Arbejdstilstand er sat på pause."</string>
<string name="accessibility_quick_settings_work_mode_changed_on" msgid="1105258550138313384">"Arbejdstilstand er slået til."</string>
<string name="accessibility_quick_settings_data_saver_changed_off" msgid="4910847127871603832">"Datasparefunktionen er slået fra."</string>
<string name="accessibility_quick_settings_data_saver_changed_on" msgid="6370606590802623078">"Datasparefunktionen er aktiveret."</string>
@@ -412,8 +410,7 @@
<string name="quick_settings_cellular_detail_data_limit" msgid="1791389609409211628">"Grænse: <xliff:g id="DATA_LIMIT">%s</xliff:g>"</string>
<string name="quick_settings_cellular_detail_data_warning" msgid="7957253810481086455">"Advarsel ved <xliff:g id="DATA_LIMIT">%s</xliff:g>"</string>
<string name="quick_settings_work_mode_label" msgid="2754212289804324685">"Arbejdsprofil"</string>
- <!-- no translation found for quick_settings_work_mode_paused (4841109346916998613) -->
- <skip />
+ <string name="quick_settings_work_mode_paused" msgid="4841109346916998613">"Sat på pause"</string>
<string name="quick_settings_night_display_label" msgid="8180030659141778180">"Nattelys"</string>
<string name="quick_settings_night_secondary_label_on_at_sunset" msgid="3358706312129866626">"Tænd ved solnedgang"</string>
<string name="quick_settings_night_secondary_label_until_sunrise" msgid="4063448287758262485">"Indtil solopgang"</string>
@@ -473,14 +470,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Total\nstilhed"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Kun\nprioritet"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Kun\nalarmer"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Trådløs opladning • Fuldt opladet om <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Oplader • Fuldt opladet om <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Oplader hurtigt • Fuldt opladet om <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Oplader langsomt • Fuldt opladet om <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Skift bruger"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Skift bruger. Nuværende bruger er <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Nuværende bruger: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
@@ -676,12 +669,10 @@
<string name="wallet_title" msgid="5369767670735827105">"Wallet"</string>
<string name="wallet_app_button_label" msgid="7123784239111190992">"Vis alle"</string>
<string name="wallet_action_button_label_unlock" msgid="8663239748726774487">"Lås op for at betale"</string>
- <!-- no translation found for wallet_secondary_label_no_card (1282609666895946317) -->
- <skip />
+ <string name="wallet_secondary_label_no_card" msgid="1282609666895946317">"Ikke konfigureret"</string>
<string name="wallet_secondary_label_device_locked" msgid="5175862019125370506">"Lås op for at bruge"</string>
<string name="wallet_error_generic" msgid="257704570182963611">"Dine kort kunne ikke hentes. Prøv igen senere."</string>
- <!-- no translation found for wallet_lockscreen_settings_label (3539105300870383570) -->
- <skip />
+ <string name="wallet_lockscreen_settings_label" msgid="3539105300870383570">"Lås skærmindstillinger"</string>
<string name="status_bar_work" msgid="5238641949837091056">"Arbejdsprofil"</string>
<string name="status_bar_airplane" msgid="4848702508684541009">"Flytilstand"</string>
<string name="add_tile" msgid="6239678623873086686">"Tilføj et felt"</string>
@@ -871,8 +862,7 @@
<string name="switch_bar_on" msgid="1770868129120096114">"Til"</string>
<string name="switch_bar_off" msgid="5669805115416379556">"Fra"</string>
<string name="tile_unavailable" msgid="3095879009136616920">"Ikke tilgængelig"</string>
- <!-- no translation found for tile_disabled (373212051546573069) -->
- <skip />
+ <string name="tile_disabled" msgid="373212051546573069">"Deaktiveret"</string>
<string name="nav_bar" msgid="4642708685386136807">"Navigationslinje"</string>
<string name="nav_bar_layout" msgid="4716392484772899544">"Layout"</string>
<string name="left_nav_bar_button_type" msgid="2634852842345192790">"Ekstra venstre knaptype"</string>
diff --git a/packages/SystemUI/res/values-el/strings.xml b/packages/SystemUI/res/values-el/strings.xml
index 3da19fc..fd8af9d 100644
--- a/packages/SystemUI/res/values-el/strings.xml
+++ b/packages/SystemUI/res/values-el/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Πλήρης\nσίγαση"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Μόνο\nπροτεραιότητας"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Μόνο\nειδοποιήσεις"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Ασύρματη φόρτιση • Πλήρης φόρτιση σε <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Φόρτιση • Πλήρης φόρτιση σε <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Γρήγορη φόρτιση • Πλήρης φόρτιση σε <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Αργή φόρτιση • Πλήρης φόρτιση σε <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Εναλλαγή χρήστη"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Εναλλαγή χρήστη, τρέχων χρήστης <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Τρέχων χρήστης <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-es-rUS/strings.xml b/packages/SystemUI/res/values-es-rUS/strings.xml
index 15347dd..58a31df 100644
--- a/packages/SystemUI/res/values-es-rUS/strings.xml
+++ b/packages/SystemUI/res/values-es-rUS/strings.xml
@@ -289,11 +289,9 @@
<string name="accessibility_quick_settings_hotspot_changed_off" msgid="7002061268910095176">"Zona móvil desactivada"</string>
<string name="accessibility_quick_settings_hotspot_changed_on" msgid="2576895346762408840">"Zona móvil activada"</string>
<string name="accessibility_casting_turned_off" msgid="1387906158563374962">"Transmisión de pantalla detenida"</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_off (9106217884005620744) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_off" msgid="9106217884005620744">"Modo de trabajo pausado."</string>
<string name="accessibility_quick_settings_work_mode_on" msgid="2779253456042059110">"Modo de trabajo activado"</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_changed_off (2653550342355027441) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_changed_off" msgid="2653550342355027441">"Se pausó el modo de trabajo."</string>
<string name="accessibility_quick_settings_work_mode_changed_on" msgid="1105258550138313384">"Se activó el modo de trabajo."</string>
<string name="accessibility_quick_settings_data_saver_changed_off" msgid="4910847127871603832">"Se desactivó el Ahorro de datos."</string>
<string name="accessibility_quick_settings_data_saver_changed_on" msgid="6370606590802623078">"Se activó el Ahorro de datos."</string>
@@ -412,8 +410,7 @@
<string name="quick_settings_cellular_detail_data_limit" msgid="1791389609409211628">"Límite de <xliff:g id="DATA_LIMIT">%s</xliff:g>"</string>
<string name="quick_settings_cellular_detail_data_warning" msgid="7957253810481086455">"Advertencia de <xliff:g id="DATA_LIMIT">%s</xliff:g>"</string>
<string name="quick_settings_work_mode_label" msgid="2754212289804324685">"Perfil de trabajo"</string>
- <!-- no translation found for quick_settings_work_mode_paused (4841109346916998613) -->
- <skip />
+ <string name="quick_settings_work_mode_paused" msgid="4841109346916998613">"Pausado"</string>
<string name="quick_settings_night_display_label" msgid="8180030659141778180">"Luz nocturna"</string>
<string name="quick_settings_night_secondary_label_on_at_sunset" msgid="3358706312129866626">"Al atardecer"</string>
<string name="quick_settings_night_secondary_label_until_sunrise" msgid="4063448287758262485">"Hasta el amanecer"</string>
@@ -473,14 +470,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Silencio\ntotal"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Solo\nprioridad"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Solo\nalarmas"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Cargando de manera inalámbrica • Se completará en <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Cargando • Se completará en <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Cargando rápido • Se completará en <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Cargando lento • Se completará en <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Cambiar usuario"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Cambiar de usuario (usuario actual: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>)"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"El usuario actual es <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
@@ -676,12 +669,10 @@
<string name="wallet_title" msgid="5369767670735827105">"Wallet"</string>
<string name="wallet_app_button_label" msgid="7123784239111190992">"Mostrar todo"</string>
<string name="wallet_action_button_label_unlock" msgid="8663239748726774487">"Desbloquear para pagar"</string>
- <!-- no translation found for wallet_secondary_label_no_card (1282609666895946317) -->
- <skip />
+ <string name="wallet_secondary_label_no_card" msgid="1282609666895946317">"Sin configurar"</string>
<string name="wallet_secondary_label_device_locked" msgid="5175862019125370506">"Desbloquear para usar"</string>
<string name="wallet_error_generic" msgid="257704570182963611">"Ocurrió un problema al obtener las tarjetas; vuelve a intentarlo más tarde"</string>
- <!-- no translation found for wallet_lockscreen_settings_label (3539105300870383570) -->
- <skip />
+ <string name="wallet_lockscreen_settings_label" msgid="3539105300870383570">"Configuración de pantalla de bloqueo"</string>
<string name="status_bar_work" msgid="5238641949837091056">"Perfil de trabajo"</string>
<string name="status_bar_airplane" msgid="4848702508684541009">"Modo de avión"</string>
<string name="add_tile" msgid="6239678623873086686">"Agregar mosaico"</string>
@@ -871,8 +862,7 @@
<string name="switch_bar_on" msgid="1770868129120096114">"Activado"</string>
<string name="switch_bar_off" msgid="5669805115416379556">"Desactivado"</string>
<string name="tile_unavailable" msgid="3095879009136616920">"No disponible"</string>
- <!-- no translation found for tile_disabled (373212051546573069) -->
- <skip />
+ <string name="tile_disabled" msgid="373212051546573069">"Inhabilitada"</string>
<string name="nav_bar" msgid="4642708685386136807">"Barra de navegación"</string>
<string name="nav_bar_layout" msgid="4716392484772899544">"Diseño"</string>
<string name="left_nav_bar_button_type" msgid="2634852842345192790">"Tipo de botón izquierdo adicional"</string>
diff --git a/packages/SystemUI/res/values-es/strings.xml b/packages/SystemUI/res/values-es/strings.xml
index 57ce1c5..a863111 100644
--- a/packages/SystemUI/res/values-es/strings.xml
+++ b/packages/SystemUI/res/values-es/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Silencio\ntotal"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Solo\ncon prioridad"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Solo\nalarmas"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Carga sin cables • En <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> terminará de cargarse"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Cargando • En <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> terminará de cargarse"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Carga rápida • En <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> terminará de cargarse"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Carga lenta • En <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> terminará de cargarse"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Cambiar de usuario"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Cambiar de usuario (usuario actual <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>)"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Usuario actual: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-eu/strings.xml b/packages/SystemUI/res/values-eu/strings.xml
index 85679b9..932ce3e 100644
--- a/packages/SystemUI/res/values-eu/strings.xml
+++ b/packages/SystemUI/res/values-eu/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Isiltasun\nosoa"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Lehentasunezkoak\nsoilik"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Alarmak\nsoilik"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Hari gabe kargatzen • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> guztiz kargatu arte"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Kargatzen • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> guztiz kargatu arte"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Bizkor kargatzen • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> guztiz kargatu arte"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Mantso kargatzen • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> guztiz kargatu arte"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Aldatu erabiltzailea"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Aldatu erabiltzailea. <xliff:g id="CURRENT_USER_NAME">%s</xliff:g> da saioa hasita daukana."</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Erabiltzailea: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-fa/strings.xml b/packages/SystemUI/res/values-fa/strings.xml
index 052a87a..89b4fbd 100644
--- a/packages/SystemUI/res/values-fa/strings.xml
+++ b/packages/SystemUI/res/values-fa/strings.xml
@@ -289,11 +289,9 @@
<string name="accessibility_quick_settings_hotspot_changed_off" msgid="7002061268910095176">"نقطه اتصال دستگاه همراه خاموش شد."</string>
<string name="accessibility_quick_settings_hotspot_changed_on" msgid="2576895346762408840">"نقطه اتصال دستگاه همراه روشن شد."</string>
<string name="accessibility_casting_turned_off" msgid="1387906158563374962">"فرستادن صفحه نمایش متوقف شد."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_off (9106217884005620744) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_off" msgid="9106217884005620744">"حالت کار موقتاً متوقف شده است."</string>
<string name="accessibility_quick_settings_work_mode_on" msgid="2779253456042059110">"حالت کار روشن."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_changed_off (2653550342355027441) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_changed_off" msgid="2653550342355027441">"حالت کار موقتاً متوقف شد."</string>
<string name="accessibility_quick_settings_work_mode_changed_on" msgid="1105258550138313384">"حالت کار روشن شد."</string>
<string name="accessibility_quick_settings_data_saver_changed_off" msgid="4910847127871603832">"صرفهجویی داده خاموش شد."</string>
<string name="accessibility_quick_settings_data_saver_changed_on" msgid="6370606590802623078">"صرفهجویی داده روشن شد."</string>
@@ -412,8 +410,7 @@
<string name="quick_settings_cellular_detail_data_limit" msgid="1791389609409211628">"<xliff:g id="DATA_LIMIT">%s</xliff:g> محدودیت"</string>
<string name="quick_settings_cellular_detail_data_warning" msgid="7957253810481086455">"هشدار <xliff:g id="DATA_LIMIT">%s</xliff:g>"</string>
<string name="quick_settings_work_mode_label" msgid="2754212289804324685">"نمایه کاری"</string>
- <!-- no translation found for quick_settings_work_mode_paused (4841109346916998613) -->
- <skip />
+ <string name="quick_settings_work_mode_paused" msgid="4841109346916998613">"موقتاً متوقف"</string>
<string name="quick_settings_night_display_label" msgid="8180030659141778180">"نور شب"</string>
<string name="quick_settings_night_secondary_label_on_at_sunset" msgid="3358706312129866626">"غروب روشن میشود"</string>
<string name="quick_settings_night_secondary_label_until_sunrise" msgid="4063448287758262485">"تا طلوع"</string>
@@ -473,14 +470,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"سکوت\nکامل"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"فقط\nاولویتدار"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"فقط\nهشدارها"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • درحال شارژ کردن بیسیم • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> تا شارژ کامل"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • درحال شارژ کردن • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> تا شارژ کامل"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • درحال شارژ کردن سریع • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> تا شارژ کامل"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • درحال شارژ کردن آهسته • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> تا شارژ کامل"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"تغییر کاربر"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"تعویض کاربر، کاربر کنونی <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"کاربر کنونی <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
@@ -676,12 +669,10 @@
<string name="wallet_title" msgid="5369767670735827105">"کیفپول"</string>
<string name="wallet_app_button_label" msgid="7123784239111190992">"نمایش همه"</string>
<string name="wallet_action_button_label_unlock" msgid="8663239748726774487">"باز کردن قفل برای پرداخت"</string>
- <!-- no translation found for wallet_secondary_label_no_card (1282609666895946317) -->
- <skip />
+ <string name="wallet_secondary_label_no_card" msgid="1282609666895946317">"تنظیمنشده"</string>
<string name="wallet_secondary_label_device_locked" msgid="5175862019125370506">"برای استفاده، قفل را باز کنید"</string>
<string name="wallet_error_generic" msgid="257704570182963611">"هنگام دریافت کارتها مشکلی پیش آمد، لطفاً بعداً دوباره امتحان کنید"</string>
- <!-- no translation found for wallet_lockscreen_settings_label (3539105300870383570) -->
- <skip />
+ <string name="wallet_lockscreen_settings_label" msgid="3539105300870383570">"تنظیمات صفحه قفل"</string>
<string name="status_bar_work" msgid="5238641949837091056">"نمایه کاری"</string>
<string name="status_bar_airplane" msgid="4848702508684541009">"حالت هواپیما"</string>
<string name="add_tile" msgid="6239678623873086686">"افزودن کاشی"</string>
@@ -871,8 +862,7 @@
<string name="switch_bar_on" msgid="1770868129120096114">"روشن"</string>
<string name="switch_bar_off" msgid="5669805115416379556">"خاموش"</string>
<string name="tile_unavailable" msgid="3095879009136616920">"در دسترس نیست"</string>
- <!-- no translation found for tile_disabled (373212051546573069) -->
- <skip />
+ <string name="tile_disabled" msgid="373212051546573069">"غیرفعال"</string>
<string name="nav_bar" msgid="4642708685386136807">"نوار پیمایش"</string>
<string name="nav_bar_layout" msgid="4716392484772899544">"طرحبندی"</string>
<string name="left_nav_bar_button_type" msgid="2634852842345192790">"نوع دکمه منتهیالیه چپ"</string>
diff --git a/packages/SystemUI/res/values-fr/strings.xml b/packages/SystemUI/res/values-fr/strings.xml
index efe1833..a9acd50 100644
--- a/packages/SystemUI/res/values-fr/strings.xml
+++ b/packages/SystemUI/res/values-fr/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Aucune\ninterruption"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Priorité\nuniquement"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Alarmes\nuniquement"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Recharge sans fil • Chargé dans <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Recharge • Chargé dans <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Recharge rapide • Chargé dans <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Recharge lente • Chargé dans <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Changer d\'utilisateur"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Changer d\'utilisateur (utilisateur actuel : <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>)"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Utilisateur actuel : <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-gl/strings.xml b/packages/SystemUI/res/values-gl/strings.xml
index d5da5d5..083435b 100644
--- a/packages/SystemUI/res/values-gl/strings.xml
+++ b/packages/SystemUI/res/values-gl/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Silencio\ntotal"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Só\nprioridade"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Só\nalarmas"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Cargando sen fíos • A carga completarase en <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Cargando • A carga completarase en <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Cargando rapidamente • A carga completarase en <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Cargando lentamente • A carga completarase en <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Cambiar usuario"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Cambiar usuario, usuario actual: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Usuario actual <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-gu/strings.xml b/packages/SystemUI/res/values-gu/strings.xml
index 7e92ccf..99d3af6 100644
--- a/packages/SystemUI/res/values-gu/strings.xml
+++ b/packages/SystemUI/res/values-gu/strings.xml
@@ -750,14 +750,10 @@
<string name="notification_channel_summary_automatic_silenced" msgid="7403004439649872047">"<b>સ્ટેટસ:</b> સાઇલન્ટ પર અવનત કરવામાં આવ્યું"</string>
<string name="notification_channel_summary_automatic_promoted" msgid="1301710305149590426">"<b>સ્ટેટસ:</b> ઉપલી રેંક આપવામાં આવી"</string>
<string name="notification_channel_summary_automatic_demoted" msgid="1831303964660807700">"<b>સ્ટેટસ:</b> નીચલી રેંક આપવામાં આવી"</string>
- <!-- no translation found for notification_channel_summary_priority_baseline (46674690072551234) -->
- <skip />
- <!-- no translation found for notification_channel_summary_priority_bubble (1275413109619074576) -->
- <skip />
- <!-- no translation found for notification_channel_summary_priority_dnd (6665395023264154361) -->
- <skip />
- <!-- no translation found for notification_channel_summary_priority_all (7151752959650048285) -->
- <skip />
+ <string name="notification_channel_summary_priority_baseline" msgid="46674690072551234">"વાતચીતના નોટિફિકેશન વિભાગની ટોચ પર અને લૉક કરેલી સ્ક્રીન પર પ્રોફાઇલ ફોટો તરીકે બતાવે છે"</string>
+ <string name="notification_channel_summary_priority_bubble" msgid="1275413109619074576">"વાતચીતના નોટિફિકેશન વિભાગની ટોચ પર અને લૉક કરેલી સ્ક્રીન પર પ્રોફાઇલ ફોટો તરીકે બતાવે છે, બબલ તરીકે દેખાય છે"</string>
+ <string name="notification_channel_summary_priority_dnd" msgid="6665395023264154361">"વાતચીતના નોટિફિકેશન વિભાગની ટોચ પર અને લૉક કરેલી સ્ક્રીન પર પ્રોફાઇલ ફોટો તરીકે બતાવે છે, ખલેલ પાડશો નહીં મોડમાં વિક્ષેપ ઊભો કરે છે"</string>
+ <string name="notification_channel_summary_priority_all" msgid="7151752959650048285">"વાતચીતના નોટિફિકેશન વિભાગની ટોચ પર અને લૉક કરેલી સ્ક્રીન પર પ્રોફાઇલ ફોટો તરીકે બતાવે છે, બબલ તરીકે દેખાય છે, ખલેલ પાડશો નહીં મોડમાં વિક્ષેપ ઊભો કરે છે"</string>
<string name="notification_conversation_channel_settings" msgid="2409977688430606835">"સેટિંગ"</string>
<string name="notification_priority_title" msgid="2079708866333537093">"પ્રાધાન્યતા"</string>
<string name="no_shortcut" msgid="8257177117568230126">"<xliff:g id="APP_NAME">%1$s</xliff:g> વાતચીતની સુવિધાઓને સપોર્ટ આપતી નથી"</string>
diff --git a/packages/SystemUI/res/values-hi/strings.xml b/packages/SystemUI/res/values-hi/strings.xml
index cfe2079..b526ff6 100644
--- a/packages/SystemUI/res/values-hi/strings.xml
+++ b/packages/SystemUI/res/values-hi/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"पूरी तरह\nशांत"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"केवल\nप्राथमिकता"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"केवल\nअलार्म"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • वायरलेस तरीके से चार्ज हो रहा है • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> में पूरा चार्ज हो जाएगा"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • चार्ज हो रहा है • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> में पूरा चार्ज हो जाएगा"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • तेज़ चार्ज हो रहा है • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> में पूरा चार्ज हो जाएगा"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • धीरे चार्ज हो रहा है • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> में पूरा चार्ज हो जाएगा"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"उपयोगकर्ता बदलें"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"उपयोगकर्ता बदलें, मौजूदा उपयोगकर्ता <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"मौजूदा उपयोगकर्ता <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-hr/strings.xml b/packages/SystemUI/res/values-hr/strings.xml
index 9246023..fedeb77 100644
--- a/packages/SystemUI/res/values-hr/strings.xml
+++ b/packages/SystemUI/res/values-hr/strings.xml
@@ -475,14 +475,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Potpuna\ntišina"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Samo\nprioritetno"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Samo\nalarmi"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • bežično punjenje • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> do napunjenosti"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • punjenje • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> do napunjenosti"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • brzo punjenje • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> do napunjenosti"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • sporo punjenje • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> do napunjenosti"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Promjena korisnika"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Promjena korisnika, trenutačni korisnik <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Trenutačan korisnik <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-hu/strings.xml b/packages/SystemUI/res/values-hu/strings.xml
index 3cfbaba..d3bd516 100644
--- a/packages/SystemUI/res/values-hu/strings.xml
+++ b/packages/SystemUI/res/values-hu/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Teljes\nnémítás"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Csak\nprioritás"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Csak\nriasztások"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Vezeték nélküli töltés • A teljes töltöttségig: <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Töltés • A teljes töltöttségig: <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Gyors töltés • A teljes töltöttségig: <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Lassú töltés • A teljes töltöttségig: <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Felhasználóváltás"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Felhasználóváltás (a jelenlegi felhasználó: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>)"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Jelenlegi felhasználó (<xliff:g id="CURRENT_USER_NAME">%s</xliff:g>)"</string>
diff --git a/packages/SystemUI/res/values-is/strings.xml b/packages/SystemUI/res/values-is/strings.xml
index 4295b96..22feecf 100644
--- a/packages/SystemUI/res/values-is/strings.xml
+++ b/packages/SystemUI/res/values-is/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Algjör\nþögn"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Aðeins\nforgangur"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Aðeins\nvekjarar"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Þráðlaus hleðsla • Full hleðsla eftir <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Í hleðslu • Full hleðsla eftir <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Hraðhleðsla • Full hleðsla eftir <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Hæg hleðsla • Full hleðsla eftir <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Skipta um notanda"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Skipta um notanda; núverandi notandi er <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Núverandi notandi er <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-it/strings.xml b/packages/SystemUI/res/values-it/strings.xml
index 78b85c9..6cc699b 100644
--- a/packages/SystemUI/res/values-it/strings.xml
+++ b/packages/SystemUI/res/values-it/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Silenzio\ntotale"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Solo con\npriorità"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Solo\nsveglie"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • In carica wireless • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> alla ricarica completa"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • In carica • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> alla ricarica completa"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Ricarica veloce • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> alla ricarica completa"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Ricarica lenta • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> alla ricarica completa"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Cambio utente"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Cambia utente, utente corrente <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Utente corrente <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-ja/strings.xml b/packages/SystemUI/res/values-ja/strings.xml
index 39abcde..0e331de 100644
--- a/packages/SystemUI/res/values-ja/strings.xml
+++ b/packages/SystemUI/res/values-ja/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"サイレント\n"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"重要な\n通知のみ"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"アラーム\nのみ"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • ワイヤレス充電中 • 完了まで <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • 充電中 • 完了まで <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • 急速充電中 • 完了まで <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • 低速充電中 • 完了まで <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"ユーザーを切り替える"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"ユーザーを切り替える、現在のユーザーは<xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"現在のユーザー: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-km/strings.xml b/packages/SystemUI/res/values-km/strings.xml
index 78f228a..fddf305 100644
--- a/packages/SystemUI/res/values-km/strings.xml
+++ b/packages/SystemUI/res/values-km/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"ស្ងៀមស្ងាត់\nទាំងស្រុង"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"អាទិភាព\nប៉ុណ្ណោះ"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"សំឡេងរោទ៍\nប៉ុណ្ណោះ"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • កំពុងសាកថ្មឥតខ្សែ • ពេញក្នុងរយៈពេល <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • កំពុងសាកថ្ម • ពេញក្នុងរយៈពេល <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • កំពុងសាកថ្មយ៉ាងឆាប់រហ័ស • ពេញក្នុងរយៈពេល <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • កំពុងសាកថ្មយឺត • ពេញក្នុងរយៈពេល <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"ប្ដូរអ្នកប្រើ"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"ប្ដូរអ្នកប្រើ អ្នកប្រើបច្ចុប្បន្ន <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"អ្នកប្រើបច្ចុប្បន្ន <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-kn/strings.xml b/packages/SystemUI/res/values-kn/strings.xml
index 3cb20af..8d542ddf 100644
--- a/packages/SystemUI/res/values-kn/strings.xml
+++ b/packages/SystemUI/res/values-kn/strings.xml
@@ -289,11 +289,9 @@
<string name="accessibility_quick_settings_hotspot_changed_off" msgid="7002061268910095176">"ಮೊಬೈಲ್ ಹಾಟ್ಸ್ಪಾಟ್ ಆಫ್ ಮಾಡಲಾಗಿದೆ."</string>
<string name="accessibility_quick_settings_hotspot_changed_on" msgid="2576895346762408840">"ಮೊಬೈಲ್ ಹಾಟ್ಸ್ಪಾಟ್ ಆನ್ ಮಾಡಲಾಗಿದೆ."</string>
<string name="accessibility_casting_turned_off" msgid="1387906158563374962">"ಸ್ಕ್ರೀನ್ ಪ್ರಸಾರವನ್ನು ನಿಲ್ಲಿಸಲಾಗಿದೆ."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_off (9106217884005620744) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_off" msgid="9106217884005620744">"ಕೆಲಸದ ಮೋಡ್ ವಿರಾಮಗೊಳಿಸಲಾಗಿದೆ."</string>
<string name="accessibility_quick_settings_work_mode_on" msgid="2779253456042059110">"ಕೆಲಸದ ಮೋಡ್ ಆನ್ ಆಗಿದೆ."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_changed_off (2653550342355027441) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_changed_off" msgid="2653550342355027441">"ಕೆಲಸದ ಮೋಡ್ ಅನ್ನು ವಿರಾಮಗೊಳಿಸಲಾಗಿದೆ."</string>
<string name="accessibility_quick_settings_work_mode_changed_on" msgid="1105258550138313384">"ಕೆಲಸದ ಮೋಡ್ ಆನ್ ಮಾಡಲಾಗಿದೆ."</string>
<string name="accessibility_quick_settings_data_saver_changed_off" msgid="4910847127871603832">"ಡೇಟಾ ಸೇವರ್ ಆಫ್ ಮಾಡಲಾಗಿದೆ."</string>
<string name="accessibility_quick_settings_data_saver_changed_on" msgid="6370606590802623078">"ಡೇಟಾ ಸೇವರ್ ಆನ್ ಮಾಡಲಾಗಿದೆ."</string>
@@ -412,8 +410,7 @@
<string name="quick_settings_cellular_detail_data_limit" msgid="1791389609409211628">"<xliff:g id="DATA_LIMIT">%s</xliff:g> ಮಿತಿ"</string>
<string name="quick_settings_cellular_detail_data_warning" msgid="7957253810481086455">"<xliff:g id="DATA_LIMIT">%s</xliff:g> ಎಚ್ಚರಿಕೆ"</string>
<string name="quick_settings_work_mode_label" msgid="2754212289804324685">"ಕೆಲಸದ ಪ್ರೊಫೈಲ್"</string>
- <!-- no translation found for quick_settings_work_mode_paused (4841109346916998613) -->
- <skip />
+ <string name="quick_settings_work_mode_paused" msgid="4841109346916998613">"ವಿರಾಮಗೊಳಿಸಲಾಗಿದೆ"</string>
<string name="quick_settings_night_display_label" msgid="8180030659141778180">"ನೈಟ್ ಲೈಟ್"</string>
<string name="quick_settings_night_secondary_label_on_at_sunset" msgid="3358706312129866626">"ಸೂರ್ಯಾಸ್ತದಲ್ಲಿ"</string>
<string name="quick_settings_night_secondary_label_until_sunrise" msgid="4063448287758262485">"ಸೂರ್ಯೋದಯದವರೆಗೆ"</string>
@@ -676,12 +673,10 @@
<string name="wallet_title" msgid="5369767670735827105">"ವಾಲೆಟ್"</string>
<string name="wallet_app_button_label" msgid="7123784239111190992">"ಎಲ್ಲವನ್ನೂ ತೋರಿಸಿ"</string>
<string name="wallet_action_button_label_unlock" msgid="8663239748726774487">"ಪಾವತಿಸಲು ಅನ್ಲಾಕ್ ಮಾಡಿ"</string>
- <!-- no translation found for wallet_secondary_label_no_card (1282609666895946317) -->
- <skip />
+ <string name="wallet_secondary_label_no_card" msgid="1282609666895946317">"ಇನ್ನೂ ಸೆಟಪ್ ಮಾಡಿಲ್ಲ"</string>
<string name="wallet_secondary_label_device_locked" msgid="5175862019125370506">"ಬಳಸಲು ಅನ್ಲಾಕ್ ಮಾಡಿ"</string>
<string name="wallet_error_generic" msgid="257704570182963611">"ನಿಮ್ಮ ಕಾರ್ಡ್ಗಳನ್ನು ಪಡೆಯುವಾಗ ಸಮಸ್ಯೆ ಉಂಟಾಗಿದೆ, ನಂತರ ಪುನಃ ಪ್ರಯತ್ನಿಸಿ"</string>
- <!-- no translation found for wallet_lockscreen_settings_label (3539105300870383570) -->
- <skip />
+ <string name="wallet_lockscreen_settings_label" msgid="3539105300870383570">"ಲಾಕ್ ಸ್ಕ್ರ್ರೀನ್ ಸೆಟ್ಟಿಂಗ್ಗಳು"</string>
<string name="status_bar_work" msgid="5238641949837091056">"ಕೆಲಸದ ಪ್ರೊಫೈಲ್"</string>
<string name="status_bar_airplane" msgid="4848702508684541009">"ಏರ್ಪ್ಲೇನ್ ಮೋಡ್"</string>
<string name="add_tile" msgid="6239678623873086686">"ಟೈಲ್ ಸೇರಿಸಿ"</string>
@@ -871,8 +866,7 @@
<string name="switch_bar_on" msgid="1770868129120096114">"ಆನ್"</string>
<string name="switch_bar_off" msgid="5669805115416379556">"ಆಫ್"</string>
<string name="tile_unavailable" msgid="3095879009136616920">"ಲಭ್ಯವಿಲ್ಲ"</string>
- <!-- no translation found for tile_disabled (373212051546573069) -->
- <skip />
+ <string name="tile_disabled" msgid="373212051546573069">"ನಿಷ್ಕ್ರಿಯಗೊಳಿಸಲಾಗಿದೆ"</string>
<string name="nav_bar" msgid="4642708685386136807">"ನ್ಯಾವಿಗೇಷನ್ ಬಾರ್"</string>
<string name="nav_bar_layout" msgid="4716392484772899544">"ಲೇಔಟ್"</string>
<string name="left_nav_bar_button_type" msgid="2634852842345192790">"ಹೆಚ್ಚುವರಿ ಎಡ ಬಟನ್ ವಿಧ"</string>
diff --git a/packages/SystemUI/res/values-lo/strings.xml b/packages/SystemUI/res/values-lo/strings.xml
index 91bdc6e..5d70e13 100644
--- a/packages/SystemUI/res/values-lo/strings.xml
+++ b/packages/SystemUI/res/values-lo/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"ຄວາມງຽບ\nທັງໝົດ"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"ບຸລິມະສິດ\nເທົ່ານັ້ນ"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"ໂມງປຸກ\nເທົ່ານັ້ນ"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • ກຳລັງສາກໄຟແບບໄຮ້ສາຍ • ຈະເຕັມໃນອີກ <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • ກຳລັງສາກໄຟ • ຈະເຕັມໃນອີກ <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • ກຳລັງສາກໄຟແບບໄວ • ຈະເຕັມໃນອີກ <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • ກຳລັງສາກໄຟແບບຊ້າ • ຈະເຕັມໃນອີກ <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"ສະຫຼັບຜູ້ໃຊ້"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"ປ່ຽນຜູ່ໃຊ້, ຜູ່ໃຊ້ປະຈຸບັນ <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"ຜູ້ໃຊ້ປະຈຸບັນ <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-lt/strings.xml b/packages/SystemUI/res/values-lt/strings.xml
index 407db29..fdb8c10 100644
--- a/packages/SystemUI/res/values-lt/strings.xml
+++ b/packages/SystemUI/res/values-lt/strings.xml
@@ -477,14 +477,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Visiška\ntyla"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Tik\nprioritetiniai"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Tik\nsignalai"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Įkraunama be laidų • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> iki visiško įkrovimo"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Įkraunama • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> iki visiško įkrovimo"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Sparčiai įkraunama • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> iki visiško įkrovimo"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Lėtai įkraunama • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> iki visiško įkrovimo"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Perjungti naudotoją"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Perjungti naudotoją, dabartinis naudotojas <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Dabartinis naudotojas <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-mk/strings.xml b/packages/SystemUI/res/values-mk/strings.xml
index c4524f3..fdb76bb 100644
--- a/packages/SystemUI/res/values-mk/strings.xml
+++ b/packages/SystemUI/res/values-mk/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Целосна\nтишина"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Само\nприоритетни"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Само\nаларми"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Се полни безжично • Полна по <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Се полни • Полна по <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Се полни брзо • Полна по <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Се полни бавно • Полна по <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Промени го корисникот"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Промени го корисникот, тековен корисник <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Тековен корисник <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-mn/strings.xml b/packages/SystemUI/res/values-mn/strings.xml
index 7001a1a..8d3dffd 100644
--- a/packages/SystemUI/res/values-mn/strings.xml
+++ b/packages/SystemUI/res/values-mn/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Дуугүй\nболгох"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Зөвхөн\nхамгийн чухлыг"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Зөвхөн\nсэрүүлэг"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Утасгүй цэнэглэж байна • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>-н дараа дүүрнэ"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Цэнэглэж байна • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>-н дараа дүүрнэ"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Хурдтай цэнэглэж байна • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>-н дараа дүүрнэ"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Удаан цэнэглэж байна • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>-н дараа дүүрнэ"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Хэрэглэгчийг сэлгэх"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Хэрэглэгчийг сэлгэх, одоогийн хэрэглэгч <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Одоогийн хэрэглэгч <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-ms/strings.xml b/packages/SystemUI/res/values-ms/strings.xml
index 837d900..267b74a 100644
--- a/packages/SystemUI/res/values-ms/strings.xml
+++ b/packages/SystemUI/res/values-ms/strings.xml
@@ -289,11 +289,9 @@
<string name="accessibility_quick_settings_hotspot_changed_off" msgid="7002061268910095176">"Tempat liputan mudah alih bergerak dimatikan."</string>
<string name="accessibility_quick_settings_hotspot_changed_on" msgid="2576895346762408840">"Tempat liputan mudah alih bergerak dihidupkan."</string>
<string name="accessibility_casting_turned_off" msgid="1387906158563374962">"Penghantaran skrin dihentikan."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_off (9106217884005620744) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_off" msgid="9106217884005620744">"Mod kerja dijeda."</string>
<string name="accessibility_quick_settings_work_mode_on" msgid="2779253456042059110">"Mod kerja hidup."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_changed_off (2653550342355027441) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_changed_off" msgid="2653550342355027441">"Mod kerja dijeda."</string>
<string name="accessibility_quick_settings_work_mode_changed_on" msgid="1105258550138313384">"Mod kerja dihidupkan."</string>
<string name="accessibility_quick_settings_data_saver_changed_off" msgid="4910847127871603832">"Penjimat Data dimatikan."</string>
<string name="accessibility_quick_settings_data_saver_changed_on" msgid="6370606590802623078">"Penjimat Data dihidupkan."</string>
@@ -412,8 +410,7 @@
<string name="quick_settings_cellular_detail_data_limit" msgid="1791389609409211628">"<xliff:g id="DATA_LIMIT">%s</xliff:g> had"</string>
<string name="quick_settings_cellular_detail_data_warning" msgid="7957253810481086455">"Amaran <xliff:g id="DATA_LIMIT">%s</xliff:g>"</string>
<string name="quick_settings_work_mode_label" msgid="2754212289804324685">"Profil kerja"</string>
- <!-- no translation found for quick_settings_work_mode_paused (4841109346916998613) -->
- <skip />
+ <string name="quick_settings_work_mode_paused" msgid="4841109346916998613">"Dijeda"</string>
<string name="quick_settings_night_display_label" msgid="8180030659141778180">"Cahaya Malam"</string>
<string name="quick_settings_night_secondary_label_on_at_sunset" msgid="3358706312129866626">"Dihidupkan pd senja"</string>
<string name="quick_settings_night_secondary_label_until_sunrise" msgid="4063448287758262485">"Hingga matahari terbit"</string>
@@ -676,12 +673,10 @@
<string name="wallet_title" msgid="5369767670735827105">"Wallet"</string>
<string name="wallet_app_button_label" msgid="7123784239111190992">"Tunjukkan semua"</string>
<string name="wallet_action_button_label_unlock" msgid="8663239748726774487">"Buka kunci untuk membayar"</string>
- <!-- no translation found for wallet_secondary_label_no_card (1282609666895946317) -->
- <skip />
+ <string name="wallet_secondary_label_no_card" msgid="1282609666895946317">"Tidak disediakan"</string>
<string name="wallet_secondary_label_device_locked" msgid="5175862019125370506">"Buka kunci untuk menggunakan"</string>
<string name="wallet_error_generic" msgid="257704570182963611">"Terdapat masalah sewaktu mendapatkan kad anda. Sila cuba sebentar lagi"</string>
- <!-- no translation found for wallet_lockscreen_settings_label (3539105300870383570) -->
- <skip />
+ <string name="wallet_lockscreen_settings_label" msgid="3539105300870383570">"Tetapan skrin kunci"</string>
<string name="status_bar_work" msgid="5238641949837091056">"Profil kerja"</string>
<string name="status_bar_airplane" msgid="4848702508684541009">"Mod pesawat"</string>
<string name="add_tile" msgid="6239678623873086686">"Tambahkan jubin"</string>
@@ -871,8 +866,7 @@
<string name="switch_bar_on" msgid="1770868129120096114">"Hidup"</string>
<string name="switch_bar_off" msgid="5669805115416379556">"Mati"</string>
<string name="tile_unavailable" msgid="3095879009136616920">"Tidak tersedia"</string>
- <!-- no translation found for tile_disabled (373212051546573069) -->
- <skip />
+ <string name="tile_disabled" msgid="373212051546573069">"Dilumpuhkan"</string>
<string name="nav_bar" msgid="4642708685386136807">"Bar navigasi"</string>
<string name="nav_bar_layout" msgid="4716392484772899544">"Reka letak"</string>
<string name="left_nav_bar_button_type" msgid="2634852842345192790">"Jenis butang kiri tambahan"</string>
diff --git a/packages/SystemUI/res/values-nb/strings.xml b/packages/SystemUI/res/values-nb/strings.xml
index fa6e62e..cf82ea4 100644
--- a/packages/SystemUI/res/values-nb/strings.xml
+++ b/packages/SystemUI/res/values-nb/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Total\nstillhet"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Bare\nPrioritet"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Bare\nalarmer"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Lader trådløst • Fulladet om <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Lader • Fulladet om <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Lader raskt • Fulladet om <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Lader sakte • Fulladet om <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Bytt bruker"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Bytt bruker, gjeldende bruker er <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Gjeldende bruker: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-nl/strings.xml b/packages/SystemUI/res/values-nl/strings.xml
index 26412ce..be1735c 100644
--- a/packages/SystemUI/res/values-nl/strings.xml
+++ b/packages/SystemUI/res/values-nl/strings.xml
@@ -289,11 +289,9 @@
<string name="accessibility_quick_settings_hotspot_changed_off" msgid="7002061268910095176">"Mobiele hotspot staat uit."</string>
<string name="accessibility_quick_settings_hotspot_changed_on" msgid="2576895346762408840">"Mobiele hotspot staat aan."</string>
<string name="accessibility_casting_turned_off" msgid="1387906158563374962">"Casten van scherm gestopt."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_off (9106217884005620744) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_off" msgid="9106217884005620744">"Werkmodus is onderbroken."</string>
<string name="accessibility_quick_settings_work_mode_on" msgid="2779253456042059110">"Werkmodus aan."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_changed_off (2653550342355027441) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_changed_off" msgid="2653550342355027441">"Werkmodus is uitgezet."</string>
<string name="accessibility_quick_settings_work_mode_changed_on" msgid="1105258550138313384">"Werkmodus staat aan."</string>
<string name="accessibility_quick_settings_data_saver_changed_off" msgid="4910847127871603832">"Databesparing staat uit."</string>
<string name="accessibility_quick_settings_data_saver_changed_on" msgid="6370606590802623078">"Databesparing staat aan."</string>
@@ -412,8 +410,7 @@
<string name="quick_settings_cellular_detail_data_limit" msgid="1791389609409211628">"Limiet van <xliff:g id="DATA_LIMIT">%s</xliff:g>"</string>
<string name="quick_settings_cellular_detail_data_warning" msgid="7957253810481086455">"Waarschuwing voor <xliff:g id="DATA_LIMIT">%s</xliff:g>"</string>
<string name="quick_settings_work_mode_label" msgid="2754212289804324685">"Werkprofiel"</string>
- <!-- no translation found for quick_settings_work_mode_paused (4841109346916998613) -->
- <skip />
+ <string name="quick_settings_work_mode_paused" msgid="4841109346916998613">"Onderbroken"</string>
<string name="quick_settings_night_display_label" msgid="8180030659141778180">"Nachtverlichting"</string>
<string name="quick_settings_night_secondary_label_on_at_sunset" msgid="3358706312129866626">"Aan bij zonsondergang"</string>
<string name="quick_settings_night_secondary_label_until_sunrise" msgid="4063448287758262485">"Tot zonsopgang"</string>
@@ -473,14 +470,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Totale\nstilte"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Alleen\nprioriteit"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Alleen\nalarmen"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Draadloos opladen • Vol over <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Opladen • Vol over <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Snel opladen • Vol over <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Langzaam opladen • Vol over <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Gebruiker wijzigen"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Schakelen tussen gebruikers, huidige gebruiker <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Huidige gebruiker <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
@@ -676,12 +669,10 @@
<string name="wallet_title" msgid="5369767670735827105">"Wallet"</string>
<string name="wallet_app_button_label" msgid="7123784239111190992">"Alles tonen"</string>
<string name="wallet_action_button_label_unlock" msgid="8663239748726774487">"Ontgrendelen om te betalen"</string>
- <!-- no translation found for wallet_secondary_label_no_card (1282609666895946317) -->
- <skip />
+ <string name="wallet_secondary_label_no_card" msgid="1282609666895946317">"Niet ingesteld"</string>
<string name="wallet_secondary_label_device_locked" msgid="5175862019125370506">"Ontgrendelen om te gebruiken"</string>
<string name="wallet_error_generic" msgid="257704570182963611">"Er is een probleem opgetreden bij het ophalen van je kaarten. Probeer het later opnieuw."</string>
- <!-- no translation found for wallet_lockscreen_settings_label (3539105300870383570) -->
- <skip />
+ <string name="wallet_lockscreen_settings_label" msgid="3539105300870383570">"Instellingen voor vergrendelscherm"</string>
<string name="status_bar_work" msgid="5238641949837091056">"Werkprofiel"</string>
<string name="status_bar_airplane" msgid="4848702508684541009">"Vliegtuigmodus"</string>
<string name="add_tile" msgid="6239678623873086686">"Tegel toevoegen"</string>
@@ -871,8 +862,7 @@
<string name="switch_bar_on" msgid="1770868129120096114">"Aan"</string>
<string name="switch_bar_off" msgid="5669805115416379556">"Uit"</string>
<string name="tile_unavailable" msgid="3095879009136616920">"Niet beschikbaar"</string>
- <!-- no translation found for tile_disabled (373212051546573069) -->
- <skip />
+ <string name="tile_disabled" msgid="373212051546573069">"Uit"</string>
<string name="nav_bar" msgid="4642708685386136807">"Navigatiebalk"</string>
<string name="nav_bar_layout" msgid="4716392484772899544">"Lay-out"</string>
<string name="left_nav_bar_button_type" msgid="2634852842345192790">"Extra knoptype links"</string>
diff --git a/packages/SystemUI/res/values-or/strings.xml b/packages/SystemUI/res/values-or/strings.xml
index 268c245..9a2cd80 100644
--- a/packages/SystemUI/res/values-or/strings.xml
+++ b/packages/SystemUI/res/values-or/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"ସମ୍ପୂର୍ଣ୍ଣ\nନୀରବ"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"କେବଳ\nପ୍ରାଥମିକତା"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"କେବଳ\nଆଲାର୍ମ"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • ୱାୟାରଲେସ୍ ଭାବେ ଚାର୍ଜ ହେଉଛି • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>ରେ ସମ୍ପୂର୍ଣ୍ଣ ହେବ"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • ଚାର୍ଜ ହେଉଛି • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>ରେ ସମ୍ପୂର୍ଣ୍ଣ ହେବ"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • ଶୀଘ୍ର ଚାର୍ଜ ହେଉଛି • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>ରେ ସମ୍ପୂର୍ଣ୍ଣ ହେବ"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • ଧୀରେ ଚାର୍ଜ ହେଉଛି • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>ରେ ସମ୍ପୂର୍ଣ୍ଣ ହେବ"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"ୟୁଜର୍ ବଦଳାନ୍ତୁ"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"ୟୁଜର୍ ବଦଳାନ୍ତୁ, ବର୍ତ୍ତମାନର ୟୁଜର୍ ହେଉଛନ୍ତି <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"ବର୍ତ୍ତମାନର ୟୁଜର୍ ହେଉଛନ୍ତି <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
@@ -750,14 +746,10 @@
<string name="notification_channel_summary_automatic_silenced" msgid="7403004439649872047">"<b>ସ୍ଥିତି:</b> ନୀରବକୁ ଡିମୋଟ୍ କରାଯାଇଛି"</string>
<string name="notification_channel_summary_automatic_promoted" msgid="1301710305149590426">"<b>ସ୍ଥିତି:</b> ରେଙ୍କ ଉପରକୁ କରାଯାଇଛି"</string>
<string name="notification_channel_summary_automatic_demoted" msgid="1831303964660807700">"<b>ସ୍ଥିତି:</b> ରେଙ୍କ ତଳକୁ କରାଯାଇଛି"</string>
- <!-- no translation found for notification_channel_summary_priority_baseline (46674690072551234) -->
- <skip />
- <!-- no translation found for notification_channel_summary_priority_bubble (1275413109619074576) -->
- <skip />
- <!-- no translation found for notification_channel_summary_priority_dnd (6665395023264154361) -->
- <skip />
- <!-- no translation found for notification_channel_summary_priority_all (7151752959650048285) -->
- <skip />
+ <string name="notification_channel_summary_priority_baseline" msgid="46674690072551234">"ବାର୍ତ୍ତାଳାପ ବିଜ୍ଞପ୍ତିଗୁଡ଼ିକର ଶୀର୍ଷରେ ଏବଂ ଲକ୍ ସ୍କ୍ରିନରେ ଏକ ପ୍ରୋଫାଇଲ୍ ଛବି ଭାବେ ଦେଖାଏ"</string>
+ <string name="notification_channel_summary_priority_bubble" msgid="1275413109619074576">"ବାର୍ତ୍ତାଳାପ ବିଜ୍ଞପ୍ତିଗୁଡ଼ିକର ଶୀର୍ଷରେ ଏବଂ ଲକ୍ ସ୍କ୍ରିନରେ ଏକ ପ୍ରୋଫାଇଲ୍ ଛବି ଭାବେ ଦେଖାଏ, ଏକ ବବଲ୍ ଭାବେ ଦେଖାଯାଏ"</string>
+ <string name="notification_channel_summary_priority_dnd" msgid="6665395023264154361">"ବାର୍ତ୍ତାଳାପ ବିଜ୍ଞପ୍ତିଗୁଡ଼ିକର ଶୀର୍ଷରେ ଏବଂ ଲକ୍ ସ୍କ୍ରିନରେ ଏକ ପ୍ରୋଫାଇଲ୍ ଛବି ଭାବେ ଦେଖାଏ, \'ବିରକ୍ତ କରନ୍ତୁ ନାହିଁ\'କୁ ବାଧା ଦିଏ"</string>
+ <string name="notification_channel_summary_priority_all" msgid="7151752959650048285">"ବାର୍ତ୍ତାଳାପ ବିଜ୍ଞପ୍ତିଗୁଡ଼ିକର ଶୀର୍ଷରେ ଏବଂ ଲକ୍ ସ୍କ୍ରିନରେ ଏକ ପ୍ରୋଫାଇଲ୍ ଛବି ଭାବେ ଦେଖାଏ, ଏକ ବବଲ୍ ଭାବେ ଦେଖାଯାଏ, \'ବିରକ୍ତ କରନ୍ତୁ ନାହିଁ\'କୁ ବାଧା ଦିଏ"</string>
<string name="notification_conversation_channel_settings" msgid="2409977688430606835">"ସେଟିଂସ୍"</string>
<string name="notification_priority_title" msgid="2079708866333537093">"ପ୍ରାଥମିକତା"</string>
<string name="no_shortcut" msgid="8257177117568230126">"<xliff:g id="APP_NAME">%1$s</xliff:g> ବାର୍ତ୍ତାଳାପ ଫିଚରଗୁଡ଼ିକୁ ସମର୍ଥନ କରେ ନାହିଁ"</string>
diff --git a/packages/SystemUI/res/values-pa/strings.xml b/packages/SystemUI/res/values-pa/strings.xml
index 635cb2f..bc9b2ee 100644
--- a/packages/SystemUI/res/values-pa/strings.xml
+++ b/packages/SystemUI/res/values-pa/strings.xml
@@ -750,14 +750,10 @@
<string name="notification_channel_summary_automatic_silenced" msgid="7403004439649872047">"<b>ਸਥਿਤੀ:</b> ਦਰਜਾ ਘਟਾ ਕੇ ਸ਼ਾਂਤ \'ਤੇ ਸੈੱਟ ਕੀਤਾ ਗਿਆ"</string>
<string name="notification_channel_summary_automatic_promoted" msgid="1301710305149590426">"<b>ਸਥਿਤੀ:</b> ਦਰਜਾ ਵਧਾਇਆ ਗਿਆ"</string>
<string name="notification_channel_summary_automatic_demoted" msgid="1831303964660807700">"<b>ਸਥਿਤੀ:</b> ਦਰਜਾ ਘਟਾਇਆ ਗਿਆ"</string>
- <!-- no translation found for notification_channel_summary_priority_baseline (46674690072551234) -->
- <skip />
- <!-- no translation found for notification_channel_summary_priority_bubble (1275413109619074576) -->
- <skip />
- <!-- no translation found for notification_channel_summary_priority_dnd (6665395023264154361) -->
- <skip />
- <!-- no translation found for notification_channel_summary_priority_all (7151752959650048285) -->
- <skip />
+ <string name="notification_channel_summary_priority_baseline" msgid="46674690072551234">"ਗੱਲਬਾਤ ਸੂਚਨਾਵਾਂ ਦੇ ਸਿਖਰ \'ਤੇ ਅਤੇ ਲਾਕ ਸਕ੍ਰੀਨ \'ਤੇ ਪ੍ਰੋਫਾਈਲ ਤਸਵੀਰ ਵਜੋਂ ਦਿਖਾਉਂਦਾ ਹੈ"</string>
+ <string name="notification_channel_summary_priority_bubble" msgid="1275413109619074576">"ਗੱਲਬਾਤ ਸੂਚਨਾਵਾਂ ਦੇ ਸਿਖਰ \'ਤੇ ਅਤੇ ਲਾਕ ਸਕ੍ਰੀਨ \'ਤੇ ਪ੍ਰੋਫਾਈਲ ਤਸਵੀਰ, ਬਬਲ ਵਜੋਂ ਦਿਖਾਉਂਦਾ ਹੈ"</string>
+ <string name="notification_channel_summary_priority_dnd" msgid="6665395023264154361">"ਗੱਲਬਾਤ ਸੂਚਨਾਵਾਂ ਦੇ ਸਿਖਰ \'ਤੇ ਅਤੇ ਲਾਕ ਸਕ੍ਰੀਨ \'ਤੇ ਪ੍ਰੋਫਾਈਲ ਤਸਵੀਰ ਵਜੋਂ ਦਿਖਾਉਂਦਾ ਹੈ, \'ਪਰੇਸ਼ਾਨ ਨਾ ਕਰੋ\' ਸੁਵਿਧਾ ਵਿੱਚ ਵੀ ਵਿਘਨ ਪੈ ਸਕਦਾ ਹੈ"</string>
+ <string name="notification_channel_summary_priority_all" msgid="7151752959650048285">"ਗੱਲਬਾਤ ਸੂਚਨਾਵਾਂ ਦੇ ਸਿਖਰ \'ਤੇ ਅਤੇ ਲਾਕ ਸਕ੍ਰੀਨ \'ਤੇ ਪ੍ਰੋਫਾਈਲ ਤਸਵੀਰ, ਬਬਲ ਵਜੋਂ ਦਿਖਾਉਂਦਾ ਹੈ, \'ਪਰੇਸ਼ਾਨ ਨਾ ਕਰੋ\' ਸੁਵਿਧਾ ਵਿੱਚ ਵੀ ਵਿਘਨ ਪੈ ਸਕਦਾ ਹੈ"</string>
<string name="notification_conversation_channel_settings" msgid="2409977688430606835">"ਸੈਟਿੰਗਾਂ"</string>
<string name="notification_priority_title" msgid="2079708866333537093">"ਤਰਜੀਹ"</string>
<string name="no_shortcut" msgid="8257177117568230126">"<xliff:g id="APP_NAME">%1$s</xliff:g> ਐਪ ਗੱਲਬਾਤ ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ ਦਾ ਸਮਰਥਨ ਨਹੀਂ ਕਰਦੀ"</string>
diff --git a/packages/SystemUI/res/values-pl/strings.xml b/packages/SystemUI/res/values-pl/strings.xml
index 6ee7453..3c6578e 100644
--- a/packages/SystemUI/res/values-pl/strings.xml
+++ b/packages/SystemUI/res/values-pl/strings.xml
@@ -477,14 +477,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Całkowita\ncisza"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Tylko\npriorytetowe"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Tylko\nalarmy"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Ładowanie bezprzewodowe • Pełne naładowanie za <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Ładowanie • Pełne naładowanie za <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Szybkie ładowanie • Pełne naładowanie za <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Wolne ładowanie • Pełne naładowanie za <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Przełącz użytkownika"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Przełącz użytkownika. Bieżący użytkownik: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Bieżący użytkownik: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-pt-rBR/strings.xml b/packages/SystemUI/res/values-pt-rBR/strings.xml
index b15a144..8228c0c 100644
--- a/packages/SystemUI/res/values-pt-rBR/strings.xml
+++ b/packages/SystemUI/res/values-pt-rBR/strings.xml
@@ -289,11 +289,9 @@
<string name="accessibility_quick_settings_hotspot_changed_off" msgid="7002061268910095176">"O ponto de acesso móvel foi desativado."</string>
<string name="accessibility_quick_settings_hotspot_changed_on" msgid="2576895346762408840">"O ponto de acesso móvel foi ativado."</string>
<string name="accessibility_casting_turned_off" msgid="1387906158563374962">"A transmissão de tela foi interrompida."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_off (9106217884005620744) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_off" msgid="9106217884005620744">"Modo de trabalho pausado."</string>
<string name="accessibility_quick_settings_work_mode_on" msgid="2779253456042059110">"Modo de trabalho ativado."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_changed_off (2653550342355027441) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_changed_off" msgid="2653550342355027441">"O modo de trabalho foi pausado."</string>
<string name="accessibility_quick_settings_work_mode_changed_on" msgid="1105258550138313384">"Modo de trabalho ativado."</string>
<string name="accessibility_quick_settings_data_saver_changed_off" msgid="4910847127871603832">"Economia de dados desativada."</string>
<string name="accessibility_quick_settings_data_saver_changed_on" msgid="6370606590802623078">"Economia de dados ativada."</string>
@@ -412,8 +410,7 @@
<string name="quick_settings_cellular_detail_data_limit" msgid="1791389609409211628">"Limite: <xliff:g id="DATA_LIMIT">%s</xliff:g>"</string>
<string name="quick_settings_cellular_detail_data_warning" msgid="7957253810481086455">"Aviso de <xliff:g id="DATA_LIMIT">%s</xliff:g>"</string>
<string name="quick_settings_work_mode_label" msgid="2754212289804324685">"Perfil de trabalho"</string>
- <!-- no translation found for quick_settings_work_mode_paused (4841109346916998613) -->
- <skip />
+ <string name="quick_settings_work_mode_paused" msgid="4841109346916998613">"Pausado"</string>
<string name="quick_settings_night_display_label" msgid="8180030659141778180">"Modo noturno"</string>
<string name="quick_settings_night_secondary_label_on_at_sunset" msgid="3358706312129866626">"Ativ. ao pôr do sol"</string>
<string name="quick_settings_night_secondary_label_until_sunrise" msgid="4063448287758262485">"Até o nascer do sol"</string>
@@ -473,14 +470,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Silêncio\ntotal"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Somente\nprioridade"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Somente\nalarmes"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Carregando sem fio • Conclusão em <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Carregando • Conclusão em <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Carga rápida • Conclusão em <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Carga lenta • Conclusão em <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Trocar usuário"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Alternar usuário. Usuário atual <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Usuário atual <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
@@ -676,12 +669,10 @@
<string name="wallet_title" msgid="5369767670735827105">"Carteira"</string>
<string name="wallet_app_button_label" msgid="7123784239111190992">"Mostrar tudo"</string>
<string name="wallet_action_button_label_unlock" msgid="8663239748726774487">"Desbloqueie para pagar"</string>
- <!-- no translation found for wallet_secondary_label_no_card (1282609666895946317) -->
- <skip />
+ <string name="wallet_secondary_label_no_card" msgid="1282609666895946317">"Dispositivos não configurados"</string>
<string name="wallet_secondary_label_device_locked" msgid="5175862019125370506">"Desbloquear para usar"</string>
<string name="wallet_error_generic" msgid="257704570182963611">"Ocorreu um problema ao carregar os cards. Tente novamente mais tarde"</string>
- <!-- no translation found for wallet_lockscreen_settings_label (3539105300870383570) -->
- <skip />
+ <string name="wallet_lockscreen_settings_label" msgid="3539105300870383570">"Configurações de tela de bloqueio"</string>
<string name="status_bar_work" msgid="5238641949837091056">"Perfil de trabalho"</string>
<string name="status_bar_airplane" msgid="4848702508684541009">"Modo avião"</string>
<string name="add_tile" msgid="6239678623873086686">"Adicionar bloco"</string>
@@ -871,8 +862,7 @@
<string name="switch_bar_on" msgid="1770868129120096114">"Ativado"</string>
<string name="switch_bar_off" msgid="5669805115416379556">"Desativado"</string>
<string name="tile_unavailable" msgid="3095879009136616920">"Indisponível"</string>
- <!-- no translation found for tile_disabled (373212051546573069) -->
- <skip />
+ <string name="tile_disabled" msgid="373212051546573069">"Desativado"</string>
<string name="nav_bar" msgid="4642708685386136807">"Barra de navegação"</string>
<string name="nav_bar_layout" msgid="4716392484772899544">"Layout"</string>
<string name="left_nav_bar_button_type" msgid="2634852842345192790">"Tipo de botão esquerdo extra"</string>
diff --git a/packages/SystemUI/res/values-pt-rPT/strings.xml b/packages/SystemUI/res/values-pt-rPT/strings.xml
index 90b1931..afebc31 100644
--- a/packages/SystemUI/res/values-pt-rPT/strings.xml
+++ b/packages/SystemUI/res/values-pt-rPT/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Silêncio\ntotal"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Apenas\nprioridade"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Apenas\nalarmes"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • A carregar sem fios • Carga completa em <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • A carregar • Carga completa em <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • A carregar rapidamente • Carga completa em <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • A carregar lentamente • Carga completa em <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Mudar utilizador"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Mudar de utilizador; o utilizador atual é <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Utilizador atual: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-pt/strings.xml b/packages/SystemUI/res/values-pt/strings.xml
index b15a144..8228c0c 100644
--- a/packages/SystemUI/res/values-pt/strings.xml
+++ b/packages/SystemUI/res/values-pt/strings.xml
@@ -289,11 +289,9 @@
<string name="accessibility_quick_settings_hotspot_changed_off" msgid="7002061268910095176">"O ponto de acesso móvel foi desativado."</string>
<string name="accessibility_quick_settings_hotspot_changed_on" msgid="2576895346762408840">"O ponto de acesso móvel foi ativado."</string>
<string name="accessibility_casting_turned_off" msgid="1387906158563374962">"A transmissão de tela foi interrompida."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_off (9106217884005620744) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_off" msgid="9106217884005620744">"Modo de trabalho pausado."</string>
<string name="accessibility_quick_settings_work_mode_on" msgid="2779253456042059110">"Modo de trabalho ativado."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_changed_off (2653550342355027441) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_changed_off" msgid="2653550342355027441">"O modo de trabalho foi pausado."</string>
<string name="accessibility_quick_settings_work_mode_changed_on" msgid="1105258550138313384">"Modo de trabalho ativado."</string>
<string name="accessibility_quick_settings_data_saver_changed_off" msgid="4910847127871603832">"Economia de dados desativada."</string>
<string name="accessibility_quick_settings_data_saver_changed_on" msgid="6370606590802623078">"Economia de dados ativada."</string>
@@ -412,8 +410,7 @@
<string name="quick_settings_cellular_detail_data_limit" msgid="1791389609409211628">"Limite: <xliff:g id="DATA_LIMIT">%s</xliff:g>"</string>
<string name="quick_settings_cellular_detail_data_warning" msgid="7957253810481086455">"Aviso de <xliff:g id="DATA_LIMIT">%s</xliff:g>"</string>
<string name="quick_settings_work_mode_label" msgid="2754212289804324685">"Perfil de trabalho"</string>
- <!-- no translation found for quick_settings_work_mode_paused (4841109346916998613) -->
- <skip />
+ <string name="quick_settings_work_mode_paused" msgid="4841109346916998613">"Pausado"</string>
<string name="quick_settings_night_display_label" msgid="8180030659141778180">"Modo noturno"</string>
<string name="quick_settings_night_secondary_label_on_at_sunset" msgid="3358706312129866626">"Ativ. ao pôr do sol"</string>
<string name="quick_settings_night_secondary_label_until_sunrise" msgid="4063448287758262485">"Até o nascer do sol"</string>
@@ -473,14 +470,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Silêncio\ntotal"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Somente\nprioridade"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Somente\nalarmes"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Carregando sem fio • Conclusão em <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Carregando • Conclusão em <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Carga rápida • Conclusão em <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Carga lenta • Conclusão em <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Trocar usuário"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Alternar usuário. Usuário atual <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Usuário atual <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
@@ -676,12 +669,10 @@
<string name="wallet_title" msgid="5369767670735827105">"Carteira"</string>
<string name="wallet_app_button_label" msgid="7123784239111190992">"Mostrar tudo"</string>
<string name="wallet_action_button_label_unlock" msgid="8663239748726774487">"Desbloqueie para pagar"</string>
- <!-- no translation found for wallet_secondary_label_no_card (1282609666895946317) -->
- <skip />
+ <string name="wallet_secondary_label_no_card" msgid="1282609666895946317">"Dispositivos não configurados"</string>
<string name="wallet_secondary_label_device_locked" msgid="5175862019125370506">"Desbloquear para usar"</string>
<string name="wallet_error_generic" msgid="257704570182963611">"Ocorreu um problema ao carregar os cards. Tente novamente mais tarde"</string>
- <!-- no translation found for wallet_lockscreen_settings_label (3539105300870383570) -->
- <skip />
+ <string name="wallet_lockscreen_settings_label" msgid="3539105300870383570">"Configurações de tela de bloqueio"</string>
<string name="status_bar_work" msgid="5238641949837091056">"Perfil de trabalho"</string>
<string name="status_bar_airplane" msgid="4848702508684541009">"Modo avião"</string>
<string name="add_tile" msgid="6239678623873086686">"Adicionar bloco"</string>
@@ -871,8 +862,7 @@
<string name="switch_bar_on" msgid="1770868129120096114">"Ativado"</string>
<string name="switch_bar_off" msgid="5669805115416379556">"Desativado"</string>
<string name="tile_unavailable" msgid="3095879009136616920">"Indisponível"</string>
- <!-- no translation found for tile_disabled (373212051546573069) -->
- <skip />
+ <string name="tile_disabled" msgid="373212051546573069">"Desativado"</string>
<string name="nav_bar" msgid="4642708685386136807">"Barra de navegação"</string>
<string name="nav_bar_layout" msgid="4716392484772899544">"Layout"</string>
<string name="left_nav_bar_button_type" msgid="2634852842345192790">"Tipo de botão esquerdo extra"</string>
diff --git a/packages/SystemUI/res/values-sk/strings.xml b/packages/SystemUI/res/values-sk/strings.xml
index 44325f7..407ad62 100644
--- a/packages/SystemUI/res/values-sk/strings.xml
+++ b/packages/SystemUI/res/values-sk/strings.xml
@@ -289,11 +289,9 @@
<string name="accessibility_quick_settings_hotspot_changed_off" msgid="7002061268910095176">"Mobilný hotspot je vypnutý."</string>
<string name="accessibility_quick_settings_hotspot_changed_on" msgid="2576895346762408840">"Mobilný hotspot je zapnutý."</string>
<string name="accessibility_casting_turned_off" msgid="1387906158563374962">"Prenášanie bolo zastavené."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_off (9106217884005620744) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_off" msgid="9106217884005620744">"Pracovný režim je pozastavený."</string>
<string name="accessibility_quick_settings_work_mode_on" msgid="2779253456042059110">"Pracovný režim zapnutý"</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_changed_off (2653550342355027441) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_changed_off" msgid="2653550342355027441">"Pracovný režim bol pozastavený."</string>
<string name="accessibility_quick_settings_work_mode_changed_on" msgid="1105258550138313384">"Pracovný režim je zapnutý."</string>
<string name="accessibility_quick_settings_data_saver_changed_off" msgid="4910847127871603832">"Šetrič dát bol vypnutý."</string>
<string name="accessibility_quick_settings_data_saver_changed_on" msgid="6370606590802623078">"Šetrič dát bol zapnutý."</string>
@@ -416,8 +414,7 @@
<string name="quick_settings_cellular_detail_data_limit" msgid="1791389609409211628">"Limit: <xliff:g id="DATA_LIMIT">%s</xliff:g>"</string>
<string name="quick_settings_cellular_detail_data_warning" msgid="7957253810481086455">"Upozornenie pri <xliff:g id="DATA_LIMIT">%s</xliff:g>"</string>
<string name="quick_settings_work_mode_label" msgid="2754212289804324685">"Pracovný profil"</string>
- <!-- no translation found for quick_settings_work_mode_paused (4841109346916998613) -->
- <skip />
+ <string name="quick_settings_work_mode_paused" msgid="4841109346916998613">"Pozastavené"</string>
<string name="quick_settings_night_display_label" msgid="8180030659141778180">"Nočný režim"</string>
<string name="quick_settings_night_secondary_label_on_at_sunset" msgid="3358706312129866626">"Zapne sa pri západe slnka"</string>
<string name="quick_settings_night_secondary_label_until_sunrise" msgid="4063448287758262485">"Do východu slnka"</string>
@@ -477,14 +474,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Úplné\nticho"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Iba\nprioritné"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Iba\nbudíky"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Nabíja sa bezdrôtovo • Do úplného nabitia zostáva <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Nabíja sa • Do úplného nabitia zostáva <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Nabíja sa rýchlo • Do úplného nabitia zostáva <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Nabíja sa pomaly • Do úplného nabitia zostáva <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Prepnutie používateľa"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Prepnúť používateľa (súčasný používateľ: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>)"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Aktuálny používateľ <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
@@ -682,12 +675,10 @@
<string name="wallet_title" msgid="5369767670735827105">"Peňaženka"</string>
<string name="wallet_app_button_label" msgid="7123784239111190992">"Zobraziť všetko"</string>
<string name="wallet_action_button_label_unlock" msgid="8663239748726774487">"Odomknúť a zaplatiť"</string>
- <!-- no translation found for wallet_secondary_label_no_card (1282609666895946317) -->
- <skip />
+ <string name="wallet_secondary_label_no_card" msgid="1282609666895946317">"Nenastavené"</string>
<string name="wallet_secondary_label_device_locked" msgid="5175862019125370506">"Odomknúť a použiť"</string>
<string name="wallet_error_generic" msgid="257704570182963611">"Pri načítavaní kariet sa vyskytol problém. Skúste to neskôr."</string>
- <!-- no translation found for wallet_lockscreen_settings_label (3539105300870383570) -->
- <skip />
+ <string name="wallet_lockscreen_settings_label" msgid="3539105300870383570">"Nastavenia uzamknutej obrazovky"</string>
<string name="status_bar_work" msgid="5238641949837091056">"Pracovný profil"</string>
<string name="status_bar_airplane" msgid="4848702508684541009">"Režim v lietadle"</string>
<string name="add_tile" msgid="6239678623873086686">"Pridať dlaždicu"</string>
@@ -881,8 +872,7 @@
<string name="switch_bar_on" msgid="1770868129120096114">"Zapnuté"</string>
<string name="switch_bar_off" msgid="5669805115416379556">"Vypnuté"</string>
<string name="tile_unavailable" msgid="3095879009136616920">"Nedostupné"</string>
- <!-- no translation found for tile_disabled (373212051546573069) -->
- <skip />
+ <string name="tile_disabled" msgid="373212051546573069">"Deaktivované"</string>
<string name="nav_bar" msgid="4642708685386136807">"Navigačný panel"</string>
<string name="nav_bar_layout" msgid="4716392484772899544">"Rozloženie"</string>
<string name="left_nav_bar_button_type" msgid="2634852842345192790">"Dodatočný typ ľavého tlačidla"</string>
diff --git a/packages/SystemUI/res/values-sq/strings.xml b/packages/SystemUI/res/values-sq/strings.xml
index 70b53cb..d44bd22 100644
--- a/packages/SystemUI/res/values-sq/strings.xml
+++ b/packages/SystemUI/res/values-sq/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Heshtje\ne plotë"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Vetëm\nme prioritet"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Vetëm\nalarmet"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Po karikohet me valë • Plot për <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Po karikohet • Plot për <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Po karikohet shpejt • Plot për <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Po karikohet ngadalë • Plot për <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Ndërro përdorues"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Ndërro përdoruesin. Përdoruesi aktual është <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Përdoruesi aktual <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
@@ -750,14 +746,10 @@
<string name="notification_channel_summary_automatic_silenced" msgid="7403004439649872047">"<b>Statusi:</b> Ulur në nivel si në heshtje"</string>
<string name="notification_channel_summary_automatic_promoted" msgid="1301710305149590426">"<b>Statusi:</b> Renditur më lart"</string>
<string name="notification_channel_summary_automatic_demoted" msgid="1831303964660807700">"<b>Statusi:</b> Renditur më poshtë"</string>
- <!-- no translation found for notification_channel_summary_priority_baseline (46674690072551234) -->
- <skip />
- <!-- no translation found for notification_channel_summary_priority_bubble (1275413109619074576) -->
- <skip />
- <!-- no translation found for notification_channel_summary_priority_dnd (6665395023264154361) -->
- <skip />
- <!-- no translation found for notification_channel_summary_priority_all (7151752959650048285) -->
- <skip />
+ <string name="notification_channel_summary_priority_baseline" msgid="46674690072551234">"Shfaqet në krye të njoftimeve të bisedës dhe si fotografia e profilit në ekranin e kyçjes"</string>
+ <string name="notification_channel_summary_priority_bubble" msgid="1275413109619074576">"Shfaqet në krye të njoftimeve të bisedës, shfaqet si fotografia e profilit në ekranin e kyçjes dhe shfaqet si flluskë"</string>
+ <string name="notification_channel_summary_priority_dnd" msgid="6665395023264154361">"Shfaqet në krye të njoftimeve të bisedës, shfaqet si fotografia e profilit në ekranin e kyçjes dhe ndërpret modalitetin \"Mos shqetëso\""</string>
+ <string name="notification_channel_summary_priority_all" msgid="7151752959650048285">"Shfaqet në krye të njoftimeve të bisedës dhe si fotografia e profilit në ekranin e kyçjes, shfaqet si flluskë dhe ndërpret modalitetin \"Mos shqetëso\""</string>
<string name="notification_conversation_channel_settings" msgid="2409977688430606835">"Cilësimet"</string>
<string name="notification_priority_title" msgid="2079708866333537093">"Përparësia"</string>
<string name="no_shortcut" msgid="8257177117568230126">"<xliff:g id="APP_NAME">%1$s</xliff:g> nuk mbështet veçoritë e bisedës"</string>
diff --git a/packages/SystemUI/res/values-sr/strings.xml b/packages/SystemUI/res/values-sr/strings.xml
index de1c9a4..93fb30f 100644
--- a/packages/SystemUI/res/values-sr/strings.xml
+++ b/packages/SystemUI/res/values-sr/strings.xml
@@ -475,14 +475,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Потпуна\nтишина"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Само\nприорит. прекиди"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Само\nаларми"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Бежично се пуни • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> до краја пуњења"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Пуни се • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> до краја пуњења"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Брзо се пуни • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> до краја пуњења"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Споро се пуни • <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g> до краја пуњења"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Замени корисника"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Промените корисника, актуелни корисник је <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Актуелни корисник <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-sv/strings.xml b/packages/SystemUI/res/values-sv/strings.xml
index fcbe07d..3e7e1b1 100644
--- a/packages/SystemUI/res/values-sv/strings.xml
+++ b/packages/SystemUI/res/values-sv/strings.xml
@@ -473,14 +473,10 @@
<string name="interruption_level_none_twoline" msgid="8579382742855486372">"Helt\ntyst"</string>
<string name="interruption_level_priority_twoline" msgid="8523482736582498083">"Endast\nprioriterade"</string>
<string name="interruption_level_alarms_twoline" msgid="2045067991335708767">"Endast\nalarm"</string>
- <!-- no translation found for keyguard_indication_charging_time_wireless (577856646141738675) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time (6492711711891071502) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_fast (8390311020603859480) -->
- <skip />
- <!-- no translation found for keyguard_indication_charging_time_slowly (301936949731705417) -->
- <skip />
+ <string name="keyguard_indication_charging_time_wireless" msgid="577856646141738675">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Laddas trådlöst • Fulladdat om <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time" msgid="6492711711891071502">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Laddas • Fulladdat om <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_fast" msgid="8390311020603859480">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Laddas snabbt • Fulladdat om <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
+ <string name="keyguard_indication_charging_time_slowly" msgid="301936949731705417">"<xliff:g id="PERCENTAGE">%2$s</xliff:g> • Laddas långsamt • Fulladdat om <xliff:g id="CHARGING_TIME_LEFT">%1$s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_switcher" msgid="5330448341251092660">"Byt användare"</string>
<string name="accessibility_multi_user_switch_switcher_with_current" msgid="5759855008166759399">"Byt användare. Aktuell användare: <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
<string name="accessibility_multi_user_switch_inactive" msgid="383168614528618402">"Aktuell användare <xliff:g id="CURRENT_USER_NAME">%s</xliff:g>"</string>
diff --git a/packages/SystemUI/res/values-zu/strings.xml b/packages/SystemUI/res/values-zu/strings.xml
index 1c70acc..0ec4a4b 100644
--- a/packages/SystemUI/res/values-zu/strings.xml
+++ b/packages/SystemUI/res/values-zu/strings.xml
@@ -289,11 +289,9 @@
<string name="accessibility_quick_settings_hotspot_changed_off" msgid="7002061268910095176">"I-hotspot ivaliwe."</string>
<string name="accessibility_quick_settings_hotspot_changed_on" msgid="2576895346762408840">"I-hotspot ivuliwe."</string>
<string name="accessibility_casting_turned_off" msgid="1387906158563374962">"Ukusakaza kwesikrini kumisiwe."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_off (9106217884005620744) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_off" msgid="9106217884005620744">"Imodi yokusebenza imisiwe."</string>
<string name="accessibility_quick_settings_work_mode_on" msgid="2779253456042059110">"Imodi yomsebenzi ivuliwe."</string>
- <!-- no translation found for accessibility_quick_settings_work_mode_changed_off (2653550342355027441) -->
- <skip />
+ <string name="accessibility_quick_settings_work_mode_changed_off" msgid="2653550342355027441">"Imodi yokusebenza imisiwe."</string>
<string name="accessibility_quick_settings_work_mode_changed_on" msgid="1105258550138313384">"Imodi yomsebenzi ivuliwe."</string>
<string name="accessibility_quick_settings_data_saver_changed_off" msgid="4910847127871603832">"Iseva yedatha ivaliwe."</string>
<string name="accessibility_quick_settings_data_saver_changed_on" msgid="6370606590802623078">"Iseva yedatha ivuliwe."</string>
@@ -412,8 +410,7 @@
<string name="quick_settings_cellular_detail_data_limit" msgid="1791389609409211628">"<xliff:g id="DATA_LIMIT">%s</xliff:g> umkhawulo"</string>
<string name="quick_settings_cellular_detail_data_warning" msgid="7957253810481086455">"<xliff:g id="DATA_LIMIT">%s</xliff:g> isexwayiso"</string>
<string name="quick_settings_work_mode_label" msgid="2754212289804324685">"Iphrofayela yomsebenzi"</string>
- <!-- no translation found for quick_settings_work_mode_paused (4841109346916998613) -->
- <skip />
+ <string name="quick_settings_work_mode_paused" msgid="4841109346916998613">"Kumisiwe"</string>
<string name="quick_settings_night_display_label" msgid="8180030659141778180">"Ukukhanya kwasebusuku"</string>
<string name="quick_settings_night_secondary_label_on_at_sunset" msgid="3358706312129866626">"Kuvulwe ekushoneni kwelanga"</string>
<string name="quick_settings_night_secondary_label_until_sunrise" msgid="4063448287758262485">"Kuze kube sekuphumeni kwelanga"</string>
@@ -676,12 +673,10 @@
<string name="wallet_title" msgid="5369767670735827105">"I-wallet"</string>
<string name="wallet_app_button_label" msgid="7123784239111190992">"Bonisa konke"</string>
<string name="wallet_action_button_label_unlock" msgid="8663239748726774487">"Vula ukuze ukhokhele"</string>
- <!-- no translation found for wallet_secondary_label_no_card (1282609666895946317) -->
- <skip />
+ <string name="wallet_secondary_label_no_card" msgid="1282609666895946317">"Akusethiwe"</string>
<string name="wallet_secondary_label_device_locked" msgid="5175862019125370506">"Vula ukuze usebenzise"</string>
<string name="wallet_error_generic" msgid="257704570182963611">"Kube khona inkinga yokuthola amakhadi akho, sicela uzame futhi ngemuva kwesikhathi"</string>
- <!-- no translation found for wallet_lockscreen_settings_label (3539105300870383570) -->
- <skip />
+ <string name="wallet_lockscreen_settings_label" msgid="3539105300870383570">"Amasethingi okukhiya isikrini"</string>
<string name="status_bar_work" msgid="5238641949837091056">"Iphrofayela yomsebenzi"</string>
<string name="status_bar_airplane" msgid="4848702508684541009">"Imodi yendiza"</string>
<string name="add_tile" msgid="6239678623873086686">"Engeza ithayili"</string>
@@ -871,8 +866,7 @@
<string name="switch_bar_on" msgid="1770868129120096114">"Vuliwe"</string>
<string name="switch_bar_off" msgid="5669805115416379556">"Valiwe"</string>
<string name="tile_unavailable" msgid="3095879009136616920">"Akutholakali"</string>
- <!-- no translation found for tile_disabled (373212051546573069) -->
- <skip />
+ <string name="tile_disabled" msgid="373212051546573069">"Kukhutshaziwe"</string>
<string name="nav_bar" msgid="4642708685386136807">"Ibha yokuzula"</string>
<string name="nav_bar_layout" msgid="4716392484772899544">"Isakhiwo"</string>
<string name="left_nav_bar_button_type" msgid="2634852842345192790">"Uhlobo lwenkinobho engakwesokunxele engeziwe"</string>
diff --git a/packages/SystemUI/res/values/attrs.xml b/packages/SystemUI/res/values/attrs.xml
index eb72442..067d56f 100644
--- a/packages/SystemUI/res/values/attrs.xml
+++ b/packages/SystemUI/res/values/attrs.xml
@@ -131,8 +131,6 @@
<declare-styleable name="SmartReplyView">
<attr name="spacing" format="dimension" />
- <attr name="singleLineButtonPaddingHorizontal" format="dimension" />
- <attr name="doubleLineButtonPaddingHorizontal" format="dimension" />
<attr name="buttonStrokeWidth" format="dimension" />
</declare-styleable>
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index 08a2e19..8d2a82c 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -286,7 +286,5 @@
<color name="accessibility_floating_menu_stroke_dark">#26FFFFFF</color> <!-- 15% -->
<!-- Wallet screen -->
- <color name="wallet_white">#FFFFFF</color>
<color name="wallet_card_border">#33FFFFFF</color>
- <color name="wallet_primary_text">@color/GM2_grey_900</color>
</resources>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index c60ec78..fa4771d 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -151,7 +151,7 @@
<dimen name="notification_max_heads_up_height_before_s">162dp</dimen>
<!-- Height of a heads up notification in the status bar -->
- <dimen name="notification_max_heads_up_height">132dp</dimen>
+ <dimen name="notification_max_heads_up_height">143dp</dimen>
<!-- Height of a heads up notification in the status bar -->
<dimen name="notification_max_heads_up_height_increased">188dp</dimen>
@@ -623,8 +623,6 @@
<dimen name="qs_notif_collapsed_space">64dp</dimen>
- <dimen name="qs_container_bottom_padding">24dp</dimen>
-
<!-- Desired qs icon overlay size. -->
<dimen name="qs_detail_icon_overlay_size">24dp</dimen>
@@ -1147,15 +1145,14 @@
<!-- Smart reply button. Total height 48dp, visible height 32dp. -->
<dimen name="smart_reply_button_spacing">8dp</dimen>
<dimen name="smart_reply_button_padding_vertical">14dp</dimen>
- <!-- Note: The following two paddings need to be different until b/78876518 is fixed. -->
- <dimen name="smart_reply_button_padding_horizontal_single_line">20dp</dimen>
- <dimen name="smart_reply_button_padding_horizontal_double_line">19dp</dimen>
+ <dimen name="smart_reply_button_padding_horizontal">16dp</dimen>
+ <dimen name="smart_reply_button_action_padding_left">8dp</dimen>
<dimen name="smart_reply_button_min_height">48dp</dimen>
<dimen name="smart_reply_button_stroke_width">1dp</dimen>
<dimen name="smart_reply_button_font_size">14sp</dimen>
<dimen name="smart_reply_button_line_spacing_extra">6sp</dimen> <!-- Total line height 20sp. -->
<!-- Corner radius = half of min_height to create rounded sides. -->
- <dimen name="smart_reply_button_corner_radius">24dp</dimen>
+ <dimen name="smart_reply_button_corner_radius">8dp</dimen>
<dimen name="smart_action_button_icon_size">18dp</dimen>
<dimen name="smart_action_button_icon_padding">8dp</dimen>
@@ -1199,7 +1196,7 @@
0
</item>
<!-- Ending text size in sp of batteryLevel for wireless charging animation -->
- <item name="wireless_charging_anim_battery_level_text_size_end" format="float" type="dimen">24
+ <item name="wireless_charging_anim_battery_level_text_size_end" format="float" type="dimen">48
</item>
<!-- time until battery info is at full opacity-->
<integer name="wireless_charging_anim_opacity_offset">80</integer>
@@ -1443,6 +1440,15 @@
<dimen name="accessibility_floating_menu_large_single_radius">33dp</dimen>
<dimen name="accessibility_floating_menu_large_multiple_radius">35dp</dimen>
+ <dimen name="accessibility_floating_tooltip_arrow_width">8dp</dimen>
+ <dimen name="accessibility_floating_tooltip_arrow_height">16dp</dimen>
+ <dimen name="accessibility_floating_tooltip_arrow_margin">-2dp</dimen>
+ <dimen name="accessibility_floating_tooltip_arrow_corner_radius">2dp</dimen>
+ <dimen name="accessibility_floating_tooltip_text_corner_radius">8dp</dimen>
+ <dimen name="accessibility_floating_tooltip_margin">16dp</dimen>
+ <dimen name="accessibility_floating_tooltip_padding">16dp</dimen>
+ <dimen name="accessibility_floating_tooltip_font_size">14sp</dimen>
+
<dimen name="rounded_slider_height">48dp</dimen>
<!-- rounded_slider_height / 2 -->
<dimen name="rounded_slider_corner_radius">24dp</dimen>
@@ -1484,7 +1490,8 @@
<!-- Wallet activity screen specs -->
<dimen name="wallet_icon_size">36sp</dimen>
- <dimen name="wallet_view_header_icon_size">56dp</dimen>
+ <dimen name="wallet_screen_header_icon_size">56dp</dimen>
+ <dimen name="wallet_screen_header_view_size">80dp</dimen>
<dimen name="card_margin">16dp</dimen>
<dimen name="card_carousel_dot_offset">24dp</dimen>
<dimen name="card_carousel_dot_unselected_radius">2dp</dimen>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 30add20..4c9618f 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -689,12 +689,12 @@
<string name="accessibility_quick_settings_hotspot_changed_on">Mobile hotspot turned on.</string>
<!-- Announcement made when the screen stopped casting (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_casting_turned_off">Screen casting stopped.</string>
- <!-- Content description of the work mode title in quick settings when off (not shown on the screen). [CHAR LIMIT=NONE] -->
+ <!-- Content description of the work mode title in quick settings when off (not shown on the screen). Paused is used as an adjective [CHAR LIMIT=NONE] -->
<string name="accessibility_quick_settings_work_mode_off">Work mode paused.</string>
<!-- Content description of the work mode title in quick settings when on (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_quick_settings_work_mode_on">Work mode on.</string>
- <!-- Announcement made when the work mode changes to off (not shown on the screen). [CHAR LIMIT=NONE] -->
- <string name="accessibility_quick_settings_work_mode_changed_off">Work mode turned paused.</string>
+ <!-- Announcement made when the work mode changes to off (not shown on the screen). Paused is used as a verb. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_quick_settings_work_mode_changed_off">Work mode paused.</string>
<!-- Announcement made when the work mode changes to on (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_quick_settings_work_mode_changed_on">Work mode turned on.</string>
<!-- Announcement made when the Data Saver changes to off (not shown on the screen). [CHAR LIMIT=NONE] -->
@@ -2828,7 +2828,7 @@
<!-- Label for button to go to media control settings screen [CHAR_LIMIT=30] -->
<string name="controls_media_settings_button">Settings</string>
- <!-- Title for Smartspace recommendation card within media controls [CHAR_LIMIT=50] -->
+ <!-- Title for Smartspace recommendation card within media controls. The "Play" means the action to play a media [CHAR_LIMIT=10] -->
<string name="controls_media_smartspace_rec_title">Play</string>
<!-- Error message indicating that a control timed out while waiting for an update [CHAR_LIMIT=30] -->
@@ -2968,4 +2968,6 @@
<!-- Message shown to suggest authentication using [CHAR LIMIT=60]-->
<string name="keyguard_try_fingerprint">Use fingerprint to open</string>
+ <!-- Content description for a chip in the status bar showing that the user is currently on a phone call. [CHAR LIMIT=NONE] -->
+ <string name="ongoing_phone_call_content_description">Ongoing phone call</string>
</resources>
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index 10f7e40..9fa63dd 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -660,9 +660,12 @@
<item name="android:tint">?android:attr/colorAccent</item>
</style>
+ <style name="MediaPlayer.AppIcon.Recommendation" parent="MediaPlayer.AppIcon">
+ <item name="android:tint">@color/transparent</item>
+ </style>
+
<style name="MediaPlayer.Album">
<item name="android:backgroundTint">@color/media_player_album_bg</item>
-
</style>
<!-- Used to style charging animation AVD animation -->
@@ -692,6 +695,7 @@
<item name="android:windowNoTitle">true</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowLightNavigationBar">true</item>
+ <item name="android:windowActivityTransitions">true</item>
</style>
<!-- Privacy dialog -->
@@ -874,12 +878,12 @@
<style name="Wallet.TextAppearance">
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
- <item name="android:textColor">@color/wallet_primary_text</item>
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:singleLine">true</item>
<item name="android:textSize">14sp</item>
</style>
- <style name="Wallet.Theme">
- <item name="android:colorControlHighlight">@*android:color/primary_text_material_dark</item>
+ <style name="Wallet.Theme" parent="@android:style/Theme.DeviceDefault">
+ <item name="android:colorBackground">@android:color/system_neutral1_900</item>
</style>
</resources>
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/QuickStepContract.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/QuickStepContract.java
index 927bce0..2cf3ad2 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/QuickStepContract.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/QuickStepContract.java
@@ -105,6 +105,8 @@
public static final int SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY = 1 << 17;
// The IME is showing
public static final int SYSUI_STATE_IME_SHOWING = 1 << 18;
+ // The window magnification is overlapped with system gesture insets at the bottom.
+ public static final int SYSUI_STATE_MAGNIFICATION_OVERLAP = 1 << 19;
@Retention(RetentionPolicy.SOURCE)
@IntDef({SYSUI_STATE_SCREEN_PINNING,
@@ -125,7 +127,8 @@
SYSUI_STATE_GLOBAL_ACTIONS_SHOWING,
SYSUI_STATE_ONE_HANDED_ACTIVE,
SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY,
- SYSUI_STATE_IME_SHOWING
+ SYSUI_STATE_IME_SHOWING,
+ SYSUI_STATE_MAGNIFICATION_OVERLAP
})
public @interface SystemUiStateFlags {}
@@ -153,6 +156,7 @@
str.add((flags & SYSUI_STATE_ALLOW_GESTURE_IGNORING_BAR_VISIBILITY) != 0
? "allow_gesture" : "");
str.add((flags & SYSUI_STATE_IME_SHOWING) != 0 ? "ime_visible" : "");
+ str.add((flags & SYSUI_STATE_MAGNIFICATION_OVERLAP) != 0 ? "magnification_overlap" : "");
return str.toString();
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
index 4b71a3a..baf3458 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
@@ -19,42 +19,22 @@
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
-import android.app.PendingIntent;
import android.app.WallpaperManager;
-import android.app.smartspace.SmartspaceConfig;
-import android.app.smartspace.SmartspaceManager;
-import android.app.smartspace.SmartspaceSession;
-import android.app.smartspace.SmartspaceTarget;
-import android.content.Intent;
-import android.content.pm.UserInfo;
import android.content.res.Resources;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.os.Handler;
-import android.os.UserHandle;
-import android.provider.Settings;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
-import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.keyguard.clock.ClockManager;
-import com.android.settingslib.Utils;
import com.android.systemui.R;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.colorextraction.SysuiColorExtractor;
-import com.android.systemui.dagger.qualifiers.Main;
-import com.android.systemui.plugins.ActivityStarter;
-import com.android.systemui.plugins.BcSmartspaceDataPlugin;
-import com.android.systemui.plugins.BcSmartspaceDataPlugin.IntentStarter;
import com.android.systemui.plugins.ClockPlugin;
-import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
-import com.android.systemui.settings.UserTracker;
-import com.android.systemui.statusbar.FeatureFlags;
+import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController;
import com.android.systemui.statusbar.notification.AnimatableProperty;
import com.android.systemui.statusbar.notification.PropertyAnimator;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
@@ -62,14 +42,10 @@
import com.android.systemui.statusbar.phone.NotificationIconAreaController;
import com.android.systemui.statusbar.phone.NotificationIconContainer;
import com.android.systemui.statusbar.policy.BatteryController;
-import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.util.ViewController;
-import com.android.systemui.util.settings.SecureSettings;
import java.util.Locale;
-import java.util.Optional;
import java.util.TimeZone;
-import java.util.concurrent.Executor;
import javax.inject.Inject;
@@ -85,9 +61,8 @@
private final KeyguardSliceViewController mKeyguardSliceViewController;
private final NotificationIconAreaController mNotificationIconAreaController;
private final BroadcastDispatcher mBroadcastDispatcher;
- private final Executor mUiExecutor;
private final BatteryController mBatteryController;
- private final FeatureFlags mFeatureFlags;
+ private final LockscreenSmartspaceController mSmartspaceController;
/**
* Clock for both small and large sizes
@@ -97,20 +72,8 @@
private AnimatableClockController mLargeClockViewController;
private FrameLayout mLargeClockFrame;
- private SmartspaceSession mSmartspaceSession;
- private SmartspaceSession.OnTargetsAvailableListener mSmartspaceCallback;
- private ConfigurationController mConfigurationController;
- private ActivityStarter mActivityStarter;
- private FalsingManager mFalsingManager;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private final KeyguardBypassController mBypassController;
- private Handler mHandler;
- private UserTracker mUserTracker;
- private SecureSettings mSecureSettings;
- private ContentObserver mSettingsObserver;
- private boolean mShowSensitiveContentForCurrentUser;
- private boolean mShowSensitiveContentForManagedUser;
- private UserHandle mManagedUserHandle;
/**
* Listener for changes to the color palette.
@@ -118,59 +81,30 @@
* The color palette changes when the wallpaper is changed.
*/
private final ColorExtractor.OnColorsChangedListener mColorsListener =
- new ColorExtractor.OnColorsChangedListener() {
- @Override
- public void onColorsChanged(ColorExtractor extractor, int which) {
- if ((which & WallpaperManager.FLAG_LOCK) != 0) {
- mView.updateColors(getGradientColors());
- }
- }
- };
-
- private final ConfigurationController.ConfigurationListener mConfigurationListener =
- new ConfigurationController.ConfigurationListener() {
- @Override
- public void onThemeChanged() {
- updateWallpaperColor();
- }
- };
-
- private ClockManager.ClockChangedListener mClockChangedListener = this::setClockPlugin;
-
- private final StatusBarStateController.StateListener mStatusBarStateListener =
- new StatusBarStateController.StateListener() {
- @Override
- public void onDozeAmountChanged(float linear, float eased) {
- if (mSmartspaceView != null) {
- mSmartspaceView.setDozeAmount(eased);
- }
+ (extractor, which) -> {
+ if ((which & WallpaperManager.FLAG_LOCK) != 0) {
+ mView.updateColors(getGradientColors());
}
};
+ private final ClockManager.ClockChangedListener mClockChangedListener = this::setClockPlugin;
+
// If set, will replace keyguard_status_area
- private BcSmartspaceDataPlugin.SmartspaceView mSmartspaceView;
- private Optional<BcSmartspaceDataPlugin> mSmartspacePlugin;
+ private View mSmartspaceView;
@Inject
public KeyguardClockSwitchController(
KeyguardClockSwitch keyguardClockSwitch,
StatusBarStateController statusBarStateController,
- SysuiColorExtractor colorExtractor, ClockManager clockManager,
+ SysuiColorExtractor colorExtractor,
+ ClockManager clockManager,
KeyguardSliceViewController keyguardSliceViewController,
NotificationIconAreaController notificationIconAreaController,
BroadcastDispatcher broadcastDispatcher,
- FeatureFlags featureFlags,
- @Main Executor uiExecutor,
BatteryController batteryController,
- ConfigurationController configurationController,
- ActivityStarter activityStarter,
- FalsingManager falsingManager,
KeyguardUpdateMonitor keyguardUpdateMonitor,
KeyguardBypassController bypassController,
- @Main Handler handler,
- UserTracker userTracker,
- SecureSettings secureSettings,
- Optional<BcSmartspaceDataPlugin> smartspacePlugin) {
+ LockscreenSmartspaceController smartspaceController) {
super(keyguardClockSwitch);
mStatusBarStateController = statusBarStateController;
mColorExtractor = colorExtractor;
@@ -178,18 +112,10 @@
mKeyguardSliceViewController = keyguardSliceViewController;
mNotificationIconAreaController = notificationIconAreaController;
mBroadcastDispatcher = broadcastDispatcher;
- mFeatureFlags = featureFlags;
- mUiExecutor = uiExecutor;
mBatteryController = batteryController;
- mConfigurationController = configurationController;
- mActivityStarter = activityStarter;
- mFalsingManager = falsingManager;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mBypassController = bypassController;
- mHandler = handler;
- mUserTracker = userTracker;
- mSecureSettings = secureSettings;
- mSmartspacePlugin = smartspacePlugin;
+ mSmartspaceController = smartspaceController;
}
/**
@@ -232,119 +158,33 @@
mBypassController);
mLargeClockViewController.init();
- mStatusBarStateController.addCallback(mStatusBarStateListener);
- mConfigurationController.addCallback(mConfigurationListener);
+ if (mSmartspaceController.isEnabled()) {
+ mSmartspaceView = mSmartspaceController.buildAndConnectView(mView);
- if (mFeatureFlags.isSmartspaceEnabled() && mSmartspacePlugin.isPresent()) {
- BcSmartspaceDataPlugin smartspaceDataPlugin = mSmartspacePlugin.get();
View ksa = mView.findViewById(R.id.keyguard_status_area);
int ksaIndex = mView.indexOfChild(ksa);
ksa.setVisibility(View.GONE);
- mSmartspaceView = smartspaceDataPlugin.getView(mView);
- mSmartspaceView.registerDataProvider(smartspaceDataPlugin);
- mSmartspaceView.setIntentStarter(new IntentStarter() {
- public void startIntent(View v, Intent i) {
- mActivityStarter.startActivity(i, true /* dismissShade */);
- }
-
- public void startPendingIntent(PendingIntent pi) {
- mActivityStarter.startPendingIntentDismissingKeyguard(pi);
- }
- });
- mSmartspaceView.setFalsingManager(mFalsingManager);
- updateWallpaperColor();
- View asView = (View) mSmartspaceView;
-
// Place smartspace view below normal clock...
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
MATCH_PARENT, WRAP_CONTENT);
lp.addRule(RelativeLayout.BELOW, R.id.lockscreen_clock_view);
- mView.addView(asView, ksaIndex, lp);
+ mView.addView(mSmartspaceView, ksaIndex, lp);
int padding = getContext().getResources()
.getDimensionPixelSize(R.dimen.below_clock_padding_start);
- asView.setPadding(padding, 0, padding, 0);
+ mSmartspaceView.setPadding(padding, 0, padding, 0);
// ... but above the large clock
lp = new RelativeLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT);
- lp.addRule(RelativeLayout.BELOW, asView.getId());
+ lp.addRule(RelativeLayout.BELOW, mSmartspaceView.getId());
mLargeClockFrame.setLayoutParams(lp);
View nic = mView.findViewById(
R.id.left_aligned_notification_icon_container);
lp = (RelativeLayout.LayoutParams) nic.getLayoutParams();
- lp.addRule(RelativeLayout.BELOW, asView.getId());
+ lp.addRule(RelativeLayout.BELOW, mSmartspaceView.getId());
nic.setLayoutParams(lp);
-
- mSmartspaceSession = getContext().getSystemService(SmartspaceManager.class)
- .createSmartspaceSession(
- new SmartspaceConfig.Builder(getContext(), "lockscreen").build());
- mSmartspaceCallback = targets -> {
- targets.removeIf(this::filterSmartspaceTarget);
- smartspaceDataPlugin.onTargetsAvailable(targets);
- };
- mSmartspaceSession.addOnTargetsAvailableListener(mUiExecutor, mSmartspaceCallback);
- mSettingsObserver = new ContentObserver(mHandler) {
- @Override
- public void onChange(boolean selfChange, Uri uri) {
- reloadSmartspace();
- }
- };
-
- getContext().getContentResolver().registerContentObserver(
- Settings.Secure.getUriFor(
- Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS),
- true, mSettingsObserver, UserHandle.USER_ALL);
- reloadSmartspace();
- }
-
- float dozeAmount = mStatusBarStateController.getDozeAmount();
- mStatusBarStateListener.onDozeAmountChanged(dozeAmount, dozeAmount);
- }
-
- @VisibleForTesting
- boolean filterSmartspaceTarget(SmartspaceTarget t) {
- if (!t.isSensitive()) return false;
-
- if (t.getUserHandle().equals(mUserTracker.getUserHandle())) {
- return !mShowSensitiveContentForCurrentUser;
- }
- if (t.getUserHandle().equals(mManagedUserHandle)) {
- return !mShowSensitiveContentForManagedUser;
- }
-
- return false;
- }
-
- private void reloadSmartspace() {
- mManagedUserHandle = getWorkProfileUser();
- final String setting = Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS;
-
- mShowSensitiveContentForCurrentUser =
- mSecureSettings.getIntForUser(setting, 0, mUserTracker.getUserId()) == 1;
- if (mManagedUserHandle != null) {
- int id = mManagedUserHandle.getIdentifier();
- mShowSensitiveContentForManagedUser =
- mSecureSettings.getIntForUser(setting, 0, id) == 1;
- }
-
- mSmartspaceSession.requestSmartspaceUpdate();
- }
-
- private UserHandle getWorkProfileUser() {
- for (UserInfo userInfo : mUserTracker.getUserProfiles()) {
- if (userInfo.isManagedProfile()) {
- return userInfo.getUserHandle();
- }
- }
- return null;
- }
-
- private void updateWallpaperColor() {
- if (mSmartspaceView != null) {
- int color = Utils.getColorAttrDefaultColor(getContext(), R.attr.wallpaperTextColor);
- mSmartspaceView.setPrimaryTextColor(color);
}
}
@@ -356,16 +196,16 @@
mColorExtractor.removeOnColorsChangedListener(mColorsListener);
mView.setClockPlugin(null, mStatusBarStateController.getState());
- if (mSmartspaceSession != null) {
- mSmartspaceSession.removeOnTargetsAvailableListener(mSmartspaceCallback);
- mSmartspaceSession.close();
- mSmartspaceSession = null;
- }
- mStatusBarStateController.removeCallback(mStatusBarStateListener);
- mConfigurationController.removeCallback(mConfigurationListener);
+ mSmartspaceController.disconnect();
- if (mSettingsObserver != null) {
- getContext().getContentResolver().unregisterContentObserver(mSettingsObserver);
+ // TODO: This is an unfortunate necessity since smartspace plugin retains a single instance
+ // of the smartspace view -- if we don't remove the view, it can't be reused by a later
+ // instance of this class. In order to fix this, we need to modify the plugin so that
+ // (a) we get a new view each time and (b) we can properly clean up an old view by making
+ // it unregister itself as a plugin listener.
+ if (mSmartspaceView != null) {
+ mView.removeView(mSmartspaceView);
+ mSmartspaceView = null;
}
}
@@ -436,7 +276,7 @@
scale, props, animate);
if (mSmartspaceView != null) {
- PropertyAnimator.setProperty((View) mSmartspaceView, AnimatableProperty.TRANSLATION_X,
+ PropertyAnimator.setProperty(mSmartspaceView, AnimatableProperty.TRANSLATION_X,
x, props, animate);
}
@@ -510,14 +350,4 @@
private int getCurrentLayoutDirection() {
return TextUtils.getLayoutDirectionFromLocale(Locale.getDefault());
}
-
- @VisibleForTesting
- ConfigurationController.ConfigurationListener getConfigurationListener() {
- return mConfigurationListener;
- }
-
- @VisibleForTesting
- ContentObserver getSettingsObserver() {
- return mSettingsObserver;
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
index 76cec0b..64a683e 100644
--- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
+++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
@@ -305,10 +305,15 @@
continue;
}
Rect subImage = new Rect(
- Math.round(area.left * b.getWidth()),
- Math.round(area.top * b.getHeight()),
- Math.round(area.right * b.getWidth()),
- Math.round(area.bottom * b.getHeight()));
+ (int) Math.floor(area.left * b.getWidth()),
+ (int) Math.floor(area.top * b.getHeight()),
+ (int) Math.ceil(area.right * b.getWidth()),
+ (int) Math.ceil(area.bottom * b.getHeight()));
+ if (subImage.isEmpty()) {
+ // Do not notify client. treat it as too small to sample
+ colors.add(null);
+ continue;
+ }
Bitmap colorImg = Bitmap.createBitmap(b,
subImage.left, subImage.top, subImage.width(), subImage.height());
WallpaperColors color = WallpaperColors.fromBitmap(colorImg);
diff --git a/packages/SystemUI/src/com/android/systemui/Prefs.java b/packages/SystemUI/src/com/android/systemui/Prefs.java
index 7f18379..bf09975 100644
--- a/packages/SystemUI/src/com/android/systemui/Prefs.java
+++ b/packages/SystemUI/src/com/android/systemui/Prefs.java
@@ -73,7 +73,8 @@
Key.TOUCHED_RINGER_TOGGLE,
Key.HAS_SEEN_ODI_CAPTIONS_TOOLTIP,
Key.HAS_SEEN_REVERSE_BOTTOM_SHEET,
- Key.CONTROLS_STRUCTURE_SWIPE_TOOLTIP_COUNT
+ Key.CONTROLS_STRUCTURE_SWIPE_TOOLTIP_COUNT,
+ Key.HAS_SEEN_ACCESSIBILITY_FLOATING_MENU_DOCK_TOOLTIP
})
// TODO: annotate these with their types so {@link PrefsCommandLine} can know how to set them
public @interface Key {
@@ -122,6 +123,8 @@
String HAS_SEEN_ODI_CAPTIONS_TOOLTIP = "HasSeenODICaptionsTooltip";
String HAS_SEEN_REVERSE_BOTTOM_SHEET = "HasSeenReverseBottomSheet";
String CONTROLS_STRUCTURE_SWIPE_TOOLTIP_COUNT = "ControlsStructureSwipeTooltipCount";
+ String HAS_SEEN_ACCESSIBILITY_FLOATING_MENU_DOCK_TOOLTIP =
+ "HasSeenAccessibilityFloatingMenuDockTooltip";
}
public static boolean getBoolean(Context context, @Key String key, boolean defaultValue) {
diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
index be50eb1..afda2a4 100644
--- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
+++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
@@ -55,8 +55,6 @@
import android.graphics.drawable.Drawable;
import android.hardware.display.DisplayManager;
import android.os.Handler;
-import android.os.HandlerExecutor;
-import android.os.HandlerThread;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings.Secure;
@@ -91,11 +89,13 @@
import com.android.systemui.statusbar.events.PrivacyDotViewController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;
+import com.android.systemui.util.concurrency.DelayableExecutor;
import com.android.systemui.util.concurrency.ThreadFactory;
import com.android.systemui.util.settings.SecureSettings;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.Executor;
import javax.inject.Inject;
@@ -122,7 +122,7 @@
@VisibleForTesting
protected boolean mIsRegistered;
private final BroadcastDispatcher mBroadcastDispatcher;
- private final Handler mMainHandler;
+ private final Executor mMainExecutor;
private final TunerService mTunerService;
private final SecureSettings mSecureSettings;
private DisplayManager.DisplayListener mDisplayListener;
@@ -153,6 +153,7 @@
private WindowManager mWindowManager;
private int mRotation;
private SecureSetting mColorInversionSetting;
+ private DelayableExecutor mExecutor;
private Handler mHandler;
private boolean mPendingRotationChange;
private boolean mIsRoundedCornerMultipleRadius;
@@ -212,7 +213,7 @@
@Inject
public ScreenDecorations(Context context,
- @Main Handler handler,
+ @Main Executor mainExecutor,
SecureSettings secureSettings,
BroadcastDispatcher broadcastDispatcher,
TunerService tunerService,
@@ -220,7 +221,7 @@
PrivacyDotViewController dotViewController,
ThreadFactory threadFactory) {
super(context);
- mMainHandler = handler;
+ mMainExecutor = mainExecutor;
mSecureSettings = secureSettings;
mBroadcastDispatcher = broadcastDispatcher;
mTunerService = tunerService;
@@ -235,17 +236,10 @@
Log.i(TAG, "ScreenDecorations is disabled");
return;
}
- mHandler = startHandlerThread();
- mHandler.post(this::startOnScreenDecorationsThread);
- mDotViewController.setUiExecutor(
- mThreadFactory.buildDelayableExecutorOnLooper(mHandler.getLooper()));
- }
-
- @VisibleForTesting
- Handler startHandlerThread() {
- HandlerThread thread = new HandlerThread("ScreenDecorations");
- thread.start();
- return thread.getThreadHandler();
+ mHandler = mThreadFactory.builderHandlerOnNewThread("ScreenDecorations");
+ mExecutor = mThreadFactory.buildDelayableExecutorOnHandler(mHandler);
+ mExecutor.execute(this::startOnScreenDecorationsThread);
+ mDotViewController.setUiExecutor(mExecutor);
}
private void startOnScreenDecorationsThread() {
@@ -332,7 +326,7 @@
mDisplayManager.getDisplay(DEFAULT_DISPLAY).getMetrics(metrics);
mDensity = metrics.density;
- mMainHandler.post(() -> mTunerService.addTunable(this, SIZE));
+ mExecutor.execute(() -> mTunerService.addTunable(this, SIZE));
// Watch color inversion and invert the overlay as needed.
if (mColorInversionSetting == null) {
@@ -351,10 +345,10 @@
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_USER_SWITCHED);
mBroadcastDispatcher.registerReceiver(mUserSwitchIntentReceiver, filter,
- new HandlerExecutor(mHandler), UserHandle.ALL);
+ mExecutor, UserHandle.ALL);
mIsRegistered = true;
} else {
- mMainHandler.post(() -> mTunerService.removeTunable(this));
+ mMainExecutor.execute(() -> mTunerService.removeTunable(this));
if (mColorInversionSetting != null) {
mColorInversionSetting.setListening(false);
@@ -567,7 +561,7 @@
Resources res = mContext.getResources();
boolean enabled = res.getBoolean(R.bool.config_enableDisplayCutoutProtection);
if (enabled) {
- mCameraListener = CameraAvailabilityListener.Factory.build(mContext, mHandler::post);
+ mCameraListener = CameraAvailabilityListener.Factory.build(mContext, mExecutor);
mCameraListener.addTransitionCallback(mCameraTransitionCallback);
mCameraListener.startListening();
}
@@ -624,7 +618,7 @@
Log.i(TAG, "ScreenDecorations is disabled");
return;
}
- mHandler.post(() -> {
+ mExecutor.execute(() -> {
int oldRotation = mRotation;
mPendingRotationChange = false;
updateOrientation();
@@ -825,7 +819,7 @@
Log.i(TAG, "ScreenDecorations is disabled");
return;
}
- mHandler.post(() -> {
+ mExecutor.execute(() -> {
if (mOverlays == null) return;
if (SIZE.equals(key)) {
Point size = mRoundedDefault;
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/DisplayIdIndexSupplier.java b/packages/SystemUI/src/com/android/systemui/accessibility/DisplayIdIndexSupplier.java
index b69001d..c472457 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/DisplayIdIndexSupplier.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/DisplayIdIndexSupplier.java
@@ -63,17 +63,15 @@
}
/**
- * Gets the object by the element index.
+ * Returns the object with the given display id.
*
- * <p> If the index is bigger than the array size, an {@link ArrayIndexOutOfBoundsException} is
- * thrown for apps targeting {@link android.os.Build.VERSION_CODES#Q} and later </p>
*
- * @param index the element index
+ * @param displayId the logical display Id
* @return T
- * @see SparseArray#valueAt(int)
*/
- public T valueAt(int index) {
- return mSparseArray.valueAt(index);
+ @Nullable
+ public T valueAt(int displayId) {
+ return mSparseArray.get(displayId);
}
@NonNull
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationGestureDetector.java b/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationGestureDetector.java
index 4c892e29..4b30ec3 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationGestureDetector.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/MagnificationGestureDetector.java
@@ -113,7 +113,7 @@
final float rawX = event.getRawX();
final float rawY = event.getRawY();
boolean handled = false;
- switch (event.getAction()) {
+ switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
mPointerDown.set(rawX, rawY);
mHandler.postAtTime(mCancelTapGestureRunnable,
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnification.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnification.java
index 4f5fdc9..cee395b 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnification.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnification.java
@@ -18,10 +18,11 @@
import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY;
+import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_MAGNIFICATION_OVERLAP;
+
import android.annotation.MainThread;
import android.annotation.Nullable;
import android.content.Context;
-import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.hardware.display.DisplayManager;
@@ -37,9 +38,13 @@
import com.android.systemui.SystemUI;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
-import com.android.systemui.navigationbar.NavigationModeController;
+import com.android.systemui.model.SysUiState;
+import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.statusbar.CommandQueue;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
import javax.inject.Inject;
/**
@@ -52,34 +57,33 @@
public class WindowMagnification extends SystemUI implements WindowMagnifierCallback,
CommandQueue.Callbacks {
private static final String TAG = "WindowMagnification";
- private static final int CONFIG_MASK =
- ActivityInfo.CONFIG_DENSITY | ActivityInfo.CONFIG_ORIENTATION
- | ActivityInfo.CONFIG_LOCALE;
private final ModeSwitchesController mModeSwitchesController;
private final Handler mHandler;
private final AccessibilityManager mAccessibilityManager;
private final CommandQueue mCommandQueue;
+ private final OverviewProxyService mOverviewProxyService;
private WindowMagnificationConnectionImpl mWindowMagnificationConnectionImpl;
private Configuration mLastConfiguration;
+ private SysUiState mSysUiState;
private static class AnimationControllerSupplier extends
DisplayIdIndexSupplier<WindowMagnificationAnimationController> {
private final Context mContext;
private final Handler mHandler;
- private final NavigationModeController mNavigationModeController;
private final WindowMagnifierCallback mWindowMagnifierCallback;
+ private final SysUiState mSysUiState;
AnimationControllerSupplier(Context context, Handler handler,
- NavigationModeController navigationModeController,
- WindowMagnifierCallback windowMagnifierCallback, DisplayManager displayManager) {
+ WindowMagnifierCallback windowMagnifierCallback,
+ DisplayManager displayManager, SysUiState sysUiState) {
super(displayManager);
mContext = context;
mHandler = handler;
- mNavigationModeController = navigationModeController;
mWindowMagnifierCallback = windowMagnifierCallback;
+ mSysUiState = sysUiState;
}
@Override
@@ -89,10 +93,7 @@
final WindowMagnificationController controller = new WindowMagnificationController(
mContext,
mHandler, new SfVsyncFrameCallbackProvider(), null,
- new SurfaceControl.Transaction(), mWindowMagnifierCallback);
- final int navBarMode = mNavigationModeController.addListener(
- controller::onNavigationModeChanged);
- controller.onNavigationModeChanged(navBarMode);
+ new SurfaceControl.Transaction(), mWindowMagnifierCallback, mSysUiState);
return new WindowMagnificationAnimationController(windowContext, controller);
}
}
@@ -103,24 +104,22 @@
@Inject
public WindowMagnification(Context context, @Main Handler mainHandler,
CommandQueue commandQueue, ModeSwitchesController modeSwitchesController,
- NavigationModeController navigationModeController) {
+ SysUiState sysUiState, OverviewProxyService overviewProxyService) {
super(context);
mHandler = mainHandler;
mLastConfiguration = new Configuration(context.getResources().getConfiguration());
mAccessibilityManager = mContext.getSystemService(AccessibilityManager.class);
mCommandQueue = commandQueue;
mModeSwitchesController = modeSwitchesController;
+ mSysUiState = sysUiState;
+ mOverviewProxyService = overviewProxyService;
mAnimationControllerSupplier = new AnimationControllerSupplier(context,
- mHandler, navigationModeController, this,
- context.getSystemService(DisplayManager.class));
+ mHandler, this, context.getSystemService(DisplayManager.class), sysUiState);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
final int configDiff = newConfig.diff(mLastConfiguration);
- if ((configDiff & CONFIG_MASK) == 0) {
- return;
- }
mLastConfiguration.setTo(newConfig);
mAnimationControllerSupplier.forEach(
animationController -> animationController.onConfigurationChanged(configDiff));
@@ -132,6 +131,28 @@
@Override
public void start() {
mCommandQueue.addCallback(this);
+ mOverviewProxyService.addCallback(new OverviewProxyService.OverviewProxyListener() {
+ @Override
+ public void onConnectionChanged(boolean isConnected) {
+ if (isConnected) {
+ updateSysUiStateFlag();
+ }
+ }
+ });
+ }
+
+ private void updateSysUiStateFlag() {
+ //TODO(b/187510533): support multi-display once SysuiState supports it.
+ final WindowMagnificationAnimationController controller =
+ mAnimationControllerSupplier.valueAt(Display.DEFAULT_DISPLAY);
+ if (controller != null) {
+ controller.updateSysUiStateFlag();
+ } else {
+ // The instance is initialized when there is an IPC request. Considering
+ // self-crash cases, we need to reset the flag in such situation.
+ mSysUiState.setFlag(SYSUI_STATE_MAGNIFICATION_OVERLAP, false)
+ .commitUpdate(Display.DEFAULT_DISPLAY);
+ }
}
@MainThread
@@ -210,6 +231,13 @@
}
}
+ @Override
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.println(TAG);
+ mAnimationControllerSupplier.forEach(
+ animationController -> animationController.dump(pw));
+ }
+
private void setWindowMagnificationConnection() {
if (mWindowMagnificationConnectionImpl == null) {
mWindowMagnificationConnectionImpl = new WindowMagnificationConnectionImpl(this,
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationAnimationController.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationAnimationController.java
index 5758b15..36fef3e 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationAnimationController.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationAnimationController.java
@@ -31,6 +31,7 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.R;
+import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -269,6 +270,14 @@
mController.enableWindowMagnification(sentScale, centerX, centerY);
}
+ public void updateSysUiStateFlag() {
+ mController.updateSysUIStateFlag();
+ }
+
+ void dump(PrintWriter pw) {
+ mController.dump(pw);
+ }
+
private static ValueAnimator newValueAnimator(Resources resources) {
final ValueAnimator valueAnimator = new ValueAnimator();
valueAnimator.setDuration(
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java
index ae16703..fcb090a 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java
@@ -16,9 +16,10 @@
package com.android.systemui.accessibility;
+import static android.view.WindowInsets.Type.systemGestures;
import static android.view.WindowManager.LayoutParams;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
+
+import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_MAGNIFICATION_OVERLAP;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
@@ -28,6 +29,7 @@
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Resources;
+import android.graphics.Insets;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
import android.graphics.Rect;
@@ -52,14 +54,17 @@
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
+import android.view.WindowMetrics;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.graphics.SfVsyncFrameCallbackProvider;
import com.android.systemui.R;
+import com.android.systemui.model.SysUiState;
import com.android.systemui.shared.system.WindowManagerWrapper;
+import java.io.PrintWriter;
import java.text.NumberFormat;
import java.util.Locale;
@@ -111,6 +116,7 @@
private final View.OnLayoutChangeListener mMirrorSurfaceViewLayoutChangeListener;
private final Runnable mMirrorViewRunnable;
private final Runnable mUpdateStateDescriptionRunnable;
+ private final Runnable mWindowInsetChangeRunnable;
private View mMirrorView;
private SurfaceView mMirrorSurfaceView;
private int mMirrorSurfaceMargin;
@@ -119,9 +125,8 @@
private int mOuterBorderSize;
// The boundary of magnification frame.
private final Rect mMagnificationFrameBoundary = new Rect();
-
- private int mNavBarMode;
- private int mNavGestureHeight;
+ // The top Y of the system gesture rect at the bottom. Set to -1 if it is invalid.
+ private int mSystemGestureTop = -1;
private final SfVsyncFrameCallbackProvider mSfVsyncFrameProvider;
private final MagnificationGestureDetector mGestureDetector;
@@ -130,6 +135,9 @@
private Locale mLocale;
private NumberFormat mPercentFormat;
private float mBounceEffectAnimationScale;
+ private SysUiState mSysUiState;
+ // Set it to true when the view is overlapped with the gesture insets at the bottom.
+ private boolean mOverlapWithGestureInsets;
@Nullable
private MirrorWindowControl mMirrorWindowControl;
@@ -137,11 +145,12 @@
WindowMagnificationController(@UiContext Context context, @NonNull Handler handler,
SfVsyncFrameCallbackProvider sfVsyncFrameProvider,
MirrorWindowControl mirrorWindowControl, SurfaceControl.Transaction transaction,
- @NonNull WindowMagnifierCallback callback) {
+ @NonNull WindowMagnifierCallback callback, SysUiState sysUiState) {
mContext = context;
mHandler = handler;
mSfVsyncFrameProvider = sfVsyncFrameProvider;
mWindowMagnifierCallback = callback;
+ mSysUiState = sysUiState;
final Display display = mContext.getDisplay();
mDisplayId = mContext.getDisplayId();
@@ -170,13 +179,18 @@
mMirrorViewRunnable = () -> {
if (mMirrorView != null) {
mMirrorView.getBoundsOnScreen(mMirrorViewBounds);
+ updateSystemUIStateIfNeeded();
mWindowMagnifierCallback.onWindowMagnifierBoundsChanged(
mDisplayId, mMirrorViewBounds);
}
};
mMirrorViewLayoutChangeListener =
- (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) ->
+ (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
+ if (!mHandler.hasCallbacks(mMirrorViewRunnable)) {
mHandler.post(mMirrorViewRunnable);
+ }
+ };
+
mMirrorSurfaceViewLayoutChangeListener =
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom)
-> applyTapExcludeRegion();
@@ -199,6 +213,7 @@
mMirrorView.setStateDescription(formatStateDescription(mScale));
}
};
+ mWindowInsetChangeRunnable = this::onWindowInsetChanged;
}
private void updateDimensions() {
@@ -210,7 +225,6 @@
R.dimen.magnification_drag_view_size);
mOuterBorderSize = mResources.getDimensionPixelSize(
R.dimen.magnification_outer_border_margin);
- updateNavigationBarDimensions();
}
private void computeBounceAnimationScale() {
@@ -220,16 +234,16 @@
mBounceEffectAnimationScale = Math.min(animationScaleMax, ANIMATION_BOUNCE_EFFECT_SCALE);
}
- private void updateNavigationBarDimensions() {
- if (!supportsSwipeUpGesture()) {
- mNavGestureHeight = 0;
- return;
+ private boolean updateSystemGestureInsetsTop() {
+ final WindowMetrics windowMetrics = mWm.getCurrentWindowMetrics();
+ final Insets insets = windowMetrics.getWindowInsets().getInsets(systemGestures());
+ final int gestureTop =
+ insets.bottom != 0 ? windowMetrics.getBounds().bottom - insets.bottom : -1;
+ if (gestureTop != mSystemGestureTop) {
+ mSystemGestureTop = gestureTop;
+ return true;
}
- mNavGestureHeight = (mWindowBounds.width() > mWindowBounds.height())
- ? mResources.getDimensionPixelSize(
- com.android.internal.R.dimen.navigation_bar_height_landscape)
- : mResources.getDimensionPixelSize(
- com.android.internal.R.dimen.navigation_bar_gesture_height);
+ return false;
}
/**
@@ -255,6 +269,7 @@
if (mMirrorWindowControl != null) {
mMirrorWindowControl.destroyControl();
}
+ updateSystemUIStateIfNeeded();
}
/**
@@ -277,6 +292,10 @@
}
}
+ private void updateSystemUIStateIfNeeded() {
+ updateSysUIState(false);
+ }
+
private void updateAccessibilityWindowTitleIfNeeded() {
if (!isWindowVisible()) return;
LayoutParams params = (LayoutParams) mMirrorView.getLayoutParams();
@@ -284,13 +303,6 @@
mWm.updateViewLayout(mMirrorView, params);
}
- /** Handles MirrorWindow position when the navigation bar mode changed. */
- public void onNavigationModeChanged(int mode) {
- mNavBarMode = mode;
- updateNavigationBarDimensions();
- updateMirrorViewLayout();
- }
-
/** Handles MirrorWindow position when the device rotation changed. */
private void onRotate() {
final Display display = mContext.getDisplay();
@@ -299,7 +311,6 @@
setMagnificationFrameBoundary();
mRotation = display.getRotation();
- updateNavigationBarDimensions();
if (!isWindowVisible()) {
return;
@@ -351,6 +362,7 @@
params.x = mMagnificationFrame.left - mMirrorSurfaceMargin;
params.y = mMagnificationFrame.top - mMirrorSurfaceMargin;
params.layoutInDisplayCutoutMode = LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
+ params.receiveInsetsIgnoringZOrder = true;
params.setTitle(mContext.getString(R.string.magnification_window_title));
params.accessibilityTitle = getAccessibilityWindowTitle();
@@ -368,6 +380,12 @@
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
mMirrorView.addOnLayoutChangeListener(mMirrorViewLayoutChangeListener);
mMirrorView.setAccessibilityDelegate(new MirrorWindowA11yDelegate());
+ mMirrorView.setOnApplyWindowInsetsListener((v, insets) -> {
+ if (!mHandler.hasCallbacks(mWindowInsetChangeRunnable)) {
+ mHandler.post(mWindowInsetChangeRunnable);
+ }
+ return v.onApplyWindowInsets(insets);
+ });
mWm.addView(mMirrorView, params);
@@ -377,6 +395,12 @@
addDragTouchListeners();
}
+ private void onWindowInsetChanged() {
+ if (updateSystemGestureInsetsTop()) {
+ updateSystemUIStateIfNeeded();
+ }
+ }
+
private void applyTapExcludeRegion() {
final Region tapExcludeRegion = calculateTapExclude();
final IWindow window = IWindow.Stub.asInterface(mMirrorView.getWindowToken());
@@ -464,17 +488,12 @@
return;
}
final int maxMirrorViewX = mWindowBounds.width() - mMirrorView.getWidth();
- final int maxMirrorViewY =
- mWindowBounds.height() - mMirrorView.getHeight() - mNavGestureHeight;
+ final int maxMirrorViewY = mWindowBounds.height() - mMirrorView.getHeight();
+
LayoutParams params =
(LayoutParams) mMirrorView.getLayoutParams();
params.x = mMagnificationFrame.left - mMirrorSurfaceMargin;
params.y = mMagnificationFrame.top - mMirrorSurfaceMargin;
- // If nav bar mode supports swipe-up gesture, the Y position of mirror view should not
- // overlap nav bar window to prevent window-dragging obscured.
- if (supportsSwipeUpGesture()) {
- params.y = Math.min(params.y, maxMirrorViewY);
- }
// Translates MirrorView position to make MirrorSurfaceView that is inside MirrorView
// able to move close to the screen edges.
@@ -508,6 +527,10 @@
return false;
}
+ public void updateSysUIStateFlag() {
+ updateSysUIState(true);
+ }
+
/**
* Calculates the desired source bounds. This will be the area under from the center of the
* displayFrame, factoring in scale.
@@ -569,6 +592,16 @@
return false;
}
+ private void updateSysUIState(boolean force) {
+ final boolean overlap = isWindowVisible() && mSystemGestureTop > 0
+ && mMirrorViewBounds.bottom > mSystemGestureTop;
+ if (force || overlap != mOverlapWithGestureInsets) {
+ mOverlapWithGestureInsets = overlap;
+ mSysUiState.setFlag(SYSUI_STATE_MAGNIFICATION_OVERLAP, mOverlapWithGestureInsets)
+ .commitUpdate(mDisplayId);
+ }
+ }
+
@Override
public void surfaceCreated(SurfaceHolder holder) {
createMirror();
@@ -676,10 +709,6 @@
return mMirrorView != null;
}
- private boolean supportsSwipeUpGesture() {
- return mNavBarMode == NAV_BAR_MODE_2BUTTON || mNavBarMode == NAV_BAR_MODE_GESTURAL;
- }
-
private CharSequence formatStateDescription(float scale) {
// Cache the locale-appropriate NumberFormat. Configuration locale is guaranteed
// non-null, so the first time this is called we will always get the appropriate
@@ -722,6 +751,14 @@
scaleAnimator.start();
}
+ public void dump(PrintWriter pw) {
+ pw.println("WindowMagnificationController (displayId=" + mDisplayId + "):");
+ pw.println(" mOverlapWithGestureInsets:" + mOverlapWithGestureInsets);
+ pw.println(" mScale:" + mScale);
+ pw.println(" mMirrorViewBounds:" + (isWindowVisible() ? mMirrorViewBounds : "empty"));
+ pw.println(" mSystemGestureTop:" + mSystemGestureTop);
+ }
+
private class MirrorWindowA11yDelegate extends View.AccessibilityDelegate {
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenu.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenu.java
index 3b3bad3..ee62768 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenu.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenu.java
@@ -18,11 +18,13 @@
import static android.provider.Settings.Secure.ACCESSIBILITY_FLOATING_MENU_FADE_ENABLED;
import static android.provider.Settings.Secure.ACCESSIBILITY_FLOATING_MENU_ICON_TYPE;
+import static android.provider.Settings.Secure.ACCESSIBILITY_FLOATING_MENU_MIGRATION_TOOLTIP_PROMPT;
import static android.provider.Settings.Secure.ACCESSIBILITY_FLOATING_MENU_OPACITY;
import static android.provider.Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE;
import static android.view.accessibility.AccessibilityManager.ACCESSIBILITY_BUTTON;
import static com.android.internal.accessibility.dialog.AccessibilityTargetHelper.getTargets;
+import static com.android.systemui.Prefs.Key.HAS_SEEN_ACCESSIBILITY_FLOATING_MENU_DOCK_TOOLTIP;
import static com.android.systemui.accessibility.floatingmenu.AccessibilityFloatingMenuView.ShapeType;
import static com.android.systemui.accessibility.floatingmenu.AccessibilityFloatingMenuView.SizeType;
@@ -34,15 +36,19 @@
import android.provider.Settings;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.systemui.Prefs;
/**
* Contains logic for an accessibility floating menu view.
*/
public class AccessibilityFloatingMenu implements IAccessibilityFloatingMenu {
- private static final int DEFAULT_FADE_EFFECT_ENABLED = 1;
+ private static final int DEFAULT_FADE_EFFECT_IS_ENABLED = 1;
+ private static final int DEFAULT_MIGRATION_TOOLTIP_PROMPT_IS_DISABLED = 0;
private static final float DEFAULT_OPACITY_VALUE = 0.55f;
private final Context mContext;
private final AccessibilityFloatingMenuView mMenuView;
+ private final MigrationTooltipView mMigrationTooltipView;
+ private final DockTooltipView mDockTooltipView;
private final Handler mHandler = new Handler(Looper.getMainLooper());
private final ContentObserver mContentObserver =
@@ -86,6 +92,8 @@
AccessibilityFloatingMenu(Context context, AccessibilityFloatingMenuView menuView) {
mContext = context;
mMenuView = menuView;
+ mMigrationTooltipView = new MigrationTooltipView(mContext, mMenuView);
+ mDockTooltipView = new DockTooltipView(mContext, mMenuView);
}
@Override
@@ -105,6 +113,9 @@
getOpacityValue(mContext));
mMenuView.setSizeType(getSizeType(mContext));
mMenuView.setShapeType(getShapeType(mContext));
+ mMenuView.setOnDragEndListener(this::showDockTooltipIfNecessary);
+
+ showMigrationTooltipIfNecessary();
registerContentObservers();
}
@@ -116,14 +127,48 @@
}
mMenuView.hide();
+ mMigrationTooltipView.hide();
+ mDockTooltipView.hide();
unregisterContentObservers();
}
+ // Migration tooltip was the android S feature. It's just used on the Android version from R
+ // to S. In addition, it only shows once.
+ private void showMigrationTooltipIfNecessary() {
+ if (isMigrationTooltipPromptEnabled(mContext)) {
+ mMigrationTooltipView.show();
+
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ ACCESSIBILITY_FLOATING_MENU_MIGRATION_TOOLTIP_PROMPT, /* disabled */ 0);
+ }
+ }
+
+ private static boolean isMigrationTooltipPromptEnabled(Context context) {
+ return Settings.Secure.getInt(
+ context.getContentResolver(), ACCESSIBILITY_FLOATING_MENU_MIGRATION_TOOLTIP_PROMPT,
+ DEFAULT_MIGRATION_TOOLTIP_PROMPT_IS_DISABLED) == /* enabled */ 1;
+ }
+
+ /**
+ * Shows tooltip when user drags accessibility floating menu for the first time.
+ */
+ private void showDockTooltipIfNecessary() {
+ if (!Prefs.get(mContext).getBoolean(
+ HAS_SEEN_ACCESSIBILITY_FLOATING_MENU_DOCK_TOOLTIP, false)) {
+ // if the menu is an oval, the user has already dragged it out, so show the tooltip.
+ if (mMenuView.isOvalShape()) {
+ mDockTooltipView.show();
+ }
+
+ Prefs.putBoolean(mContext, HAS_SEEN_ACCESSIBILITY_FLOATING_MENU_DOCK_TOOLTIP, true);
+ }
+ }
+
private static boolean isFadeEffectEnabled(Context context) {
return Settings.Secure.getInt(
context.getContentResolver(), ACCESSIBILITY_FLOATING_MENU_FADE_ENABLED,
- DEFAULT_FADE_EFFECT_ENABLED) == /* enable */ 1;
+ DEFAULT_FADE_EFFECT_IS_ENABLED) == /* enabled */ 1;
}
private static float getOpacityValue(Context context) {
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuView.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuView.java
index 934e20d..49e6b47 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuView.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuView.java
@@ -19,6 +19,8 @@
import static android.util.MathUtils.constrain;
import static android.util.MathUtils.sq;
+import static java.util.Objects.requireNonNull;
+
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
@@ -43,7 +45,9 @@
import android.view.WindowManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
+import android.view.animation.Animation;
import android.view.animation.OvershootInterpolator;
+import android.view.animation.TranslateAnimation;
import android.widget.FrameLayout;
import androidx.annotation.DimenRes;
@@ -60,6 +64,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Optional;
/**
* Accessibility floating menu is used for the actions of accessibility features, it's also the
@@ -78,6 +83,10 @@
private static final int MIN_WINDOW_Y = 0;
private static final float LOCATION_Y_PERCENTAGE = 0.8f;
+ private static final int ANIMATION_START_OFFSET = 600;
+ private static final int ANIMATION_DURATION_MS = 600;
+ private static final float ANIMATION_TO_X_VALUE = 0.5f;
+
private boolean mIsFadeEffectEnabled;
private boolean mIsShowing;
private boolean mIsDownInEnlargedTouchArea;
@@ -107,6 +116,7 @@
private float mPercentageY = LOCATION_Y_PERCENTAGE;
private float mSquareScaledTouchSlop;
private final Configuration mLastConfiguration;
+ private Optional<OnDragEndListener> mOnDragEndListener = Optional.empty();
private final RecyclerView mListView;
private final AccessibilityTargetAdapter mAdapter;
private float mFadeOutValue;
@@ -161,6 +171,17 @@
int RIGHT = 1;
}
+ /**
+ * Interface for a callback to be invoked when the floating menu was dragging.
+ */
+ interface OnDragEndListener {
+
+ /**
+ * Invoked when the floating menu has dragged end.
+ */
+ void onDragEnd();
+ }
+
public AccessibilityFloatingMenuView(Context context) {
this(context, new RecyclerView(context));
}
@@ -201,6 +222,8 @@
updateRadiusWith(mSizeType, mRadiusType, mTargets.size());
fadeOut();
+
+ mOnDragEndListener.ifPresent(OnDragEndListener::onDragEnd);
}
});
@@ -266,7 +289,7 @@
// Must switch the oval shape type before tapping the corresponding item in the
// list view, otherwise it can't work on it.
- if (mShapeType == ShapeType.HALF_OVAL) {
+ if (!isOvalShape()) {
setShapeType(ShapeType.OVAL);
return true;
@@ -299,10 +322,6 @@
@Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
- if (super.performAccessibilityAction(action, arguments)) {
- return true;
- }
-
fadeIn();
final Rect bounds = getAvailableBounds();
@@ -340,7 +359,7 @@
return true;
}
- return false;
+ return super.performAccessibilityAction(action, arguments);
}
void show() {
@@ -367,6 +386,10 @@
return mIsShowing;
}
+ boolean isOvalShape() {
+ return mShapeType == ShapeType.OVAL;
+ }
+
void onTargetsChanged(List<AccessibilityTarget> newTargets) {
fadeIn();
@@ -411,6 +434,41 @@
fadeOut();
}
+ public void setOnDragEndListener(OnDragEndListener onDragListener) {
+ mOnDragEndListener = Optional.ofNullable(onDragListener);
+ }
+
+ void startTranslateXAnimation() {
+ fadeIn();
+
+ final float toXValue = mAlignment == Alignment.RIGHT
+ ? ANIMATION_TO_X_VALUE
+ : -ANIMATION_TO_X_VALUE;
+ final TranslateAnimation animation =
+ new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,
+ Animation.RELATIVE_TO_SELF, toXValue,
+ Animation.RELATIVE_TO_SELF, 0,
+ Animation.RELATIVE_TO_SELF, 0);
+ animation.setDuration(ANIMATION_DURATION_MS);
+ animation.setRepeatMode(Animation.REVERSE);
+ animation.setInterpolator(new OvershootInterpolator());
+ animation.setRepeatCount(Animation.INFINITE);
+ animation.setStartOffset(ANIMATION_START_OFFSET);
+ mListView.startAnimation(animation);
+ }
+
+ void stopTranslateXAnimation() {
+ mListView.clearAnimation();
+
+ fadeOut();
+ }
+
+ Rect getWindowLocationOnScreen() {
+ final int left = mCurrentLayoutParams.x;
+ final int top = mCurrentLayoutParams.y;
+ return new Rect(left, top, left + getWindowWidth(), top + getWindowHeight());
+ }
+
void updateOpacityWith(boolean isFadeEffectEnabled, float newOpacityValue) {
mIsFadeEffectEnabled = isFadeEffectEnabled;
mFadeOutValue = newOpacityValue;
@@ -534,11 +592,7 @@
}
private Handler createUiHandler() {
- final Looper looper = Looper.myLooper();
- if (looper == null) {
- throw new IllegalArgumentException("looper must not be null");
- }
- return new Handler(looper);
+ return new Handler(requireNonNull(Looper.myLooper(), "looper must not be null"));
}
private void updateDimensions() {
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AnnotationLinkSpan.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AnnotationLinkSpan.java
new file mode 100644
index 0000000..d8e80fe
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AnnotationLinkSpan.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2021 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.floatingmenu;
+
+import android.text.Annotation;
+import android.text.SpannableString;
+import android.text.SpannableStringBuilder;
+import android.text.style.ClickableSpan;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+
+import java.util.Arrays;
+import java.util.Optional;
+
+/**
+ * A span that turns the text wrapped by annotation tag into the clickable link text.
+ */
+class AnnotationLinkSpan extends ClickableSpan {
+ private final Optional<View.OnClickListener> mClickListener;
+
+ private AnnotationLinkSpan(View.OnClickListener listener) {
+ mClickListener = Optional.ofNullable(listener);
+ }
+
+ @Override
+ public void onClick(View view) {
+ mClickListener.ifPresent(listener -> listener.onClick(view));
+ }
+
+ /**
+ * Makes the text has the link with the click action. In addition, the span will match first
+ * LinkInfo and attach into the text.
+ *
+ * @param text the text wrapped by annotation tag
+ * @param linkInfos used to attach the click action into the corresponding span
+ * @return the text attached with the span
+ */
+ static CharSequence linkify(CharSequence text, LinkInfo... linkInfos) {
+ final SpannableString msg = new SpannableString(text);
+ final Annotation[] spans =
+ msg.getSpans(/* queryStart= */ 0, msg.length(), Annotation.class);
+ final SpannableStringBuilder builder = new SpannableStringBuilder(msg);
+
+ Arrays.asList(spans).forEach(annotationTag -> {
+ final String key = annotationTag.getValue();
+ final Optional<LinkInfo> linkInfo =
+ Arrays.asList(linkInfos).stream().filter(
+ info -> info.mAnnotation.isPresent()
+ && info.mAnnotation.get().equals(key)).findFirst();
+
+ linkInfo.flatMap(info -> info.mListener).ifPresent(listener -> {
+ final AnnotationLinkSpan span = new AnnotationLinkSpan(listener);
+ builder.setSpan(span,
+ msg.getSpanStart(annotationTag),
+ msg.getSpanEnd(annotationTag),
+ msg.getSpanFlags(span));
+ });
+ });
+
+ return builder;
+ }
+
+ /**
+ * Data class to store the annotation and the click action.
+ */
+ static class LinkInfo {
+ static final String DEFAULT_ANNOTATION = "link";
+ private final Optional<String> mAnnotation;
+ private final Optional<View.OnClickListener> mListener;
+
+ LinkInfo(@NonNull String annotation, View.OnClickListener listener) {
+ mAnnotation = Optional.of(annotation);
+ mListener = Optional.ofNullable(listener);
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/BaseTooltipView.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/BaseTooltipView.java
new file mode 100644
index 0000000..1abf559
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/BaseTooltipView.java
@@ -0,0 +1,297 @@
+/*
+ * Copyright (C) 2021 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.floatingmenu;
+
+import static android.util.TypedValue.COMPLEX_UNIT_PX;
+import static android.view.View.MeasureSpec.AT_MOST;
+import static android.view.View.MeasureSpec.UNSPECIFIED;
+
+import android.annotation.UiContext;
+import android.content.Context;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.graphics.CornerPathEffect;
+import android.graphics.Paint;
+import android.graphics.PixelFormat;
+import android.graphics.Rect;
+import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.ShapeDrawable;
+import android.os.Bundle;
+import android.text.method.MovementMethod;
+import android.util.DisplayMetrics;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.view.accessibility.AccessibilityNodeInfo;
+import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.android.settingslib.Utils;
+import com.android.systemui.R;
+import com.android.systemui.recents.TriangleShape;
+
+/**
+ * Base tooltip view that shows the information about the operation of the
+ * Accessibility floating menu. In addition, the anchor view is only for {@link
+ * AccessibilityFloatingMenuView}, it should be more suited for displaying one-off menus to avoid
+ * the performance hit for the extra window.
+ */
+class BaseTooltipView extends FrameLayout {
+ private int mFontSize;
+ private int mTextViewMargin;
+ private int mTextViewPadding;
+ private int mTextViewCornerRadius;
+ private int mArrowMargin;
+ private int mArrowWidth;
+ private int mArrowHeight;
+ private int mArrowCornerRadius;
+ private int mScreenWidth;
+ private boolean mIsShowing;
+ private TextView mTextView;
+ private final WindowManager.LayoutParams mCurrentLayoutParams;
+ private final WindowManager mWindowManager;
+ private final AccessibilityFloatingMenuView mAnchorView;
+
+ BaseTooltipView(@UiContext Context context, AccessibilityFloatingMenuView anchorView) {
+ super(context);
+ mWindowManager = context.getSystemService(WindowManager.class);
+ mAnchorView = anchorView;
+ mCurrentLayoutParams = createDefaultLayoutParams();
+
+ updateDimensions();
+ initViews();
+ }
+
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+
+ updateDimensions();
+ updateTextView();
+
+ mAnchorView.onConfigurationChanged(newConfig);
+ final Rect anchorViewLocation = mAnchorView.getWindowLocationOnScreen();
+ updateArrowWith(anchorViewLocation);
+ updateWidthWith(anchorViewLocation);
+ updateLocationWith(anchorViewLocation);
+
+ mWindowManager.updateViewLayout(this, mCurrentLayoutParams);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
+ hide();
+ }
+
+ return super.onTouchEvent(event);
+ }
+
+ @Override
+ public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
+ super.onInitializeAccessibilityNodeInfo(info);
+
+ info.addAction(AccessibilityAction.ACTION_DISMISS);
+ }
+
+ @Override
+ public boolean performAccessibilityAction(int action, Bundle arguments) {
+ if (action == AccessibilityAction.ACTION_DISMISS.getId()) {
+ hide();
+ return true;
+ }
+
+ return super.performAccessibilityAction(action, arguments);
+ }
+
+ void show() {
+ if (isShowing()) {
+ return;
+ }
+
+ mIsShowing = true;
+ final Rect anchorViewLocation = mAnchorView.getWindowLocationOnScreen();
+ updateArrowWith(anchorViewLocation);
+ updateWidthWith(anchorViewLocation);
+ updateLocationWith(anchorViewLocation);
+
+ mWindowManager.addView(this, mCurrentLayoutParams);
+ }
+
+ void hide() {
+ if (!isShowing()) {
+ return;
+ }
+
+ mIsShowing = false;
+ mWindowManager.removeView(this);
+ }
+
+ void setDescription(CharSequence text) {
+ mTextView.setText(text);
+ }
+
+ void setMovementMethod(MovementMethod movement) {
+ mTextView.setMovementMethod(movement);
+ }
+
+ private boolean isShowing() {
+ return mIsShowing;
+ }
+
+ private void initViews() {
+ final View contentView =
+ LayoutInflater.from(getContext()).inflate(
+ R.layout.accessibility_floating_menu_tooltip, this, false);
+
+ mTextView = contentView.findViewById(R.id.text);
+
+ addView(contentView);
+ }
+
+ private static WindowManager.LayoutParams createDefaultLayoutParams() {
+ final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
+ WindowManager.LayoutParams.WRAP_CONTENT,
+ WindowManager.LayoutParams.WRAP_CONTENT,
+ WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL,
+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+ | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
+ PixelFormat.TRANSLUCENT);
+ params.windowAnimations = android.R.style.Animation_Translucent;
+ params.gravity = Gravity.START | Gravity.TOP;
+
+ return params;
+ }
+
+ private void updateDimensions() {
+ final Resources res = getResources();
+ final DisplayMetrics dm = res.getDisplayMetrics();
+ mScreenWidth = dm.widthPixels;
+ mArrowWidth =
+ res.getDimensionPixelSize(R.dimen.accessibility_floating_tooltip_arrow_width);
+ mArrowHeight =
+ res.getDimensionPixelSize(R.dimen.accessibility_floating_tooltip_arrow_height);
+ mArrowMargin =
+ res.getDimensionPixelSize(
+ R.dimen.accessibility_floating_tooltip_arrow_margin);
+ mArrowCornerRadius =
+ res.getDimensionPixelSize(
+ R.dimen.accessibility_floating_tooltip_arrow_corner_radius);
+ mFontSize =
+ res.getDimensionPixelSize(R.dimen.accessibility_floating_tooltip_font_size);
+ mTextViewMargin =
+ res.getDimensionPixelSize(R.dimen.accessibility_floating_tooltip_margin);
+ mTextViewPadding =
+ res.getDimensionPixelSize(R.dimen.accessibility_floating_tooltip_padding);
+ mTextViewCornerRadius =
+ res.getDimensionPixelSize(
+ R.dimen.accessibility_floating_tooltip_text_corner_radius);
+ }
+
+ private void updateTextView() {
+ mTextView.setTextSize(COMPLEX_UNIT_PX, mFontSize);
+ mTextView.setPadding(mTextViewPadding, mTextViewPadding, mTextViewPadding,
+ mTextViewPadding);
+
+ final GradientDrawable gradientDrawable = (GradientDrawable) mTextView.getBackground();
+ gradientDrawable.setCornerRadius(mTextViewCornerRadius);
+ }
+
+ private void updateArrowWith(Rect anchorViewLocation) {
+ final boolean isAnchorViewOnLeft = isAnchorViewOnLeft(anchorViewLocation);
+ final View arrowView = findViewById(isAnchorViewOnLeft
+ ? R.id.arrow_left
+ : R.id.arrow_right);
+ arrowView.setVisibility(VISIBLE);
+ drawArrow(arrowView, isAnchorViewOnLeft);
+
+ final LinearLayout.LayoutParams layoutParams =
+ (LinearLayout.LayoutParams) arrowView.getLayoutParams();
+ layoutParams.width = mArrowWidth;
+ layoutParams.height = mArrowHeight;
+
+ final int leftMargin = isAnchorViewOnLeft ? 0 : mArrowMargin;
+ final int rightMargin = isAnchorViewOnLeft ? mArrowMargin : 0;
+ layoutParams.setMargins(leftMargin, 0, rightMargin, 0);
+ arrowView.setLayoutParams(layoutParams);
+ }
+
+ private void updateWidthWith(Rect anchorViewLocation) {
+ final ViewGroup.LayoutParams layoutParams = mTextView.getLayoutParams();
+ layoutParams.width = getTextWidthWith(anchorViewLocation);
+ mTextView.setLayoutParams(layoutParams);
+ }
+
+ private void updateLocationWith(Rect anchorViewLocation) {
+ mCurrentLayoutParams.x = isAnchorViewOnLeft(anchorViewLocation)
+ ? anchorViewLocation.width()
+ : mScreenWidth - getWindowWidthWith(anchorViewLocation)
+ - anchorViewLocation.width();
+ mCurrentLayoutParams.y =
+ anchorViewLocation.centerY() - (getTextHeightWith(anchorViewLocation) / 2);
+ }
+
+ private void drawArrow(View view, boolean isPointingLeft) {
+ final ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
+ final TriangleShape triangleShape =
+ TriangleShape.createHorizontal(layoutParams.width, layoutParams.height,
+ isPointingLeft);
+ final ShapeDrawable arrowDrawable = new ShapeDrawable(triangleShape);
+ final Paint arrowPaint = arrowDrawable.getPaint();
+ arrowPaint.setColor(Utils.getColorAttrDefaultColor(getContext(),
+ com.android.internal.R.attr.colorAccentPrimary));
+ final CornerPathEffect effect = new CornerPathEffect(mArrowCornerRadius);
+ arrowPaint.setPathEffect(effect);
+ view.setBackground(arrowDrawable);
+ }
+
+ private boolean isAnchorViewOnLeft(Rect anchorViewLocation) {
+ return anchorViewLocation.left < (mScreenWidth / 2);
+ }
+
+ private int getTextWidthWith(Rect anchorViewLocation) {
+ final int widthSpec =
+ MeasureSpec.makeMeasureSpec(getAvailableTextWidthWith(anchorViewLocation), AT_MOST);
+ final int heightSpec =
+ MeasureSpec.makeMeasureSpec(0, UNSPECIFIED);
+ mTextView.measure(widthSpec, heightSpec);
+ return mTextView.getMeasuredWidth();
+ }
+
+ private int getTextHeightWith(Rect anchorViewLocation) {
+ final int widthSpec =
+ MeasureSpec.makeMeasureSpec(getAvailableTextWidthWith(anchorViewLocation), AT_MOST);
+ final int heightSpec =
+ MeasureSpec.makeMeasureSpec(0, UNSPECIFIED);
+ mTextView.measure(widthSpec, heightSpec);
+ return mTextView.getMeasuredHeight();
+ }
+
+ private int getAvailableTextWidthWith(Rect anchorViewLocation) {
+ return mScreenWidth - anchorViewLocation.width() - mArrowWidth - mArrowMargin
+ - mTextViewMargin;
+ }
+
+ private int getWindowWidthWith(Rect anchorViewLocation) {
+ return getTextWidthWith(anchorViewLocation) + mArrowWidth + mArrowMargin;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/DockTooltipView.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/DockTooltipView.java
new file mode 100644
index 0000000..49056a6
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/DockTooltipView.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2021 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.floatingmenu;
+
+import android.content.Context;
+
+import com.android.systemui.R;
+
+/**
+ * Dock tooltip view that shows the info about moving the Accessibility button to the edge to hide.
+ */
+class DockTooltipView extends BaseTooltipView {
+ private final AccessibilityFloatingMenuView mAnchorView;
+
+ DockTooltipView(Context context, AccessibilityFloatingMenuView anchorView) {
+ super(context, anchorView);
+ mAnchorView = anchorView;
+
+ setDescription(
+ getContext().getText(R.string.accessibility_floating_button_docking_tooltip));
+ }
+
+ @Override
+ void hide() {
+ super.hide();
+
+ mAnchorView.stopTranslateXAnimation();
+ }
+
+ @Override
+ void show() {
+ super.show();
+
+ mAnchorView.startTranslateXAnimation();
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MigrationTooltipView.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MigrationTooltipView.java
new file mode 100644
index 0000000..e4f3e31
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MigrationTooltipView.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2021 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.floatingmenu;
+
+import static com.android.internal.accessibility.AccessibilityShortcutController.ACCESSIBILITY_BUTTON_COMPONENT_NAME;
+
+import android.content.Context;
+import android.content.Intent;
+import android.provider.Settings;
+import android.text.method.LinkMovementMethod;
+
+import com.android.systemui.R;
+
+/**
+ * Migration tooltip view that shows the information about the Accessibility button was replaced
+ * with the floating menu.
+ */
+class MigrationTooltipView extends BaseTooltipView {
+ MigrationTooltipView(Context context, AccessibilityFloatingMenuView anchorView) {
+ super(context, anchorView);
+
+ final Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_DETAILS_SETTINGS);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.putExtra(Intent.EXTRA_COMPONENT_NAME,
+ ACCESSIBILITY_BUTTON_COMPONENT_NAME.flattenToShortString());
+
+ final AnnotationLinkSpan.LinkInfo linkInfo = new AnnotationLinkSpan.LinkInfo(
+ AnnotationLinkSpan.LinkInfo.DEFAULT_ANNOTATION,
+ v -> {
+ getContext().startActivity(intent);
+ hide();
+ });
+
+ final int textResId = R.string.accessibility_floating_button_migration_tooltip;
+ setDescription(AnnotationLinkSpan.linkify(getContext().getText(textResId), linkInfo));
+ setMovementMethod(LinkMovementMethod.getInstance());
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java
index 5f27400..875bfdb 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java
@@ -59,7 +59,6 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.R;
-import com.android.systemui.biometrics.HbmTypes.HbmType;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.doze.DozeReceiver;
@@ -72,6 +71,8 @@
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.util.concurrency.DelayableExecutor;
+import java.util.Optional;
+
import javax.inject.Inject;
/**
@@ -87,7 +88,7 @@
*/
@SuppressWarnings("deprecation")
@SysUISingleton
-public class UdfpsController implements DozeReceiver, HbmCallback {
+public class UdfpsController implements DozeReceiver {
private static final String TAG = "UdfpsController";
private static final long AOD_INTERRUPT_TIMEOUT_MILLIS = 1000;
@@ -105,11 +106,12 @@
@NonNull private final DumpManager mDumpManager;
@NonNull private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@NonNull private final KeyguardViewMediator mKeyguardViewMediator;
- @NonNull private final Vibrator mVibrator;
+ @Nullable private final Vibrator mVibrator;
@NonNull private final Handler mMainHandler;
@NonNull private final FalsingManager mFalsingManager;
@NonNull private final PowerManager mPowerManager;
@NonNull private final AccessibilityManager mAccessibilityManager;
+ @Nullable private final UdfpsHbmCallback mHbmCallback;
// Currently the UdfpsController supports a single UDFPS sensor. If devices have multiple
// sensors, this, in addition to a lot of the code here, will be updated.
@VisibleForTesting final FingerprintSensorPropertiesInternal mSensorProps;
@@ -135,7 +137,8 @@
private boolean mScreenOn;
private Runnable mAodInterruptRunnable;
- private static final AudioAttributes VIBRATION_SONIFICATION_ATTRIBUTES =
+ @VisibleForTesting
+ static final AudioAttributes VIBRATION_SONIFICATION_ATTRIBUTES =
new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
@@ -144,7 +147,8 @@
private final VibrationEffect mEffectTick = VibrationEffect.get(VibrationEffect.EFFECT_TICK);
private final VibrationEffect mEffectTextureTick =
VibrationEffect.get(VibrationEffect.EFFECT_TEXTURE_TICK);
- private final VibrationEffect mEffectClick = VibrationEffect.get(VibrationEffect.EFFECT_CLICK);
+ @VisibleForTesting
+ final VibrationEffect mEffectClick = VibrationEffect.get(VibrationEffect.EFFECT_CLICK);
private final VibrationEffect mEffectHeavy =
VibrationEffect.get(VibrationEffect.EFFECT_HEAVY_CLICK);
private final VibrationEffect mDoubleClick =
@@ -152,6 +156,9 @@
private final Runnable mAcquiredVibration = new Runnable() {
@Override
public void run() {
+ if (mVibrator == null) {
+ return;
+ }
String effect = Settings.Global.getString(mContext.getContentResolver(),
"udfps_acquired_type");
mVibrator.vibrate(getVibration(effect, mEffectTick), VIBRATION_SONIFICATION_ATTRIBUTES);
@@ -389,24 +396,28 @@
PowerManager.USER_ACTIVITY_EVENT_TOUCH, 0);
// TODO: this should eventually be removed after ux testing
- final ContentResolver contentResolver = mContext.getContentResolver();
- int startEnabled = Settings.Global.getInt(contentResolver,
- "udfps_start", 0);
- if (startEnabled > 0) {
- String startEffectSetting = Settings.Global.getString(
- contentResolver, "udfps_start_type");
- mVibrator.vibrate(getVibration(startEffectSetting, mEffectClick),
- VIBRATION_SONIFICATION_ATTRIBUTES);
+ if (mVibrator != null) {
+ final ContentResolver contentResolver =
+ mContext.getContentResolver();
+ int startEnabled = Settings.Global.getInt(contentResolver,
+ "udfps_start", 1);
+ if (startEnabled > 0) {
+ String startEffectSetting = Settings.Global.getString(
+ contentResolver, "udfps_start_type");
+ mVibrator.vibrate(getVibration(startEffectSetting,
+ mEffectClick), VIBRATION_SONIFICATION_ATTRIBUTES);
+ }
+
+ int acquiredEnabled = Settings.Global.getInt(contentResolver,
+ "udfps_acquired", 0);
+ if (acquiredEnabled > 0) {
+ int delay = Settings.Global.getInt(contentResolver,
+ "udfps_acquired_delay", 500);
+ mMainHandler.removeCallbacks(mAcquiredVibration);
+ mMainHandler.postDelayed(mAcquiredVibration, delay);
+ }
}
- int acquiredEnabled = Settings.Global.getInt(contentResolver,
- "udfps_acquired", 0);
- if (acquiredEnabled > 0) {
- int delay = Settings.Global.getInt(contentResolver,
- "udfps_acquired_delay", 500);
- mMainHandler.removeCallbacks(mAcquiredVibration);
- mMainHandler.postDelayed(mAcquiredVibration, delay);
- }
handled = true;
} else if (sinceLastLog >= MIN_TOUCH_LOG_INTERVAL) {
Log.v(TAG, "onTouch | finger move: " + touchInfo);
@@ -456,11 +467,13 @@
@NonNull FalsingManager falsingManager,
@NonNull PowerManager powerManager,
@NonNull AccessibilityManager accessibilityManager,
- @NonNull ScreenLifecycle screenLifecycle) {
+ @NonNull ScreenLifecycle screenLifecycle,
+ @Nullable Vibrator vibrator,
+ @NonNull Optional<UdfpsHbmCallback> hbmCallback) {
mContext = context;
// TODO (b/185124905): inject main handler and vibrator once done prototyping
mMainHandler = new Handler(Looper.getMainLooper());
- mVibrator = context.getSystemService(Vibrator.class);
+ mVibrator = vibrator;
mInflater = inflater;
// The fingerprint manager is queried for UDFPS before this class is constructed, so the
// fingerprint manager should never be null.
@@ -476,6 +489,7 @@
mFalsingManager = falsingManager;
mPowerManager = powerManager;
mAccessibilityManager = accessibilityManager;
+ mHbmCallback = hbmCallback.orElse(null);
screenLifecycle.addObserver(mScreenObserver);
mScreenOn = screenLifecycle.getScreenState() == ScreenLifecycle.SCREEN_ON;
@@ -609,7 +623,7 @@
Log.v(TAG, "showUdfpsOverlay | adding window reason=" + reason);
mView = (UdfpsView) mInflater.inflate(R.layout.udfps_view, null, false);
mView.setSensorProperties(mSensorProps);
- mView.setHbmCallback(this);
+ mView.setHbmCallback(mHbmCallback);
UdfpsAnimationViewController animation = inflateUdfpsAnimation(reason);
animation.init();
mView.setAnimationViewController(animation);
@@ -781,17 +795,6 @@
mView.stopIllumination();
}
- @Override
- public void enableHbm(@HbmType int hbmType, @Nullable Surface surface) {
- // Do nothing. This method can be implemented for devices that require the high-brightness
- // mode for fingerprint illumination.
- }
-
- @Override
- public void disableHbm(@HbmType int hbmType, @Nullable Surface surface) {
- // Do nothing. This method can be implemented for devices that require the high-brightness
- // mode for fingerprint illumination.
- }
private VibrationEffect getVibration(String effect, VibrationEffect defaultEffect) {
if (TextUtils.isEmpty(effect)) {
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java
index cd5abd7..2c48d0a 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java
@@ -36,7 +36,7 @@
public class UdfpsEnrollDrawable extends UdfpsDrawable {
private static final String TAG = "UdfpsAnimationEnroll";
- static final float PROGRESS_BAR_RADIUS = 180.f;
+ static final float PROGRESS_BAR_RADIUS = 360.f;
@NonNull private final Drawable mMovingTargetFpIcon;
@NonNull private final Paint mSensorOutlinePaint;
@@ -96,11 +96,6 @@
return;
}
- if (mSensorRect != null) {
- canvas.drawOval(mSensorRect, mSensorOutlinePaint);
- }
- mFingerprintDrawable.draw(canvas);
-
// Draw moving target
if (mEnrollHelper.isCenterEnrollmentComplete()) {
mFingerprintDrawable.setAlpha(mAlpha == 255 ? 64 : mAlpha);
@@ -117,6 +112,10 @@
mMovingTargetFpIcon.draw(canvas);
canvas.restore();
} else {
+ if (mSensorRect != null) {
+ canvas.drawOval(mSensorRect, mSensorOutlinePaint);
+ }
+ mFingerprintDrawable.draw(canvas);
mFingerprintDrawable.setAlpha(mAlpha);
mSensorOutlinePaint.setAlpha(mAlpha);
}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/HbmCallback.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHbmCallback.java
similarity index 92%
rename from packages/SystemUI/src/com/android/systemui/biometrics/HbmCallback.java
rename to packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHbmCallback.java
index d90d0f8..85f0d27 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/HbmCallback.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHbmCallback.java
@@ -19,18 +19,18 @@
import android.annotation.Nullable;
import android.view.Surface;
-import com.android.systemui.biometrics.HbmTypes.HbmType;
+import com.android.systemui.biometrics.UdfpsHbmTypes.HbmType;
/**
* Interface for controlling the high-brightness mode (HBM). UdfpsView can use this callback to
* enable the HBM while showing the fingerprint illumination, and to disable the HBM after the
* illumination is no longer necessary.
*/
-public interface HbmCallback {
+public interface UdfpsHbmCallback {
/**
* UdfpsView will call this to enable the HBM when the fingerprint illumination is needed.
*
- * @param hbmType The type of HBM that should be enabled. See {@link HbmTypes}.
+ * @param hbmType The type of HBM that should be enabled. See {@link UdfpsHbmTypes}.
* @param surface The surface for which the HBM is requested, in case the HBM implementation
* needs to set special surface flags to enable the HBM. Can be null.
*/
@@ -39,7 +39,7 @@
/**
* UdfpsView will call this to disable the HBM when the illumination is not longer needed.
*
- * @param hbmType The type of HBM that should be disabled. See {@link HbmTypes}.
+ * @param hbmType The type of HBM that should be disabled. See {@link UdfpsHbmTypes}.
* @param surface The surface for which the HBM is requested, in case the HBM implementation
* needs to unset special surface flags to disable the HBM. Can be null.
*/
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/HbmTypes.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHbmTypes.java
similarity index 97%
rename from packages/SystemUI/src/com/android/systemui/biometrics/HbmTypes.java
rename to packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHbmTypes.java
index f798005..3ab0bd6 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/HbmTypes.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHbmTypes.java
@@ -25,7 +25,7 @@
/**
* Different high-brightness mode (HBM) types that are relevant to this package.
*/
-public final class HbmTypes {
+public final class UdfpsHbmTypes {
/** HBM that applies to the whole screen. */
public static final int GLOBAL_HBM = IUdfpsHbmListener.GLOBAL_HBM;
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsIlluminator.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsIlluminator.java
index 8bea05b..1676bcd 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsIlluminator.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsIlluminator.java
@@ -26,7 +26,7 @@
/**
* @param callback Invoked when HBM should be enabled or disabled.
*/
- void setHbmCallback(@Nullable HbmCallback callback);
+ void setHbmCallback(@Nullable UdfpsHbmCallback callback);
/**
* Invoked when illumination should start.
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsSurfaceView.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsSurfaceView.java
index 4d441bd..aa5f0f6 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsSurfaceView.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsSurfaceView.java
@@ -31,7 +31,7 @@
import android.view.SurfaceHolder;
import android.view.SurfaceView;
-import com.android.systemui.biometrics.HbmTypes.HbmType;
+import com.android.systemui.biometrics.UdfpsHbmTypes.HbmType;
/**
* Under-display fingerprint sensor Surface View. The surface should be used for HBM-specific things
@@ -41,7 +41,7 @@
private static final String TAG = "UdfpsSurfaceView";
private static final String SETTING_HBM_TYPE =
"com.android.systemui.biometrics.UdfpsSurfaceView.hbmType";
- private static final @HbmType int DEFAULT_HBM_TYPE = HbmTypes.GLOBAL_HBM;
+ private static final @HbmType int DEFAULT_HBM_TYPE = UdfpsHbmTypes.GLOBAL_HBM;
/**
* This is used instead of {@link android.graphics.drawable.Drawable}, because the latter has
@@ -57,7 +57,7 @@
private final @HbmType int mHbmType;
@NonNull private RectF mSensorRect;
- @Nullable private HbmCallback mHbmCallback;
+ @Nullable private UdfpsHbmCallback mHbmCallback;
public UdfpsSurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -90,7 +90,7 @@
}
@Override
- public void setHbmCallback(@Nullable HbmCallback callback) {
+ public void setHbmCallback(@Nullable UdfpsHbmCallback callback) {
mHbmCallback = callback;
}
@@ -102,7 +102,7 @@
Log.e(TAG, "startIllumination | mHbmCallback is null");
}
- if (mHbmType == HbmTypes.GLOBAL_HBM) {
+ if (mHbmType == UdfpsHbmTypes.GLOBAL_HBM) {
drawImmediately(mIlluminationDotDrawable);
}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java
index f10d5f3..a1d3040 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java
@@ -101,7 +101,7 @@
}
@Override
- public void setHbmCallback(@Nullable HbmCallback callback) {
+ public void setHbmCallback(@Nullable UdfpsHbmCallback callback) {
mHbmSurfaceView.setHbmCallback(callback);
}
diff --git a/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingAnimation.java b/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingAnimation.java
index 9d47bbb..f01ac68 100644
--- a/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingAnimation.java
+++ b/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingAnimation.java
@@ -34,7 +34,7 @@
*/
public class WirelessChargingAnimation {
- public static final long DURATION = 1133;
+ public static final long DURATION = 1500;
private static final String TAG = "WirelessChargingView";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
diff --git a/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingLayout.java b/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingLayout.java
index 38ffec1..0d3e2ae 100644
--- a/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/charging/WirelessChargingLayout.java
@@ -20,6 +20,7 @@
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
+import android.graphics.Color;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.util.TypedValue;
@@ -42,7 +43,9 @@
*/
public class WirelessChargingLayout extends FrameLayout {
public static final int UNKNOWN_BATTERY_LEVEL = -1;
- private static final long RIPPLE_ANIMATION_DURATION = 1133;
+ private static final long RIPPLE_ANIMATION_DURATION = 1500;
+ private static final int SCRIM_COLOR = 0x4C000000;
+ private static final int SCRIM_FADE_DURATION = 300;
private ChargingRippleView mRippleView;
public WirelessChargingLayout(Context context) {
@@ -121,6 +124,19 @@
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(textSizeAnimator, textOpacityAnimator, textFadeAnimator);
+ ValueAnimator scrimFadeInAnimator = ObjectAnimator.ofArgb(this,
+ "backgroundColor", Color.TRANSPARENT, SCRIM_COLOR);
+ scrimFadeInAnimator.setDuration(SCRIM_FADE_DURATION);
+ scrimFadeInAnimator.setInterpolator(Interpolators.LINEAR);
+ ValueAnimator scrimFadeOutAnimator = ObjectAnimator.ofArgb(this,
+ "backgroundColor", SCRIM_COLOR, Color.TRANSPARENT);
+ scrimFadeOutAnimator.setDuration(SCRIM_FADE_DURATION);
+ scrimFadeOutAnimator.setInterpolator(Interpolators.LINEAR);
+ scrimFadeOutAnimator.setStartDelay(RIPPLE_ANIMATION_DURATION - SCRIM_FADE_DURATION);
+ AnimatorSet animatorSetScrim = new AnimatorSet();
+ animatorSetScrim.playTogether(scrimFadeInAnimator, scrimFadeOutAnimator);
+ animatorSetScrim.start();
+
mRippleView = findViewById(R.id.wireless_charging_ripple);
OnAttachStateChangeListener listener = new OnAttachStateChangeListener() {
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt
index 26be987..a904cef 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/ui/ControlsUiControllerImpl.kt
@@ -120,7 +120,7 @@
private val onSeedingComplete = Consumer<Boolean> {
accepted ->
if (accepted) {
- selectedStructure = controlsController.get().getFavorites().maxBy {
+ selectedStructure = controlsController.get().getFavorites().maxByOrNull {
it.controls.size
} ?: EMPTY_STRUCTURE
updatePreferences(selectedStructure)
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java b/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java
index fd80d50..26db33d 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java
@@ -29,6 +29,7 @@
import android.app.WallpaperManager;
import android.app.admin.DevicePolicyManager;
import android.app.role.RoleManager;
+import android.app.smartspace.SmartspaceManager;
import android.app.trust.TrustManager;
import android.content.ContentResolver;
import android.content.Context;
@@ -400,4 +401,10 @@
static PermissionManager providePermissionManager(Context context) {
return context.getSystemService(PermissionManager.class);
}
+
+ @Provides
+ @Singleton
+ static SmartspaceManager provideSmartspaceManager(Context context) {
+ return context.getSystemService(SmartspaceManager.class);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
index 7fa48d4..1396099 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
@@ -29,6 +29,7 @@
import com.android.systemui.SystemUIFactory;
import com.android.systemui.appops.dagger.AppOpsModule;
import com.android.systemui.assist.AssistModule;
+import com.android.systemui.biometrics.UdfpsHbmCallback;
import com.android.systemui.classifier.FalsingModule;
import com.android.systemui.controls.dagger.ControlsModule;
import com.android.systemui.dagger.qualifiers.Main;
@@ -160,6 +161,9 @@
@BindsOptionalOf
abstract StatusBar optionalStatusBar();
+ @BindsOptionalOf
+ abstract UdfpsHbmCallback optionalUdfpsHbmCallback();
+
@SysUISingleton
@Binds
abstract SystemClock bindSystemClock(SystemClockImpl systemClock);
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
index a83b13c..3873c25 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java
@@ -226,7 +226,7 @@
ActionsDialog dialog = new ActionsDialog(getContext(), mAdapter, mOverflowAdapter,
this::getWalletViewController, mDepthController, mSysuiColorExtractor,
mStatusBarService, mNotificationShadeWindowController,
- mSysUiState, this::onRotate, isKeyguardShowing(), mPowerAdapter);
+ mSysUiState, this::onRotate, isKeyguardShowing(), mPowerAdapter, getEventLogger());
if (shouldShowLockMessage(dialog)) {
dialog.showLockMessage();
@@ -294,11 +294,11 @@
SysuiColorExtractor sysuiColorExtractor, IStatusBarService statusBarService,
NotificationShadeWindowController notificationShadeWindowController,
SysUiState sysuiState, Runnable onRotateCallback, boolean keyguardShowing,
- MyPowerOptionsAdapter powerAdapter) {
+ MyPowerOptionsAdapter powerAdapter, UiEventLogger uiEventLogger) {
super(context, com.android.systemui.R.style.Theme_SystemUI_Dialog_GlobalActions,
adapter, overflowAdapter, depthController, sysuiColorExtractor,
statusBarService, notificationShadeWindowController, sysuiState,
- onRotateCallback, keyguardShowing, powerAdapter);
+ onRotateCallback, keyguardShowing, powerAdapter, uiEventLogger);
mWalletFactory = walletFactory;
// Update window attributes
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java
index 2eb3762..f9bb35fc 100644
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java
@@ -249,7 +249,43 @@
GA_SCREENSHOT_PRESS(347),
@UiEvent(doc = "The global actions screenshot button was long pressed.")
- GA_SCREENSHOT_LONG_PRESS(348);
+ GA_SCREENSHOT_LONG_PRESS(348),
+
+ @UiEvent(doc = "The global actions power off button was pressed.")
+ GA_SHUTDOWN_PRESS(802),
+
+ @UiEvent(doc = "The global actions power off button was long pressed.")
+ GA_SHUTDOWN_LONG_PRESS(803),
+
+ @UiEvent(doc = "The global actions reboot button was pressed.")
+ GA_REBOOT_PRESS(349),
+
+ @UiEvent(doc = "The global actions reboot button was long pressed.")
+ GA_REBOOT_LONG_PRESS(804),
+
+ @UiEvent(doc = "The global actions lockdown button was pressed.")
+ GA_LOCKDOWN_PRESS(354), // already created by cwren apparently
+
+ @UiEvent(doc = "Power menu was opened via quick settings button.")
+ GA_OPEN_QS(805),
+
+ @UiEvent(doc = "Power menu was opened via power + volume up.")
+ GA_OPEN_POWER_VOLUP(806),
+
+ @UiEvent(doc = "Power menu was opened via long press on power.")
+ GA_OPEN_LONG_PRESS_POWER(807),
+
+ @UiEvent(doc = "Power menu was closed via long press on power.")
+ GA_CLOSE_LONG_PRESS_POWER(808),
+
+ @UiEvent(doc = "Power menu was dismissed by back gesture.")
+ GA_CLOSE_BACK(809),
+
+ @UiEvent(doc = "Power menu was dismissed by tapping outside dialog.")
+ GA_CLOSE_TAP_OUTSIDE(810),
+
+ @UiEvent(doc = "Power menu was closed via power + volume up.")
+ GA_CLOSE_POWER_VOLUP(811);
private final int mId;
@@ -349,6 +385,10 @@
return mContext;
}
+ protected UiEventLogger getEventLogger() {
+ return mUiEventLogger;
+ }
+
/**
* Show the global actions dialog (creating if necessary)
*
@@ -581,7 +621,7 @@
mAdapter, mOverflowAdapter,
mDepthController, mSysuiColorExtractor,
mStatusBarService, mNotificationShadeWindowController,
- mSysUiState, this::onRotate, mKeyguardShowing, mPowerAdapter);
+ mSysUiState, this::onRotate, mKeyguardShowing, mPowerAdapter, mUiEventLogger);
dialog.setOnDismissListener(this);
dialog.setOnShowListener(this);
@@ -679,13 +719,14 @@
@VisibleForTesting
final class ShutDownAction extends SinglePressAction implements LongPressAction {
- private ShutDownAction() {
+ ShutDownAction() {
super(R.drawable.ic_lock_power_off,
R.string.global_action_power_off);
}
@Override
public boolean onLongPress() {
+ mUiEventLogger.log(GlobalActionsEvent.GA_SHUTDOWN_LONG_PRESS);
if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
mWindowManagerFuncs.reboot(true);
return true;
@@ -705,6 +746,7 @@
@Override
public void onPress() {
+ mUiEventLogger.log(GlobalActionsEvent.GA_SHUTDOWN_PRESS);
// shutdown by making sure radio and power are handled accordingly.
mWindowManagerFuncs.shutdown();
}
@@ -807,12 +849,13 @@
@VisibleForTesting
final class RestartAction extends SinglePressAction implements LongPressAction {
- private RestartAction() {
+ RestartAction() {
super(R.drawable.ic_restart, R.string.global_action_restart);
}
@Override
public boolean onLongPress() {
+ mUiEventLogger.log(GlobalActionsEvent.GA_REBOOT_LONG_PRESS);
if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {
mWindowManagerFuncs.reboot(true);
return true;
@@ -832,6 +875,7 @@
@Override
public void onPress() {
+ mUiEventLogger.log(GlobalActionsEvent.GA_REBOOT_PRESS);
mWindowManagerFuncs.reboot(false);
}
}
@@ -1062,6 +1106,7 @@
public void onPress() {
mLockPatternUtils.requireStrongAuth(STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN,
UserHandle.USER_ALL);
+ mUiEventLogger.log(GlobalActionsEvent.GA_LOCKDOWN_PRESS);
try {
mIWindowManager.lockNow(null);
// Lock profiles (if any) on the background thread.
@@ -2049,6 +2094,7 @@
private ListPopupWindow mOverflowPopup;
private Dialog mPowerOptionsDialog;
protected final Runnable mOnRotateCallback;
+ private UiEventLogger mUiEventLogger;
protected ViewGroup mContainer;
@@ -2058,7 +2104,7 @@
SysuiColorExtractor sysuiColorExtractor, IStatusBarService statusBarService,
NotificationShadeWindowController notificationShadeWindowController,
SysUiState sysuiState, Runnable onRotateCallback, boolean keyguardShowing,
- MyPowerOptionsAdapter powerAdapter) {
+ MyPowerOptionsAdapter powerAdapter, UiEventLogger uiEventLogger) {
super(context, themeRes);
mContext = context;
mAdapter = adapter;
@@ -2071,6 +2117,7 @@
mSysUiState = sysuiState;
mOnRotateCallback = onRotateCallback;
mKeyguardShowing = keyguardShowing;
+ mUiEventLogger = uiEventLogger;
// Window initialization
Window window = getWindow();
@@ -2141,7 +2188,7 @@
mGlobalActionsLayout.setAdapter(mAdapter);
mContainer = findViewById(com.android.systemui.R.id.global_actions_container);
mContainer.setOnClickListener(v -> {
- // TODO: add logging (b/182830510)
+ mUiEventLogger.log(GlobalActionsEvent.GA_CLOSE_TAP_OUTSIDE);
cancel();
});
@@ -2218,6 +2265,12 @@
}
@Override
+ public void onBackPressed() {
+ super.onBackPressed();
+ mUiEventLogger.log(GlobalActionsEvent.GA_CLOSE_BACK);
+ }
+
+ @Override
public void show() {
super.show();
// split this up so we can override but still call Dialog.show
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt b/packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt
index 644876c..ef53233 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaCarouselController.kt
@@ -115,7 +115,7 @@
private var needsReordering: Boolean = false
private var keysNeedRemoval = mutableSetOf<String>()
private var bgColor = getBackgroundColor()
- private var shouldScrollToActivePlayer: Boolean = false
+ protected var shouldScrollToActivePlayer: Boolean = false
private var isRtl: Boolean = false
set(value) {
if (value != field) {
@@ -184,7 +184,14 @@
true /* persistent */)
mediaManager.addListener(object : MediaDataManager.Listener {
override fun onMediaDataLoaded(key: String, oldKey: String?, data: MediaData) {
- addOrUpdatePlayer(key, oldKey, data)
+ if (addOrUpdatePlayer(key, oldKey, data)) {
+ MediaPlayerData.getMediaPlayer(key, null)?.let {
+ logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
+ it.mInstanceId,
+ /* isRecommendationCard */ false,
+ it.surfaceForSmartspaceLogging)
+ }
+ }
val canRemove = data.isPlaying?.let { !it } ?: data.isClearable && !data.active
if (canRemove && !Utils.useMediaResumption(context)) {
// This view isn't playing, let's remove this! This happens e.g when
@@ -203,6 +210,12 @@
override fun onSmartspaceMediaDataLoaded(key: String, data: SmartspaceTarget) {
Log.d(TAG, "My Smartspace media update is here")
addSmartspaceMediaRecommendations(key, data)
+ MediaPlayerData.getMediaPlayer(key, null)?.let {
+ logSmartspaceCardReported(759, // SMARTSPACE_CARD_RECEIVED
+ it.mInstanceId,
+ /* isRecommendationCard */ true,
+ it.surfaceForSmartspaceLogging)
+ }
if (mediaCarouselScrollHandler.visibleToUser) {
logSmartspaceImpression()
}
@@ -276,7 +289,8 @@
}
}
- private fun addOrUpdatePlayer(key: String, oldKey: String?, data: MediaData) {
+ // Returns true if new player is added
+ private fun addOrUpdatePlayer(key: String, oldKey: String?, data: MediaData): Boolean {
val dataCopy = data.copy(backgroundColor = bgColor)
val existingPlayer = MediaPlayerData.getMediaPlayer(key, oldKey)
if (existingPlayer == null) {
@@ -295,7 +309,7 @@
} else {
existingPlayer.bindPlayer(dataCopy, key)
MediaPlayerData.addMediaPlayer(key, dataCopy, existingPlayer)
- if (visualStabilityManager.isReorderingAllowed) {
+ if (visualStabilityManager.isReorderingAllowed || shouldScrollToActivePlayer) {
reorderAllPlayers()
} else {
needsReordering = true
@@ -309,6 +323,7 @@
if (MediaPlayerData.players().size != mediaContent.childCount) {
Log.wtf(TAG, "Size of players list and number of views in carousel are out of sync")
}
+ return existingPlayer == null
}
private fun addSmartspaceMediaRecommendations(key: String, data: SmartspaceTarget) {
@@ -325,7 +340,7 @@
val lp = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT)
newRecs.recommendationViewHolder?.recommendations?.setLayoutParams(lp)
- newRecs.bindRecommendation(data, bgColor, { v -> shouldScrollToActivePlayer = true })
+ newRecs.bindRecommendation(data, bgColor)
MediaPlayerData.addMediaRecommendation(key, newRecs)
updatePlayerToState(newRecs, noAnimation = true)
reorderAllPlayers()
@@ -520,12 +535,20 @@
this.desiredLocation = desiredLocation
this.desiredHostState = it
currentlyExpanded = it.expansion > 0
+
+ val shouldCloseGuts = !currentlyExpanded && !mediaManager.hasActiveMedia() &&
+ desiredHostState.showsOnlyActiveMedia
+
for (mediaPlayer in MediaPlayerData.players()) {
if (animate) {
mediaPlayer.mediaViewController.animatePendingStateChange(
duration = duration,
delay = startDelay)
}
+ if (shouldCloseGuts && mediaPlayer.mediaViewController.isGutsVisible) {
+ mediaPlayer.closeGuts(!animate)
+ }
+
mediaPlayer.mediaViewController.onLocationPreChange(desiredLocation)
}
mediaCarouselScrollHandler.showsSettingsButton = !it.showsOnlyActiveMedia
@@ -541,9 +564,9 @@
}
}
- fun closeGuts() {
+ fun closeGuts(immediate: Boolean = true) {
MediaPlayerData.players().forEach {
- it.closeGuts(true)
+ it.closeGuts(immediate)
}
}
@@ -641,7 +664,7 @@
@VisibleForTesting
internal object MediaPlayerData {
private val EMPTY = MediaData(-1, false, 0, null, null, null, null, null,
- emptyList(), emptyList(), "INVALID", null, null, null, false, null)
+ emptyList(), emptyList(), "INVALID", null, null, null, true, null)
data class MediaSortKey(
// Is Smartspace media recommendation. When the Smartspace media is present, it should
@@ -694,7 +717,7 @@
/** Returns the index of the first non-timeout media. */
fun getActiveMediaIndex(): Int {
mediaPlayers.entries.forEachIndexed { index, e ->
- if (e.key.data.active) {
+ if (!e.key.isSsMediaRec && e.key.data.active) {
return index
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaCarouselScrollHandler.kt b/packages/SystemUI/src/com/android/systemui/media/MediaCarouselScrollHandler.kt
index e5a6271..c806bcf 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaCarouselScrollHandler.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaCarouselScrollHandler.kt
@@ -59,7 +59,7 @@
private val mainExecutor: DelayableExecutor,
private val dismissCallback: () -> Unit,
private var translationChangedListener: () -> Unit,
- private val closeGuts: () -> Unit,
+ private val closeGuts: (immediate: Boolean) -> Unit,
private val falsingCollector: FalsingCollector,
private val falsingManager: FalsingManager,
private val logSmartspaceImpression: () -> Unit
@@ -473,7 +473,7 @@
if (oldIndex != visibleMediaIndex && visibleToUser) {
logSmartspaceImpression()
}
- closeGuts()
+ closeGuts(false)
updatePlayerVisibilities()
}
val relativeLocation = visibleMediaIndex.toFloat() + if (playerWidthPlusPadding > 0)
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
index fe3463f..3e9559b 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
@@ -25,7 +25,8 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
-import android.graphics.PorterDuff;
+import android.graphics.ColorMatrix;
+import android.graphics.ColorMatrixColorFilter;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
@@ -212,7 +213,8 @@
mMediaViewController.openGuts();
return true;
} else {
- return false;
+ closeGuts();
+ return true;
}
});
mPlayerViewHolder.getCancel().setOnClickListener(v -> {
@@ -276,7 +278,7 @@
if (mMediaViewController.isGutsVisible()) return;
logSmartspaceCardReported(760, // SMARTSPACE_CARD_CLICK
- false);
+ /* isRecommendationCard */ false);
mActivityStarter.postStartActivityDismissingKeyguard(clickIntent,
buildLaunchAnimatorController(mPlayerViewHolder.getPlayer()));
});
@@ -384,7 +386,7 @@
button.setEnabled(true);
button.setOnClickListener(v -> {
logSmartspaceCardReported(760, // SMARTSPACE_CARD_CLICK
- false);
+ /* isRecommendationCard */ false);
action.run();
});
}
@@ -418,7 +420,7 @@
mPlayerViewHolder.getDismiss().setEnabled(isDismissible);
mPlayerViewHolder.getDismiss().setOnClickListener(v -> {
logSmartspaceCardReported(761, // SMARTSPACE_CARD_DISMISS
- false);
+ /* isRecommendationCard */ false);
if (mKey != null) {
closeGuts();
@@ -472,10 +474,7 @@
}
/** Bind this recommendation view based on the data given. */
- public void bindRecommendation(
- @NonNull SmartspaceTarget target,
- @NonNull int backgroundColor,
- @Nullable View.OnClickListener callback) {
+ public void bindRecommendation(@NonNull SmartspaceTarget target, @NonNull int backgroundColor) {
if (mRecommendationViewHolder == null) {
return;
}
@@ -515,8 +514,9 @@
// Get the logo from app's package name when applicable.
String packageName = extras.getString(EXTRAS_MEDIA_SOURCE_PACKAGE_NAME);
try {
- icon = mContext.getPackageManager().getApplicationIcon(
+ Drawable drawable = mContext.getPackageManager().getApplicationIcon(
packageName);
+ icon = convertToGrayscale(drawable);
} catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, "No media source icon can be fetched via package name", e);
}
@@ -528,18 +528,13 @@
// Set up media source app's logo.
ImageView mediaSourceLogoImageView = mediaLogoItems.get(uiComponentIndex);
mediaSourceLogoImageView.setImageDrawable(icon);
- // TODO(b/186699032): Tint the app logo using the accent color.
- mediaSourceLogoImageView.setColorFilter(backgroundColor, PorterDuff.Mode.XOR);
// Set up media item cover.
ImageView mediaCoverImageView = mediaCoverItems.get(uiComponentIndex);
mediaCoverImageView.setImageIcon(recommendation.getIcon());
// Set up the click listener if applicable.
- setSmartspaceRecItemOnClickListener(
- mediaCoverImageView,
- recommendation,
- callback);
+ setSmartspaceRecItemOnClickListener(mediaCoverImageView, recommendation);
if (uiComponentIndex < MEDIA_RECOMMENDATION_ITEMS_PER_ROW) {
setVisibleAndAlpha(collapsedSet,
@@ -563,7 +558,7 @@
// Set up long press to show guts setting panel.
mRecommendationViewHolder.getDismiss().setOnClickListener(v -> {
logSmartspaceCardReported(761, // SMARTSPACE_CARD_DISMISS
- true);
+ /* isRecommendationCard */ true);
closeGuts();
mKeyguardDismissUtil.executeWhenUnlocked(() -> {
mMediaDataManagerLazy.get().dismissSmartspaceRecommendation(
@@ -651,6 +646,15 @@
return (state.getState() == PlaybackState.STATE_PLAYING);
}
+ /** Convert the pass-in source drawable to a grayscale one. */
+ private Drawable convertToGrayscale(Drawable drawable) {
+ ColorMatrix matrix = new ColorMatrix();
+ matrix.setSaturation(0);
+ ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
+ drawable.setColorFilter(filter);
+ return drawable;
+ }
+
private void setVisibleAndAlpha(ConstraintSet set, int actionId, boolean visible) {
set.setVisibility(actionId, visible ? ConstraintSet.VISIBLE : ConstraintSet.GONE);
set.setAlpha(actionId, visible ? 1.0f : 0.0f);
@@ -658,8 +662,7 @@
private void setSmartspaceRecItemOnClickListener(
@NonNull View view,
- @NonNull SmartspaceAction action,
- @Nullable View.OnClickListener callback) {
+ @NonNull SmartspaceAction action) {
if (view == null || action == null || action.getIntent() == null) {
Log.e(TAG, "No tap action can be set up");
return;
@@ -668,7 +671,7 @@
view.setOnClickListener(v -> {
// When media recommendation card is shown, it will always be the top card.
logSmartspaceCardReported(760, // SMARTSPACE_CARD_CLICK
- true);
+ /* isRecommendationCard */ true);
if (shouldSmartspaceRecItemOpenInForeground(action)) {
// Request to unlock the device if the activity needs to be opened in foreground.
@@ -682,9 +685,8 @@
view.getContext().startActivity(action.getIntent());
}
- if (callback != null) {
- callback.onClick(v);
- }
+ // Automatically scroll to the active player once the media is loaded.
+ mMediaCarouselController.setShouldScrollToActivePlayer(true);
});
}
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt
index 3c28f6e..60e832a 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaHierarchyManager.kt
@@ -273,6 +273,7 @@
} else {
updateDesiredLocation()
qsExpanded = false
+ closeGuts()
}
mediaCarouselController.mediaCarouselScrollHandler.visibleToUser = isVisibleToUser()
}
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarOverlayController.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarOverlayController.java
index 2d0d5cd..40f908b 100644
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarOverlayController.java
+++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarOverlayController.java
@@ -16,7 +16,6 @@
package com.android.systemui.navigationbar;
-import android.annotation.ColorInt;
import android.content.Context;
import android.view.View;
@@ -46,10 +45,9 @@
}
/**
- * Initialize the controller with visibility change callback and light/dark icon color.
+ * Initialize the controller with visibility change callback.
*/
- public void init(Consumer<Boolean> visibilityChangeCallback, @ColorInt int lightIconColor,
- @ColorInt int darkIconColor) {}
+ public void init(Consumer<Boolean> visibilityChangeCallback) {}
/**
* Set whether the view can be shown.
@@ -72,11 +70,6 @@
public void unregisterListeners() {}
/**
- * Set the dark intensity for all drawables.
- */
- public void setDarkIntensity(float darkIntensity) {}
-
- /**
* Return the current view.
*/
public View getCurrentView() {
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarTransitions.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarTransitions.java
index fbc7c92..b4f8c10 100644
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarTransitions.java
+++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarTransitions.java
@@ -198,7 +198,6 @@
}
mView.getRotationButtonController().setDarkIntensity(darkIntensity);
- Dependency.get(NavigationBarOverlayController.class).setDarkIntensity(darkIntensity);
for (DarkIntensityListener listener : mDarkIntensityListeners) {
listener.onDarkIntensity(darkIntensity);
}
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
index f82d265..fcbd596 100644
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarView.java
@@ -61,7 +61,6 @@
import android.view.WindowManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
-import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import com.android.internal.annotations.VisibleForTesting;
@@ -326,8 +325,7 @@
mRecentsOnboarding = new RecentsOnboarding(context, mOverviewProxyService);
mNavBarOverlayController = Dependency.get(NavigationBarOverlayController.class);
if (mNavBarOverlayController.isNavigationBarOverlayEnabled()) {
- mNavBarOverlayController.init(
- mNavbarOverlayVisibilityChangeCallback, mLightIconColor, mDarkIconColor);
+ mNavBarOverlayController.init(mNavbarOverlayVisibilityChangeCallback);
}
mConfiguration = new Configuration();
diff --git a/packages/SystemUI/src/com/android/systemui/people/PeopleProvider.java b/packages/SystemUI/src/com/android/systemui/people/PeopleProvider.java
index 0f66456..b55d86e 100644
--- a/packages/SystemUI/src/com/android/systemui/people/PeopleProvider.java
+++ b/packages/SystemUI/src/com/android/systemui/people/PeopleProvider.java
@@ -18,7 +18,9 @@
import android.content.ContentProvider;
import android.content.ContentValues;
+import android.content.Context;
import android.content.pm.PackageManager;
+import android.content.pm.ProviderInfo;
import android.database.Cursor;
import android.net.Uri;
import android.os.Binder;
@@ -27,16 +29,19 @@
import android.util.Log;
import android.widget.RemoteViews;
+import com.android.systemui.SystemUIAppComponentFactory;
import com.android.systemui.people.widget.PeopleSpaceWidgetManager;
import com.android.systemui.shared.system.PeopleProviderUtils;
import javax.inject.Inject;
/** API that returns a People Tile preview. */
-public class PeopleProvider extends ContentProvider {
+public class PeopleProvider extends ContentProvider implements
+ SystemUIAppComponentFactory.ContextInitializer {
private static final String TAG = "PeopleProvider";
private static final boolean DEBUG = PeopleSpaceUtils.DEBUG;
private static final String EMPTY_STRING = "";
+ private SystemUIAppComponentFactory.ContextAvailableCallback mCallback;
@Inject
PeopleSpaceWidgetManager mPeopleSpaceWidgetManager;
@@ -82,8 +87,8 @@
Log.e(TAG, "Could not initialize people widget manager");
return null;
}
- RemoteViews view =
- mPeopleSpaceWidgetManager.getPreview(shortcutId, userHandle, packageName, extras);
+ RemoteViews view = mPeopleSpaceWidgetManager.getPreview(shortcutId, userHandle, packageName,
+ extras);
if (view == null) {
if (DEBUG) Log.d(TAG, "No preview available for shortcutId: " + shortcutId);
return null;
@@ -130,5 +135,17 @@
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
throw new IllegalArgumentException("Invalid method");
}
+
+ @Override
+ public void attachInfo(Context context, ProviderInfo info) {
+ mCallback.onContextAvailable(context);
+ super.attachInfo(context, info);
+ }
+
+ @Override
+ public void setContextAvailableCallback(
+ SystemUIAppComponentFactory.ContextAvailableCallback callback) {
+ mCallback = callback;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java b/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java
index 29685a4..7b5ab0d 100644
--- a/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java
+++ b/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceUtils.java
@@ -416,9 +416,8 @@
&& birthdayString == null;
boolean addBirthdayStatus = !hasBirthdayStatus(storedTile, context)
&& birthdayString != null;
- boolean shouldUpdate =
- storedTile.getContactAffinity() != affinity || outdatedBirthdayStatus
- || addBirthdayStatus;
+ boolean shouldUpdate = storedTile.getContactAffinity() != affinity || outdatedBirthdayStatus
+ || addBirthdayStatus;
if (shouldUpdate) {
if (DEBUG) Log.d(TAG, "Update " + storedTile.getUserName() + " from contacts");
manager.updateAppWidgetOptionsAndView(appWidgetId,
diff --git a/packages/SystemUI/src/com/android/systemui/people/PeopleTileViewHelper.java b/packages/SystemUI/src/com/android/systemui/people/PeopleTileViewHelper.java
index 06f8a60..9fc9cad 100644
--- a/packages/SystemUI/src/com/android/systemui/people/PeopleTileViewHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/people/PeopleTileViewHelper.java
@@ -41,8 +41,6 @@
import android.app.people.PeopleSpaceTile;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
@@ -57,13 +55,13 @@
import android.util.IconDrawableFactory;
import android.util.Log;
import android.util.Pair;
+import android.view.Gravity;
import android.view.View;
import android.widget.RemoteViews;
import android.widget.TextView;
import com.android.internal.annotations.VisibleForTesting;
import com.android.launcher3.icons.FastBitmapDrawable;
-import com.android.settingslib.Utils;
import com.android.systemui.R;
import com.android.systemui.people.widget.LaunchConversationActivity;
import com.android.systemui.people.widget.PeopleSpaceWidgetProvider;
@@ -195,16 +193,10 @@
*/
private RemoteViews getViewForTile() {
if (DEBUG) Log.d(TAG, "Creating view for tile key: " + mKey.toString());
- if (mTile == null || mTile.isPackageSuspended() || mTile.isUserQuieted()) {
- if (DEBUG) Log.d(TAG, "Create empty view: " + mTile);
- return createEmptyView();
- }
-
- boolean dndBlockingTileData = isDndBlockingTileData(mTile);
- if (dndBlockingTileData) {
- if (DEBUG) Log.d(TAG, "Create DND view: " + mTile.getNotificationPolicyState());
- // TODO: Create DND view.
- return createEmptyView();
+ if (mTile == null || mTile.isPackageSuspended() || mTile.isUserQuieted()
+ || isDndBlockingTileData(mTile)) {
+ if (DEBUG) Log.d(TAG, "Create suppressed view: " + mTile);
+ return createSuppressedView();
}
if (Objects.equals(mTile.getNotificationCategory(), CATEGORY_MISSED_CALL)) {
@@ -265,34 +257,27 @@
return !tile.canBypassDnd();
}
- private RemoteViews createEmptyView() {
- RemoteViews views = new RemoteViews(mContext.getPackageName(),
- R.layout.people_tile_empty_layout);
- Drawable appIcon = getAppBadge(mKey.getPackageName(), mKey.getUserId());
+ private RemoteViews createSuppressedView() {
+ RemoteViews views;
+ if (mTile.isUserQuieted()) {
+ views = new RemoteViews(mContext.getPackageName(),
+ R.layout.people_tile_work_profile_quiet_layout);
+ } else {
+ views = new RemoteViews(mContext.getPackageName(),
+ R.layout.people_tile_suppressed_layout);
+ }
+ Drawable appIcon = mContext.getDrawable(R.drawable.ic_conversation_icon);
Bitmap appIconAsBitmap = convertDrawableToBitmap(appIcon);
- FastBitmapDrawable drawable = new FastBitmapDrawable(
- appIconAsBitmap);
+ FastBitmapDrawable drawable = new FastBitmapDrawable(appIconAsBitmap);
drawable.setIsDisabled(true);
Bitmap convertedBitmap = convertDrawableToBitmap(drawable);
- views.setImageViewBitmap(R.id.item, convertedBitmap);
+ views.setImageViewBitmap(R.id.icon, convertedBitmap);
return views;
}
- private Drawable getAppBadge(String packageName, int userId) {
- Drawable badge = null;
- try {
- final ApplicationInfo appInfo = mContext.getPackageManager().getApplicationInfoAsUser(
- packageName, PackageManager.GET_META_DATA, userId);
- badge = Utils.getBadgedIcon(mContext, appInfo);
- } catch (PackageManager.NameNotFoundException e) {
- badge = mContext.getPackageManager().getDefaultActivityIcon();
- }
- return badge;
- }
-
private void setMaxLines(RemoteViews views, boolean showSender) {
int textSize = mLayoutSize == LAYOUT_LARGE ? getSizeInDp(
- R.dimen.content_text_size_for_medium)
+ R.dimen.content_text_size_for_large)
: getSizeInDp(R.dimen.content_text_size_for_medium);
int lineHeight = getLineHeight(textSize);
int notificationContentHeight = getContentHeightForLayout(lineHeight);
@@ -422,9 +407,6 @@
views.setViewVisibility(R.id.availability, View.GONE);
}
- if (mTile.getUserName() != null) {
- views.setTextViewText(R.id.name, mTile.getUserName().toString());
- }
views.setBoolean(R.id.image, "setClipToOutline", true);
views.setImageViewBitmap(R.id.person_icon,
getPersonIconBitmap(mContext, mTile, maxAvatarSize));
@@ -537,25 +519,31 @@
statusText = getStatusTextByType(status.getActivity());
}
views.setViewVisibility(R.id.predefined_icon, View.VISIBLE);
- views.setViewVisibility(R.id.messages_count, View.GONE);
- setMaxLines(views, false);
- // Secondary text color for statuses.
- views.setColorAttr(R.id.text_content, "setTextColor", android.R.attr.textColorSecondary);
views.setTextViewText(R.id.text_content, statusText);
+ if (mLayoutSize == LAYOUT_LARGE) {
+ views.setInt(R.id.content, "setGravity", Gravity.BOTTOM);
+ }
Icon statusIcon = status.getIcon();
if (statusIcon != null) {
- // No multi-line text with status images on medium layout.
- views.setViewVisibility(R.id.text_content, View.GONE);
+ // No text content styled text on medium or large.
+ views.setViewVisibility(R.id.scrim_layout, View.VISIBLE);
+ views.setImageViewIcon(R.id.status_icon, statusIcon);
// Show 1-line subtext on large layout with status images.
if (mLayoutSize == LAYOUT_LARGE) {
- views.setViewVisibility(R.id.subtext, View.VISIBLE);
- views.setTextViewText(R.id.subtext, statusText);
+ if (DEBUG) Log.d(TAG, "Remove name for large");
+ views.setViewVisibility(R.id.name, View.GONE);
+ views.setColorAttr(R.id.text_content, "setTextColor",
+ android.R.attr.textColorPrimary);
+ } else if (mLayoutSize == LAYOUT_MEDIUM) {
+ views.setViewVisibility(R.id.text_content, View.GONE);
+ views.setTextViewText(R.id.name, statusText);
}
- views.setViewVisibility(R.id.image, View.VISIBLE);
- views.setImageViewIcon(R.id.image, statusIcon);
} else {
- views.setViewVisibility(R.id.image, View.GONE);
+ // Secondary text color for statuses without icons.
+ views.setColorAttr(R.id.text_content, "setTextColor",
+ android.R.attr.textColorSecondary);
+ setMaxLines(views, false);
}
// TODO: Set status pre-defined icons
views.setImageViewResource(R.id.predefined_icon, R.drawable.ic_person);
@@ -741,16 +729,23 @@
views.setViewVisibility(R.id.name, View.VISIBLE);
views.setViewVisibility(R.id.text_content, View.VISIBLE);
views.setViewVisibility(R.id.subtext, View.GONE);
+ views.setViewVisibility(R.id.image, View.GONE);
+ views.setViewVisibility(R.id.scrim_layout, View.GONE);
}
if (mLayoutSize == LAYOUT_MEDIUM) {
if (DEBUG) Log.d(TAG, "Set vertical padding: " + mMediumVerticalPadding);
int horizontalPadding = (int) Math.floor(MAX_MEDIUM_PADDING * mDensity);
int verticalPadding = (int) Math.floor(mMediumVerticalPadding * mDensity);
- views.setViewPadding(R.id.item, horizontalPadding, verticalPadding, horizontalPadding,
+ views.setViewPadding(R.id.content, horizontalPadding, verticalPadding,
+ horizontalPadding,
verticalPadding);
}
views.setViewVisibility(R.id.messages_count, View.GONE);
+ if (mTile.getUserName() != null) {
+ views.setTextViewText(R.id.name, mTile.getUserName());
+ }
+
return views;
}
@@ -761,6 +756,9 @@
views.setViewVisibility(R.id.predefined_icon, View.GONE);
views.setViewVisibility(R.id.messages_count, View.GONE);
}
+ if (mTile.getUserName() != null) {
+ views.setTextViewText(R.id.name, mTile.getUserName());
+ }
String status = getLastInteractionString(mContext,
mTile.getLastInteractionTimestamp());
if (status != null) {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java b/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java
index dd1a4af..3a3f3f1 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java
@@ -129,6 +129,12 @@
@Override
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
mNavBarInset = insets.getInsets(WindowInsets.Type.navigationBars()).bottom;
+ mQSPanelContainer.setPaddingRelative(
+ mQSPanelContainer.getPaddingStart(),
+ mQSPanelContainer.getPaddingTop(),
+ mQSPanelContainer.getPaddingEnd(),
+ mNavBarInset
+ );
return super.onApplyWindowInsets(insets);
}
@@ -138,8 +144,7 @@
// bottom and footer are inside the screen.
MarginLayoutParams layoutParams = (MarginLayoutParams) mQSPanelContainer.getLayoutParams();
- int availableScreenHeight = getDisplayHeight() - mNavBarInset;
- int maxQs = availableScreenHeight - layoutParams.topMargin - layoutParams.bottomMargin
+ int maxQs = getDisplayHeight() - layoutParams.topMargin - layoutParams.bottomMargin
- getPaddingBottom();
int padding = mPaddingLeft + mPaddingRight + layoutParams.leftMargin
+ layoutParams.rightMargin;
@@ -148,10 +153,8 @@
mQSPanelContainer.measure(qsPanelWidthSpec,
MeasureSpec.makeMeasureSpec(maxQs, MeasureSpec.AT_MOST));
int width = mQSPanelContainer.getMeasuredWidth() + padding;
- int height = layoutParams.topMargin + layoutParams.bottomMargin
- + mQSPanelContainer.getMeasuredHeight() + getPaddingBottom();
super.onMeasure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(availableScreenHeight, MeasureSpec.EXACTLY));
+ MeasureSpec.makeMeasureSpec(getDisplayHeight(), MeasureSpec.EXACTLY));
// QSCustomizer will always be the height of the screen, but do this after
// other measuring to avoid changing the height of the QS.
mQSCustomizer.measure(widthMeasureSpec,
@@ -200,12 +203,6 @@
layoutParams.topMargin = mContext.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.quick_qs_offset_height);
mQSPanelContainer.setLayoutParams(layoutParams);
- mQSPanelContainer.setPaddingRelative(
- mQSPanelContainer.getPaddingStart(),
- mQSPanelContainer.getPaddingTop(),
- mQSPanelContainer.getPaddingEnd(),
- mContext.getResources().getDimensionPixelSize(R.dimen.qs_container_bottom_padding)
- );
int sideMargins = getResources().getDimensionPixelSize(R.dimen.notification_side_paddings);
int padding = getResources().getDimensionPixelSize(
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java b/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java
index 05197e4..0335319 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java
@@ -30,6 +30,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
+import android.view.WindowInsets;
import android.view.accessibility.AccessibilityEvent;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -153,11 +154,18 @@
MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams();
lp.topMargin = mContext.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.quick_qs_offset_height);
- lp.bottomMargin = mContext.getResources().getDimensionPixelSize(
- R.dimen.qs_container_bottom_padding);
setLayoutParams(lp);
}
+ @Override
+ public WindowInsets onApplyWindowInsets(WindowInsets insets) {
+ int bottomNavBar = insets.getInsets(WindowInsets.Type.navigationBars()).bottom;
+ MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams();
+ lp.bottomMargin = bottomNavBar;
+ setLayoutParams(lp);
+ return super.onApplyWindowInsets(insets);
+ }
+
public boolean isClosingDetail() {
return mClosingDetail;
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFooterViewController.java b/packages/SystemUI/src/com/android/systemui/qs/QSFooterViewController.java
index 1fa9260..f6d9389 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSFooterViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSFooterViewController.java
@@ -29,6 +29,7 @@
import android.widget.Toast;
import com.android.internal.logging.MetricsLogger;
+import com.android.internal.logging.UiEventLogger;
import com.android.internal.logging.nano.MetricsProto;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.R;
@@ -73,6 +74,7 @@
private final View mPowerMenuLite;
private final boolean mShowPMLiteButton;
private GlobalActionsDialogLite mGlobalActionsDialog;
+ private final UiEventLogger mUiEventLogger;
private final UserInfoController.OnUserInfoChangedListener mOnUserInfoChangedListener =
new UserInfoController.OnUserInfoChangedListener() {
@@ -122,6 +124,7 @@
startSettingsActivity();
}
} else if (v == mPowerMenuLite) {
+ mUiEventLogger.log(GlobalActionsDialogLite.GlobalActionsEvent.GA_OPEN_QS);
mGlobalActionsDialog.showOrHideDialog(false, true);
}
}
@@ -139,7 +142,7 @@
QuickQSPanelController quickQSPanelController,
TunerService tunerService, MetricsLogger metricsLogger, FalsingManager falsingManager,
@Named(PM_LITE_ENABLED) boolean showPMLiteButton,
- GlobalActionsDialogLite globalActionsDialog) {
+ GlobalActionsDialogLite globalActionsDialog, UiEventLogger uiEventLogger) {
super(view);
mUserManager = userManager;
mUserInfoController = userInfoController;
@@ -161,6 +164,7 @@
mPowerMenuLite = mView.findViewById(R.id.pm_lite);
mShowPMLiteButton = showPMLiteButton;
mGlobalActionsDialog = globalActionsDialog;
+ mUiEventLogger = uiEventLogger;
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java
index 04e32a1..3a6f1d5 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java
@@ -190,6 +190,16 @@
|| vpnName != null || vpnNameWorkProfile != null
|| isProfileOwnerOfOrganizationOwnedDevice || isParentalControlsEnabled
|| (hasWorkProfile && isNetworkLoggingEnabled);
+ // Update the view to be untappable if the device is an organization-owned device with a
+ // managed profile and there is no policy set which requires a privacy disclosure.
+ if (mIsVisible && isProfileOwnerOfOrganizationOwnedDevice && !isNetworkLoggingEnabled
+ && !hasCACertsInWorkProfile && vpnNameWorkProfile == null) {
+ mRootView.setClickable(false);
+ mRootView.findViewById(R.id.footer_icon).setVisibility(View.GONE);
+ } else {
+ mRootView.setClickable(true);
+ mRootView.findViewById(R.id.footer_icon).setVisibility(View.VISIBLE);
+ }
// Update the string
mFooterTextContent = getFooterText(isDeviceManaged, hasWorkProfile,
hasCACerts, hasCACertsInWorkProfile, isNetworkLoggingEnabled, vpnName,
@@ -345,20 +355,15 @@
private View createOrganizationDialogView() {
final boolean isDeviceManaged = mSecurityController.isDeviceManaged();
- boolean isProfileOwnerOfOrganizationOwnedDevice =
- mSecurityController.isProfileOwnerOfOrganizationOwnedDevice();
final boolean hasWorkProfile = mSecurityController.hasWorkProfile();
final CharSequence deviceOwnerOrganization =
mSecurityController.getDeviceOwnerOrganizationName();
- final CharSequence workProfileOrganizationName =
- mSecurityController.getWorkProfileOrganizationName();
final boolean hasCACerts = mSecurityController.hasCACertInCurrentUser();
final boolean hasCACertsInWorkProfile = mSecurityController.hasCACertInWorkProfile();
final boolean isNetworkLoggingEnabled = mSecurityController.isNetworkLoggingEnabled();
final String vpnName = mSecurityController.getPrimaryVpnName();
final String vpnNameWorkProfile = mSecurityController.getWorkProfileVpnName();
-
View dialogView = LayoutInflater.from(mContext)
.inflate(R.layout.quick_settings_footer_dialog, null, false);
@@ -368,8 +373,7 @@
deviceManagementSubtitle.setText(getManagementTitle(deviceOwnerOrganization));
CharSequence managementMessage = getManagementMessage(isDeviceManaged,
- deviceOwnerOrganization, isProfileOwnerOfOrganizationOwnedDevice,
- workProfileOrganizationName);
+ deviceOwnerOrganization);
if (managementMessage == null) {
dialogView.findViewById(R.id.device_management_disclosures).setVisibility(View.GONE);
} else {
@@ -377,11 +381,7 @@
TextView deviceManagementWarning =
(TextView) dialogView.findViewById(R.id.device_management_warning);
deviceManagementWarning.setText(managementMessage);
- // Don't show the policies button for profile owner of org owned device, because there
- // is no policies settings screen for it
- if (!isProfileOwnerOfOrganizationOwnedDevice) {
- mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getSettingsButton(), this);
- }
+ mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getSettingsButton(), this);
}
// ca certificate section
@@ -496,12 +496,11 @@
}
protected CharSequence getManagementMessage(boolean isDeviceManaged,
- CharSequence organizationName, boolean isProfileOwnerOfOrganizationOwnedDevice,
- CharSequence workProfileOrganizationName) {
- if (!isDeviceManaged && !isProfileOwnerOfOrganizationOwnedDevice) {
+ CharSequence organizationName) {
+ if (!isDeviceManaged) {
return null;
}
- if (isDeviceManaged && organizationName != null) {
+ if (organizationName != null) {
if (isFinancedDevice()) {
return mContext.getString(R.string.monitoring_financed_description_named_management,
organizationName, organizationName);
@@ -509,9 +508,6 @@
return mContext.getString(
R.string.monitoring_description_named_management, organizationName);
}
- } else if (isProfileOwnerOfOrganizationOwnedDevice && workProfileOrganizationName != null) {
- return mContext.getString(
- R.string.monitoring_description_named_management, workProfileOrganizationName);
}
return mContext.getString(R.string.monitoring_description_management);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
index 73a6b34..81b5318 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
@@ -23,7 +23,7 @@
import android.graphics.Color;
import android.graphics.Rect;
import android.util.AttributeSet;
-import android.util.MathUtils;
+import android.util.FeatureFlagUtils;
import android.util.Pair;
import android.view.DisplayCutout;
import android.view.View;
@@ -36,9 +36,7 @@
import com.android.settingslib.Utils;
import com.android.systemui.BatteryMeterView;
import com.android.systemui.R;
-import com.android.systemui.animation.Interpolators;
import com.android.systemui.qs.QSDetail.Callback;
-import com.android.systemui.statusbar.StatusBarIconView;
import com.android.systemui.statusbar.phone.StatusBarIconController.TintedIconManager;
import com.android.systemui.statusbar.phone.StatusBarWindowView;
import com.android.systemui.statusbar.phone.StatusIconContainer;
@@ -67,7 +65,11 @@
private View mQSCarriers;
private Clock mClockView;
- private Space mSpace;
+ private Space mDatePrivacySeparator;
+ private View mClockIconsSeparator;
+ private boolean mShowClockIconsSeparator;
+ private ViewGroup mRightLayout;
+
private BatteryMeterView mBatteryRemainingIcon;
private StatusIconContainer mIconContainer;
private View mPrivacyChip;
@@ -80,19 +82,27 @@
private int mWaterfallTopInset;
private int mCutOutPaddingLeft;
private int mCutOutPaddingRight;
- private float mClockIconsAlpha = 1.0f;
+ private float mViewAlpha = 1.0f;
private float mKeyguardExpansionFraction;
private int mTextColorPrimary = Color.TRANSPARENT;
private int mTopViewMeasureHeight;
private final String mMobileSlotName;
+ private final String mNoCallingSlotName;
private final String mCallStrengthSlotName;
+ private final boolean mProviderModel;
public QuickStatusBarHeader(Context context, AttributeSet attrs) {
super(context, attrs);
- mMobileSlotName = context.getString(com.android.internal.R.string.status_bar_no_calling);
+ mMobileSlotName = context.getString(com.android.internal.R.string.status_bar_mobile);
+ mNoCallingSlotName = context.getString(com.android.internal.R.string.status_bar_no_calling);
mCallStrengthSlotName =
context.getString(com.android.internal.R.string.status_bar_call_strength);
+ if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
+ mProviderModel = true;
+ } else {
+ mProviderModel = false;
+ }
}
/**
@@ -117,9 +127,11 @@
mPrivacyChip = findViewById(R.id.privacy_chip);
mDateView = findViewById(R.id.date);
mSecurityHeaderView = findViewById(R.id.header_text_container);
+ mClockIconsSeparator = findViewById(R.id.separator);
+ mRightLayout = findViewById(R.id.rightLayout);
mClockView = findViewById(R.id.clock);
- mSpace = findViewById(R.id.space);
+ mDatePrivacySeparator = findViewById(R.id.space);
// Tint for the battery icons are handled in setupHost()
mBatteryRemainingIcon = findViewById(R.id.batteryRemainingIcon);
@@ -230,36 +242,50 @@
}
private void updateAlphaAnimator() {
- StatusBarIconView noCallingIcon =
- ((StatusBarIconView) mIconContainer.getViewForSlot(mMobileSlotName));
- StatusBarIconView callStrengthIcon =
- ((StatusBarIconView) mIconContainer.getViewForSlot(mCallStrengthSlotName));
TouchAnimator.Builder builder = new TouchAnimator.Builder()
// The following two views have to be hidden manually, so as not to hide the
// Privacy chip in QQS
.addFloat(mDateView, "alpha", 0, 1)
.addFloat(mSecurityHeaderView, "alpha", 0, 1)
- .addFloat(mQSCarriers, "alpha", 0, 1);
- builder.setListener(new TouchAnimator.ListenerAdapter() {
- @Override
- public void onAnimationAtEnd() {
- mIconContainer.addIgnoredSlot(mMobileSlotName);
- mIconContainer.addIgnoredSlot(mCallStrengthSlotName);
- }
+ .addFloat(mQSCarriers, "alpha", 0, 1)
+ .setListener(new TouchAnimator.ListenerAdapter() {
+ @Override
+ public void onAnimationAtEnd() {
+ // TODO(b/185580157): Remove the mProviderModel if the mobile slot can be
+ // hidden in Provider model.
+ if (mProviderModel) {
+ mIconContainer.addIgnoredSlot(mNoCallingSlotName);
+ mIconContainer.addIgnoredSlot(mCallStrengthSlotName);
+ } else {
+ mIconContainer.addIgnoredSlot(mMobileSlotName);
+ }
+ }
- @Override
- public void onAnimationStarted() {
- mIconContainer.addIgnoredSlot(mMobileSlotName);
- mIconContainer.addIgnoredSlot(mCallStrengthSlotName);
- }
+ @Override
+ public void onAnimationStarted() {
+ if (mProviderModel) {
+ mIconContainer.addIgnoredSlot(mNoCallingSlotName);
+ mIconContainer.addIgnoredSlot(mCallStrengthSlotName);
+ } else {
+ mIconContainer.addIgnoredSlot(mMobileSlotName);
+ }
- @Override
- public void onAnimationAtStart() {
- super.onAnimationAtStart();
- mIconContainer.removeIgnoredSlot(mMobileSlotName);
- mIconContainer.removeIgnoredSlot(mCallStrengthSlotName);
- }
- });
+ setSeparatorVisibility(false);
+ }
+
+ @Override
+ public void onAnimationAtStart() {
+ super.onAnimationAtStart();
+ if (mProviderModel) {
+ mIconContainer.removeIgnoredSlot(mNoCallingSlotName);
+ mIconContainer.removeIgnoredSlot(mCallStrengthSlotName);
+ } else {
+ mIconContainer.removeIgnoredSlot(mMobileSlotName);
+ }
+
+ setSeparatorVisibility(mShowClockIconsSeparator);
+ }
+ });
mAlphaAnimator = builder.build();
}
@@ -337,20 +363,30 @@
cutout, cornerCutoutPadding, -1);
mDatePrivacyView.setPadding(padding.first, 0, padding.second, 0);
mClockIconsView.setPadding(padding.first, 0, padding.second, 0);
- LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mSpace.getLayoutParams();
+ LinearLayout.LayoutParams datePrivacySeparatorLayoutParams =
+ (LinearLayout.LayoutParams) mDatePrivacySeparator.getLayoutParams();
+ LinearLayout.LayoutParams mClockIconsSeparatorLayoutParams =
+ (LinearLayout.LayoutParams) mClockIconsSeparator.getLayoutParams();
boolean cornerCutout = cornerCutoutPadding != null
&& (cornerCutoutPadding.first == 0 || cornerCutoutPadding.second == 0);
if (cutout != null) {
Rect topCutout = cutout.getBoundingRectTop();
if (topCutout.isEmpty() || cornerCutout) {
- lp.width = 0;
- mSpace.setVisibility(View.GONE);
+ datePrivacySeparatorLayoutParams.width = 0;
+ mDatePrivacySeparator.setVisibility(View.GONE);
+ mClockIconsSeparatorLayoutParams.width = 0;
+ setSeparatorVisibility(false);
+ mShowClockIconsSeparator = false;
} else {
- lp.width = topCutout.width();
- mSpace.setVisibility(View.VISIBLE);
+ datePrivacySeparatorLayoutParams.width = topCutout.width();
+ mDatePrivacySeparator.setVisibility(View.VISIBLE);
+ mClockIconsSeparatorLayoutParams.width = topCutout.width();
+ mShowClockIconsSeparator = true;
+ setSeparatorVisibility(mKeyguardExpansionFraction == 0f);
}
}
- mSpace.setLayoutParams(lp);
+ mDatePrivacySeparator.setLayoutParams(datePrivacySeparatorLayoutParams);
+ mClockIconsSeparator.setLayoutParams(mClockIconsSeparatorLayoutParams);
mCutOutPaddingLeft = padding.first;
mCutOutPaddingRight = padding.second;
mWaterfallTopInset = cutout == null ? 0 : cutout.getWaterfallInsets().top;
@@ -358,6 +394,32 @@
return super.onApplyWindowInsets(insets);
}
+ /**
+ * Sets the visibility of the separator between clock and icons.
+ *
+ * This separator is "visible" when there is a center cutout, to block that space. In that
+ * case, the clock and the layout on the right (containing the icons and the battery meter) are
+ * set to weight 1 to take the available space.
+ * @param visible whether the separator between clock and icons should be visible.
+ */
+ private void setSeparatorVisibility(boolean visible) {
+ int newVisibility = visible ? View.VISIBLE : View.GONE;
+ if (mClockIconsSeparator.getVisibility() == newVisibility) return;
+
+ mClockIconsSeparator.setVisibility(visible ? View.VISIBLE : View.GONE);
+ mQSCarriers.setVisibility(visible ? View.GONE : View.VISIBLE);
+
+ LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mClockView.getLayoutParams();
+ lp.width = visible ? 0 : WRAP_CONTENT;
+ lp.weight = visible ? 1f : 0f;
+ mClockView.setLayoutParams(lp);
+
+ lp = (LinearLayout.LayoutParams) mRightLayout.getLayoutParams();
+ lp.width = visible ? 0 : WRAP_CONTENT;
+ lp.weight = visible ? 1f : 0f;
+ mRightLayout.setLayoutParams(lp);
+ }
+
private void updateHeadersPadding() {
setContentMargins(mDatePrivacyView, 0, 0);
setContentMargins(mClockIconsView, 0, 0);
@@ -408,35 +470,12 @@
}
/**
- * When QS is scrolling, mClockIconsAlpha should scroll away and fade out.
- *
- * For a given scroll level, this method does the following:
- * <ol>
- * <li>Determine the alpha that {@code mClockIconsView} should have when the panel is fully
- * expanded.</li>
- * <li>Set the scroll of {@code mClockIconsView} to the same of {@code QSPanel}.</li>
- * <li>Set the alpha of {@code mClockIconsView} to that determined by the expansion of
- * the panel, interpolated between 1 (no expansion) and {@code mClockIconsAlpha} (fully
- * expanded), matching the animator.</li>
- * </ol>
+ * Scroll the headers away.
*
* @param scrollY the scroll of the QSPanel container
*/
public void setExpandedScrollAmount(int scrollY) {
- // The scrolling of the expanded qs has changed. Since the header text isn't part of it,
- // but would overlap content, we're fading it out.
- float newAlpha = 1.0f;
- if (mClockIconsView.getHeight() > 0) {
- newAlpha = MathUtils.map(0, mClockIconsView.getHeight() / 2.0f, 1.0f, 0.0f,
- scrollY);
- newAlpha = Interpolators.ALPHA_OUT.getInterpolation(newAlpha);
- }
mClockIconsView.setScrollY(scrollY);
- if (newAlpha != mClockIconsAlpha) {
- mClockIconsAlpha = newAlpha;
- mClockIconsView.setAlpha(MathUtils.lerp(1.0f, mClockIconsAlpha,
- mKeyguardExpansionFraction));
- updateAlphaAnimator();
- }
+ mDatePrivacyView.setScrollY(scrollY);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
index 2d777a5..b3ec39f 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
@@ -16,6 +16,8 @@
package com.android.systemui.qs.tileimpl
+import android.animation.ArgbEvaluator
+import android.animation.PropertyValuesHolder
import android.animation.ValueAnimator
import android.content.Context
import android.content.res.ColorStateList
@@ -43,6 +45,7 @@
import com.android.systemui.plugins.qs.QSTile
import com.android.systemui.plugins.qs.QSTile.BooleanState
import com.android.systemui.plugins.qs.QSTileView
+import com.android.systemui.qs.tileimpl.QSIconViewImpl.QS_ANIM_LENGTH
import java.util.Objects
private const val TAG = "QSTileViewImpl"
@@ -54,6 +57,10 @@
companion object {
private const val INVALID = -1
+ private const val BACKGROUND_NAME = "background"
+ private const val LABEL_NAME = "label"
+ private const val SECONDARY_LABEL_NAME = "secondaryLabel"
+ private const val CHEVRON_NAME = "chevron"
}
override var heightOverride: Int = HeightOverrideable.NO_OVERRIDE
@@ -83,9 +90,19 @@
private lateinit var ripple: RippleDrawable
private lateinit var colorBackgroundDrawable: Drawable
private var paintColor: Int = 0
- private var paintAnimator: ValueAnimator? = null
- private var labelAnimator: ValueAnimator? = null
- private var secondaryLabelAnimator: ValueAnimator? = null
+ private val singleAnimator: ValueAnimator = ValueAnimator().apply {
+ setDuration(QS_ANIM_LENGTH)
+ addUpdateListener { animation ->
+ setAllColors(
+ // These casts will throw an exception if some property is missing. We should
+ // always have all properties.
+ animation.getAnimatedValue(BACKGROUND_NAME) as Int,
+ animation.getAnimatedValue(LABEL_NAME) as Int,
+ animation.getAnimatedValue(SECONDARY_LABEL_NAME) as Int,
+ animation.getAnimatedValue(CHEVRON_NAME) as Int
+ )
+ }
+ }
private var accessibilityClass: String? = null
private var stateDescriptionDeltas: CharSequence? = null
@@ -104,8 +121,7 @@
clipToPadding = false
isFocusable = true
background = createTileBackground()
- paintColor = getCircleColor(QSTile.State.DEFAULT_STATE)
- colorBackgroundDrawable.setTint(paintColor)
+ setColor(getBackgroundColorForState(QSTile.State.DEFAULT_STATE))
val padding = resources.getDimensionPixelSize(R.dimen.qs_tile_padding)
val startPadding = resources.getDimensionPixelSize(R.dimen.qs_tile_start_padding)
@@ -166,8 +182,8 @@
labelContainer.ignoreLastView = true
secondaryLabel.alpha = 0f
}
- label.setTextColor(getLabelColor(QSTile.State.DEFAULT_STATE))
- secondaryLabel.setTextColor(getSecondaryLabelColor(QSTile.State.DEFAULT_STATE))
+ setLabelColor(getLabelColorForState(QSTile.State.DEFAULT_STATE))
+ setSecondaryLabelColor(getSecondaryLabelColorForState(QSTile.State.DEFAULT_STATE))
addView(labelContainer)
}
@@ -176,6 +192,7 @@
.inflate(R.layout.qs_tile_side_icon, this, false) as ViewGroup
customDrawableView = sideView.requireViewById(R.id.customDrawable)
chevronView = sideView.requireViewById(R.id.chevron)
+ setChevronColor(getChevronColorForState(QSTile.State.DEFAULT_STATE))
addView(sideView)
}
@@ -322,19 +339,6 @@
icon.setIcon(state, allowAnimations)
contentDescription = state.contentDescription
- // Background color animation
- val newColor = getCircleColor(state.state)
- if (allowAnimations) {
- animateBackground(newColor)
- } else {
- clearBackgroundAnimator()
- colorBackgroundDrawable.setTintList(ColorStateList.valueOf(newColor)).also {
- paintColor = newColor
- }
- paintColor = newColor
- }
- //
-
// State handling and description
val stateDescription = StringBuilder()
val stateText = getStateText(state)
@@ -383,23 +387,80 @@
}
}
- if (allowAnimations) {
- animateLabelColor(getLabelColor(state.state))
- animateSecondaryLabelColor(getSecondaryLabelColor(state.state))
- } else {
- label.setTextColor(getLabelColor(state.state))
- secondaryLabel.setTextColor(getSecondaryLabelColor(state.state))
+ // Colors
+ if (state.state != lastState) {
+ singleAnimator.cancel()
+ if (allowAnimations) {
+ singleAnimator.setValues(
+ colorValuesHolder(
+ BACKGROUND_NAME,
+ paintColor,
+ getBackgroundColorForState(state.state)
+ ),
+ colorValuesHolder(
+ LABEL_NAME,
+ label.currentTextColor,
+ getLabelColorForState(state.state)
+ ),
+ colorValuesHolder(
+ SECONDARY_LABEL_NAME,
+ label.currentTextColor,
+ getSecondaryLabelColorForState(state.state)
+ ),
+ colorValuesHolder(
+ CHEVRON_NAME,
+ chevronView.imageTintList?.defaultColor ?: 0,
+ getChevronColorForState(state.state)
+ )
+ )
+ singleAnimator.start()
+ } else {
+ setAllColors(
+ getBackgroundColorForState(state.state),
+ getLabelColorForState(state.state),
+ getLabelColorForState(state.state),
+ getChevronColorForState(state.state)
+ )
+ }
}
// Right side icon
loadSideViewDrawableIfNecessary(state)
- chevronView.imageTintList = ColorStateList.valueOf(getSecondaryLabelColor(state.state))
label.isEnabled = !state.disabledByPolicy
lastState = state.state
}
+ private fun setAllColors(
+ backgroundColor: Int,
+ labelColor: Int,
+ secondaryLabelColor: Int,
+ chevronColor: Int
+ ) {
+ setColor(backgroundColor)
+ setLabelColor(labelColor)
+ setSecondaryLabelColor(secondaryLabelColor)
+ setChevronColor(chevronColor)
+ }
+
+ private fun setColor(color: Int) {
+ colorBackgroundDrawable.setTint(color)
+ paintColor = color
+ }
+
+ private fun setLabelColor(color: Int) {
+ label.setTextColor(color)
+ }
+
+ private fun setSecondaryLabelColor(color: Int) {
+ secondaryLabel.setTextColor(color)
+ }
+
+ private fun setChevronColor(color: Int) {
+ chevronView.imageTintList = ColorStateList.valueOf(color)
+ }
+
private fun loadSideViewDrawableIfNecessary(state: QSTile.State) {
if (state.sideViewCustomDrawable != null) {
customDrawableView.setImageDrawable(state.sideViewCustomDrawable)
@@ -446,63 +507,7 @@
return locInScreen.get(1) >= -height
}
- private fun animateBackground(newBackgroundColor: Int) {
- if (newBackgroundColor != paintColor) {
- clearBackgroundAnimator()
- paintAnimator = ValueAnimator.ofArgb(paintColor, newBackgroundColor)
- .setDuration(QSIconViewImpl.QS_ANIM_LENGTH).apply {
- addUpdateListener { animation: ValueAnimator ->
- val c = animation.animatedValue as Int
- colorBackgroundDrawable.setTintList(ColorStateList.valueOf(c)).also {
- paintColor = c
- }
- }
- start()
- }
- }
- }
-
- private fun animateLabelColor(color: Int) {
- val currentColor = label.textColors.defaultColor
- if (currentColor != color) {
- clearLabelAnimator()
- labelAnimator = ValueAnimator.ofArgb(currentColor, color)
- .setDuration(QSIconViewImpl.QS_ANIM_LENGTH).apply {
- addUpdateListener {
- label.setTextColor(it.animatedValue as Int)
- }
- start()
- }
- }
- }
-
- private fun animateSecondaryLabelColor(color: Int) {
- val currentColor = secondaryLabel.textColors.defaultColor
- if (currentColor != color) {
- clearSecondaryLabelAnimator()
- secondaryLabelAnimator = ValueAnimator.ofArgb(currentColor, color)
- .setDuration(QSIconViewImpl.QS_ANIM_LENGTH).apply {
- addUpdateListener {
- secondaryLabel.setTextColor(it.animatedValue as Int)
- }
- start()
- }
- }
- }
-
- private fun clearBackgroundAnimator() {
- paintAnimator?.cancel()?.also { paintAnimator = null }
- }
-
- private fun clearLabelAnimator() {
- labelAnimator?.cancel()?.also { labelAnimator = null }
- }
-
- private fun clearSecondaryLabelAnimator() {
- secondaryLabelAnimator?.cancel()?.also { secondaryLabelAnimator = null }
- }
-
- private fun getCircleColor(state: Int): Int {
+ private fun getBackgroundColorForState(state: Int): Int {
return when (state) {
Tile.STATE_ACTIVE -> colorActive
Tile.STATE_INACTIVE -> colorInactive
@@ -514,7 +519,7 @@
}
}
- private fun getLabelColor(state: Int): Int {
+ private fun getLabelColorForState(state: Int): Int {
return when (state) {
Tile.STATE_ACTIVE -> colorLabelActive
Tile.STATE_INACTIVE -> colorLabelInactive
@@ -526,7 +531,7 @@
}
}
- private fun getSecondaryLabelColor(state: Int): Int {
+ private fun getSecondaryLabelColorForState(state: Int): Int {
return when (state) {
Tile.STATE_ACTIVE -> colorLabelActive
Tile.STATE_INACTIVE, Tile.STATE_UNAVAILABLE -> colorLabelUnavailable
@@ -536,4 +541,12 @@
}
}
}
+
+ private fun getChevronColorForState(state: Int): Int = getSecondaryLabelColorForState(state)
+}
+
+private fun colorValuesHolder(name: String, vararg values: Int): PropertyValuesHolder {
+ return PropertyValuesHolder.ofInt(name, *values).apply {
+ setEvaluator(ArgbEvaluator.getInstance())
+ }
}
\ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/LongScreenshotActivity.java b/packages/SystemUI/src/com/android/systemui/screenshot/LongScreenshotActivity.java
index fa28754..30c9b44 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/LongScreenshotActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/LongScreenshotActivity.java
@@ -22,7 +22,6 @@
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.HardwareRenderer;
-import android.graphics.Matrix;
import android.graphics.RecordingCanvas;
import android.graphics.Rect;
import android.graphics.RenderNode;
@@ -35,7 +34,6 @@
import android.util.Log;
import android.view.ScrollCaptureResponse;
import android.view.View;
-import android.view.Window;
import android.widget.ImageView;
import androidx.constraintlayout.widget.ConstraintLayout;
@@ -68,8 +66,6 @@
public static final String EXTRA_CAPTURE_RESPONSE = "capture-response";
private static final String KEY_SAVED_IMAGE_PATH = "saved-image-path";
- private static final boolean USE_SHARED_ELEMENT = false;
-
private final UiEventLogger mUiEventLogger;
private final Executor mUiExecutor;
private final Executor mBackgroundExecutor;
@@ -89,6 +85,7 @@
private ListenableFuture<File> mCacheSaveFuture;
private ListenableFuture<ImageLoader.Result> mCacheLoadFuture;
+ private Bitmap mOutputBitmap;
private LongScreenshot mLongScreenshot;
private boolean mTransitionStarted;
@@ -114,7 +111,7 @@
public void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate(savedInstanceState = " + savedInstanceState + ")");
super.onCreate(savedInstanceState);
- getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
+
setContentView(R.layout.long_screenshot);
mPreview = requireViewById(R.id.preview);
@@ -173,7 +170,6 @@
}
}, mUiExecutor);
mCacheLoadFuture = null;
- return;
} else {
LongScreenshot longScreenshot = mLongScreenshotHolder.takeLongScreenshot();
if (longScreenshot != null) {
@@ -189,7 +185,6 @@
Log.d(TAG, "onLongScreenshotReceived(longScreenshot=" + longScreenshot + ")");
mLongScreenshot = longScreenshot;
mPreview.setImageDrawable(mLongScreenshot.getDrawable());
- mTransitionView.setImageDrawable(mLongScreenshot.getDrawable());
updateImageDimensions();
mCropView.setVisibility(View.VISIBLE);
mMagnifierView.setDrawable(mLongScreenshot.getDrawable(),
@@ -310,19 +305,15 @@
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
- if (USE_SHARED_ELEMENT) {
- updateImageDimensions();
- mTransitionView.setVisibility(View.VISIBLE);
- // TODO: listen for transition completing instead of finishing onStop
- mTransitionStarted = true;
- startActivity(intent,
- ActivityOptions.makeSceneTransitionAnimation(this, mTransitionView,
- ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME).toBundle());
- } else {
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- startActivityAsUser(intent, UserHandle.CURRENT);
- finishAndRemoveTask();
- }
+ mTransitionView.setImageBitmap(mOutputBitmap);
+ mTransitionView.setVisibility(View.VISIBLE);
+ mTransitionView.setTransitionName(
+ ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME);
+ // TODO: listen for transition completing instead of finishing onStop
+ mTransitionStarted = true;
+ startActivity(intent,
+ ActivityOptions.makeSceneTransitionAnimation(this, mTransitionView,
+ ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME).toBundle());
}
private void doShare(Uri uri) {
@@ -368,9 +359,11 @@
return;
}
- Bitmap output = renderBitmap(mPreview.getDrawable(), bounds);
+ updateImageDimensions();
+
+ mOutputBitmap = renderBitmap(drawable, bounds);
ListenableFuture<ImageExporter.Result> exportFuture = mImageExporter.export(
- mBackgroundExecutor, UUID.randomUUID(), output, ZonedDateTime.now());
+ mBackgroundExecutor, UUID.randomUUID(), mOutputBitmap, ZonedDateTime.now());
exportFuture.addListener(() -> onExportCompleted(action, exportFuture), mUiExecutor);
}
@@ -419,7 +412,6 @@
// The image width and height on screen
int imageHeight = previewHeight;
int imageWidth = previewWidth;
- float scale;
if (imageRatio > viewRatio) {
// Image is full width and height is constrained, compute extra padding to inform
// CropView
@@ -428,15 +420,13 @@
mCropView.setExtraPadding(extraPadding + mPreview.getPaddingTop(),
extraPadding + mPreview.getPaddingBottom());
imageTop += (previewHeight - imageHeight) / 2;
- scale = imageHeight / bounds.height();
mCropView.setExtraPadding(extraPadding, extraPadding);
mCropView.setImageWidth(previewWidth);
} else {
imageWidth = (int) (previewWidth * imageRatio / viewRatio);
imageLeft += (previewWidth - imageWidth) / 2;
- scale = imageWidth / (float) bounds.width();
// Image is full height
- mCropView.setExtraPadding(mPreview.getPaddingTop(), mPreview.getPaddingBottom());
+ mCropView.setExtraPadding(mPreview.getPaddingTop(), mPreview.getPaddingBottom());
mCropView.setImageWidth((int) (previewHeight * imageRatio));
}
@@ -449,10 +439,5 @@
params.width = boundaries.width();
params.height = boundaries.height();
mTransitionView.setLayoutParams(params);
-
- Matrix matrix = new Matrix();
- matrix.postScale(scale, scale, 0, 0);
- matrix.postTranslate(-boundaries.left, -boundaries.top);
- mTransitionView.setImageMatrix(matrix);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java
index 7f31fdd..5437ce6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java
@@ -18,7 +18,6 @@
import static com.android.systemui.statusbar.RemoteInputController.processForRemoteInput;
import static com.android.systemui.statusbar.notification.NotificationEntryManager.UNDEFINED_DISMISS_REASON;
-import static com.android.systemui.statusbar.phone.StatusBar.DEBUG;
import android.annotation.NonNull;
import android.annotation.SuppressLint;
@@ -35,6 +34,7 @@
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.statusbar.dagger.StatusBarModule;
import com.android.systemui.statusbar.phone.NotificationListenerWithPlugins;
+import com.android.systemui.statusbar.phone.StatusBar;
import java.util.ArrayList;
import java.util.List;
@@ -46,6 +46,7 @@
@SuppressLint("OverrideAbstract")
public class NotificationListener extends NotificationListenerWithPlugins {
private static final String TAG = "NotificationListener";
+ private static final boolean DEBUG = StatusBar.DEBUG;
private final Context mContext;
private final NotificationManager mNotificationManager;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java
index 70b3a7b..ca81a7b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java
@@ -169,7 +169,7 @@
Pair<Intent, ActivityOptions> options = response.getLaunchOptions(view);
mLogger.logStartingIntentWithDefaultHandler(entry, pendingIntent);
boolean started = RemoteViews.startPendingIntent(view, pendingIntent, options);
- if (started) releaseNotificationIfKeptForRemoteInputHistory(entry.getKey());
+ if (started) releaseNotificationIfKeptForRemoteInputHistory(entry);
return started;
});
}
@@ -608,7 +608,11 @@
* (after unlock, if applicable), and will then wait a short time to allow the app to update the
* notification in response to the action.
*/
- private void releaseNotificationIfKeptForRemoteInputHistory(String key) {
+ private void releaseNotificationIfKeptForRemoteInputHistory(NotificationEntry entry) {
+ if (entry == null) {
+ return;
+ }
+ final String key = entry.getKey();
if (isNotificationKeptForRemoteInputHistory(key)) {
mMainHandler.postDelayed(() -> {
if (isNotificationKeptForRemoteInputHistory(key)) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarDependenciesModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarDependenciesModule.java
index eb7854e..4919593 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarDependenciesModule.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StatusBarDependenciesModule.java
@@ -61,6 +61,7 @@
import com.android.systemui.statusbar.phone.StatusBarIconControllerImpl;
import com.android.systemui.statusbar.phone.StatusBarRemoteInputCallback;
import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController;
+import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallLogger;
import com.android.systemui.statusbar.policy.RemoteInputUriController;
import com.android.systemui.tracing.ProtoTracer;
import com.android.systemui.util.DeviceConfigProxy;
@@ -243,11 +244,12 @@
SystemClock systemClock,
ActivityStarter activityStarter,
@Main Executor mainExecutor,
- IActivityManager iActivityManager) {
+ IActivityManager iActivityManager,
+ OngoingCallLogger logger) {
OngoingCallController ongoingCallController =
new OngoingCallController(
notifCollection, featureFlags, systemClock, activityStarter, mainExecutor,
- iActivityManager);
+ iActivityManager, logger);
ongoingCallController.init();
return ongoingCallController;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt
index 2481ed4..5f10e55 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt
@@ -29,13 +29,11 @@
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.plugins.statusbar.StatusBarStateController
+import com.android.systemui.statusbar.StatusBarState.SHADE
+import com.android.systemui.statusbar.StatusBarState.SHADE_LOCKED
import com.android.systemui.statusbar.phone.StatusBarLocationPublisher
import com.android.systemui.statusbar.phone.StatusBarMarginUpdatedListener
import com.android.systemui.util.concurrency.DelayableExecutor
-import com.android.systemui.util.leak.RotationUtils.ROTATION_LANDSCAPE
-import com.android.systemui.util.leak.RotationUtils.ROTATION_NONE
-import com.android.systemui.util.leak.RotationUtils.ROTATION_SEASCAPE
-import com.android.systemui.util.leak.RotationUtils.ROTATION_UPSIDE_DOWN
import java.lang.IllegalStateException
import java.util.concurrent.Executor
@@ -50,7 +48,7 @@
* will have its gravity set towards the corner (i.e., top-right corner gets top|right gravity), and
* the contained ImageView will be set to center_vertical and away from the corner horizontally. The
* Views will match the status bar top padding and status bar height so that the dot can appear to
- * reside directly after the status bar system contents (basically to the right of the battery).
+ * reside directly after the status bar system contents (basically after the battery).
*
* NOTE: any operation that modifies views directly must run on the provided executor, because
* these views are owned by ScreenDecorations and it runs in its own thread
@@ -85,21 +83,27 @@
// Privacy dots are created in ScreenDecoration's UiThread, which is not the main thread
private var uiExecutor: DelayableExecutor? = null
- private var e: DelayableExecutor? = null
+
+ private val marginListener: StatusBarMarginUpdatedListener =
+ object : StatusBarMarginUpdatedListener {
+ override fun onStatusBarMarginUpdated(marginLeft: Int, marginRight: Int) {
+ setStatusBarMargins(marginLeft, marginRight)
+ }
+ }
private val views: Sequence<View>
get() = if (!this::tl.isInitialized) sequenceOf() else sequenceOf(tl, tr, br, bl)
init {
- locationPublisher.addCallback(object : StatusBarMarginUpdatedListener {
- override fun onStatusBarMarginUpdated(marginLeft: Int, marginRight: Int) {
- setStatusBarMargins(marginLeft, marginRight)
- }
- })
+ locationPublisher.addCallback(marginListener)
stateController.addCallback(object : StatusBarStateController.StateListener {
override fun onExpandedChanged(isExpanded: Boolean) {
- setStatusBarExpanded(isExpanded)
+ updateStatusBarState()
+ }
+
+ override fun onStateChanged(newState: Int) {
+ updateStatusBarState()
}
})
}
@@ -108,6 +112,13 @@
uiExecutor = e
}
+ fun setQsExpanded(expanded: Boolean) {
+ dlog("setQsExpanded $expanded")
+ synchronized(lock) {
+ nextViewState = nextViewState.copy(qsExpanded = expanded)
+ }
+ }
+
@UiThread
fun setNewRotation(rot: Int) {
dlog("updateRotation: $rot")
@@ -125,8 +136,8 @@
val index = newCorner.cornerIndex()
val h = when (rot) {
- ROTATION_NONE, ROTATION_UPSIDE_DOWN -> sbHeightPortrait
- ROTATION_LANDSCAPE, ROTATION_SEASCAPE -> sbHeightLandscape
+ 0, 2 -> sbHeightPortrait
+ 1, 3 -> sbHeightLandscape
else -> 0
}
synchronized(lock) {
@@ -326,15 +337,22 @@
}
}
- /**
- * We won't show the dot when quick settings is showing
- */
- private fun setStatusBarExpanded(expanded: Boolean) {
+ private fun updateStatusBarState() {
synchronized(lock) {
- nextViewState = nextViewState.copy(hideDotForQuickSettings = expanded)
+ nextViewState = nextViewState.copy(shadeExpanded = isShadeInQs())
}
}
+ /**
+ * If we are unlocked with an expanded shade, QS is showing. On keyguard, the shade is always
+ * expanded so we use other signals from the panel view controller to know if QS is expanded
+ */
+ @GuardedBy("lock")
+ private fun isShadeInQs(): Boolean {
+ return (stateController.isExpanded && stateController.state == SHADE) ||
+ (stateController.state == SHADE_LOCKED)
+ }
+
private fun scheduleUpdate() {
dlog("scheduleUpdate: ")
@@ -431,13 +449,20 @@
}
}
+private fun vlog(s: String) {
+ if (DEBUG_VERBOSE) {
+ Log.d(TAG, s)
+ }
+}
+
const val TOP_LEFT = 0
const val TOP_RIGHT = 1
const val BOTTOM_RIGHT = 2
const val BOTTOM_LEFT = 3
private const val DURATION = 160L
private const val TAG = "PrivacyDotViewController"
-private const val DEBUG = false
+private const val DEBUG = true
+private const val DEBUG_VERBOSE = false
private fun Int.toGravity(): Int {
return when (this) {
@@ -460,10 +485,10 @@
}
private data class ViewState(
- // don't @ me with names
val systemPrivacyEventIsActive: Boolean = false,
- val hideDotForQuickSettings: Boolean = false,
- val statusBarExpanded: Boolean = false,
+ val shadeExpanded: Boolean = false,
+ val qsExpanded: Boolean = false,
+
val rotation: Int = 0,
val height: Int = 0,
val marginLeft: Int = 0,
@@ -472,7 +497,7 @@
val designatedCorner: View? = null
) {
fun shouldShowDot(): Boolean {
- return systemPrivacyEventIsActive && !hideDotForQuickSettings
+ return systemPrivacyEventIsActive && !shadeExpanded && !qsExpanded
}
fun needsLayout(other: ViewState): Boolean {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt
new file mode 100644
index 0000000..ce60c85
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt
@@ -0,0 +1,277 @@
+/*
+ * Copyright (C) 2021 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.lockscreen
+
+import android.app.PendingIntent
+import android.app.smartspace.SmartspaceConfig
+import android.app.smartspace.SmartspaceManager
+import android.app.smartspace.SmartspaceSession
+import android.app.smartspace.SmartspaceTarget
+import android.content.ContentResolver
+import android.content.Context
+import android.content.Intent
+import android.content.pm.UserInfo
+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 android.view.ViewGroup
+import com.android.settingslib.Utils
+import com.android.systemui.R
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Main
+import com.android.systemui.plugins.ActivityStarter
+import com.android.systemui.plugins.BcSmartspaceDataPlugin
+import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceTargetListener
+import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceView
+import com.android.systemui.plugins.FalsingManager
+import com.android.systemui.plugins.statusbar.StatusBarStateController
+import com.android.systemui.settings.UserTracker
+import com.android.systemui.statusbar.FeatureFlags
+import com.android.systemui.statusbar.policy.ConfigurationController
+import com.android.systemui.util.concurrency.Execution
+import com.android.systemui.util.settings.SecureSettings
+import java.lang.RuntimeException
+import java.util.Optional
+import java.util.concurrent.Executor
+import javax.inject.Inject
+
+/**
+ * Controller for managing the smartspace view on the lockscreen
+ */
+@SysUISingleton
+class LockscreenSmartspaceController @Inject constructor(
+ private val context: Context,
+ private val featureFlags: FeatureFlags,
+ private val smartspaceManager: SmartspaceManager,
+ private val activityStarter: ActivityStarter,
+ private val falsingManager: FalsingManager,
+ private val secureSettings: SecureSettings,
+ private val userTracker: UserTracker,
+ private val contentResolver: ContentResolver,
+ private val configurationController: ConfigurationController,
+ private val statusBarStateController: StatusBarStateController,
+ private val execution: Execution,
+ @Main private val uiExecutor: Executor,
+ @Main private val handler: Handler,
+ optionalPlugin: Optional<BcSmartspaceDataPlugin>
+) {
+ private var session: SmartspaceSession? = null
+ private val plugin: BcSmartspaceDataPlugin? = optionalPlugin.orElse(null)
+ private lateinit var smartspaceView: SmartspaceView
+
+ lateinit var view: View
+ private set
+
+ private var showSensitiveContentForCurrentUser = false
+ private var showSensitiveContentForManagedUser = false
+ private var managedUserHandle: UserHandle? = null
+
+ fun isEnabled(): Boolean {
+ execution.assertIsMainThread()
+
+ return featureFlags.isSmartspaceEnabled && plugin != null
+ }
+
+ /**
+ * Constructs the smartspace view and connects it to the smartspace service. Subsequent calls
+ * are idempotent until [disconnect] is called.
+ */
+ fun buildAndConnectView(parent: ViewGroup): View {
+ execution.assertIsMainThread()
+
+ if (!isEnabled()) {
+ throw RuntimeException("Cannot build view when not enabled")
+ }
+
+ buildView(parent)
+ connectSession()
+
+ return view
+ }
+
+ private fun buildView(parent: ViewGroup) {
+ if (plugin == null || this::view.isInitialized) {
+ return
+ }
+
+ val ssView = plugin.getView(parent)
+ ssView.registerDataProvider(plugin)
+ ssView.setIntentStarter(object : BcSmartspaceDataPlugin.IntentStarter {
+ override fun startIntent(v: View?, i: Intent?) {
+ activityStarter.startActivity(i, true /* dismissShade */)
+ }
+
+ override fun startPendingIntent(pi: PendingIntent?) {
+ activityStarter.startPendingIntentDismissingKeyguard(pi)
+ }
+ })
+ ssView.setFalsingManager(falsingManager)
+
+ this.smartspaceView = ssView
+ this.view = ssView as View
+
+ updateTextColorFromWallpaper()
+ statusBarStateListener.onDozeAmountChanged(0f, statusBarStateController.dozeAmount)
+ }
+
+ private fun connectSession() {
+ if (plugin == null || session != null) {
+ return
+ }
+ val session = smartspaceManager.createSmartspaceSession(
+ SmartspaceConfig.Builder(context, "lockscreen").build())
+ session.addOnTargetsAvailableListener(uiExecutor, sessionListener)
+
+ userTracker.addCallback(userTrackerCallback, uiExecutor)
+ contentResolver.registerContentObserver(
+ secureSettings.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS),
+ true,
+ settingsObserver,
+ UserHandle.USER_ALL
+ )
+ configurationController.addCallback(configChangeListener)
+ statusBarStateController.addCallback(statusBarStateListener)
+
+ this.session = session
+
+ reloadSmartspace()
+ }
+
+ /**
+ * Disconnects the smartspace view from the smartspace service and cleans up any resources.
+ * Calling [buildAndConnectView] again will cause the same view to be reconnected to the
+ * service.
+ */
+ fun disconnect() {
+ execution.assertIsMainThread()
+
+ if (session == null) {
+ return
+ }
+
+ session?.let {
+ it.removeOnTargetsAvailableListener(sessionListener)
+ it.close()
+ }
+ userTracker.removeCallback(userTrackerCallback)
+ contentResolver.unregisterContentObserver(settingsObserver)
+ configurationController.removeCallback(configChangeListener)
+ statusBarStateController.removeCallback(statusBarStateListener)
+ session = null
+
+ plugin?.onTargetsAvailable(emptyList())
+ }
+
+ fun addListener(listener: SmartspaceTargetListener) {
+ execution.assertIsMainThread()
+ plugin?.registerListener(listener)
+ }
+
+ fun removeListener(listener: SmartspaceTargetListener) {
+ execution.assertIsMainThread()
+ plugin?.unregisterListener(listener)
+ }
+
+ private val sessionListener = SmartspaceSession.OnTargetsAvailableListener { targets ->
+ execution.assertIsMainThread()
+ val filteredTargets = targets.filter(::filterSmartspaceTarget)
+ plugin?.onTargetsAvailable(filteredTargets)
+ }
+
+ private val userTrackerCallback = object : UserTracker.Callback {
+ override fun onUserChanged(newUser: Int, userContext: Context) {
+ execution.assertIsMainThread()
+ reloadSmartspace()
+ }
+
+ override fun onProfilesChanged(profiles: List<UserInfo>) {
+ }
+ }
+
+ private val settingsObserver = object : ContentObserver(handler) {
+ override fun onChange(selfChange: Boolean, uri: Uri?) {
+ execution.assertIsMainThread()
+ reloadSmartspace()
+ }
+ }
+
+ private val configChangeListener = object : ConfigurationController.ConfigurationListener {
+ override fun onThemeChanged() {
+ execution.assertIsMainThread()
+ updateTextColorFromWallpaper()
+ }
+ }
+
+ private val statusBarStateListener = object : StatusBarStateController.StateListener {
+ override fun onDozeAmountChanged(linear: Float, eased: Float) {
+ execution.assertIsMainThread()
+ smartspaceView.setDozeAmount(eased)
+ }
+ }
+
+ private fun filterSmartspaceTarget(t: SmartspaceTarget): Boolean {
+ return when (t.userHandle) {
+ userTracker.userHandle -> {
+ !t.isSensitive || showSensitiveContentForCurrentUser
+ }
+ managedUserHandle -> {
+ // Really, this should be "if this managed profile is associated with the current
+ // active user", but we don't have a good way to check that, so instead we cheat:
+ // Only the primary user can have an associated managed profile, so only show
+ // content for the managed profile if the primary user is active
+ userTracker.userHandle.identifier == UserHandle.USER_SYSTEM &&
+ (!t.isSensitive || showSensitiveContentForManagedUser)
+ }
+ else -> {
+ false
+ }
+ }
+ }
+
+ private fun updateTextColorFromWallpaper() {
+ val wallpaperTextColor = Utils.getColorAttrDefaultColor(context, R.attr.wallpaperTextColor)
+ smartspaceView.setPrimaryTextColor(wallpaperTextColor)
+ }
+
+ private fun reloadSmartspace() {
+ val setting = Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS
+
+ showSensitiveContentForCurrentUser =
+ secureSettings.getIntForUser(setting, 0, userTracker.userId) == 1
+
+ managedUserHandle = getWorkProfileUser()
+ val managedId = managedUserHandle?.identifier
+ if (managedId != null) {
+ showSensitiveContentForManagedUser =
+ secureSettings.getIntForUser(setting, 0, managedId) == 1
+ }
+
+ session?.requestSmartspaceUpdate()
+ }
+
+ private fun getWorkProfileUser(): UserHandle? {
+ for (userInfo in userTracker.userProfiles) {
+ if (userInfo.isManagedProfile) {
+ return userInfo.userHandle
+ }
+ }
+ return null
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/legacy/NotificationGroupManagerLegacy.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/legacy/NotificationGroupManagerLegacy.java
index d6356de..f40f24a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/legacy/NotificationGroupManagerLegacy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/legacy/NotificationGroupManagerLegacy.java
@@ -16,7 +16,9 @@
package com.android.systemui.statusbar.notification.collection.legacy;
+import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.app.Notification;
import android.service.notification.StatusBarNotification;
import android.util.ArraySet;
import android.util.Log;
@@ -31,6 +33,7 @@
import com.android.systemui.statusbar.notification.collection.render.GroupExpansionManager;
import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager;
import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier;
+import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
import com.android.wm.shell.bubbles.Bubbles;
@@ -39,10 +42,12 @@
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
+import java.util.TreeSet;
import javax.inject.Inject;
@@ -58,13 +63,21 @@
public class NotificationGroupManagerLegacy implements OnHeadsUpChangedListener, StateListener,
GroupMembershipManager, GroupExpansionManager, Dumpable {
- private static final String TAG = "NotificationGroupManager";
+ private static final String TAG = "NotifGroupManager";
+ private static final boolean DEBUG = StatusBar.DEBUG;
+ private static final boolean SPEW = StatusBar.SPEW;
+ /**
+ * The maximum amount of time (in ms) between the posting of notifications that can be
+ * considered part of the same update batch.
+ */
+ private static final long POST_BATCH_MAX_AGE = 5000;
private final HashMap<String, NotificationGroup> mGroupMap = new HashMap<>();
private final ArraySet<OnGroupExpansionChangeListener> mExpansionChangeListeners =
new ArraySet<>();
private final ArraySet<OnGroupChangeListener> mGroupChangeListeners = new ArraySet<>();
private final Lazy<PeopleNotificationIdentifier> mPeopleNotificationIdentifier;
private final Optional<Bubbles> mBubblesOptional;
+ private final EventBuffer mEventBuffer = new EventBuffer();
private int mBarState = -1;
private HashMap<String, StatusBarNotification> mIsolatedEntries = new HashMap<>();
private HeadsUpManager mHeadsUpManager;
@@ -134,8 +147,14 @@
* When we want to remove an entry from being tracked for grouping
*/
public void onEntryRemoved(NotificationEntry removed) {
+ if (SPEW) {
+ Log.d(TAG, "onEntryRemoved: entry=" + removed);
+ }
onEntryRemovedInternal(removed, removed.getSbn());
- mIsolatedEntries.remove(removed.getKey());
+ StatusBarNotification oldSbn = mIsolatedEntries.remove(removed.getKey());
+ if (oldSbn != null) {
+ updateSuppression(mGroupMap.get(oldSbn.getGroupKey()));
+ }
}
/**
@@ -162,6 +181,9 @@
// the close future. See b/23676310 for reference.
return;
}
+ if (SPEW) {
+ Log.d(TAG, "onEntryRemovedInternal: entry=" + removed + " group=" + group.groupKey);
+ }
if (isGroupChild(removed.getKey(), isGroup, isGroupSummary)) {
group.children.remove(removed.getKey());
} else {
@@ -182,6 +204,9 @@
* Notify the group manager that a new entry was added
*/
public void onEntryAdded(final NotificationEntry added) {
+ if (SPEW) {
+ Log.d(TAG, "onEntryAdded: entry=" + added);
+ }
updateIsolation(added);
onEntryAddedInternal(added);
}
@@ -195,13 +220,16 @@
String groupKey = getGroupKey(sbn);
NotificationGroup group = mGroupMap.get(groupKey);
if (group == null) {
- group = new NotificationGroup();
+ group = new NotificationGroup(groupKey);
mGroupMap.put(groupKey, group);
for (OnGroupChangeListener listener : mGroupChangeListeners) {
listener.onGroupCreated(group, groupKey);
}
}
+ if (SPEW) {
+ Log.d(TAG, "onEntryAddedInternal: entry=" + added + " group=" + group.groupKey);
+ }
if (isGroupChild) {
NotificationEntry existing = group.children.get(added.getKey());
if (existing != null && existing != added) {
@@ -213,9 +241,11 @@
+ " added removed" + added.isRowRemoved(), new Throwable());
}
group.children.put(added.getKey(), added);
+ addToPostBatchHistory(group, added);
updateSuppression(group);
} else {
group.summary = added;
+ addToPostBatchHistory(group, added);
group.expanded = added.areChildrenExpanded();
updateSuppression(group);
if (!group.children.isEmpty()) {
@@ -231,6 +261,27 @@
}
}
+ private void addToPostBatchHistory(NotificationGroup group, @Nullable NotificationEntry entry) {
+ if (entry == null) {
+ return;
+ }
+ boolean didAdd = group.postBatchHistory.add(new PostRecord(entry));
+ if (didAdd) {
+ trimPostBatchHistory(group.postBatchHistory);
+ }
+ }
+
+ /** remove all history that's too old to be in the batch. */
+ private void trimPostBatchHistory(@NonNull TreeSet<PostRecord> postBatchHistory) {
+ if (postBatchHistory.size() <= 1) {
+ return;
+ }
+ long batchStartTime = postBatchHistory.last().postTime - POST_BATCH_MAX_AGE;
+ while (!postBatchHistory.isEmpty() && postBatchHistory.first().postTime < batchStartTime) {
+ postBatchHistory.pollFirst();
+ }
+ }
+
private void onEntryBecomingChild(NotificationEntry entry) {
updateIsolation(entry);
}
@@ -239,6 +290,9 @@
if (group == null) {
return;
}
+ NotificationEntry prevAlertOverride = group.alertOverride;
+ group.alertOverride = getPriorityConversationAlertOverride(group);
+
int childCount = 0;
boolean hasBubbles = false;
for (NotificationEntry entry : group.children.values()) {
@@ -255,18 +309,150 @@
group.suppressed = group.summary != null && !group.expanded
&& (childCount == 1
|| (childCount == 0
- && group.summary.getSbn().getNotification().isGroupSummary()
- && (hasIsolatedChildren(group) || hasBubbles)));
- if (prevSuppressed != group.suppressed) {
- for (OnGroupChangeListener listener : mGroupChangeListeners) {
- if (!mIsUpdatingUnchangedGroup) {
- listener.onGroupSuppressionChanged(group, group.suppressed);
- listener.onGroupsChanged();
+ && group.summary.getSbn().getNotification().isGroupSummary()
+ && (hasIsolatedChildren(group) || hasBubbles)));
+
+ boolean alertOverrideChanged = prevAlertOverride != group.alertOverride;
+ boolean suppressionChanged = prevSuppressed != group.suppressed;
+ if (alertOverrideChanged || suppressionChanged) {
+ if (DEBUG && alertOverrideChanged) {
+ Log.d(TAG, "updateSuppression: alertOverride was=" + prevAlertOverride
+ + " now=" + group.alertOverride + " group:\n" + group);
+ }
+ if (DEBUG && suppressionChanged) {
+ Log.d(TAG,
+ "updateSuppression: suppressed changed to " + group.suppressed
+ + " group:\n" + group);
+ }
+ if (!mIsUpdatingUnchangedGroup) {
+ if (alertOverrideChanged) {
+ mEventBuffer.notifyAlertOverrideChanged(group, prevAlertOverride);
+ }
+ if (suppressionChanged) {
+ for (OnGroupChangeListener listener : mGroupChangeListeners) {
+ listener.onGroupSuppressionChanged(group, group.suppressed);
+ }
+ }
+ mEventBuffer.notifyGroupsChanged();
+ } else {
+ if (DEBUG) {
+ Log.d(TAG, group + " did not notify listeners of above change(s)");
}
}
}
}
+ /**
+ * Finds the isolated logical child of this group which is should be alerted instead.
+ *
+ * Notifications from priority conversations are isolated from their groups to make them more
+ * prominent, however apps may post these with a GroupAlertBehavior that has the group receiving
+ * the alert. This would lead to the group alerting even though the conversation that was
+ * updated was not actually a part of that group. This method finds the best priority
+ * conversation in this situation, if there is one, so they can be set as the alertOverride of
+ * the group.
+ *
+ * @param group the group to check
+ * @return the entry which should receive the alert instead of the group, if any.
+ */
+ @Nullable
+ private NotificationEntry getPriorityConversationAlertOverride(NotificationGroup group) {
+ // GOAL: if there is a priority child which wouldn't alert based on its groupAlertBehavior,
+ // but which should be alerting (because priority conversations are isolated), find it.
+ if (group == null || group.summary == null) {
+ if (SPEW) {
+ Log.d(TAG, "getPriorityConversationAlertOverride: null group or summary");
+ }
+ return null;
+ }
+ if (isIsolated(group.summary.getKey())) {
+ if (SPEW) {
+ Log.d(TAG, "getPriorityConversationAlertOverride: isolated group");
+ }
+ return null;
+ }
+
+ // Precondiions:
+ // * Only necessary when all notifications in the group use GROUP_ALERT_SUMMARY
+ // * Only necessary when at least one notification in the group is on a priority channel
+ if (group.summary.getSbn().getNotification().getGroupAlertBehavior()
+ != Notification.GROUP_ALERT_SUMMARY) {
+ if (SPEW) {
+ Log.d(TAG, "getPriorityConversationAlertOverride: summary != GROUP_ALERT_SUMMARY");
+ }
+ return null;
+ }
+
+ // Get the important children first, copy the keys for the final importance check,
+ // then add the non-isolated children to the map for unified lookup.
+ HashMap<String, NotificationEntry> children = getImportantConversations(group);
+ if (children == null || children.isEmpty()) {
+ if (SPEW) {
+ Log.d(TAG, "getPriorityConversationAlertOverride: no important conversations");
+ }
+ return null;
+ }
+ HashSet<String> importantChildKeys = new HashSet<>(children.keySet());
+ children.putAll(group.children);
+
+ // Ensure all children have GROUP_ALERT_SUMMARY
+ for (NotificationEntry child : children.values()) {
+ if (child.getSbn().getNotification().getGroupAlertBehavior()
+ != Notification.GROUP_ALERT_SUMMARY) {
+ if (SPEW) {
+ Log.d(TAG, "getPriorityConversationAlertOverride: "
+ + "child != GROUP_ALERT_SUMMARY");
+ }
+ return null;
+ }
+ }
+
+ // Create a merged post history from all the children
+ TreeSet<PostRecord> combinedHistory = new TreeSet<>(group.postBatchHistory);
+ for (String importantChildKey : importantChildKeys) {
+ NotificationGroup importantChildGroup = mGroupMap.get(importantChildKey);
+ combinedHistory.addAll(importantChildGroup.postBatchHistory);
+ }
+ trimPostBatchHistory(combinedHistory);
+
+ // This is a streamlined implementation of the following idea:
+ // * From the subset of notifications in the latest 'batch' of updates. A batch is:
+ // * Notifs posted less than POST_BATCH_MAX_AGE before the most recently posted.
+ // * Only including notifs newer than the second-to-last post of any notification.
+ // * Find the newest child in the batch -- the with the largest 'when' value.
+ // * If the newest child is a priority conversation, set that as the override.
+ HashSet<String> batchKeys = new HashSet<>();
+ long newestChildWhen = -1;
+ NotificationEntry newestChild = null;
+ // Iterate backwards through the post history, tracking the child with the smallest sort key
+ for (PostRecord record : combinedHistory.descendingSet()) {
+ if (batchKeys.contains(record.key)) {
+ // Once you see a notification again, the batch has ended
+ break;
+ }
+ batchKeys.add(record.key);
+ NotificationEntry child = children.get(record.key);
+ if (child != null) {
+ long childWhen = child.getSbn().getNotification().when;
+ if (newestChild == null || childWhen > newestChildWhen) {
+ newestChildWhen = childWhen;
+ newestChild = child;
+ }
+ }
+ }
+ if (newestChild != null && importantChildKeys.contains(newestChild.getKey())) {
+ if (SPEW) {
+ Log.d(TAG, "getPriorityConversationAlertOverride: result=" + newestChild);
+ }
+ return newestChild;
+ }
+ if (SPEW) {
+ Log.d(TAG, "getPriorityConversationAlertOverride: result=null, newestChild="
+ + newestChild);
+ }
+ return null;
+ }
+
private boolean hasIsolatedChildren(NotificationGroup group) {
return getNumberOfIsolatedChildren(group.summary.getSbn().getGroupKey()) != 0;
}
@@ -281,12 +467,33 @@
return count;
}
+ @Nullable
+ private HashMap<String, NotificationEntry> getImportantConversations(NotificationGroup group) {
+ String groupKey = group.summary.getSbn().getGroupKey();
+ HashMap<String, NotificationEntry> result = null;
+ for (StatusBarNotification sbn : mIsolatedEntries.values()) {
+ if (sbn.getGroupKey().equals(groupKey)) {
+ NotificationEntry entry = mGroupMap.get(sbn.getKey()).summary;
+ if (isImportantConversation(entry)) {
+ if (result == null) {
+ result = new HashMap<>();
+ }
+ result.put(sbn.getKey(), entry);
+ }
+ }
+ }
+ return result;
+ }
+
/**
* Update an entry's group information
* @param entry notification entry to update
* @param oldNotification previous notification info before this update
*/
public void onEntryUpdated(NotificationEntry entry, StatusBarNotification oldNotification) {
+ if (SPEW) {
+ Log.d(TAG, "onEntryUpdated: entry=" + entry);
+ }
onEntryUpdated(entry, oldNotification.getGroupKey(), oldNotification.isGroup(),
oldNotification.getNotification().isGroupSummary());
}
@@ -325,7 +532,17 @@
* Whether the given notification is the summary of a group that is being suppressed
*/
public boolean isSummaryOfSuppressedGroup(StatusBarNotification sbn) {
- return isGroupSuppressed(getGroupKey(sbn)) && sbn.getNotification().isGroupSummary();
+ return sbn.getNotification().isGroupSummary() && isGroupSuppressed(getGroupKey(sbn));
+ }
+
+ /**
+ * If the given notification is a summary, get the group for it.
+ */
+ public NotificationGroup getGroupForSummary(StatusBarNotification sbn) {
+ if (sbn.getNotification().isGroupSummary()) {
+ return mGroupMap.get(getGroupKey(sbn));
+ }
+ return null;
}
private boolean isOnlyChild(StatusBarNotification sbn) {
@@ -545,9 +762,7 @@
if (!sbn.isGroup() || sbn.getNotification().isGroupSummary()) {
return false;
}
- int peopleNotificationType =
- mPeopleNotificationIdentifier.get().getPeopleNotificationType(entry);
- if (peopleNotificationType == PeopleNotificationIdentifier.TYPE_IMPORTANT_PERSON) {
+ if (isImportantConversation(entry)) {
return true;
}
if (mHeadsUpManager != null && !mHeadsUpManager.isAlerting(entry.getKey())) {
@@ -560,18 +775,25 @@
|| isGroupNotFullyVisible(notificationGroup));
}
+ private boolean isImportantConversation(NotificationEntry entry) {
+ int peopleNotificationType =
+ mPeopleNotificationIdentifier.get().getPeopleNotificationType(entry);
+ return peopleNotificationType == PeopleNotificationIdentifier.TYPE_IMPORTANT_PERSON;
+ }
+
/**
* Isolate a notification from its group so that it visually shows as its own group.
*
* @param entry the notification to isolate
*/
private void isolateNotification(NotificationEntry entry) {
- StatusBarNotification sbn = entry.getSbn();
-
+ if (SPEW) {
+ Log.d(TAG, "isolateNotification: entry=" + entry);
+ }
// We will be isolated now, so lets update the groups
onEntryRemovedInternal(entry, entry.getSbn());
- mIsolatedEntries.put(sbn.getKey(), sbn);
+ mIsolatedEntries.put(entry.getKey(), entry.getSbn());
onEntryAddedInternal(entry);
// We also need to update the suppression of the old group, because this call comes
@@ -588,6 +810,14 @@
* Update the isolation of an entry, splitting it from the group.
*/
public void updateIsolation(NotificationEntry entry) {
+ // We need to buffer a few events because we do isolation changes in 3 steps:
+ // removeInternal, update mIsolatedEntries, addInternal. This means that often the
+ // alertOverride will update on the removal, however processing the event in that case can
+ // cause problems because the mIsolatedEntries map is not in its final state, so the event
+ // listener may be unable to correctly determine the true state of the group. By delaying
+ // the alertOverride change until after the add phase, we can ensure that listeners only
+ // have to handle a consistent state.
+ mEventBuffer.startBuffering();
boolean isIsolated = isIsolated(entry.getSbn().getKey());
if (shouldIsolate(entry)) {
if (!isIsolated) {
@@ -596,6 +826,7 @@
} else if (isIsolated) {
stopIsolatingNotification(entry);
}
+ mEventBuffer.flushAndStopBuffering();
}
/**
@@ -604,15 +835,15 @@
* @param entry the notification to un-isolate
*/
private void stopIsolatingNotification(NotificationEntry entry) {
- StatusBarNotification sbn = entry.getSbn();
- if (isIsolated(sbn.getKey())) {
- // not isolated anymore, we need to update the groups
- onEntryRemovedInternal(entry, entry.getSbn());
- mIsolatedEntries.remove(sbn.getKey());
- onEntryAddedInternal(entry);
- for (OnGroupChangeListener listener : mGroupChangeListeners) {
- listener.onGroupsChanged();
- }
+ if (SPEW) {
+ Log.d(TAG, "stopIsolatingNotification: entry=" + entry);
+ }
+ // not isolated anymore, we need to update the groups
+ onEntryRemovedInternal(entry, entry.getSbn());
+ mIsolatedEntries.remove(entry.getKey());
+ onEntryAddedInternal(entry);
+ for (OnGroupChangeListener listener : mGroupChangeListeners) {
+ listener.onGroupsChanged();
}
}
@@ -648,33 +879,154 @@
}
/**
+ * A record of a notification being posted, containing the time of the post and the key of the
+ * notification entry. These are stored in a TreeSet by the NotificationGroup and used to
+ * calculate a batch of notifications.
+ */
+ public static class PostRecord implements Comparable<PostRecord> {
+ public final long postTime;
+ public final String key;
+
+ /** constructs a record containing the post time and key from the notification entry */
+ public PostRecord(@NonNull NotificationEntry entry) {
+ this.postTime = entry.getSbn().getPostTime();
+ this.key = entry.getKey();
+ }
+
+ @Override
+ public int compareTo(PostRecord o) {
+ int postTimeComparison = Long.compare(this.postTime, o.postTime);
+ return postTimeComparison == 0
+ ? String.CASE_INSENSITIVE_ORDER.compare(this.key, o.key)
+ : postTimeComparison;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ PostRecord that = (PostRecord) o;
+ return postTime == that.postTime && key.equals(that.key);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(postTime, key);
+ }
+ }
+
+ /**
* Represents a notification group in the notification shade.
*/
public static class NotificationGroup {
+ public final String groupKey;
public final HashMap<String, NotificationEntry> children = new HashMap<>();
+ public final TreeSet<PostRecord> postBatchHistory = new TreeSet<>();
public NotificationEntry summary;
public boolean expanded;
/**
* Is this notification group suppressed, i.e its summary is hidden
*/
public boolean suppressed;
+ /**
+ * The child (which is isolated from this group) to which the alert should be transferred,
+ * due to priority conversations.
+ */
+ public NotificationEntry alertOverride;
+
+ NotificationGroup(String groupKey) {
+ this.groupKey = groupKey;
+ }
@Override
public String toString() {
- String result = " summary:\n "
- + (summary != null ? summary.getSbn() : "null")
- + (summary != null && summary.getDebugThrowable() != null
- ? Log.getStackTraceString(summary.getDebugThrowable())
- : "");
- result += "\n children size: " + children.size();
+ StringBuilder sb = new StringBuilder();
+ sb.append(" groupKey: ").append(groupKey);
+ sb.append("\n summary:");
+ appendEntry(sb, summary);
+ sb.append("\n children size: ").append(children.size());
for (NotificationEntry child : children.values()) {
- result += "\n " + child.getSbn()
- + (child.getDebugThrowable() != null
- ? Log.getStackTraceString(child.getDebugThrowable())
- : "");
+ appendEntry(sb, child);
}
- result += "\n summary suppressed: " + suppressed;
- return result;
+ sb.append("\n alertOverride:");
+ appendEntry(sb, alertOverride);
+ sb.append("\n summary suppressed: ").append(suppressed);
+ return sb.toString();
+ }
+
+ private void appendEntry(StringBuilder sb, NotificationEntry entry) {
+ sb.append("\n ").append(entry != null ? entry.getSbn() : "null");
+ if (entry != null && entry.getDebugThrowable() != null) {
+ sb.append(Log.getStackTraceString(entry.getDebugThrowable()));
+ }
+ }
+ }
+
+ /**
+ * This class is a toggleable buffer for a subset of events of {@link OnGroupChangeListener}.
+ * When buffering, instead of notifying the listeners it will set internal state that will allow
+ * it to notify listeners of those events later
+ */
+ private class EventBuffer {
+ private final HashMap<String, NotificationEntry> mOldAlertOverrideByGroup = new HashMap<>();
+ private boolean mIsBuffering = false;
+ private boolean mDidGroupsChange = false;
+
+ void notifyAlertOverrideChanged(NotificationGroup group,
+ NotificationEntry oldAlertOverride) {
+ if (mIsBuffering) {
+ // The value in this map is the override before the event. If there is an entry
+ // already in the map, then we are effectively coalescing two events, which means
+ // we need to preserve the original initial value.
+ mOldAlertOverrideByGroup.putIfAbsent(group.groupKey, oldAlertOverride);
+ } else {
+ for (OnGroupChangeListener listener : mGroupChangeListeners) {
+ listener.onGroupAlertOverrideChanged(group, oldAlertOverride,
+ group.alertOverride);
+ }
+ }
+ }
+
+ void notifyGroupsChanged() {
+ if (mIsBuffering) {
+ mDidGroupsChange = true;
+ } else {
+ for (OnGroupChangeListener listener : mGroupChangeListeners) {
+ listener.onGroupsChanged();
+ }
+ }
+ }
+
+ void startBuffering() {
+ mIsBuffering = true;
+ }
+
+ void flushAndStopBuffering() {
+ // stop buffering so that we can call our own helpers
+ mIsBuffering = false;
+ // alert all group alert override changes for groups that were not removed
+ for (Map.Entry<String, NotificationEntry> entry : mOldAlertOverrideByGroup.entrySet()) {
+ NotificationGroup group = mGroupMap.get(entry.getKey());
+ if (group == null) {
+ // The group can be null if this alertOverride changed before the group was
+ // permanently removed, meaning that there's no guarantee that listeners will
+ // that field clear.
+ continue;
+ }
+ NotificationEntry oldAlertOverride = entry.getValue();
+ if (group.alertOverride == oldAlertOverride) {
+ // If the final alertOverride equals the initial, it means we coalesced two
+ // events which undid the change, so we can drop it entirely.
+ continue;
+ }
+ notifyAlertOverrideChanged(group, oldAlertOverride);
+ }
+ mOldAlertOverrideByGroup.clear();
+ // alert that groups changed
+ if (mDidGroupsChange) {
+ notifyGroupsChanged();
+ mDidGroupsChange = false;
+ }
}
}
@@ -714,6 +1066,18 @@
boolean suppressed) {}
/**
+ * The alert override of a group has changed.
+ *
+ * @param group the group that has changed
+ * @param oldAlertOverride the previous notification to which the group's alerts were sent
+ * @param newAlertOverride the notification to which the group's alerts should now be sent
+ */
+ default void onGroupAlertOverrideChanged(
+ NotificationGroup group,
+ @Nullable NotificationEntry oldAlertOverride,
+ @Nullable NotificationEntry newAlertOverride) {}
+
+ /**
* A group of children just received a summary notification and should therefore become
* children of it.
*
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index 120f973..3b64d48f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -664,7 +664,7 @@
mDebugPaint.setColor(Color.CYAN);
canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
- y = (int) (mAmbientState.getStackY() + mAmbientState.getStackHeight());
+ y = (int) (mAmbientState.getStackY() + mSidePaddings + mAmbientState.getStackHeight());
mDebugPaint.setColor(Color.BLUE);
canvas.drawLine(0, y, getWidth(), y, mDebugPaint);
}
@@ -1148,12 +1148,14 @@
if (mOnStackYChanged != null) {
mOnStackYChanged.run();
}
-
- final float stackEndHeight = getHeight() - getEmptyBottomMargin() - mTopPadding;
- mAmbientState.setStackEndHeight(stackEndHeight);
- mAmbientState.setStackHeight(
- MathUtils.lerp(stackEndHeight * StackScrollAlgorithm.START_FRACTION,
- stackEndHeight, fraction));
+ if (mQsExpansionFraction <= 0) {
+ final float stackEndHeight = Math.max(0f,
+ getHeight() - getEmptyBottomMargin() - stackY - mSidePaddings);
+ mAmbientState.setStackEndHeight(stackEndHeight);
+ mAmbientState.setStackHeight(
+ MathUtils.lerp(stackEndHeight * StackScrollAlgorithm.START_FRACTION,
+ stackEndHeight, fraction));
+ }
}
void setOnStackYChanged(Runnable onStackYChanged) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java
index d94d030..b2d39a9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java
@@ -58,6 +58,7 @@
private int mStatusBarHeight;
private float mHeadsUpInset;
private int mPinnedZTranslationExtra;
+ private float mNotificationScrimPadding;
public StackScrollAlgorithm(
Context context,
@@ -82,6 +83,7 @@
mPinnedZTranslationExtra = res.getDimensionPixelSize(
R.dimen.heads_up_pinned_elevation);
mGapHeight = res.getDimensionPixelSize(R.dimen.notification_section_divider_height);
+ mNotificationScrimPadding = res.getDimensionPixelSize(R.dimen.notification_side_paddings);
}
/**
@@ -258,6 +260,9 @@
// expanded. Consider updating these states in updateContentView instead so that we don't
// have to recalculate in every frame.
float currentY = -scrollY;
+ if (!ambientState.isOnKeyguard()) {
+ currentY += mNotificationScrimPadding;
+ }
float previousY = 0;
state.firstViewInShelf = null;
state.viewHeightBeforeShelf = -1;
@@ -318,6 +323,9 @@
AmbientState ambientState) {
// The y coordinate of the current child.
float currentYPosition = -algorithmState.scrollY;
+ if (!ambientState.isOnKeyguard()) {
+ currentYPosition += mNotificationScrimPadding;
+ }
int childCount = algorithmState.visibleChildren.size();
for (int i = 0; i < childCount; i++) {
currentYPosition = updateChild(i, algorithmState, ambientState, currentYPosition);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java
index 2b51b56..c5a155e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java
@@ -23,6 +23,7 @@
import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.ANIMATING_IN;
import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.ANIMATING_OUT;
import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.IDLE;
+import static com.android.systemui.statusbar.events.SystemStatusAnimationSchedulerKt.SHOWING_PERSISTENT_DOT;
import android.animation.ValueAnimator;
import android.annotation.Nullable;
@@ -325,11 +326,13 @@
// Show the ongoing call chip only if there is an ongoing call *and* notification icons
// are allowed. (The ongoing call chip occupies the same area as the notification icons,
// so if the icons are disabled then the call chip should be, too.)
- if (hasOngoingCall && !disableNotifications) {
+ boolean showOngoingCallChip = hasOngoingCall && !disableNotifications;
+ if (showOngoingCallChip) {
showOngoingCallChip(animate);
} else {
hideOngoingCallChip(animate);
}
+ mOngoingCallController.notifyChipVisibilityChanged(showOngoingCallChip);
}
private boolean shouldHideNotificationIcons() {
@@ -348,7 +351,8 @@
private void showSystemIconArea(boolean animate) {
// Only show the system icon area if we are not currently animating
- if (mAnimationScheduler.getAnimationState() == IDLE) {
+ int state = mAnimationScheduler.getAnimationState();
+ if (state == IDLE || state == SHOWING_PERSISTENT_DOT) {
animateShow(mSystemIconArea, animate);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
index 71ba091..c64b893 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -929,7 +929,7 @@
}
GetWalletCardsRequest request =
new GetWalletCardsRequest(1 /* cardWidth */, 1 /* cardHeight */,
- 1 /* iconSizePx */, 2 /* maxCards */);
+ 1 /* iconSizePx */, 1 /* maxCards */);
mQuickAccessWalletClient.getWalletCards(mUiExecutor, request, mCardRetriever);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java
index 3181f52..9787a944 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelper.java
@@ -22,12 +22,12 @@
import android.os.SystemClock;
import android.service.notification.StatusBarNotification;
import android.util.ArrayMap;
+import android.util.Log;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.Dependency;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
-import com.android.systemui.statusbar.AlertingNotificationManager;
import com.android.systemui.statusbar.notification.NotificationEntryListener;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
@@ -41,17 +41,21 @@
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
import java.util.ArrayList;
+import java.util.List;
import java.util.Objects;
/**
* A helper class dealing with the alert interactions between {@link NotificationGroupManagerLegacy}
* and {@link HeadsUpManager}. In particular, this class deals with keeping
- * the correct notification in a group alerting based off the group suppression.
+ * the correct notification in a group alerting based off the group suppression and alertOverride.
*/
public class NotificationGroupAlertTransferHelper implements OnHeadsUpChangedListener,
StateListener {
private static final long ALERT_TRANSFER_TIMEOUT = 300;
+ private static final String TAG = "NotifGroupAlertTransfer";
+ private static final boolean DEBUG = StatusBar.DEBUG;
+ private static final boolean SPEW = StatusBar.SPEW;
/**
* The list of entries containing group alert metadata for each group. Keyed by group key.
@@ -142,41 +146,98 @@
@Override
public void onGroupSuppressionChanged(NotificationGroup group, boolean suppressed) {
- if (suppressed) {
- if (mHeadsUpManager.isAlerting(group.summary.getKey())) {
- handleSuppressedSummaryAlerted(group.summary, mHeadsUpManager);
- }
- } else {
- // Group summary can be null if we are no longer suppressed because the summary was
- // removed. In that case, we don't need to alert the summary.
- if (group.summary == null) {
- return;
- }
- GroupAlertEntry groupAlertEntry = mGroupAlertEntries.get(mGroupManager.getGroupKey(
- group.summary.getSbn()));
- // Group is no longer suppressed. We should check if we need to transfer the alert
- // back to the summary now that it's no longer suppressed.
- if (groupAlertEntry.mAlertSummaryOnNextAddition) {
- if (!mHeadsUpManager.isAlerting(group.summary.getKey())) {
- alertNotificationWhenPossible(group.summary, mHeadsUpManager);
- }
- groupAlertEntry.mAlertSummaryOnNextAddition = false;
- } else {
- checkShouldTransferBack(groupAlertEntry);
- }
+ if (DEBUG) {
+ Log.d(TAG, "!! onGroupSuppressionChanged: group.summary=" + group.summary
+ + " suppressed=" + suppressed);
}
+ NotificationEntry oldAlertOverride = group.alertOverride;
+ onGroupChanged(group, oldAlertOverride);
+ }
+
+ @Override
+ public void onGroupAlertOverrideChanged(NotificationGroup group,
+ @Nullable NotificationEntry oldAlertOverride,
+ @Nullable NotificationEntry newAlertOverride) {
+ if (DEBUG) {
+ Log.d(TAG, "!! onGroupAlertOverrideChanged: group.summary=" + group.summary
+ + " oldAlertOverride=" + oldAlertOverride
+ + " newAlertOverride=" + newAlertOverride);
+ }
+ onGroupChanged(group, oldAlertOverride);
}
};
- @Override
- public void onHeadsUpStateChanged(NotificationEntry entry, boolean isHeadsUp) {
- onAlertStateChanged(entry, isHeadsUp, mHeadsUpManager);
+ /**
+ * Called when either the suppressed or alertOverride fields of the group changed
+ *
+ * @param group the group which changed
+ * @param oldAlertOverride the previous value of group.alertOverride
+ */
+ private void onGroupChanged(NotificationGroup group,
+ NotificationEntry oldAlertOverride) {
+ // Group summary can be null if we are no longer suppressed because the summary was
+ // removed. In that case, we don't need to alert the summary.
+ if (group.summary == null) {
+ if (DEBUG) {
+ Log.d(TAG, "onGroupChanged: summary is null");
+ }
+ return;
+ }
+ if (group.suppressed || group.alertOverride != null) {
+ checkForForwardAlertTransfer(group.summary, oldAlertOverride);
+ } else {
+ if (DEBUG) {
+ Log.d(TAG, "onGroupChanged: maybe transfer back");
+ }
+ GroupAlertEntry groupAlertEntry = mGroupAlertEntries.get(mGroupManager.getGroupKey(
+ group.summary.getSbn()));
+ // Group is no longer suppressed or overridden.
+ // We should check if we need to transfer the alert back to the summary.
+ if (groupAlertEntry.mAlertSummaryOnNextAddition) {
+ if (!mHeadsUpManager.isAlerting(group.summary.getKey())) {
+ alertNotificationWhenPossible(group.summary);
+ }
+ groupAlertEntry.mAlertSummaryOnNextAddition = false;
+ } else {
+ checkShouldTransferBack(groupAlertEntry);
+ }
+ }
}
- private void onAlertStateChanged(NotificationEntry entry, boolean isAlerting,
- AlertingNotificationManager alertManager) {
- if (isAlerting && mGroupManager.isSummaryOfSuppressedGroup(entry.getSbn())) {
- handleSuppressedSummaryAlerted(entry, alertManager);
+ @Override
+ public void onHeadsUpStateChanged(NotificationEntry entry, boolean isHeadsUp) {
+ if (DEBUG) {
+ Log.d(TAG, "!! onHeadsUpStateChanged: entry=" + entry + " isHeadsUp=" + isHeadsUp);
+ }
+ if (isHeadsUp && entry.getSbn().getNotification().isGroupSummary()) {
+ // a group summary is alerting; trigger the forward transfer checks
+ checkForForwardAlertTransfer(entry, /* oldAlertOverride */ null);
+ }
+ }
+
+ /**
+ * Handles changes in a group's suppression or alertOverride, but where at least one of those
+ * conditions is still true (either the group is suppressed, the group has an alertOverride,
+ * or both). The method determined which kind of child needs to receive the alert, finds the
+ * entry currently alerting, and makes the transfer.
+ *
+ * Internally, this is handled with two main cases: the override needs the alert, or there is
+ * no override but the summary is suppressed (so an isolated child needs the alert).
+ *
+ * @param summary the notification entry of the summary of the logical group.
+ * @param oldAlertOverride the former value of group.alertOverride, before whatever event
+ * required us to check for for a transfer condition.
+ */
+ private void checkForForwardAlertTransfer(NotificationEntry summary,
+ NotificationEntry oldAlertOverride) {
+ if (DEBUG) {
+ Log.d(TAG, "checkForForwardAlertTransfer: enter");
+ }
+ NotificationGroup group = mGroupManager.getGroupForSummary(summary.getSbn());
+ if (group != null && group.alertOverride != null) {
+ handleOverriddenSummaryAlerted(summary);
+ } else if (mGroupManager.isSummaryOfSuppressedGroup(summary.getSbn())) {
+ handleSuppressedSummaryAlerted(summary, oldAlertOverride);
}
}
@@ -186,9 +247,16 @@
// see as early as we can if we need to abort a transfer.
@Override
public void onPendingEntryAdded(NotificationEntry entry) {
+ if (DEBUG) {
+ Log.d(TAG, "!! onPendingEntryAdded: entry=" + entry);
+ }
String groupKey = mGroupManager.getGroupKey(entry.getSbn());
GroupAlertEntry groupAlertEntry = mGroupAlertEntries.get(groupKey);
- if (groupAlertEntry != null) {
+ if (groupAlertEntry != null && groupAlertEntry.mGroup.alertOverride == null) {
+ // new pending group entries require us to transfer back from the child to the
+ // group, but alertOverrides are only present in very limited circumstances, so
+ // while it's possible the group should ALSO alert, the previous detection which set
+ // this alertOverride won't be invalidated by this notification added to this group.
checkShouldTransferBack(groupAlertEntry);
}
}
@@ -262,43 +330,128 @@
}
/**
- * Handles the scenario where a summary that has been suppressed is alerted. A suppressed
+ * Handles the scenario where a summary that has been suppressed is itself, or has a former
+ * alertOverride (in the form of an isolated logical child) which was alerted. A suppressed
* summary should for all intents and purposes be invisible to the user and as a result should
* not alert. When this is the case, it is our responsibility to pass the alert to the
* appropriate child which will be the representative notification alerting for the group.
*
- * @param summary the summary that is suppressed and alerting
- * @param alertManager the alert manager that manages the alerting summary
+ * @param summary the summary that is suppressed and (potentially) alerting
+ * @param oldAlertOverride the alertOverride before whatever event triggered this method. If
+ * the alert override was removed, this will be the entry that should
+ * be transferred back from.
*/
private void handleSuppressedSummaryAlerted(@NonNull NotificationEntry summary,
- @NonNull AlertingNotificationManager alertManager) {
- StatusBarNotification sbn = summary.getSbn();
+ NotificationEntry oldAlertOverride) {
+ if (DEBUG) {
+ Log.d(TAG, "handleSuppressedSummaryAlerted: summary=" + summary);
+ }
GroupAlertEntry groupAlertEntry =
- mGroupAlertEntries.get(mGroupManager.getGroupKey(sbn));
+ mGroupAlertEntries.get(mGroupManager.getGroupKey(summary.getSbn()));
+
if (!mGroupManager.isSummaryOfSuppressedGroup(summary.getSbn())
- || !alertManager.isAlerting(sbn.getKey())
|| groupAlertEntry == null) {
+ if (DEBUG) {
+ Log.d(TAG, "handleSuppressedSummaryAlerted: invalid state");
+ }
+ return;
+ }
+ boolean summaryIsAlerting = mHeadsUpManager.isAlerting(summary.getKey());
+ boolean priorityIsAlerting = oldAlertOverride != null
+ && mHeadsUpManager.isAlerting(oldAlertOverride.getKey());
+ if (!summaryIsAlerting && !priorityIsAlerting) {
+ if (DEBUG) {
+ Log.d(TAG, "handleSuppressedSummaryAlerted: no summary or override alerting");
+ }
return;
}
if (pendingInflationsWillAddChildren(groupAlertEntry.mGroup)) {
// New children will actually be added to this group, let's not transfer the alert.
+ if (DEBUG) {
+ Log.d(TAG, "handleSuppressedSummaryAlerted: pending inflations");
+ }
return;
}
NotificationEntry child =
mGroupManager.getLogicalChildren(summary.getSbn()).iterator().next();
- if (child != null) {
- if (child.getRow().keepInParent()
- || child.isRowRemoved()
- || child.isRowDismissed()) {
- // The notification is actually already removed. No need to alert it.
- return;
+ if (summaryIsAlerting) {
+ if (DEBUG) {
+ Log.d(TAG, "handleSuppressedSummaryAlerted: transfer summary -> child");
}
- if (!alertManager.isAlerting(child.getKey()) && onlySummaryAlerts(summary)) {
- groupAlertEntry.mLastAlertTransferTime = SystemClock.elapsedRealtime();
+ tryTransferAlertState(summary, /*from*/ summary, /*to*/ child, groupAlertEntry);
+ return;
+ }
+ // Summary didn't have the alert, so we're in "transfer back" territory. First, make sure
+ // it's not too late to transfer back, then transfer the alert from the oldAlertOverride to
+ // the isolated child which should receive the alert.
+ if (!canStillTransferBack(groupAlertEntry)) {
+ if (DEBUG) {
+ Log.d(TAG, "handleSuppressedSummaryAlerted: transfer from override: too late");
}
- transferAlertState(summary, child, alertManager);
+ return;
+ }
+
+ if (DEBUG) {
+ Log.d(TAG, "handleSuppressedSummaryAlerted: transfer override -> child");
+ }
+ tryTransferAlertState(summary, /*from*/ oldAlertOverride, /*to*/ child, groupAlertEntry);
+ }
+
+ /**
+ * Checks for and handles the scenario where the given entry is the summary of a group which
+ * has an alertOverride, and either the summary itself or one of its logical isolated children
+ * is currently alerting (which happens if the summary is suppressed).
+ */
+ private void handleOverriddenSummaryAlerted(NotificationEntry summary) {
+ if (DEBUG) {
+ Log.d(TAG, "handleOverriddenSummaryAlerted: summary=" + summary);
+ }
+ GroupAlertEntry groupAlertEntry =
+ mGroupAlertEntries.get(mGroupManager.getGroupKey(summary.getSbn()));
+ NotificationGroup group = mGroupManager.getGroupForSummary(summary.getSbn());
+ if (group == null || group.alertOverride == null || groupAlertEntry == null) {
+ if (DEBUG) {
+ Log.d(TAG, "handleOverriddenSummaryAlerted: invalid state");
+ }
+ return;
+ }
+ boolean summaryIsAlerting = mHeadsUpManager.isAlerting(summary.getKey());
+ if (summaryIsAlerting) {
+ if (DEBUG) {
+ Log.d(TAG, "handleOverriddenSummaryAlerted: transfer summary -> override");
+ }
+ tryTransferAlertState(summary, /*from*/ summary, group.alertOverride, groupAlertEntry);
+ return;
+ }
+ // Summary didn't have the alert, so we're in "transfer back" territory. First, make sure
+ // it's not too late to transfer back, then remove the alert from any of the logical
+ // children, and if one of them was alerting, we can alert the override.
+ if (!canStillTransferBack(groupAlertEntry)) {
+ if (DEBUG) {
+ Log.d(TAG, "handleOverriddenSummaryAlerted: transfer from child: too late");
+ }
+ return;
+ }
+ List<NotificationEntry> children = mGroupManager.getLogicalChildren(summary.getSbn());
+ if (children == null) {
+ if (DEBUG) {
+ Log.d(TAG, "handleOverriddenSummaryAlerted: no children");
+ }
+ return;
+ }
+ children.remove(group.alertOverride); // do not release the alert on our desired destination
+ boolean releasedChild = releaseChildAlerts(children);
+ if (releasedChild) {
+ if (DEBUG) {
+ Log.d(TAG, "handleOverriddenSummaryAlerted: transfer child -> override");
+ }
+ tryTransferAlertState(summary, /*from*/ null, group.alertOverride, groupAlertEntry);
+ } else {
+ if (DEBUG) {
+ Log.d(TAG, "handleOverriddenSummaryAlerted: no child alert released");
+ }
}
}
@@ -307,14 +460,37 @@
* immediately to have the incorrect one up as short as possible. The second should alert
* when possible.
*
+ * @param summary entry of the summary
* @param fromEntry entry to transfer alert from
* @param toEntry entry to transfer to
- * @param alertManager alert manager for the alert type
*/
- private void transferAlertState(@NonNull NotificationEntry fromEntry, @NonNull NotificationEntry toEntry,
- @NonNull AlertingNotificationManager alertManager) {
- alertManager.removeNotification(fromEntry.getKey(), true /* releaseImmediately */);
- alertNotificationWhenPossible(toEntry, alertManager);
+ private void tryTransferAlertState(
+ NotificationEntry summary,
+ NotificationEntry fromEntry,
+ NotificationEntry toEntry,
+ GroupAlertEntry groupAlertEntry) {
+ if (toEntry != null) {
+ if (toEntry.getRow().keepInParent()
+ || toEntry.isRowRemoved()
+ || toEntry.isRowDismissed()) {
+ // The notification is actually already removed. No need to alert it.
+ return;
+ }
+ if (!mHeadsUpManager.isAlerting(toEntry.getKey()) && onlySummaryAlerts(summary)) {
+ groupAlertEntry.mLastAlertTransferTime = SystemClock.elapsedRealtime();
+ }
+ if (DEBUG) {
+ Log.d(TAG, "transferAlertState: fromEntry=" + fromEntry + " toEntry=" + toEntry);
+ }
+ transferAlertState(fromEntry, toEntry);
+ }
+ }
+ private void transferAlertState(@Nullable NotificationEntry fromEntry,
+ @NonNull NotificationEntry toEntry) {
+ if (fromEntry != null) {
+ mHeadsUpManager.removeNotification(fromEntry.getKey(), true /* releaseImmediately */);
+ }
+ alertNotificationWhenPossible(toEntry);
}
/**
@@ -326,11 +502,13 @@
* more children are coming. Thus, if a child is added within a certain timeframe after we
* transfer, we back out and alert the summary again.
*
+ * An alert can only transfer back within a small window of time after a transfer away from the
+ * summary to a child happened.
+ *
* @param groupAlertEntry group alert entry to check
*/
private void checkShouldTransferBack(@NonNull GroupAlertEntry groupAlertEntry) {
- if (SystemClock.elapsedRealtime() - groupAlertEntry.mLastAlertTransferTime
- < ALERT_TRANSFER_TIMEOUT) {
+ if (canStillTransferBack(groupAlertEntry)) {
NotificationEntry summary = groupAlertEntry.mGroup.summary;
if (!onlySummaryAlerts(summary)) {
@@ -338,30 +516,17 @@
}
ArrayList<NotificationEntry> children = mGroupManager.getLogicalChildren(
summary.getSbn());
- int numChildren = children.size();
+ int numActiveChildren = children.size();
int numPendingChildren = getPendingChildrenNotAlerting(groupAlertEntry.mGroup);
- numChildren += numPendingChildren;
+ int numChildren = numActiveChildren + numPendingChildren;
if (numChildren <= 1) {
return;
}
- boolean releasedChild = false;
- for (int i = 0; i < children.size(); i++) {
- NotificationEntry entry = children.get(i);
- if (onlySummaryAlerts(entry) && mHeadsUpManager.isAlerting(entry.getKey())) {
- releasedChild = true;
- mHeadsUpManager.removeNotification(
- entry.getKey(), true /* releaseImmediately */);
- }
- if (mPendingAlerts.containsKey(entry.getKey())) {
- // This is the child that would've been removed if it was inflated.
- releasedChild = true;
- mPendingAlerts.get(entry.getKey()).mAbortOnInflation = true;
- }
- }
+ boolean releasedChild = releaseChildAlerts(children);
if (releasedChild && !mHeadsUpManager.isAlerting(summary.getKey())) {
- boolean notifyImmediately = (numChildren - numPendingChildren) > 1;
+ boolean notifyImmediately = numActiveChildren > 1;
if (notifyImmediately) {
- alertNotificationWhenPossible(summary, mHeadsUpManager);
+ alertNotificationWhenPossible(summary);
} else {
// Should wait until the pending child inflates before alerting.
groupAlertEntry.mAlertSummaryOnNextAddition = true;
@@ -371,25 +536,61 @@
}
}
+ private boolean canStillTransferBack(@NonNull GroupAlertEntry groupAlertEntry) {
+ return SystemClock.elapsedRealtime() - groupAlertEntry.mLastAlertTransferTime
+ < ALERT_TRANSFER_TIMEOUT;
+ }
+
+ private boolean releaseChildAlerts(List<NotificationEntry> children) {
+ boolean releasedChild = false;
+ if (SPEW) {
+ Log.d(TAG, "releaseChildAlerts: numChildren=" + children.size());
+ }
+ for (int i = 0; i < children.size(); i++) {
+ NotificationEntry entry = children.get(i);
+ if (SPEW) {
+ Log.d(TAG, "releaseChildAlerts: checking i=" + i + " entry=" + entry
+ + " onlySummaryAlerts=" + onlySummaryAlerts(entry)
+ + " isAlerting=" + mHeadsUpManager.isAlerting(entry.getKey())
+ + " isPendingAlert=" + mPendingAlerts.containsKey(entry.getKey()));
+ }
+ if (onlySummaryAlerts(entry) && mHeadsUpManager.isAlerting(entry.getKey())) {
+ releasedChild = true;
+ mHeadsUpManager.removeNotification(
+ entry.getKey(), true /* releaseImmediately */);
+ }
+ if (mPendingAlerts.containsKey(entry.getKey())) {
+ // This is the child that would've been removed if it was inflated.
+ releasedChild = true;
+ mPendingAlerts.get(entry.getKey()).mAbortOnInflation = true;
+ }
+ }
+ if (SPEW) {
+ Log.d(TAG, "releaseChildAlerts: didRelease=" + releasedChild);
+ }
+ return releasedChild;
+ }
+
/**
* Tries to alert the notification. If its content view is not inflated, we inflate and continue
* when the entry finishes inflating the view.
*
* @param entry entry to show
- * @param alertManager alert manager for the alert type
*/
- private void alertNotificationWhenPossible(@NonNull NotificationEntry entry,
- @NonNull AlertingNotificationManager alertManager) {
- @InflationFlag int contentFlag = alertManager.getContentFlag();
+ private void alertNotificationWhenPossible(@NonNull NotificationEntry entry) {
+ @InflationFlag int contentFlag = mHeadsUpManager.getContentFlag();
final RowContentBindParams params = mRowContentBindStage.getStageParams(entry);
if ((params.getContentViews() & contentFlag) == 0) {
+ if (DEBUG) {
+ Log.d(TAG, "alertNotificationWhenPossible: async requestRebind entry=" + entry);
+ }
mPendingAlerts.put(entry.getKey(), new PendingAlertInfo(entry));
params.requireContentViews(contentFlag);
mRowContentBindStage.requestRebind(entry, en -> {
PendingAlertInfo alertInfo = mPendingAlerts.remove(entry.getKey());
if (alertInfo != null) {
if (alertInfo.isStillValid()) {
- alertNotificationWhenPossible(entry, mHeadsUpManager);
+ alertNotificationWhenPossible(entry);
} else {
// The transfer is no longer valid. Free the content.
mRowContentBindStage.getStageParams(entry).markContentViewsFreeable(
@@ -400,10 +601,16 @@
});
return;
}
- if (alertManager.isAlerting(entry.getKey())) {
- alertManager.updateNotification(entry.getKey(), true /* alert */);
+ if (mHeadsUpManager.isAlerting(entry.getKey())) {
+ if (DEBUG) {
+ Log.d(TAG, "alertNotificationWhenPossible: continue alerting entry=" + entry);
+ }
+ mHeadsUpManager.updateNotification(entry.getKey(), true /* alert */);
} else {
- alertManager.showNotification(entry);
+ if (DEBUG) {
+ Log.d(TAG, "alertNotificationWhenPossible: start alerting entry=" + entry);
+ }
+ mHeadsUpManager.showNotification(entry);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
index c0d713b..075a0c8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
@@ -122,6 +122,7 @@
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.VibratorHelper;
+import com.android.systemui.statusbar.events.PrivacyDotViewController;
import com.android.systemui.statusbar.notification.AnimatableProperty;
import com.android.systemui.statusbar.notification.ConversationNotificationManager;
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
@@ -306,6 +307,7 @@
private final QSDetailDisplayer mQSDetailDisplayer;
private final FeatureFlags mFeatureFlags;
private final ScrimController mScrimController;
+ private final PrivacyDotViewController mPrivacyDotViewController;
// Maximum # notifications to show on Keyguard; extras will be collapsed in an overflow card.
// If there are exactly 1 + mMaxKeyguardNotifications, then still shows all notifications
@@ -602,6 +604,7 @@
FeatureFlags featureFlags,
QuickAccessWalletClient quickAccessWalletClient,
KeyguardMediaController keyguardMediaController,
+ PrivacyDotViewController privacyDotViewController,
@Main Executor uiExecutor) {
super(view, falsingManager, dozeLog, keyguardStateController,
(SysuiStatusBarStateController) statusBarStateController, vibratorHelper,
@@ -610,6 +613,7 @@
mView = view;
mVibratorHelper = vibratorHelper;
mKeyguardMediaController = keyguardMediaController;
+ mPrivacyDotViewController = privacyDotViewController;
mMetricsLogger = metricsLogger;
mActivityManager = activityManager;
mConfigurationController = configurationController;
@@ -1895,6 +1899,7 @@
mKeyguardBypassController.setQSExpanded(expanded);
mStatusBarKeyguardViewManager.setQsExpanded(expanded);
mLockIconViewController.setQsExpanded(expanded);
+ mPrivacyDotViewController.setQsExpanded(expanded);
}
}
@@ -2067,14 +2072,13 @@
final int qsPanelBottomY = calculateQsBottomPosition(getQsExpansionFraction());
final boolean visible = (getQsExpansionFraction() > 0 || qsPanelBottomY > 0)
&& !mShouldUseSplitNotificationShade;
- final float notificationTop = mAmbientState.getStackY()
- - mNotificationScrimPadding
- - mAmbientState.getScrollY();
+ final float notificationTop = mAmbientState.getStackY() - mAmbientState.getScrollY();
setQsExpansionEnabled(mAmbientState.getScrollY() == 0);
int radius = mScrimCornerRadius;
if (!mShouldUseSplitNotificationShade) {
- top = (int) Math.min(qsPanelBottomY, notificationTop);
+ top = (int) (isOnKeyguard() ? Math.min(qsPanelBottomY, notificationTop)
+ : notificationTop);
bottom = getView().getBottom();
left = getView().getLeft();
right = getView().getRight();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarSignalPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarSignalPolicy.java
index 142cf21..ebf2465 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarSignalPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarSignalPolicy.java
@@ -97,13 +97,13 @@
mActivityEnabled = mContext.getResources().getBoolean(R.bool.config_showActivity);
mIconController = iconController;
+ mCarrierConfigTracker = carrierConfigTracker;
mNetworkController = Dependency.get(NetworkController.class);
mSecurityController = Dependency.get(SecurityController.class);
Dependency.get(TunerService.class).addTunable(this, StatusBarIconController.ICON_HIDE_LIST);
mNetworkController.addCallback(this);
mSecurityController.addCallback(this);
- mCarrierConfigTracker = carrierConfigTracker;
}
public void destroy() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallChronometer.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallChronometer.kt
index 1fe77fd..6e27cae 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallChronometer.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallChronometer.kt
@@ -56,6 +56,7 @@
// call starts.
minimumTextWidth = 0
shouldHideText = false
+ visibility = VISIBLE
super.setBase(base)
}
@@ -76,6 +77,9 @@
if (desiredTextWidth > enforcedTextWidth) {
shouldHideText = true
+ // Changing visibility ensures that the content description is not read aloud when the
+ // time isn't displayed.
+ visibility = GONE
setMeasuredDimension(0, 0)
} else {
// It's possible that the current text could fit in a smaller width, but we don't want
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt
index 6d1df5b..e9d256c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallController.kt
@@ -49,7 +49,8 @@
private val systemClock: SystemClock,
private val activityStarter: ActivityStarter,
@Main private val mainExecutor: Executor,
- private val iActivityManager: IActivityManager
+ private val iActivityManager: IActivityManager,
+ private val logger: OngoingCallLogger
) : CallbackController<OngoingCallListener> {
/** Null if there's no ongoing call. */
@@ -104,7 +105,7 @@
/**
* Sets the chip view that will contain ongoing call information.
*
- * Should only be called from [CollapedStatusBarFragment].
+ * Should only be called from [CollapsedStatusBarFragment].
*/
fun setChipView(chipView: ViewGroup) {
this.chipView = chipView
@@ -113,6 +114,16 @@
}
}
+
+ /**
+ * Called when the chip's visibility may have changed.
+ *
+ * Should only be called from [CollapsedStatusBarFragment].
+ */
+ fun notifyChipVisibilityChanged(chipIsVisible: Boolean) {
+ logger.logChipVisibilityChanged(chipIsVisible)
+ }
+
/**
* Returns true if there's an active ongoing call that should be displayed in a status bar chip.
*/
@@ -150,6 +161,7 @@
timeView.start()
currentChipView.setOnClickListener {
+ logger.logChipClicked()
activityStarter.postStartActivityDismissingKeyguard(
currentOngoingCallInfo.intent, 0,
ActivityLaunchAnimator.Controller.fromView(it))
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallLogger.kt
new file mode 100644
index 0000000..177f215
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallLogger.kt
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2021 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.phone.ongoingcall
+
+import androidx.annotation.VisibleForTesting
+import com.android.internal.logging.UiEvent
+import com.android.internal.logging.UiEventLogger
+import com.android.systemui.dagger.SysUISingleton
+import javax.inject.Inject
+
+/** A class to log events for the ongoing call chip. */
+@SysUISingleton
+class OngoingCallLogger @Inject constructor(private val logger: UiEventLogger) {
+
+ private var chipIsVisible: Boolean = false
+
+ /** Logs that the ongoing call chip was clicked. */
+ fun logChipClicked() {
+ logger.log(OngoingCallEvents.ONGOING_CALL_CLICKED)
+ }
+
+ /**
+ * If needed, logs that the ongoing call chip's visibility has changed.
+ *
+ * For now, only logs when the chip changes from not visible to visible.
+ */
+ fun logChipVisibilityChanged(chipIsVisible: Boolean) {
+ if (chipIsVisible && chipIsVisible != this.chipIsVisible) {
+ logger.log(OngoingCallEvents.ONGOING_CALL_VISIBLE)
+ }
+ this.chipIsVisible = chipIsVisible
+ }
+
+ @VisibleForTesting
+ enum class OngoingCallEvents(val metricId: Int) : UiEventLogger.UiEventEnum {
+ @UiEvent(doc = "The ongoing call chip became visible")
+ ONGOING_CALL_VISIBLE(813),
+
+ @UiEvent(doc = "The ongoing call chip was clicked")
+ ONGOING_CALL_CLICKED(814);
+
+ override fun getId() = metricId
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java
index 82ad00a..2e75395 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java
@@ -30,6 +30,8 @@
import android.view.accessibility.AccessibilityManager;
import com.android.internal.logging.MetricsLogger;
+import com.android.internal.logging.UiEvent;
+import com.android.internal.logging.UiEventLogger;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.statusbar.AlertingNotificationManager;
@@ -60,9 +62,28 @@
private final ArrayMap<String, Long> mSnoozedPackages;
private final AccessibilityManagerWrapper mAccessibilityMgr;
+ private final UiEventLogger mUiEventLogger;
+
+ /**
+ * Enum entry for notification peek logged from this class.
+ */
+ enum NotificationPeekEvent implements UiEventLogger.UiEventEnum {
+ @UiEvent(doc = "Heads-up notification peeked on screen.")
+ NOTIFICATION_PEEK(801);
+
+ private final int mId;
+ NotificationPeekEvent(int id) {
+ mId = id;
+ }
+ @Override public int getId() {
+ return mId;
+ }
+ }
+
public HeadsUpManager(@NonNull final Context context) {
mContext = context;
mAccessibilityMgr = Dependency.get(AccessibilityManagerWrapper.class);
+ mUiEventLogger = Dependency.get(UiEventLogger.class);
Resources resources = context.getResources();
mMinimumDisplayTime = resources.getInteger(R.integer.heads_up_notification_minimum_time);
mAutoDismissNotificationDecay = resources.getInteger(R.integer.heads_up_notification_decay);
@@ -130,6 +151,11 @@
if (entry.isRowPinned() != isPinned) {
entry.setRowPinned(isPinned);
updatePinnedMode();
+ if (isPinned && entry.getSbn() != null) {
+ mUiEventLogger.logWithInstanceId(
+ NotificationPeekEvent.NOTIFICATION_PEEK, entry.getSbn().getUid(),
+ entry.getSbn().getPackageName(), entry.getSbn().getInstanceId());
+ }
for (OnHeadsUpChangedListener listener : mListeners) {
if (isPinned) {
listener.onHeadsUpPinned(entry);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
index f45218d..07e9fed 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java
@@ -364,11 +364,11 @@
if (network.equals(mLastNetwork) && validated == lastValidated) {
// Should not rely on getTransportTypes() returning the same order of transport
// types. So sort the array before comparing.
- int[] newTypes = networkCapabilities.getTransportTypes();
+ int[] newTypes = getProcessedTransportTypes(networkCapabilities);
Arrays.sort(newTypes);
int[] lastTypes = (mLastNetworkCapabilities != null)
- ? mLastNetworkCapabilities.getTransportTypes() : null;
+ ? getProcessedTransportTypes(mLastNetworkCapabilities) : null;
if (lastTypes != null) Arrays.sort(lastTypes);
if (Arrays.equals(newTypes, lastTypes)) {
@@ -533,6 +533,21 @@
return mPhone.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
}
+ private int[] getProcessedTransportTypes(NetworkCapabilities networkCapabilities) {
+ int[] transportTypes = networkCapabilities.getTransportTypes();
+ for (int i = 0; i < transportTypes.length; i++) {
+ // For VCN over WiFi, the transportType is set to be TRANSPORT_CELLULAR in the
+ // NetworkCapabilities, but we need to convert it into TRANSPORT_WIFI in order to
+ // distinguish it from VCN over Cellular.
+ if (transportTypes[i] == NetworkCapabilities.TRANSPORT_CELLULAR
+ && Utils.tryGetWifiInfoForVcn(networkCapabilities) != null) {
+ transportTypes[i] = NetworkCapabilities.TRANSPORT_WIFI;
+ break;
+ }
+ }
+ return transportTypes;
+ }
+
private MobileSignalController getDataController() {
int dataSubId = mSubDefaults.getActiveDataSubId();
return getControllerWithSubId(dataSubId);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
index edec618..41b1dd1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
@@ -23,6 +23,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
+import android.widget.TextView;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ContrastColorUtil;
@@ -58,15 +59,6 @@
/** Spacing to be applied between views. */
private final int mSpacing;
- /** Horizontal padding of smart reply buttons if all of them use only one line of text. */
- private final int mSingleLineButtonPaddingHorizontal;
-
- /** Horizontal padding of smart reply buttons if at least one of them uses two lines of text. */
- private final int mDoubleLineButtonPaddingHorizontal;
-
- /** Increase in width of a smart reply button as a result of using two lines instead of one. */
- private final int mSingleToDoubleLineButtonWidthIncrease;
-
private final BreakIterator mBreakIterator;
private PriorityQueue<Button> mCandidateButtonQueueForSqueezing;
@@ -114,8 +106,6 @@
mDefaultBackgroundColor);
int spacing = 0;
- int singleLineButtonPaddingHorizontal = 0;
- int doubleLineButtonPaddingHorizontal = 0;
int strokeWidth = 0;
final TypedArray arr = context.obtainStyledAttributes(attrs, R.styleable.SmartReplyView,
@@ -125,10 +115,6 @@
int attr = arr.getIndex(i);
if (attr == R.styleable.SmartReplyView_spacing) {
spacing = arr.getDimensionPixelSize(i, 0);
- } else if (attr == R.styleable.SmartReplyView_singleLineButtonPaddingHorizontal) {
- singleLineButtonPaddingHorizontal = arr.getDimensionPixelSize(i, 0);
- } else if (attr == R.styleable.SmartReplyView_doubleLineButtonPaddingHorizontal) {
- doubleLineButtonPaddingHorizontal = arr.getDimensionPixelSize(i, 0);
} else if (attr == R.styleable.SmartReplyView_buttonStrokeWidth) {
strokeWidth = arr.getDimensionPixelSize(i, 0);
}
@@ -137,10 +123,6 @@
mStrokeWidth = strokeWidth;
mSpacing = spacing;
- mSingleLineButtonPaddingHorizontal = singleLineButtonPaddingHorizontal;
- mDoubleLineButtonPaddingHorizontal = doubleLineButtonPaddingHorizontal;
- mSingleToDoubleLineButtonWidthIncrease =
- 2 * (doubleLineButtonPaddingHorizontal - singleLineButtonPaddingHorizontal);
mBreakIterator = BreakIterator.getLineInstance();
@@ -222,6 +204,12 @@
return new LayoutParams(params.width, params.height);
}
+ private void clearLayoutLineCount(View view) {
+ if (view instanceof TextView) {
+ ((TextView) view).nullLayouts();
+ }
+ }
+
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int targetWidth = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.UNSPECIFIED
@@ -237,8 +225,7 @@
SmartSuggestionMeasures accumulatedMeasures = new SmartSuggestionMeasures(
mPaddingLeft + mPaddingRight,
- 0 /* maxChildHeight */,
- mSingleLineButtonPaddingHorizontal);
+ 0 /* maxChildHeight */);
int displayedChildCount = 0;
// Set up a list of suggestions where actions come before replies. Note that the Buttons
@@ -268,8 +255,7 @@
continue;
}
- child.setPadding(accumulatedMeasures.mButtonPaddingHorizontal, child.getPaddingTop(),
- accumulatedMeasures.mButtonPaddingHorizontal, child.getPaddingBottom());
+ clearLayoutLineCount(child);
child.measure(MEASURE_SPEC_ANY_LENGTH, heightMeasureSpec);
coveredSuggestions.add(child);
@@ -299,18 +285,6 @@
accumulatedMeasures.mMaxChildHeight =
Math.max(accumulatedMeasures.mMaxChildHeight, childHeight);
- // Do we need to increase the number of lines in smart reply buttons to two?
- final boolean increaseToTwoLines =
- (accumulatedMeasures.mButtonPaddingHorizontal
- == mSingleLineButtonPaddingHorizontal)
- && (lineCount == 2 || accumulatedMeasures.mMeasuredWidth > targetWidth);
- if (increaseToTwoLines) {
- accumulatedMeasures.mMeasuredWidth +=
- (displayedChildCount + 1) * mSingleToDoubleLineButtonWidthIncrease;
- accumulatedMeasures.mButtonPaddingHorizontal =
- mDoubleLineButtonPaddingHorizontal;
- }
-
// If the last button doesn't fit into the remaining width, try squeezing preceding
// smart reply buttons.
if (accumulatedMeasures.mMeasuredWidth > targetWidth) {
@@ -372,18 +346,11 @@
mCandidateButtonQueueForSqueezing.clear();
// Finally, we need to re-measure some buttons.
- remeasureButtonsIfNecessary(accumulatedMeasures.mButtonPaddingHorizontal,
- accumulatedMeasures.mMaxChildHeight);
+ remeasureButtonsIfNecessary(accumulatedMeasures.mMaxChildHeight);
int buttonHeight = Math.max(getSuggestedMinimumHeight(), mPaddingTop
+ accumulatedMeasures.mMaxChildHeight + mPaddingBottom);
- // Set the corner radius to half the button height to make the side of the buttons look like
- // a semicircle.
- for (View smartSuggestionButton : smartSuggestions) {
- setCornerRadius((Button) smartSuggestionButton, ((float) buttonHeight) / 2);
- }
-
setMeasuredDimension(
resolveSize(Math.max(getSuggestedMinimumWidth(),
accumulatedMeasures.mMeasuredWidth),
@@ -411,18 +378,14 @@
private static class SmartSuggestionMeasures {
int mMeasuredWidth = -1;
int mMaxChildHeight = -1;
- int mButtonPaddingHorizontal = -1;
- SmartSuggestionMeasures(int measuredWidth, int maxChildHeight,
- int buttonPaddingHorizontal) {
+ SmartSuggestionMeasures(int measuredWidth, int maxChildHeight) {
this.mMeasuredWidth = measuredWidth;
this.mMaxChildHeight = maxChildHeight;
- this.mButtonPaddingHorizontal = buttonPaddingHorizontal;
}
public SmartSuggestionMeasures clone() {
- return new SmartSuggestionMeasures(
- mMeasuredWidth, mMaxChildHeight, mButtonPaddingHorizontal);
+ return new SmartSuggestionMeasures(mMeasuredWidth, mMaxChildHeight);
}
}
@@ -553,17 +516,11 @@
private int squeezeButtonToTextWidth(Button button, int heightMeasureSpec, int textWidth) {
int oldWidth = button.getMeasuredWidth();
- if (button.getPaddingLeft() != mDoubleLineButtonPaddingHorizontal) {
- // Correct for the fact that the button was laid out with single-line horizontal
- // padding.
- oldWidth += mSingleToDoubleLineButtonWidthIncrease;
- }
// Re-measure the squeezed smart reply button.
- button.setPadding(mDoubleLineButtonPaddingHorizontal, button.getPaddingTop(),
- mDoubleLineButtonPaddingHorizontal, button.getPaddingBottom());
+ clearLayoutLineCount(button);
final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(
- 2 * mDoubleLineButtonPaddingHorizontal + textWidth
+ button.getPaddingLeft() + button.getPaddingRight() + textWidth
+ getLeftCompoundDrawableWidthWithPadding(button), MeasureSpec.AT_MOST);
button.measure(widthMeasureSpec, heightMeasureSpec);
@@ -579,8 +536,7 @@
}
}
- private void remeasureButtonsIfNecessary(
- int buttonPaddingHorizontal, int maxChildHeight) {
+ private void remeasureButtonsIfNecessary(int maxChildHeight) {
final int maxChildHeightMeasure =
MeasureSpec.makeMeasureSpec(maxChildHeight, MeasureSpec.EXACTLY);
@@ -602,24 +558,7 @@
newWidth = Integer.MAX_VALUE;
}
- // Re-measure reason 2: The button's horizontal padding is incorrect (because it was
- // measured with the wrong number of lines).
- if (child.getPaddingLeft() != buttonPaddingHorizontal) {
- requiresNewMeasure = true;
- if (newWidth != Integer.MAX_VALUE) {
- if (buttonPaddingHorizontal == mSingleLineButtonPaddingHorizontal) {
- // Change padding (2->1 line).
- newWidth -= mSingleToDoubleLineButtonWidthIncrease;
- } else {
- // Change padding (1->2 lines).
- newWidth += mSingleToDoubleLineButtonWidthIncrease;
- }
- }
- child.setPadding(buttonPaddingHorizontal, child.getPaddingTop(),
- buttonPaddingHorizontal, child.getPaddingBottom());
- }
-
- // Re-measure reason 3: The button's height is less than the max height of all buttons
+ // Re-measure reason 2: The button's height is less than the max height of all buttons
// (all should have the same height).
if (child.getMeasuredHeight() != maxChildHeight) {
requiresNewMeasure = true;
@@ -725,23 +664,6 @@
button.setTextColor(mCurrentTextColor);
}
- private void setCornerRadius(Button button, float radius) {
- Drawable drawable = button.getBackground();
- if (drawable instanceof RippleDrawable) {
- // Mutate in case other notifications are using this drawable.
- drawable = drawable.mutate();
- RippleDrawable ripple = (RippleDrawable) drawable;
- Drawable inset = ripple.getDrawable(0);
- if (inset instanceof InsetDrawable) {
- Drawable background = ((InsetDrawable) inset).getDrawable();
- if (background instanceof GradientDrawable) {
- GradientDrawable gradientDrawable = (GradientDrawable) background;
- gradientDrawable.setCornerRadius(radius);
- }
- }
- }
- }
-
enum SmartButtonType {
REPLY,
ACTION
diff --git a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayApplier.java b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayApplier.java
index 3c1e123..865aa23f 100644
--- a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayApplier.java
+++ b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayApplier.java
@@ -66,6 +66,13 @@
"android.theme.customization.accent_color";
static final String OVERLAY_CATEGORY_SYSTEM_PALETTE =
"android.theme.customization.system_palette";
+
+ static final String OVERLAY_COLOR_SOURCE = "android.theme.customization.color_source";
+
+ static final String COLOR_SOURCE_PRESET = "preset";
+
+ static final String TIMESTAMP_FIELD = "_applied_timestamp";
+
@VisibleForTesting
static final String OVERLAY_CATEGORY_FONT = "android.theme.customization.font";
@VisibleForTesting
diff --git a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
index 9bdd8c0..195114f 100644
--- a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
+++ b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java
@@ -15,8 +15,11 @@
*/
package com.android.systemui.theme;
+import static com.android.systemui.theme.ThemeOverlayApplier.COLOR_SOURCE_PRESET;
import static com.android.systemui.theme.ThemeOverlayApplier.OVERLAY_CATEGORY_ACCENT_COLOR;
import static com.android.systemui.theme.ThemeOverlayApplier.OVERLAY_CATEGORY_SYSTEM_PALETTE;
+import static com.android.systemui.theme.ThemeOverlayApplier.OVERLAY_COLOR_SOURCE;
+import static com.android.systemui.theme.ThemeOverlayApplier.TIMESTAMP_FIELD;
import android.annotation.Nullable;
import android.app.WallpaperColors;
@@ -90,12 +93,12 @@
private final UserManager mUserManager;
private final BroadcastDispatcher mBroadcastDispatcher;
private final Executor mBgExecutor;
- private final SecureSettings mSecureSettings;
+ private SecureSettings mSecureSettings;
private final Executor mMainExecutor;
private final Handler mBgHandler;
private final WallpaperManager mWallpaperManager;
private final boolean mIsMonetEnabled;
- private final UserTracker mUserTracker;
+ private UserTracker mUserTracker;
private DeviceProvisionedController mDeviceProvisionedController;
private WallpaperColors mSystemColors;
// If fabricated overlays were already created for the current theme.
@@ -112,6 +115,8 @@
private boolean mAcceptColorEvents = true;
// Defers changing themes until Setup Wizard is done.
private boolean mDeferredThemeEvaluation;
+ // Determines if we should ignore THEME_CUSTOMIZATION_OVERLAY_PACKAGES setting changes.
+ private boolean mSkipSettingChange;
private final DeviceProvisionedListener mDeviceProvisionedListener =
new DeviceProvisionedListener() {
@@ -162,6 +167,35 @@
}
}
}
+ // Check if we need to reset to default colors (if a color override was set that is sourced
+ // from the wallpaper)
+ int currentUser = mUserTracker.getUserId();
+ String overlayPackageJson = mSecureSettings.getStringForUser(
+ Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES,
+ currentUser);
+ if (!TextUtils.isEmpty(overlayPackageJson)) {
+ try {
+ JSONObject jsonObject = new JSONObject(overlayPackageJson);
+ if ((jsonObject.has(OVERLAY_CATEGORY_ACCENT_COLOR)
+ || jsonObject.has(OVERLAY_CATEGORY_SYSTEM_PALETTE))
+ && !COLOR_SOURCE_PRESET.equals(
+ jsonObject.optString(OVERLAY_COLOR_SOURCE))) {
+ mSkipSettingChange = true;
+ jsonObject.remove(OVERLAY_CATEGORY_ACCENT_COLOR);
+ jsonObject.remove(OVERLAY_CATEGORY_SYSTEM_PALETTE);
+ jsonObject.remove(OVERLAY_COLOR_SOURCE);
+ jsonObject.put(TIMESTAMP_FIELD, System.currentTimeMillis());
+ if (DEBUG) {
+ Log.d(TAG, "Updating theme setting from "
+ + overlayPackageJson + " to " + jsonObject.toString());
+ }
+ mSecureSettings.putString(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES,
+ jsonObject.toString());
+ }
+ } catch (JSONException e) {
+ Log.i(TAG, "Failed to parse THEME_CUSTOMIZATION_OVERLAY_PACKAGES.", e);
+ }
+ }
reevaluateSystemTheme(false /* forceReload */);
};
@@ -232,6 +266,11 @@
mDeferredThemeEvaluation = true;
return;
}
+ if (mSkipSettingChange) {
+ if (DEBUG) Log.d(TAG, "Skipping setting change");
+ mSkipSettingChange = false;
+ return;
+ }
reevaluateSystemTheme(true /* forceReload */);
}
},
diff --git a/packages/SystemUI/src/com/android/systemui/util/concurrency/ThreadFactory.java b/packages/SystemUI/src/com/android/systemui/util/concurrency/ThreadFactory.java
index 2270f96..7a5ceb5 100644
--- a/packages/SystemUI/src/com/android/systemui/util/concurrency/ThreadFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/util/concurrency/ThreadFactory.java
@@ -16,6 +16,7 @@
package com.android.systemui.util.concurrency;
+import android.os.Handler;
import android.os.Looper;
import java.util.concurrent.Executor;
@@ -29,6 +30,14 @@
*/
public interface ThreadFactory {
/**
+ * Returns a {@link Handler} running on a named thread.
+ *
+ * The thread is implicitly started and may be left running indefinitely, depending on the
+ * implementation. Assume this is the case and use responsibly.
+ */
+ Handler builderHandlerOnNewThread(String threadName);
+
+ /**
* Return an {@link java.util.concurrent.Executor} running on a named thread.
*
* The thread is implicitly started and may be left running indefinitely, depending on the
@@ -45,6 +54,11 @@
DelayableExecutor buildDelayableExecutorOnNewThread(String threadName);
/**
+ * Return an {@link DelayableExecutor} running on the given HandlerThread.
+ **/
+ DelayableExecutor buildDelayableExecutorOnHandler(Handler handler);
+
+ /**
* Return an {@link DelayableExecutor} running the given Looper
**/
DelayableExecutor buildDelayableExecutorOnLooper(Looper looper);
diff --git a/packages/SystemUI/src/com/android/systemui/util/concurrency/ThreadFactoryImpl.java b/packages/SystemUI/src/com/android/systemui/util/concurrency/ThreadFactoryImpl.java
index 2d9f2b4..184b831 100644
--- a/packages/SystemUI/src/com/android/systemui/util/concurrency/ThreadFactoryImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/util/concurrency/ThreadFactoryImpl.java
@@ -16,6 +16,7 @@
package com.android.systemui.util.concurrency;
+import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
@@ -27,16 +28,31 @@
@Inject
ThreadFactoryImpl() {}
+ @Override
+ public Handler builderHandlerOnNewThread(String threadName) {
+ HandlerThread handlerThread = new HandlerThread(threadName);
+ handlerThread.start();
+ return new Handler(handlerThread.getLooper());
+ }
+
+ @Override
public Executor buildExecutorOnNewThread(String threadName) {
return buildDelayableExecutorOnNewThread(threadName);
}
+ @Override
public DelayableExecutor buildDelayableExecutorOnNewThread(String threadName) {
HandlerThread handlerThread = new HandlerThread(threadName);
handlerThread.start();
- return new ExecutorImpl(handlerThread.getLooper());
+ return buildDelayableExecutorOnLooper(handlerThread.getLooper());
}
+ @Override
+ public DelayableExecutor buildDelayableExecutorOnHandler(Handler handler) {
+ return buildDelayableExecutorOnLooper(handler.getLooper());
+ }
+
+ @Override
public DelayableExecutor buildDelayableExecutorOnLooper(Looper looper) {
return new ExecutorImpl(looper);
}
diff --git a/packages/SystemUI/src/com/android/systemui/wallet/ui/DotIndicatorDecoration.java b/packages/SystemUI/src/com/android/systemui/wallet/ui/DotIndicatorDecoration.java
index 644addf..5e9bae9 100644
--- a/packages/SystemUI/src/com/android/systemui/wallet/ui/DotIndicatorDecoration.java
+++ b/packages/SystemUI/src/com/android/systemui/wallet/ui/DotIndicatorDecoration.java
@@ -20,13 +20,10 @@
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
-import android.text.TextPaint;
import android.util.MathUtils;
import android.view.View;
-import android.widget.TextView;
import androidx.annotation.ColorInt;
-import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils;
import androidx.recyclerview.widget.RecyclerView;
@@ -39,12 +36,10 @@
@ColorInt private final int mUnselectedColor;
@ColorInt private final int mSelectedColor;
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
- private final TextPaint mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
private WalletCardCarousel mCardCarousel;
DotIndicatorDecoration(Context context) {
super();
-
mUnselectedRadius =
context.getResources().getDimensionPixelSize(
R.dimen.card_carousel_dot_unselected_radius);
@@ -53,13 +48,8 @@
R.dimen.card_carousel_dot_selected_radius);
mDotMargin = context.getResources().getDimensionPixelSize(R.dimen.card_carousel_dot_margin);
- TextView textView = new TextView(context);
- mTextPaint.set(textView.getPaint());
- // Text color is not copied from text appearance.
- mTextPaint.setColor(ContextCompat.getColor(context, R.color.GM2_blue_600));
-
- mUnselectedColor = ContextCompat.getColor(context, R.color.GM2_grey_300);
- mSelectedColor = ContextCompat.getColor(context, R.color.GM2_blue_600);
+ mUnselectedColor = context.getColor(com.android.internal.R.color.system_neutral1_300);
+ mSelectedColor = context.getColor(com.android.internal.R.color.system_neutral1_0);
}
@Override
@@ -107,9 +97,9 @@
int i = isLayoutLtr() ? itemsDrawn : itemCount - itemsDrawn - 1;
if (isSelectedItem(i)) {
- drawSelectedDot(canvas, interpolatedProgress, i);
+ drawSelectedDot(canvas, interpolatedProgress);
} else if (isNextItemInScrollingDirection(i)) {
- drawFadingUnselectedDot(canvas, interpolatedProgress, i);
+ drawFadingUnselectedDot(canvas, interpolatedProgress);
} else {
drawUnselectedDot(canvas);
}
@@ -121,7 +111,7 @@
this.mCardCarousel = null; // No need to hold a reference.
}
- private void drawSelectedDot(Canvas canvas, float progress, int position) {
+ private void drawSelectedDot(Canvas canvas, float progress) {
// Divide progress by 2 because the other half of the animation is done by
// drawFadingUnselectedDot.
mPaint.setColor(
@@ -132,13 +122,13 @@
canvas.translate(radius * 2, 0);
}
- private void drawFadingUnselectedDot(Canvas canvas, float progress, int position) {
+ private void drawFadingUnselectedDot(Canvas canvas, float progress) {
// Divide progress by 2 because the first half of the animation is done by drawSelectedDot.
int blendedColor =
ColorUtils.blendARGB(
mUnselectedColor, mSelectedColor, progress / 2);
mPaint.setColor(getTransitionAdjustedColor(blendedColor));
- float radius = MathUtils.lerp(mSelectedRadius, mUnselectedRadius, progress / 2);
+ float radius = MathUtils.lerp(mUnselectedRadius, mSelectedColor, progress / 2);
canvas.drawCircle(radius, 0, radius, mPaint);
canvas.translate(radius * 2, 0);
}
diff --git a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java
index ac8b16a..66bd48b 100644
--- a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java
@@ -17,6 +17,7 @@
package com.android.systemui.wallet.ui;
import android.graphics.Color;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.service.quickaccesswallet.QuickAccessWalletClient;
@@ -95,7 +96,7 @@
}
setTitle("");
getActionBar().setDisplayHomeAsUpEnabled(true);
- getActionBar().setHomeAsUpIndicator(R.drawable.ic_close);
+ getActionBar().setHomeAsUpIndicator(getHomeIndicatorDrawable());
getActionBar().setHomeActionContentDescription(R.string.accessibility_desc_close);
WalletView walletView = requireViewById(R.id.wallet_view);
mWalletScreenController = new WalletScreenController(
@@ -175,4 +176,10 @@
mWalletScreenController.onDismissed();
super.onDestroy();
}
+
+ private Drawable getHomeIndicatorDrawable() {
+ Drawable drawable = getDrawable(R.drawable.ic_close);
+ drawable.setTint(getColor(com.android.internal.R.color.system_neutral1_300));
+ return drawable;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java
index ec62981..b57d937 100644
--- a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java
+++ b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java
@@ -234,7 +234,9 @@
mWalletView.show();
mWalletView.hideErrorMessage();
int iconSizePx =
- mContext.getResources().getDimensionPixelSize(R.dimen.wallet_view_header_icon_size);
+ mContext
+ .getResources()
+ .getDimensionPixelSize(R.dimen.wallet_screen_header_icon_size);
GetWalletCardsRequest request =
new GetWalletCardsRequest(cardWidthPx, cardHeightPx, iconSizePx, MAX_CARDS);
mWalletClient.getWalletCards(mExecutor, request, this);
@@ -340,7 +342,11 @@
@Override
public CharSequence getLabel() {
- return mWalletCard.getCardLabel();
+ CharSequence label = mWalletCard.getCardLabel();
+ if (label == null) {
+ return "";
+ }
+ return label;
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletView.java b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletView.java
index c547bb3..e42ce6a 100644
--- a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletView.java
+++ b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletView.java
@@ -37,6 +37,7 @@
import android.widget.TextView;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.settingslib.Utils;
import com.android.systemui.R;
import java.util.List;
@@ -100,7 +101,7 @@
public void onCardScroll(WalletCardViewInfo centerCard, WalletCardViewInfo nextCard,
float percentDistanceFromCenter) {
CharSequence centerCardText = getLabelText(centerCard);
- Drawable centerCardIcon = centerCard.getIcon();
+ Drawable centerCardIcon = getHeaderIcon(mContext, centerCard);
if (!TextUtils.equals(mCenterCardText, centerCardText)) {
mCenterCardText = centerCardText;
mCardLabel.setText(centerCardText);
@@ -133,7 +134,8 @@
mCardCarouselContainer.setVisibility(VISIBLE);
mErrorView.setVisibility(GONE);
mEmptyStateView.setVisibility(GONE);
- renderHeaderIconAndActionButton(data.get(selectedIndex), isDeviceLocked);
+ mIcon.setImageDrawable(getHeaderIcon(mContext, data.get(selectedIndex)));
+ renderActionButton(data.get(selectedIndex), isDeviceLocked);
if (shouldAnimate) {
animateViewsShown(mIcon, mCardLabel, mActionButton);
}
@@ -220,10 +222,15 @@
return mCardLabel;
}
- private void renderHeaderIconAndActionButton(WalletCardViewInfo walletCard, boolean isLocked) {
- mIcon.setImageDrawable(walletCard.getIcon());
- mIcon.setVisibility(VISIBLE);
- renderActionButton(walletCard, isLocked);
+ @Nullable
+ private static Drawable getHeaderIcon(Context context, WalletCardViewInfo walletCard) {
+ Drawable icon = walletCard.getIcon();
+ if (icon != null) {
+ icon.setTint(
+ Utils.getColorAttrDefaultColor(
+ context, com.android.internal.R.attr.colorAccentPrimary));
+ }
+ return icon;
}
private void renderActionButton(WalletCardViewInfo walletCard, boolean isDeviceLocked) {
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java
index 8c5f74d..98467d4 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java
@@ -19,30 +19,20 @@
import static org.junit.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;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.app.smartspace.SmartspaceTarget;
-import android.content.Context;
-import android.content.pm.UserInfo;
import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.os.Handler;
-import android.os.UserHandle;
-import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
-import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
-import androidx.annotation.Nullable;
+import androidx.test.filters.SmallTest;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.keyguard.clock.ClockManager;
@@ -50,21 +40,14 @@
import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.colorextraction.SysuiColorExtractor;
-import com.android.systemui.plugins.ActivityStarter;
-import com.android.systemui.plugins.BcSmartspaceDataPlugin;
-import com.android.systemui.plugins.BcSmartspaceDataPlugin.IntentStarter;
import com.android.systemui.plugins.ClockPlugin;
-import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
-import com.android.systemui.settings.UserTracker;
-import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.StatusBarState;
+import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.NotificationIconAreaController;
import com.android.systemui.statusbar.phone.NotificationIconContainer;
import com.android.systemui.statusbar.policy.BatteryController;
-import com.android.systemui.statusbar.policy.ConfigurationController;
-import com.android.systemui.util.settings.SecureSettings;
import org.junit.Before;
import org.junit.Test;
@@ -74,78 +57,54 @@
import org.mockito.MockitoAnnotations;
import org.mockito.verification.VerificationMode;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.Executor;
-
@SmallTest
@RunWith(AndroidTestingRunner.class)
public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
@Mock
+ private KeyguardClockSwitch mView;
+ @Mock
private StatusBarStateController mStatusBarStateController;
@Mock
private SysuiColorExtractor mColorExtractor;
@Mock
private ClockManager mClockManager;
@Mock
- private KeyguardClockSwitch mView;
- @Mock
- private NotificationIconContainer mNotificationIcons;
- @Mock
- private ClockPlugin mClockPlugin;
- @Mock
- ColorExtractor.GradientColors mGradientColors;
- @Mock
KeyguardSliceViewController mKeyguardSliceViewController;
@Mock
- Resources mResources;
- @Mock
NotificationIconAreaController mNotificationIconAreaController;
@Mock
BroadcastDispatcher mBroadcastDispatcher;
@Mock
- private FeatureFlags mFeatureFlags;
+ BatteryController mBatteryController;
@Mock
- private Executor mExecutor;
+ KeyguardUpdateMonitor mKeyguardUpdateMonitor;
+ @Mock
+ KeyguardBypassController mBypassController;
+ @Mock
+ LockscreenSmartspaceController mSmartspaceController;
+
+ @Mock
+ Resources mResources;
+ @Mock
+ private ClockPlugin mClockPlugin;
+ @Mock
+ ColorExtractor.GradientColors mGradientColors;
+
+ @Mock
+ private NotificationIconContainer mNotificationIcons;
@Mock
private AnimatableClockView mClockView;
@Mock
private AnimatableClockView mLargeClockView;
@Mock
private FrameLayout mLargeClockFrame;
- @Mock
- BatteryController mBatteryController;
- @Mock
- ConfigurationController mConfigurationController;
- @Mock
- Optional<BcSmartspaceDataPlugin> mOptionalSmartspaceDataProvider;
- @Mock
- BcSmartspaceDataPlugin mSmartspaceDataProvider;
- @Mock
- SmartspaceView mSmartspaceView;
- @Mock
- ActivityStarter mActivityStarter;
- @Mock
- FalsingManager mFalsingManager;
- @Mock
- KeyguardUpdateMonitor mKeyguardUpdateMonitor;
- @Mock
- KeyguardBypassController mBypassController;
- @Mock
- Handler mHandler;
- @Mock
- UserTracker mUserTracker;
- @Mock
- SecureSettings mSecureSettings;
+
+ private final View mFakeSmartspaceView = new View(mContext);
private KeyguardClockSwitchController mController;
private View mStatusArea;
- private static final int USER_ID = 5;
- private static final int MANAGED_USER_ID = 15;
-
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
@@ -162,9 +121,9 @@
when(mClockView.getContext()).thenReturn(getContext());
when(mLargeClockView.getContext()).thenReturn(getContext());
- when(mFeatureFlags.isSmartspaceEnabled()).thenReturn(true);
when(mView.isAttachedToWindow()).thenReturn(true);
when(mResources.getString(anyInt())).thenReturn("h:mm");
+ when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView);
mController = new KeyguardClockSwitchController(
mView,
mStatusBarStateController,
@@ -173,28 +132,16 @@
mKeyguardSliceViewController,
mNotificationIconAreaController,
mBroadcastDispatcher,
- mFeatureFlags,
- mExecutor,
mBatteryController,
- mConfigurationController,
- mActivityStarter,
- mFalsingManager,
mKeyguardUpdateMonitor,
mBypassController,
- mHandler,
- mUserTracker,
- mSecureSettings,
- mOptionalSmartspaceDataProvider
- );
+ mSmartspaceController);
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE);
when(mColorExtractor.getColors(anyInt())).thenReturn(mGradientColors);
mStatusArea = new View(getContext());
when(mView.findViewById(R.id.keyguard_status_area)).thenReturn(mStatusArea);
- when(mOptionalSmartspaceDataProvider.isPresent()).thenReturn(true);
- when(mOptionalSmartspaceDataProvider.get()).thenReturn(mSmartspaceDataProvider);
- when(mSmartspaceDataProvider.getView(any())).thenReturn(mSmartspaceView);
}
@Test
@@ -255,119 +202,34 @@
@Test
public void testSmartspaceEnabledRemovesKeyguardStatusArea() {
- when(mFeatureFlags.isSmartspaceEnabled()).thenReturn(true);
+ when(mSmartspaceController.isEnabled()).thenReturn(true);
+ when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView);
mController.init();
assertEquals(View.GONE, mStatusArea.getVisibility());
}
@Test
- public void testSmartspaceEnabledNoDataProviderShowsKeyguardStatusArea() {
- when(mFeatureFlags.isSmartspaceEnabled()).thenReturn(true);
- when(mOptionalSmartspaceDataProvider.isPresent()).thenReturn(false);
- mController.init();
-
- assertEquals(View.VISIBLE, mStatusArea.getVisibility());
- }
-
- @Test
public void testSmartspaceDisabledShowsKeyguardStatusArea() {
- when(mFeatureFlags.isSmartspaceEnabled()).thenReturn(false);
+ when(mSmartspaceController.isEnabled()).thenReturn(false);
mController.init();
assertEquals(View.VISIBLE, mStatusArea.getVisibility());
}
@Test
- public void testThemeChangeNotifiesSmartspace() {
+ public void testDetachRemovesSmartspaceView() {
+ when(mSmartspaceController.isEnabled()).thenReturn(true);
+ when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView);
mController.init();
- verify(mSmartspaceView).setPrimaryTextColor(anyInt());
+ verify(mView).addView(eq(mFakeSmartspaceView), anyInt(), any());
- mController.getConfigurationListener().onThemeChanged();
- verify(mSmartspaceView, times(2)).setPrimaryTextColor(anyInt());
- }
+ ArgumentCaptor<View.OnAttachStateChangeListener> listenerArgumentCaptor =
+ ArgumentCaptor.forClass(View.OnAttachStateChangeListener.class);
+ verify(mView).addOnAttachStateChangeListener(listenerArgumentCaptor.capture());
- @Test
- public void doNotFilterRegularTarget() {
- setupPrimaryAndManagedUser();
- mController.init();
-
- when(mSecureSettings.getIntForUser(anyString(), anyInt(), eq(USER_ID))).thenReturn(0);
- when(mSecureSettings.getIntForUser(anyString(), anyInt(), eq(MANAGED_USER_ID)))
- .thenReturn(0);
-
- mController.getSettingsObserver().onChange(true, null);
-
- SmartspaceTarget t = mock(SmartspaceTarget.class);
- when(t.isSensitive()).thenReturn(false);
- when(t.getUserHandle()).thenReturn(new UserHandle(USER_ID));
- assertEquals(false, mController.filterSmartspaceTarget(t));
-
- reset(t);
- when(t.isSensitive()).thenReturn(false);
- when(t.getUserHandle()).thenReturn(new UserHandle(MANAGED_USER_ID));
- assertEquals(false, mController.filterSmartspaceTarget(t));
- }
-
- @Test
- public void filterAllSensitiveTargetsAllUsers() {
- setupPrimaryAndManagedUser();
- mController.init();
-
- when(mSecureSettings.getIntForUser(anyString(), anyInt(), eq(USER_ID))).thenReturn(0);
- when(mSecureSettings.getIntForUser(anyString(), anyInt(), eq(MANAGED_USER_ID)))
- .thenReturn(0);
-
- mController.getSettingsObserver().onChange(true, null);
-
- SmartspaceTarget t = mock(SmartspaceTarget.class);
- when(t.isSensitive()).thenReturn(true);
- when(t.getUserHandle()).thenReturn(new UserHandle(USER_ID));
- assertEquals(true, mController.filterSmartspaceTarget(t));
-
- reset(t);
- when(t.isSensitive()).thenReturn(true);
- when(t.getUserHandle()).thenReturn(new UserHandle(MANAGED_USER_ID));
- assertEquals(true, mController.filterSmartspaceTarget(t));
- }
-
- @Test
- public void filterSensitiveManagedUserTargets() {
- setupPrimaryAndManagedUser();
- mController.init();
-
- when(mSecureSettings.getIntForUser(anyString(), anyInt(), eq(USER_ID))).thenReturn(1);
- when(mSecureSettings.getIntForUser(anyString(), anyInt(), eq(MANAGED_USER_ID)))
- .thenReturn(0);
-
- mController.getSettingsObserver().onChange(true, null);
-
- SmartspaceTarget t = mock(SmartspaceTarget.class);
- when(t.isSensitive()).thenReturn(true);
- when(t.getUserHandle()).thenReturn(new UserHandle(USER_ID));
- assertEquals(false, mController.filterSmartspaceTarget(t));
-
- reset(t);
- when(t.isSensitive()).thenReturn(true);
- when(t.getUserHandle()).thenReturn(new UserHandle(MANAGED_USER_ID));
- assertEquals(true, mController.filterSmartspaceTarget(t));
- }
-
- private void setupPrimaryAndManagedUser() {
- UserInfo userInfo = mock(UserInfo.class);
- when(userInfo.isManagedProfile()).thenReturn(true);
- when(userInfo.getUserHandle()).thenReturn(new UserHandle(MANAGED_USER_ID));
- when(mUserTracker.getUserProfiles()).thenReturn(List.of(userInfo));
-
- when(mUserTracker.getUserId()).thenReturn(USER_ID);
- when(mUserTracker.getUserHandle()).thenReturn(new UserHandle(USER_ID));
- }
-
- private void setupPrimaryAndNoManagedUser() {
- when(mUserTracker.getUserProfiles()).thenReturn(Collections.emptyList());
-
- when(mUserTracker.getUserId()).thenReturn(USER_ID);
- when(mUserTracker.getUserHandle()).thenReturn(new UserHandle(USER_ID));
+ listenerArgumentCaptor.getValue().onViewDetachedFromWindow(mView);
+ verify(mView).removeView(mFakeSmartspaceView);
}
private void verifyAttachment(VerificationMode times) {
@@ -377,25 +239,4 @@
any(ColorExtractor.OnColorsChangedListener.class));
verify(mView, times).updateColors(mGradientColors);
}
-
- private static class SmartspaceView extends View
- implements BcSmartspaceDataPlugin.SmartspaceView {
- SmartspaceView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public void registerDataProvider(BcSmartspaceDataPlugin plugin) { }
-
- public void setPrimaryTextColor(int color) { }
-
- public void setDozeAmount(float amount) { }
-
- public void setIntentStarter(IntentStarter intentStarter) { }
-
- public void setFalsingManager(FalsingManager falsingManager) { }
-
- public void setDnd(@Nullable Drawable dndIcon, @Nullable String description) { }
-
- public void setNextAlarm(@Nullable Drawable dndIcon, @Nullable String description) { }
- }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
index b9ce203..ed5cbe2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
@@ -67,7 +67,6 @@
import com.android.systemui.tuner.TunerService;
import com.android.systemui.util.concurrency.FakeExecutor;
import com.android.systemui.util.concurrency.FakeThreadFactory;
-import com.android.systemui.util.concurrency.ThreadFactory;
import com.android.systemui.util.settings.FakeSettings;
import com.android.systemui.util.settings.SecureSettings;
import com.android.systemui.util.time.FakeSystemClock;
@@ -87,13 +86,12 @@
private static final Rect ZERO_RECT = new Rect();
- private TestableLooper mTestableLooper;
private ScreenDecorations mScreenDecorations;
private WindowManager mWindowManager;
private DisplayManager mDisplayManager;
private SecureSettings mSecureSettings;
- private Handler mMainHandler;
- private ThreadFactory mThreadFactory;
+ private final FakeExecutor mExecutor = new FakeExecutor(new FakeSystemClock());
+ private FakeThreadFactory mThreadFactory;
@Mock
private TunerService mTunerService;
@Mock
@@ -107,10 +105,10 @@
public void setup() {
MockitoAnnotations.initMocks(this);
- mTestableLooper = TestableLooper.get(this);
- mMainHandler = new Handler(mTestableLooper.getLooper());
+ Handler mainHandler = new Handler(TestableLooper.get(this).getLooper());
mSecureSettings = new FakeSettings();
- mThreadFactory = new FakeThreadFactory(new FakeExecutor(new FakeSystemClock()));
+ mThreadFactory = new FakeThreadFactory(mExecutor);
+ mThreadFactory.setHandler(mainHandler);
mWindowManager = mock(WindowManager.class);
WindowMetrics metrics = mContext.getSystemService(WindowManager.class)
@@ -124,30 +122,25 @@
when(mDisplayManager.getDisplay(anyInt())).thenReturn(display);
mContext.addMockSystemService(DisplayManager.class, mDisplayManager);
- mScreenDecorations = spy(new ScreenDecorations(mContext, mMainHandler, mSecureSettings,
+ mScreenDecorations = spy(new ScreenDecorations(mContext, mExecutor, mSecureSettings,
mBroadcastDispatcher, mTunerService, mUserTracker, mDotViewController,
mThreadFactory) {
@Override
public void start() {
super.start();
- mTestableLooper.processAllMessages();
- }
-
- @Override
- Handler startHandlerThread() {
- return new Handler(mTestableLooper.getLooper());
+ mExecutor.runAllReady();
}
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
- mTestableLooper.processAllMessages();
+ mExecutor.runAllReady();
}
@Override
public void onTuningChanged(String key, String newValue) {
super.onTuningChanged(key, newValue);
- mTestableLooper.processAllMessages();
+ mExecutor.runAllReady();
}
});
reset(mTunerService);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/IWindowMagnificationConnectionTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/IWindowMagnificationConnectionTest.java
index 1d9eaae..77286b1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/IWindowMagnificationConnectionTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/IWindowMagnificationConnectionTest.java
@@ -37,7 +37,8 @@
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
-import com.android.systemui.navigationbar.NavigationModeController;
+import com.android.systemui.model.SysUiState;
+import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.statusbar.CommandQueue;
import org.junit.Before;
@@ -67,9 +68,12 @@
@Mock
private ModeSwitchesController mModeSwitchesController;
@Mock
- private NavigationModeController mNavigationModeController;
+ private SysUiState mSysUiState;
@Mock
private IRemoteMagnificationAnimationCallback mAnimationCallback;
+ @Mock
+ private OverviewProxyService mOverviewProxyService;
+
private IWindowMagnificationConnection mIWindowMagnificationConnection;
private WindowMagnification mWindowMagnification;
@@ -83,8 +87,8 @@
}).when(mAccessibilityManager).setWindowMagnificationConnection(
any(IWindowMagnificationConnection.class));
mWindowMagnification = new WindowMagnification(getContext(),
- getContext().getMainThreadHandler(), mCommandQueue, mModeSwitchesController,
- mNavigationModeController);
+ getContext().getMainThreadHandler(), mCommandQueue,
+ mModeSwitchesController, mSysUiState, mOverviewProxyService);
mWindowMagnification.mAnimationControllerSupplier = new FakeAnimationControllerSupplier(
mContext.getSystemService(DisplayManager.class));
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java
index 4e4c33a..045fb57f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationAnimationControllerTest.java
@@ -41,6 +41,7 @@
import com.android.internal.graphics.SfVsyncFrameCallbackProvider;
import com.android.systemui.SysuiTestCase;
+import com.android.systemui.model.SysUiState;
import org.junit.After;
import org.junit.Before;
@@ -83,6 +84,8 @@
IRemoteMagnificationAnimationCallback mAnimationCallback;
@Mock
IRemoteMagnificationAnimationCallback mAnimationCallback2;
+ @Mock
+ SysUiState mSysUiState;
private SpyWindowMagnificationController mController;
private WindowMagnificationController mSpyController;
private WindowMagnificationAnimationController mWindowMagnificationAnimationController;
@@ -98,7 +101,7 @@
mWaitIntermediateAnimationPeriod = ANIMATION_DURATION_MS / 2;
mController = new SpyWindowMagnificationController(mContext, mHandler,
mSfVsyncFrameProvider, null, new SurfaceControl.Transaction(),
- mWindowMagnifierCallback);
+ mWindowMagnifierCallback, mSysUiState);
mSpyController = mController.getSpyController();
mWindowMagnificationAnimationController = new WindowMagnificationAnimationController(
mContext, mController, newValueAnimator());
@@ -394,6 +397,13 @@
verify(mSpyController).onConfigurationChanged(100);
}
+ @Test
+ public void updateSysUiStateFlag_passThrough() {
+ mWindowMagnificationAnimationController.updateSysUiStateFlag();
+
+ verify(mSpyController).updateSysUIStateFlag();
+ }
+
private void verifyFinalSpec(float expectedScale, float expectedCenterX,
float expectedCenterY) {
assertEquals(expectedScale, mController.getScale(), 0f);
@@ -440,9 +450,9 @@
SpyWindowMagnificationController(Context context, Handler handler,
SfVsyncFrameCallbackProvider sfVsyncFrameProvider,
MirrorWindowControl mirrorWindowControl, SurfaceControl.Transaction transaction,
- WindowMagnifierCallback callback) {
+ WindowMagnifierCallback callback, SysUiState sysUiState) {
super(context, handler, sfVsyncFrameProvider, mirrorWindowControl, transaction,
- callback);
+ callback, sysUiState);
mSpyController = Mockito.mock(WindowMagnificationController.class);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java
index 7d617db..b8734df 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java
@@ -17,12 +17,15 @@
package com.android.systemui.accessibility;
import static android.view.Choreographer.FrameCallback;
-import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
+import static android.view.WindowInsets.Type.systemGestures;
import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
+import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_MAGNIFICATION_OVERLAP;
+
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -33,6 +36,9 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -40,49 +46,60 @@
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Resources;
+import android.graphics.Insets;
+import android.graphics.Rect;
+import android.graphics.Region;
import android.os.Handler;
import android.os.SystemClock;
import android.testing.AndroidTestingRunner;
import android.testing.TestableResources;
+import android.text.TextUtils;
import android.view.Display;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowInsets;
import android.view.WindowManager;
+import android.view.WindowMetrics;
import android.view.accessibility.AccessibilityNodeInfo;
import androidx.test.InstrumentationRegistry;
-import androidx.test.filters.SmallTest;
+import androidx.test.filters.LargeTest;
import com.android.internal.graphics.SfVsyncFrameCallbackProvider;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
+import com.android.systemui.model.SysUiState;
+import com.android.systemui.util.leak.ReferenceTestUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Answers;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-@SmallTest
+@LargeTest
@RunWith(AndroidTestingRunner.class)
public class WindowMagnificationControllerTest extends SysuiTestCase {
+ private static final int LAYOUT_CHANGE_TIMEOUT_MS = 5000;
@Mock
- Handler mHandler;
+ private Handler mHandler;
@Mock
- SfVsyncFrameCallbackProvider mSfVsyncFrameProvider;
+ private SfVsyncFrameCallbackProvider mSfVsyncFrameProvider;
@Mock
- MirrorWindowControl mMirrorWindowControl;
+ private MirrorWindowControl mMirrorWindowControl;
@Mock
- WindowMagnifierCallback mWindowMagnifierCallback;
- @Mock
- SurfaceControl.Transaction mTransaction;
- @Mock
+ private WindowMagnifierCallback mWindowMagnifierCallback;
+ @Mock (answer = Answers.RETURNS_DEEP_STUBS)
+ private SurfaceControl.Transaction mTransaction;
private WindowManager mWindowManager;
+ private SysUiState mSysUiState = new SysUiState();
private Resources mResources;
private WindowMagnificationController mWindowMagnificationController;
private Instrumentation mInstrumentation;
@@ -93,37 +110,30 @@
MockitoAnnotations.initMocks(this);
mContext = Mockito.spy(getContext());
mInstrumentation = InstrumentationRegistry.getInstrumentation();
- WindowManager wm = mContext.getSystemService(WindowManager.class);
- doAnswer(invocation ->
- wm.getMaximumWindowMetrics()
- ).when(mWindowManager).getMaximumWindowMetrics();
- doAnswer(invocation ->
- wm.getCurrentWindowMetrics()
- ).when(mWindowManager).getCurrentWindowMetrics();
+ final WindowManager wm = mContext.getSystemService(WindowManager.class);
+ mWindowManager = spy(new TestableWindowManager(wm));
+
mContext.addMockSystemService(Context.WINDOW_SERVICE, mWindowManager);
doAnswer(invocation -> {
- mMirrorView = invocation.getArgument(0);
- WindowManager.LayoutParams lp = invocation.getArgument(1);
- mMirrorView.setLayoutParams(lp);
- return null;
- }).when(mWindowManager).addView(any(View.class), any(WindowManager.LayoutParams.class));
- doAnswer(invocation -> {
- mMirrorView = null;
- return null;
- }).when(mWindowManager).removeView(any(View.class));
- doAnswer(invocation -> {
FrameCallback callback = invocation.getArgument(0);
callback.doFrame(0);
return null;
}).when(mSfVsyncFrameProvider).postFrameCallback(
any(FrameCallback.class));
- when(mTransaction.remove(any())).thenReturn(mTransaction);
- when(mTransaction.setGeometry(any(), any(), any(),
- anyInt())).thenReturn(mTransaction);
+ doAnswer(invocation -> {
+ final Runnable runnable = invocation.getArgument(0);
+ runnable.run();
+ return null;
+ }).when(mHandler).post(
+ any(Runnable.class));
+
+ mSysUiState.addCallback(Mockito.mock(SysUiState.SysUiStateCallback.class));
+
mResources = getContext().getOrCreateTestableResources().getResources();
mWindowMagnificationController = new WindowMagnificationController(mContext,
mHandler, mSfVsyncFrameProvider,
- mMirrorWindowControl, mTransaction, mWindowMagnifierCallback);
+ mMirrorWindowControl, mTransaction, mWindowMagnifierCallback, mSysUiState);
+
verify(mMirrorWindowControl).setWindowDelegate(
any(MirrorWindowControl.MirrorWindowDelegate.class));
}
@@ -135,12 +145,21 @@
}
@Test
- public void enableWindowMagnification_showControl() {
+ public void enableWindowMagnification_showControlAndNotifyBoundsChanged() {
mInstrumentation.runOnMainSync(() -> {
mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
Float.NaN);
});
+
verify(mMirrorWindowControl).showControl();
+ ArgumentCaptor<Rect> boundsCaptor = ArgumentCaptor.forClass(Rect.class);
+ verify(mWindowMagnifierCallback,
+ timeout(LAYOUT_CHANGE_TIMEOUT_MS)).onWindowMagnifierBoundsChanged(
+ eq(mContext.getDisplayId()), boundsCaptor.capture());
+ final Rect actualBounds = new Rect();
+ mMirrorView.getBoundsOnScreen(actualBounds);
+ assertEquals(actualBounds, boundsCaptor.getValue());
+
}
@Test
@@ -158,6 +177,25 @@
}
@Test
+ public void deleteWindowMagnification_enableAtTheBottom_overlapFlagIsFalse() {
+ final WindowManager wm = mContext.getSystemService(WindowManager.class);
+ final Rect bounds = wm.getCurrentWindowMetrics().getBounds();
+
+ mInstrumentation.runOnMainSync(() -> {
+ mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
+ bounds.bottom);
+ });
+ ReferenceTestUtils.waitForCondition(this::hasMagnificationOverlapFlag);
+
+ mInstrumentation.runOnMainSync(() -> {
+ mWindowMagnificationController.deleteWindowMagnification();
+ });
+
+ verify(mMirrorWindowControl).destroyControl();
+ assertFalse(hasMagnificationOverlapFlag());
+ }
+
+ @Test
public void moveMagnifier_schedulesFrame() {
mInstrumentation.runOnMainSync(() -> {
mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
@@ -210,7 +248,8 @@
});
assertEquals(Surface.ROTATION_90, mWindowMagnificationController.mRotation);
- verify(mWindowManager).updateViewLayout(any(), any());
+ // The first invocation is called when the surface is created.
+ verify(mWindowManager, times(2)).updateViewLayout(any(), any());
}
@Test
@@ -318,17 +357,6 @@
}
@Test
- public void onNavigationModeChanged_updateMirrorViewLayout() {
- mInstrumentation.runOnMainSync(() -> {
- mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
- Float.NaN);
- mWindowMagnificationController.onNavigationModeChanged(NAV_BAR_MODE_GESTURAL);
- });
-
- verify(mWindowManager).updateViewLayout(eq(mMirrorView), any());
- }
-
- @Test
public void enableWindowMagnification_hasA11yWindowTitle() {
mInstrumentation.runOnMainSync(() -> {
mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
@@ -353,16 +381,12 @@
final TestableResources testableResources = getContext().getOrCreateTestableResources();
testableResources.addOverride(com.android.internal.R.string.android_system_label,
newA11yWindowTitle);
- when(mContext.getResources()).thenReturn(testableResources.getResources());
mInstrumentation.runOnMainSync(() -> {
mWindowMagnificationController.onConfigurationChanged(ActivityInfo.CONFIG_LOCALE);
});
- ArgumentCaptor<WindowManager.LayoutParams> paramsArgumentCaptor = ArgumentCaptor.forClass(
- WindowManager.LayoutParams.class);
- verify(mWindowManager).updateViewLayout(eq(mMirrorView), paramsArgumentCaptor.capture());
- assertEquals(newA11yWindowTitle, paramsArgumentCaptor.getValue().accessibilityTitle);
+ assertTrue(TextUtils.equals(newA11yWindowTitle, getAccessibilityWindowTitle()));
}
@Test
@@ -386,4 +410,95 @@
}
fail("mMirrorView scale is not changed");
}
+
+ @Test
+ public void moveWindowMagnificationToTheBottom_enabled_overlapFlagIsTrue() {
+ final WindowManager wm = mContext.getSystemService(WindowManager.class);
+ final Rect bounds = wm.getCurrentWindowMetrics().getBounds();
+ mInstrumentation.runOnMainSync(() -> {
+ mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
+ Float.NaN);
+ });
+
+ mInstrumentation.runOnMainSync(() -> {
+ mWindowMagnificationController.moveWindowMagnifier(0, bounds.height());
+ });
+
+ ReferenceTestUtils.waitForCondition(() -> hasMagnificationOverlapFlag());
+ }
+
+ private CharSequence getAccessibilityWindowTitle() {
+ if (mMirrorView == null) {
+ return null;
+ }
+ WindowManager.LayoutParams layoutParams =
+ (WindowManager.LayoutParams) mMirrorView.getLayoutParams();
+ return layoutParams.accessibilityTitle;
+ }
+
+ private boolean hasMagnificationOverlapFlag() {
+ return (mSysUiState.getFlags() & SYSUI_STATE_MAGNIFICATION_OVERLAP) != 0;
+ }
+
+ private class TestableWindowManager implements WindowManager {
+
+ private final WindowManager mWindowManager;
+
+ TestableWindowManager(WindowManager windowManager) {
+ mWindowManager = windowManager;
+ }
+
+ @Override
+ public Display getDefaultDisplay() {
+ return mWindowManager.getDefaultDisplay();
+ }
+
+ @Override
+ public void removeViewImmediate(View view) {
+ mWindowManager.removeViewImmediate(view);
+ }
+
+ @Override
+ public void requestAppKeyboardShortcuts(KeyboardShortcutsReceiver receiver, int deviceId) {
+ mWindowManager.requestAppKeyboardShortcuts(receiver, deviceId);
+ }
+
+ @Override
+ public Region getCurrentImeTouchRegion() {
+ return mWindowManager.getCurrentImeTouchRegion();
+ }
+
+ @Override
+ public void addView(View view, ViewGroup.LayoutParams params) {
+ mMirrorView = view;
+ mWindowManager.addView(view, params);
+ }
+
+ @Override
+ public void updateViewLayout(View view, ViewGroup.LayoutParams params) {
+ mWindowManager.updateViewLayout(view, params);
+ }
+
+ @Override
+ public void removeView(View view) {
+ mMirrorView = null;
+ mWindowManager.removeView(view);
+ }
+
+ @Override
+ public WindowMetrics getCurrentWindowMetrics() {
+ final Insets systemGesturesInsets = Insets.of(0, 0, 0, 10);
+ final WindowInsets insets = new WindowInsets.Builder()
+ .setInsets(systemGestures(), systemGesturesInsets)
+ .build();
+ final WindowMetrics windowMetrics = new WindowMetrics(
+ mWindowManager.getCurrentWindowMetrics().getBounds(), insets);
+ return windowMetrics;
+ }
+
+ @Override
+ public WindowMetrics getMaximumWindowMetrics() {
+ return mWindowManager.getMaximumWindowMetrics();
+ }
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationTest.java
index 7833114..6ef7cc3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationTest.java
@@ -16,15 +16,21 @@
package com.android.systemui.accessibility;
+import static com.android.systemui.recents.OverviewProxyService.OverviewProxyListener;
+import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_MAGNIFICATION_OVERLAP;
+
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 static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
+import android.hardware.display.DisplayManager;
import android.os.RemoteException;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
@@ -36,12 +42,14 @@
import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
-import com.android.systemui.navigationbar.NavigationModeController;
+import com.android.systemui.model.SysUiState;
+import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.statusbar.CommandQueue;
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;
@@ -50,17 +58,21 @@
@TestableLooper.RunWithLooper
public class WindowMagnificationTest extends SysuiTestCase {
+ private static final int TEST_DISPLAY = Display.DEFAULT_DISPLAY;
@Mock
private AccessibilityManager mAccessibilityManager;
@Mock
private ModeSwitchesController mModeSwitchesController;
@Mock
- private NavigationModeController mNavigationModeController;
+ private SysUiState mSysUiState;
@Mock
private IWindowMagnificationConnectionCallback mConnectionCallback;
+ @Mock
+ private OverviewProxyService mOverviewProxyService;
+
private CommandQueue mCommandQueue;
private WindowMagnification mWindowMagnification;
-
+ private OverviewProxyListener mOverviewProxyListener;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
@@ -72,11 +84,18 @@
}).when(mAccessibilityManager).setWindowMagnificationConnection(
any(IWindowMagnificationConnection.class));
+ when(mSysUiState.setFlag(anyInt(), anyBoolean())).thenReturn(mSysUiState);
+
mCommandQueue = new CommandQueue(getContext());
mWindowMagnification = new WindowMagnification(getContext(),
getContext().getMainThreadHandler(), mCommandQueue, mModeSwitchesController,
- mNavigationModeController);
+ mSysUiState, mOverviewProxyService);
mWindowMagnification.start();
+
+ final ArgumentCaptor<OverviewProxyListener> listenerArgumentCaptor =
+ ArgumentCaptor.forClass(OverviewProxyListener.class);
+ verify(mOverviewProxyService).addCallback(listenerArgumentCaptor.capture());
+ mOverviewProxyListener = listenerArgumentCaptor.getValue();
}
@Test
@@ -99,10 +118,9 @@
mCommandQueue.requestWindowMagnificationConnection(true);
waitForIdleSync();
- mWindowMagnification.onWindowMagnifierBoundsChanged(Display.DEFAULT_DISPLAY, testBounds);
+ mWindowMagnification.onWindowMagnifierBoundsChanged(TEST_DISPLAY, testBounds);
- verify(mConnectionCallback).onWindowMagnifierBoundsChanged(Display.DEFAULT_DISPLAY,
- testBounds);
+ verify(mConnectionCallback).onWindowMagnifierBoundsChanged(TEST_DISPLAY, testBounds);
}
@Test
@@ -111,10 +129,9 @@
mCommandQueue.requestWindowMagnificationConnection(true);
waitForIdleSync();
- mWindowMagnification.onPerformScaleAction(Display.DEFAULT_DISPLAY, newScale);
+ mWindowMagnification.onPerformScaleAction(TEST_DISPLAY, newScale);
- verify(mConnectionCallback).onPerformScaleAction(eq(Display.DEFAULT_DISPLAY),
- eq(newScale));
+ verify(mConnectionCallback).onPerformScaleAction(TEST_DISPLAY, newScale);
}
@Test
@@ -122,9 +139,9 @@
mCommandQueue.requestWindowMagnificationConnection(true);
waitForIdleSync();
- mWindowMagnification.onAccessibilityActionPerformed(Display.DEFAULT_DISPLAY);
+ mWindowMagnification.onAccessibilityActionPerformed(TEST_DISPLAY);
- verify(mConnectionCallback).onAccessibilityActionPerformed(eq(Display.DEFAULT_DISPLAY));
+ verify(mConnectionCallback).onAccessibilityActionPerformed(TEST_DISPLAY);
}
@Test
@@ -135,4 +152,42 @@
verify(mModeSwitchesController).onConfigurationChanged(anyInt());
}
+
+ @Test
+ public void overviewProxyIsConnected_noController_resetFlag() {
+ mOverviewProxyListener.onConnectionChanged(true);
+
+ verify(mSysUiState).setFlag(SYSUI_STATE_MAGNIFICATION_OVERLAP, false);
+ verify(mSysUiState).commitUpdate(mContext.getDisplayId());
+ }
+
+ @Test
+ public void overviewProxyIsConnected_controllerIsAvailable_updateSysUiStateFlag() {
+ final WindowMagnificationAnimationController mController = mock(
+ WindowMagnificationAnimationController.class);
+ mWindowMagnification.mAnimationControllerSupplier = new FakeAnimationControllerSupplier(
+ mContext.getSystemService(DisplayManager.class), mController);
+ mWindowMagnification.mAnimationControllerSupplier.get(TEST_DISPLAY);
+
+ mOverviewProxyListener.onConnectionChanged(true);
+
+ verify(mController).updateSysUiStateFlag();
+ }
+
+ private static class FakeAnimationControllerSupplier extends
+ DisplayIdIndexSupplier<WindowMagnificationAnimationController> {
+
+ private final WindowMagnificationAnimationController mController;
+
+ FakeAnimationControllerSupplier(DisplayManager displayManager,
+ WindowMagnificationAnimationController controller) {
+ super(displayManager);
+ mController = controller;
+ }
+
+ @Override
+ protected WindowMagnificationAnimationController createInstance(Display display) {
+ return mController;
+ }
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/AnnotationLinkSpanTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/AnnotationLinkSpanTest.java
new file mode 100644
index 0000000..46c930f
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/AnnotationLinkSpanTest.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2021 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.floatingmenu;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.mock;
+
+import android.testing.AndroidTestingRunner;
+import android.text.SpannableStringBuilder;
+import android.view.View;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.systemui.R;
+import com.android.systemui.SysuiTestCase;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/** Tests for {@link AnnotationLinkSpan}. */
+@SmallTest
+@RunWith(AndroidTestingRunner.class)
+public class AnnotationLinkSpanTest extends SysuiTestCase {
+
+ private AnnotationLinkSpan.LinkInfo mLinkInfo;
+
+ @Before
+ public void setUp() {
+ mLinkInfo = new AnnotationLinkSpan.LinkInfo(
+ AnnotationLinkSpan.LinkInfo.DEFAULT_ANNOTATION,
+ mock(View.OnClickListener.class));
+ }
+
+ @Test
+ public void linkifyText_textAttachedWithSpan() {
+ final CharSequence text = getContext().getText(
+ R.string.accessibility_floating_button_migration_tooltip);
+ final SpannableStringBuilder builder =
+ (SpannableStringBuilder) AnnotationLinkSpan.linkify(text, mLinkInfo);
+ final int AnnotationLinkSpanNum =
+ builder.getSpans(/* queryStart= */ 0, builder.length(),
+ AnnotationLinkSpan.class).length;
+
+ assertThat(AnnotationLinkSpanNum).isEqualTo(1);
+ }
+
+ @Test
+ public void linkifyText_withoutAnnotationTag_textWithoutSpan() {
+ final CharSequence text = "text without any annotation tag";
+ final SpannableStringBuilder builder =
+ (SpannableStringBuilder) AnnotationLinkSpan.linkify(text, mLinkInfo);
+ final int AnnotationLinkSpanNum =
+ builder.getSpans(/* queryStart= */ 0, builder.length(),
+ AnnotationLinkSpan.class).length;
+
+ assertThat(AnnotationLinkSpanNum).isEqualTo(0);
+ }
+
+ @Test
+ public void linkifyText_twoLinkInfoWithSameAnnotation_listenerInvoked() {
+ final AtomicBoolean isClicked = new AtomicBoolean(false);
+ final CharSequence text = getContext().getText(
+ R.string.accessibility_floating_button_migration_tooltip);
+ final View.OnClickListener firstListener = v -> isClicked.set(true);
+ final AnnotationLinkSpan.LinkInfo firstLinkInfo = new AnnotationLinkSpan.LinkInfo(
+ AnnotationLinkSpan.LinkInfo.DEFAULT_ANNOTATION, firstListener);
+
+ final SpannableStringBuilder builder =
+ (SpannableStringBuilder) AnnotationLinkSpan.linkify(text, firstLinkInfo, mLinkInfo);
+ final AnnotationLinkSpan[] firstAnnotationLinkSpan =
+ builder.getSpans(/* queryStart= */ 0, builder.length(),
+ AnnotationLinkSpan.class);
+ firstAnnotationLinkSpan[0].onClick(mock(View.class));
+
+ assertThat(isClicked.get()).isTrue();
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/BaseTooltipViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/BaseTooltipViewTest.java
new file mode 100644
index 0000000..6db5761
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/BaseTooltipViewTest.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2021 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.floatingmenu;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
+import android.view.MotionEvent;
+import android.view.WindowManager;
+import android.view.accessibility.AccessibilityNodeInfo;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.systemui.SysuiTestCase;
+import com.android.systemui.accessibility.MotionEventHelper;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/** Tests for {@link BaseTooltipView}. */
+@SmallTest
+@RunWith(AndroidTestingRunner.class)
+@TestableLooper.RunWithLooper
+public class BaseTooltipViewTest extends SysuiTestCase {
+
+ @Mock
+ private WindowManager mWindowManager;
+
+ private AccessibilityFloatingMenuView mMenuView;
+ private BaseTooltipView mToolTipView;
+
+ private final MotionEventHelper mMotionEventHelper = new MotionEventHelper();
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ final WindowManager wm = mContext.getSystemService(WindowManager.class);
+ doAnswer(invocation -> wm.getMaximumWindowMetrics()).when(
+ mWindowManager).getMaximumWindowMetrics();
+ mContext.addMockSystemService(Context.WINDOW_SERVICE, mWindowManager);
+
+ mMenuView = new AccessibilityFloatingMenuView(mContext);
+ mToolTipView = new BaseTooltipView(mContext, mMenuView);
+ }
+
+ @Test
+ public void showToolTipView_success() {
+ mToolTipView.show();
+
+ verify(mWindowManager).addView(eq(mToolTipView), any(WindowManager.LayoutParams.class));
+ }
+
+ @Test
+ public void touchOutsideWhenToolTipViewShown_dismiss() {
+ final MotionEvent outsideEvent =
+ mMotionEventHelper.obtainMotionEvent(/* downTime= */ 0,
+ /* eventTime= */1,
+ MotionEvent.ACTION_OUTSIDE,
+ /* x= */ 0,
+ /* y= */ 0);
+
+ mToolTipView.show();
+ mToolTipView.dispatchTouchEvent(outsideEvent);
+
+ verify(mWindowManager).removeView(mToolTipView);
+ }
+
+ @Test
+ public void getAccessibilityActionList_matchResult() {
+ final AccessibilityNodeInfo infos = new AccessibilityNodeInfo();
+ mToolTipView.onInitializeAccessibilityNodeInfo(infos);
+
+ assertThat(infos.getActionList().size()).isEqualTo(1);
+ }
+
+ @Test
+ public void accessibilityAction_dismiss_success() {
+ final BaseTooltipView tooltipView =
+ spy(new BaseTooltipView(mContext, mMenuView));
+
+ final boolean isActionPerformed =
+ tooltipView.performAccessibilityAction(
+ AccessibilityNodeInfo.AccessibilityAction.ACTION_DISMISS.getId(),
+ /* arguments= */ null);
+
+ assertThat(isActionPerformed).isTrue();
+ verify(tooltipView).hide();
+ }
+
+ @After
+ public void tearDown() {
+ mToolTipView.hide();
+ mMotionEventHelper.recycleEvents();
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/DockTooltipViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/DockTooltipViewTest.java
new file mode 100644
index 0000000..41b948f
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/DockTooltipViewTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2021 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.floatingmenu;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
+import android.view.MotionEvent;
+import android.view.WindowManager;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.systemui.SysuiTestCase;
+import com.android.systemui.accessibility.MotionEventHelper;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/** Tests for {@link DockTooltipView}. */
+@SmallTest
+@RunWith(AndroidTestingRunner.class)
+@TestableLooper.RunWithLooper
+public class DockTooltipViewTest extends SysuiTestCase {
+
+ @Mock
+ private WindowManager mWindowManager;
+
+ private AccessibilityFloatingMenuView mMenuView;
+ private DockTooltipView mDockTooltipView;
+ private final MotionEventHelper mMotionEventHelper = new MotionEventHelper();
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ final WindowManager wm = mContext.getSystemService(WindowManager.class);
+ doAnswer(invocation -> wm.getMaximumWindowMetrics()).when(
+ mWindowManager).getMaximumWindowMetrics();
+ mContext.addMockSystemService(Context.WINDOW_SERVICE, mWindowManager);
+
+ mMenuView = spy(new AccessibilityFloatingMenuView(mContext));
+ mDockTooltipView = new DockTooltipView(mContext, mMenuView);
+ }
+
+ @Test
+ public void showTooltip_success() {
+ mDockTooltipView.show();
+
+ verify(mMenuView).startTranslateXAnimation();
+ verify(mWindowManager).addView(eq(mDockTooltipView), any(WindowManager.LayoutParams.class));
+ }
+
+ @Test
+ public void hideTooltip_success() {
+ mDockTooltipView.show();
+ mDockTooltipView.hide();
+
+ verify(mMenuView).stopTranslateXAnimation();
+ verify(mWindowManager).removeView(mDockTooltipView);
+ }
+
+ @Test
+ public void touchOutsideWhenToolTipViewShown_stopAnimation() {
+ final MotionEvent outsideEvent =
+ mMotionEventHelper.obtainMotionEvent(/* downTime= */ 0,
+ /* eventTime= */ 1,
+ MotionEvent.ACTION_OUTSIDE,
+ /* x= */ 0,
+ /* y= */ 0);
+
+ mDockTooltipView.show();
+ mDockTooltipView.dispatchTouchEvent(outsideEvent);
+
+ verify(mMenuView).stopTranslateXAnimation();
+ }
+
+ @After
+ public void tearDown() {
+ mMotionEventHelper.recycleEvents();
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MigrationTooltipViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MigrationTooltipViewTest.java
new file mode 100644
index 0000000..c5bd2fe
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MigrationTooltipViewTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2021 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.floatingmenu;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
+import android.text.SpannableString;
+import android.text.method.LinkMovementMethod;
+import android.widget.TextView;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.systemui.R;
+import com.android.systemui.SysuiTestCase;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/** Tests for {@link MigrationTooltipView}. */
+@SmallTest
+@RunWith(AndroidTestingRunner.class)
+@TestableLooper.RunWithLooper
+public class MigrationTooltipViewTest extends SysuiTestCase {
+
+ private TextView mTextView;
+
+ @Before
+ public void setUp() {
+ final AccessibilityFloatingMenuView menuView = new AccessibilityFloatingMenuView(mContext);
+ final MigrationTooltipView toolTipView = new MigrationTooltipView(mContext, menuView);
+ mTextView = toolTipView.findViewById(R.id.text);
+ }
+
+ @Test
+ public void onCreate_setLinkMovementMethod() {
+ assertThat(mTextView.getMovementMethod()).isInstanceOf(LinkMovementMethod.class);
+ }
+
+ @Test
+ public void onCreate_setDescription_matchTextAndSpanNum() {
+ final CharSequence expectedTextWithoutSpan =
+ AnnotationLinkSpan.linkify(mContext.getText(
+ R.string.accessibility_floating_button_migration_tooltip)).toString();
+ final SpannableString spannableString = (SpannableString) mTextView.getText();
+ final int AnnotationLinkSpanNum =
+ spannableString.getSpans(/* queryStart= */ 0, spannableString.length(),
+ AnnotationLinkSpan.class).length;
+
+ assertThat(AnnotationLinkSpanNum).isEqualTo(1);
+ assertThat(mTextView.getText().toString().contentEquals(expectedTextWithoutSpan)).isTrue();
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java
index 875696a..46c1848 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java
@@ -35,6 +35,7 @@
import android.hardware.fingerprint.IUdfpsOverlayControllerCallback;
import android.os.PowerManager;
import android.os.RemoteException;
+import android.os.Vibrator;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
import android.view.LayoutInflater;
@@ -69,6 +70,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
@SmallTest
@RunWith(AndroidTestingRunner.class)
@@ -93,6 +95,8 @@
@Mock
private WindowManager mWindowManager;
@Mock
+ private UdfpsHbmCallback mHbmCallback;
+ @Mock
private StatusBarStateController mStatusBarStateController;
@Mock
private StatusBar mStatusBar;
@@ -114,6 +118,8 @@
private AccessibilityManager mAccessibilityManager;
@Mock
private ScreenLifecycle mScreenLifecycle;
+ @Mock
+ private Vibrator mVibrator;
private FakeExecutor mFgExecutor;
@@ -170,7 +176,9 @@
mFalsingManager,
mPowerManager,
mAccessibilityManager,
- mScreenLifecycle);
+ mScreenLifecycle,
+ mVibrator,
+ Optional.of(mHbmCallback));
verify(mFingerprintManager).setUdfpsOverlayController(mOverlayCaptor.capture());
mOverlayController = mOverlayCaptor.getValue();
verify(mScreenLifecycle).addObserver(mScreenObserverCaptor.capture());
@@ -302,4 +310,29 @@
// THEN no illumination because screen is off
verify(mUdfpsView, never()).startIllumination(any());
}
+
+ @Test
+ public void playHapticOnTouchUdfpsArea() throws RemoteException {
+ // Configure UdfpsView to accept the ACTION_DOWN event
+ when(mUdfpsView.isIlluminationRequested()).thenReturn(false);
+ when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true);
+
+ // GIVEN that the overlay is showing
+ mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
+ IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
+ mFgExecutor.runAllReady();
+
+ // WHEN ACTION_DOWN is received
+ verify(mUdfpsView).setOnTouchListener(mTouchListenerCaptor.capture());
+ MotionEvent downEvent = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 0, 0);
+ mTouchListenerCaptor.getValue().onTouch(mUdfpsView, downEvent);
+ downEvent.recycle();
+ MotionEvent moveEvent = MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 0, 0, 0);
+ mTouchListenerCaptor.getValue().onTouch(mUdfpsView, moveEvent);
+ moveEvent.recycle();
+
+ // THEN click haptic is played
+ verify(mVibrator).vibrate(mUdfpsController.mEffectClick,
+ UdfpsController.VIBRATION_SONIFICATION_ATTRIBUTES);
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java
index 80716f9..003368d9 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java
@@ -39,6 +39,7 @@
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.IWindowManager;
+import android.view.View;
import android.view.WindowManagerPolicyConstants;
import androidx.test.filters.SmallTest;
@@ -172,6 +173,44 @@
}
@Test
+ public void testShouldLogClose_backButton() {
+ mGlobalActionsDialogLite = spy(mGlobalActionsDialogLite);
+ doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems();
+ doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayLockdown(any());
+ doReturn(true).when(mGlobalActionsDialogLite).shouldShowAction(any());
+ String[] actions = {
+ GlobalActionsDialog.GLOBAL_ACTION_KEY_EMERGENCY,
+ GlobalActionsDialog.GLOBAL_ACTION_KEY_LOCKDOWN,
+ GlobalActionsDialog.GLOBAL_ACTION_KEY_POWER,
+ GlobalActionsDialog.GLOBAL_ACTION_KEY_RESTART,
+ };
+ doReturn(actions).when(mGlobalActionsDialogLite).getDefaultActions();
+ GlobalActionsDialogLite.ActionsDialogLite dialog = mGlobalActionsDialogLite.createDialog();
+ dialog.onBackPressed();
+ mTestableLooper.processAllMessages();
+ verifyLogPosted(GlobalActionsDialog.GlobalActionsEvent.GA_CLOSE_BACK);
+ }
+
+ @Test
+ public void testShouldLogOnTapOutside() {
+ mGlobalActionsDialogLite = spy(mGlobalActionsDialogLite);
+ doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems();
+ doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayLockdown(any());
+ doReturn(true).when(mGlobalActionsDialogLite).shouldShowAction(any());
+ String[] actions = {
+ GlobalActionsDialog.GLOBAL_ACTION_KEY_EMERGENCY,
+ GlobalActionsDialog.GLOBAL_ACTION_KEY_LOCKDOWN,
+ GlobalActionsDialog.GLOBAL_ACTION_KEY_POWER,
+ GlobalActionsDialog.GLOBAL_ACTION_KEY_RESTART,
+ };
+ doReturn(actions).when(mGlobalActionsDialogLite).getDefaultActions();
+ GlobalActionsDialogLite.ActionsDialogLite dialog = mGlobalActionsDialogLite.createDialog();
+ View container = dialog.findViewById(com.android.systemui.R.id.global_actions_container);
+ container.callOnClick();
+ verifyLogPosted(GlobalActionsDialog.GlobalActionsEvent.GA_CLOSE_TAP_OUTSIDE);
+ }
+
+ @Test
public void testShouldLogBugreportPress() throws InterruptedException {
GlobalActionsDialog.BugReportAction bugReportAction =
mGlobalActionsDialogLite.makeBugReportActionForTesting();
@@ -286,4 +325,44 @@
assertThat(mGlobalActionsDialogLite.mOverflowItems).isEmpty();
assertThat(mGlobalActionsDialogLite.mPowerItems).isEmpty();
}
+
+ @Test
+ public void testShouldLogLockdownPress() {
+ GlobalActionsDialogLite.LockDownAction lockDownAction =
+ mGlobalActionsDialogLite.new LockDownAction();
+ lockDownAction.onPress();
+ verifyLogPosted(GlobalActionsDialog.GlobalActionsEvent.GA_LOCKDOWN_PRESS);
+ }
+
+ @Test
+ public void testShouldLogShutdownPress() {
+ GlobalActionsDialogLite.ShutDownAction shutDownAction =
+ mGlobalActionsDialogLite.new ShutDownAction();
+ shutDownAction.onPress();
+ verifyLogPosted(GlobalActionsDialog.GlobalActionsEvent.GA_SHUTDOWN_PRESS);
+ }
+
+ @Test
+ public void testShouldLogShutdownLongPress() {
+ GlobalActionsDialogLite.ShutDownAction shutDownAction =
+ mGlobalActionsDialogLite.new ShutDownAction();
+ shutDownAction.onLongPress();
+ verifyLogPosted(GlobalActionsDialog.GlobalActionsEvent.GA_SHUTDOWN_LONG_PRESS);
+ }
+
+ @Test
+ public void testShouldLogRebootPress() {
+ GlobalActionsDialogLite.RestartAction restartAction =
+ mGlobalActionsDialogLite.new RestartAction();
+ restartAction.onPress();
+ verifyLogPosted(GlobalActionsDialog.GlobalActionsEvent.GA_REBOOT_PRESS);
+ }
+
+ @Test
+ public void testShouldLogRebootLongPress() {
+ GlobalActionsDialogLite.RestartAction restartAction =
+ mGlobalActionsDialogLite.new RestartAction();
+ restartAction.onLongPress();
+ verifyLogPosted(GlobalActionsDialog.GlobalActionsEvent.GA_REBOOT_LONG_PRESS);
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/MediaControlPanelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/MediaControlPanelTest.kt
index dd3a192..e62fa91 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/MediaControlPanelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/MediaControlPanelTest.kt
@@ -289,6 +289,7 @@
captor.value.onLongClick(holder.player)
verify(mediaViewController, never()).openGuts()
+ verify(mediaViewController).closeGuts(false)
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/MediaHierarchyManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/MediaHierarchyManagerTest.kt
index 406f40c..a974421 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/MediaHierarchyManagerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/MediaHierarchyManagerTest.kt
@@ -24,6 +24,7 @@
import com.android.systemui.SysuiTestCase
import com.android.systemui.controls.controller.ControlsControllerImplTest.Companion.eq
import com.android.systemui.keyguard.WakefulnessLifecycle
+import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.statusbar.NotificationLockscreenUserManager
import com.android.systemui.statusbar.StatusBarState
import com.android.systemui.statusbar.SysuiStatusBarStateController
@@ -73,11 +74,15 @@
@Mock
private lateinit var mediaCarouselController: MediaCarouselController
@Mock
+ private lateinit var mediaCarouselScrollHandler: MediaCarouselScrollHandler
+ @Mock
private lateinit var wakefulnessLifecycle: WakefulnessLifecycle
@Mock
private lateinit var statusBarKeyguardViewManager: StatusBarKeyguardViewManager
@Captor
private lateinit var wakefullnessObserver: ArgumentCaptor<(WakefulnessLifecycle.Observer)>
+ @Captor
+ private lateinit var statusBarCallback: ArgumentCaptor<(StatusBarStateController.StateListener)>
@JvmField
@Rule
val mockito = MockitoJUnit.rule()
@@ -96,10 +101,13 @@
wakefulnessLifecycle,
statusBarKeyguardViewManager)
verify(wakefulnessLifecycle).addObserver(wakefullnessObserver.capture())
+ verify(statusBarStateController).addCallback(statusBarCallback.capture())
setupHost(lockHost, MediaHierarchyManager.LOCATION_LOCKSCREEN)
setupHost(qsHost, MediaHierarchyManager.LOCATION_QS)
setupHost(qqsHost, MediaHierarchyManager.LOCATION_QQS)
`when`(statusBarStateController.state).thenReturn(StatusBarState.SHADE)
+ `when`(mediaCarouselController.mediaCarouselScrollHandler)
+ .thenReturn(mediaCarouselScrollHandler)
// We'll use the viewmanager to verify a few calls below, let's reset this.
clearInvocations(mediaCarouselController)
}
@@ -153,4 +161,11 @@
verify(mediaCarouselController).closeGuts()
}
+
+ @Test
+ fun testCloseGutsWhenDoze() {
+ statusBarCallback.value.onDozingChanged(true)
+
+ verify(mediaCarouselController).closeGuts()
+ }
}
\ No newline at end of file
diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java
index 5c70a4ef2..7172307 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/people/PeopleTileViewHelperTest.java
@@ -17,6 +17,7 @@
package com.android.systemui.people;
import static android.app.Notification.CATEGORY_MISSED_CALL;
+import static android.app.people.ConversationStatus.ACTIVITY_ANNIVERSARY;
import static android.app.people.ConversationStatus.ACTIVITY_BIRTHDAY;
import static android.app.people.ConversationStatus.ACTIVITY_GAME;
import static android.app.people.ConversationStatus.ACTIVITY_NEW_STORY;
@@ -25,6 +26,7 @@
import static android.app.people.PeopleSpaceTile.SHOW_CONTACTS;
import static android.app.people.PeopleSpaceTile.SHOW_IMPORTANT_CONVERSATIONS;
import static android.app.people.PeopleSpaceTile.SHOW_STARRED_CONTACTS;
+import static android.appwidget.AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT;
import static android.appwidget.AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH;
import static com.android.systemui.people.PeopleSpaceUtils.STARRED_CONTACT;
@@ -127,6 +129,9 @@
.build();
@Mock
+ private Icon mIcon;
+
+ @Mock
private Context mMockContext;
@Mock
private PackageManager mPackageManager;
@@ -169,7 +174,7 @@
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
getSizeInDp(R.dimen.required_width_for_large));
- mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
+ mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
getSizeInDp(R.dimen.required_height_for_large));
RemoteViews largeView = getPeopleTileViewHelper(
PERSON_TILE_WITHOUT_NOTIFICATION, mOptions).getViews();
@@ -218,7 +223,7 @@
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
getSizeInDp(R.dimen.required_width_for_large));
- mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
+ mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
getSizeInDp(R.dimen.required_height_for_large));
RemoteViews largeView = getPeopleTileViewHelper(
tileWithLastInteraction, mOptions).getViews();
@@ -278,7 +283,7 @@
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
getSizeInDp(R.dimen.required_width_for_large));
- mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
+ mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
getSizeInDp(R.dimen.required_height_for_large));
RemoteViews largeView = getPeopleTileViewHelper(
tileWithAvailabilityAndNewStory, mOptions).getViews();
@@ -340,7 +345,7 @@
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
getSizeInDp(R.dimen.required_width_for_large));
- mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
+ mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
getSizeInDp(R.dimen.required_height_for_large));
RemoteViews largeView = getPeopleTileViewHelper(
tileWithStatusTemplate, mOptions).getViews();
@@ -376,6 +381,8 @@
assertEquals(name.getText(), NAME);
assertEquals(View.GONE, result.findViewById(R.id.subtext).getVisibility());
assertEquals(View.VISIBLE, result.findViewById(R.id.predefined_icon).getVisibility());
+ assertEquals(View.GONE, result.findViewById(R.id.scrim_layout).getVisibility());
+ assertEquals(View.GONE, result.findViewById(R.id.image).getVisibility());
// Has availability.
assertEquals(View.VISIBLE, result.findViewById(R.id.availability).getVisibility());
// Has person icon.
@@ -403,7 +410,7 @@
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
getSizeInDp(R.dimen.required_width_for_large));
- mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
+ mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
getSizeInDp(R.dimen.required_height_for_large));
RemoteViews largeView = getPeopleTileViewHelper(
tileWithStatusTemplate, mOptions).getViews();
@@ -413,6 +420,8 @@
assertEquals(name.getText(), NAME);
assertEquals(View.GONE, largeResult.findViewById(R.id.subtext).getVisibility());
assertEquals(View.VISIBLE, largeResult.findViewById(R.id.predefined_icon).getVisibility());
+ assertEquals(View.GONE, largeResult.findViewById(R.id.scrim_layout).getVisibility());
+ assertEquals(View.GONE, largeResult.findViewById(R.id.image).getVisibility());
// Has availability.
assertEquals(View.VISIBLE, largeResult.findViewById(R.id.availability).getVisibility());
// Has person icon.
@@ -426,6 +435,55 @@
}
@Test
+ public void testCreateRemoteViewsWithStatusTemplateWithImageOnMediumAndLarge() {
+ PeopleSpaceTile tileWithIconInStatusTemplate =
+ PERSON_TILE_WITHOUT_NOTIFICATION.toBuilder().setStatuses(
+ Arrays.asList(new ConversationStatus.Builder(PERSON_TILE.getId(),
+ ACTIVITY_ANNIVERSARY).setDescription("Anniversary").setAvailability(
+ AVAILABILITY_AVAILABLE).setIcon(mIcon).build())).build();
+ RemoteViews views = getPeopleTileViewHelper(
+ tileWithIconInStatusTemplate, mOptions).getViews();
+ View result = views.apply(mContext, null);
+
+ assertEquals(View.GONE, result.findViewById(R.id.subtext).getVisibility());
+ assertEquals(View.VISIBLE, result.findViewById(R.id.predefined_icon).getVisibility());
+ assertEquals(View.VISIBLE, result.findViewById(R.id.scrim_layout).getVisibility());
+ assertEquals(View.GONE, result.findViewById(R.id.image).getVisibility());
+ // Has availability.
+ assertEquals(View.VISIBLE, result.findViewById(R.id.availability).getVisibility());
+ // Has person icon.
+ assertEquals(View.VISIBLE, result.findViewById(R.id.person_icon).getVisibility());
+ // Has status.
+ TextView statusContent = (TextView) result.findViewById(R.id.name);
+ assertEquals(statusContent.getText(), "Anniversary");
+ assertThat(statusContent.getMaxLines()).isEqualTo(1);
+
+ mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
+ getSizeInDp(R.dimen.required_width_for_large));
+ mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
+ getSizeInDp(R.dimen.required_height_for_large));
+ RemoteViews largeView = getPeopleTileViewHelper(
+ tileWithIconInStatusTemplate, mOptions).getViews();
+ View largeResult = largeView.apply(mContext, null);
+
+ assertEquals(View.GONE, largeResult.findViewById(R.id.subtext).getVisibility());
+ assertEquals(View.GONE, largeResult.findViewById(R.id.name).getVisibility());
+ assertEquals(View.VISIBLE, largeResult.findViewById(R.id.predefined_icon).getVisibility());
+ assertEquals(View.VISIBLE, largeResult.findViewById(R.id.scrim_layout).getVisibility());
+ assertEquals(View.GONE, largeResult.findViewById(R.id.image).getVisibility());
+ // Has availability.
+ assertEquals(View.VISIBLE, largeResult.findViewById(R.id.availability).getVisibility());
+ // Has person icon.
+ View personIcon = largeResult.findViewById(R.id.person_icon);
+ assertEquals(View.VISIBLE, personIcon.getVisibility());
+ // Has status content.
+ statusContent = (TextView) largeResult.findViewById(R.id.text_content);
+ assertEquals(View.VISIBLE, statusContent.getVisibility());
+ assertEquals(statusContent.getText(), "Anniversary");
+ assertThat(statusContent.getMaxLines()).isEqualTo(2);
+ }
+
+ @Test
public void testCreateRemoteViewsWithPackageSuspended() {
PeopleSpaceTile tile = PERSON_TILE.toBuilder()
.setIsPackageSuspended(true)
@@ -434,7 +492,7 @@
tile, mOptions).getViews();
View result = views.apply(mContext, null);
- assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_empty_layout);
+ assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_suppressed_layout);
}
@Test
@@ -446,7 +504,7 @@
tile, mOptions).getViews();
View result = views.apply(mContext, null);
- assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_empty_layout);
+ assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_work_profile_quiet_layout);
}
@Test
@@ -458,7 +516,7 @@
tileWithDndBlocking, mOptions).getViews();
View result = views.apply(mContext, null);
- assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_empty_layout);
+ assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_suppressed_layout);
tileWithDndBlocking = PERSON_TILE.toBuilder()
.setNotificationPolicyState(BLOCK_CONVERSATIONS)
@@ -468,7 +526,7 @@
tileWithDndBlocking, mOptions).getViews();
result = views.apply(mContext, null);
- assertNotEquals(result.getSourceLayoutResId(), R.layout.people_tile_empty_layout);
+ assertNotEquals(result.getSourceLayoutResId(), R.layout.people_tile_suppressed_layout);
tileWithDndBlocking = PERSON_TILE.toBuilder()
.setNotificationPolicyState(SHOW_IMPORTANT_CONVERSATIONS)
@@ -477,7 +535,7 @@
tileWithDndBlocking, mOptions).getViews();
result = views.apply(mContext, null);
- assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_empty_layout);
+ assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_suppressed_layout);
tileWithDndBlocking = PERSON_TILE.toBuilder()
.setNotificationPolicyState(SHOW_IMPORTANT_CONVERSATIONS)
@@ -487,7 +545,7 @@
tileWithDndBlocking, mOptions).getViews();
result = views.apply(mContext, null);
- assertNotEquals(result.getSourceLayoutResId(), R.layout.people_tile_empty_layout);
+ assertNotEquals(result.getSourceLayoutResId(), R.layout.people_tile_suppressed_layout);
tileWithDndBlocking = PERSON_TILE.toBuilder()
.setNotificationPolicyState(SHOW_STARRED_CONTACTS)
@@ -497,7 +555,7 @@
tileWithDndBlocking, mOptions).getViews();
result = views.apply(mContext, null);
- assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_empty_layout);
+ assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_suppressed_layout);
tileWithDndBlocking = PERSON_TILE.toBuilder()
.setNotificationPolicyState(SHOW_STARRED_CONTACTS)
@@ -507,7 +565,7 @@
tileWithDndBlocking, mOptions).getViews();
result = views.apply(mContext, null);
- assertNotEquals(result.getSourceLayoutResId(), R.layout.people_tile_empty_layout);
+ assertNotEquals(result.getSourceLayoutResId(), R.layout.people_tile_suppressed_layout);
tileWithDndBlocking = PERSON_TILE.toBuilder()
.setNotificationPolicyState(SHOW_CONTACTS)
@@ -517,7 +575,7 @@
tileWithDndBlocking, mOptions).getViews();
result = views.apply(mContext, null);
- assertNotEquals(result.getSourceLayoutResId(), R.layout.people_tile_empty_layout);
+ assertNotEquals(result.getSourceLayoutResId(), R.layout.people_tile_suppressed_layout);
tileWithDndBlocking = PERSON_TILE.toBuilder()
.setNotificationPolicyState(SHOW_CONTACTS)
@@ -527,7 +585,7 @@
tileWithDndBlocking, mOptions).getViews();
result = views.apply(mContext, null);
- assertNotEquals(result.getSourceLayoutResId(), R.layout.people_tile_empty_layout);
+ assertNotEquals(result.getSourceLayoutResId(), R.layout.people_tile_suppressed_layout);
tileWithDndBlocking = PERSON_TILE.toBuilder()
.setNotificationPolicyState(SHOW_CONTACTS)
@@ -536,7 +594,7 @@
tileWithDndBlocking, mOptions).getViews();
result = views.apply(mContext, null);
- assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_empty_layout);
+ assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_suppressed_layout);
}
@Test
@@ -581,7 +639,7 @@
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
getSizeInDp(R.dimen.required_width_for_large));
- mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
+ mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
getSizeInDp(R.dimen.required_height_for_large));
RemoteViews largeView = getPeopleTileViewHelper(
tileWithMissedCallNotification, mOptions).getViews();
@@ -617,6 +675,7 @@
assertEquals(name.getText(), NAME);
assertEquals(View.GONE, result.findViewById(R.id.subtext).getVisibility());
assertEquals(View.GONE, result.findViewById(R.id.predefined_icon).getVisibility());
+ assertEquals(View.GONE, result.findViewById(R.id.scrim_layout).getVisibility());
// Has availability.
assertEquals(View.VISIBLE, result.findViewById(R.id.availability).getVisibility());
// Has person icon.
@@ -649,7 +708,7 @@
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
getSizeInDp(R.dimen.required_width_for_large));
- mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
+ mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
getSizeInDp(R.dimen.required_height_for_large));
RemoteViews largeView = getPeopleTileViewHelper(
tileWithStatusAndNotification, mOptions).getViews();
@@ -659,6 +718,7 @@
assertEquals(name.getText(), NAME);
assertEquals(View.GONE, largeResult.findViewById(R.id.subtext).getVisibility());
assertEquals(View.GONE, largeResult.findViewById(R.id.predefined_icon).getVisibility());
+ assertEquals(View.GONE, largeResult.findViewById(R.id.scrim_layout).getVisibility());
// Has availability.
assertEquals(View.VISIBLE, largeResult.findViewById(R.id.availability).getVisibility());
// Has person icon.
@@ -725,7 +785,7 @@
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
getSizeInDp(R.dimen.required_width_for_large));
- mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
+ mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
getSizeInDp(R.dimen.required_height_for_large));
RemoteViews largeView = getPeopleTileViewHelper(
tileWithStatusAndNotification, mOptions).getViews();
@@ -802,7 +862,7 @@
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
getSizeInDp(R.dimen.required_width_for_large));
- mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
+ mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
getSizeInDp(R.dimen.required_height_for_large));
RemoteViews largeView = getPeopleTileViewHelper(
tileWithStatusAndNotification, mOptions).getViews();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java
index 107ce28..d63c529 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/people/widget/PeopleSpaceWidgetManagerTest.java
@@ -1041,7 +1041,6 @@
Bundle newOptions = new Bundle();
mManager.onAppWidgetOptionsChanged(SECOND_WIDGET_ID_WITH_SHORTCUT, newOptions);
-
// Check that options is not modified
verify(mAppWidgetManager, never()).updateAppWidgetOptions(
eq(SECOND_WIDGET_ID_WITH_SHORTCUT), any());
@@ -1478,6 +1477,8 @@
widgetSp5.edit().clear().commit();
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
sp.edit().clear().commit();
+ mManager.mListeners.clear();
+ mManager.mTiles.clear();
}
private void setStorageForTile(String shortcutId, String packageName, int widgetId,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSDetailTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSDetailTest.java
index c050b62..ba2b37c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSDetailTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSDetailTest.java
@@ -30,6 +30,7 @@
import android.testing.ViewUtils;
import android.view.LayoutInflater;
import android.view.View;
+import android.widget.FrameLayout;
import androidx.test.filters.SmallTest;
@@ -58,24 +59,26 @@
private DetailAdapter mMockDetailAdapter;
private TestableLooper mTestableLooper;
private UiEventLoggerFake mUiEventLogger;
+ private FrameLayout mParent;
@Before
public void setup() throws Exception {
mTestableLooper = TestableLooper.get(this);
mUiEventLogger = QSEvents.INSTANCE.setLoggerForTesting();
- mTestableLooper.runWithLooper(() -> {
- mMetricsLogger = mDependency.injectMockDependency(MetricsLogger.class);
- mActivityStarter = mDependency.injectMockDependency(ActivityStarter.class);
- mQsDetail = (QSDetail) LayoutInflater.from(mContext).inflate(R.layout.qs_detail, null);
- mQsPanelController = mock(QSPanelController.class);
- mQuickHeader = mock(QuickStatusBarHeader.class);
- mQsDetail.setQsPanel(mQsPanelController, mQuickHeader, mock(QSFooter.class));
+ mParent = new FrameLayout(mContext);
+ mMetricsLogger = mDependency.injectMockDependency(MetricsLogger.class);
+ mActivityStarter = mDependency.injectMockDependency(ActivityStarter.class);
+ LayoutInflater.from(mContext).inflate(R.layout.qs_detail, mParent);
+ mQsDetail = (QSDetail) mParent.getChildAt(0);
- mMockDetailAdapter = mock(DetailAdapter.class);
- when(mMockDetailAdapter.createDetailView(any(), any(), any()))
- .thenReturn(mock(View.class));
- });
+ mQsPanelController = mock(QSPanelController.class);
+ mQuickHeader = mock(QuickStatusBarHeader.class);
+ mQsDetail.setQsPanel(mQsPanelController, mQuickHeader, mock(QSFooter.class));
+
+ mMockDetailAdapter = mock(DetailAdapter.class);
+ when(mMockDetailAdapter.createDetailView(any(), any(), any()))
+ .thenReturn(new View(mContext));
// Only detail in use is the user detail
when(mMockDetailAdapter.openDetailEvent())
@@ -84,16 +87,18 @@
.thenReturn(QSUserSwitcherEvent.QS_USER_DETAIL_CLOSE);
when(mMockDetailAdapter.moreSettingsEvent())
.thenReturn(QSUserSwitcherEvent.QS_USER_MORE_SETTINGS);
+ ViewUtils.attachView(mParent);
}
@After
public void tearDown() {
QSEvents.INSTANCE.resetLogger();
+ mTestableLooper.processAllMessages();
+ ViewUtils.detachView(mParent);
}
@Test
public void testShowDetail_Metrics() {
- ViewUtils.attachView(mQsDetail);
mTestableLooper.processAllMessages();
mQsDetail.handleShowingDetail(mMockDetailAdapter, 0, 0, false);
@@ -107,14 +112,10 @@
assertEquals(1, mUiEventLogger.numLogs());
assertEquals(QSUserSwitcherEvent.QS_USER_DETAIL_CLOSE.getId(), mUiEventLogger.eventId(0));
-
- ViewUtils.detachView(mQsDetail);
- mTestableLooper.processAllMessages();
}
@Test
public void testMoreSettingsButton() {
- ViewUtils.attachView(mQsDetail);
mTestableLooper.processAllMessages();
mQsDetail.handleShowingDetail(mMockDetailAdapter, 0, 0, false);
@@ -127,9 +128,6 @@
assertEquals(QSUserSwitcherEvent.QS_USER_MORE_SETTINGS.getId(), mUiEventLogger.eventId(0));
verify(mActivityStarter).postStartActivityDismissingKeyguard(any(), anyInt());
-
- ViewUtils.detachView(mQsDetail);
- mTestableLooper.processAllMessages();
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFooterViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFooterViewControllerTest.java
index d35597f..6f7bf3b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFooterViewControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFooterViewControllerTest.java
@@ -21,6 +21,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -35,6 +36,7 @@
import androidx.test.filters.SmallTest;
import com.android.internal.logging.MetricsLogger;
+import com.android.internal.logging.UiEventLogger;
import com.android.internal.logging.testing.FakeMetricsLogger;
import com.android.systemui.Dependency;
import com.android.systemui.R;
@@ -82,6 +84,7 @@
private QuickQSPanelController mQuickQSPanelController;
private FakeTunerService mFakeTunerService;
private MetricsLogger mMetricsLogger = new FakeMetricsLogger();
+ private FalsingManagerFake mFalsingManager;
@Mock
private SettingsButton mSettingsButton;
@@ -95,12 +98,15 @@
private View mPowerMenuLiteView;
@Mock
private GlobalActionsDialogLite mGlobalActionsDialog;
+ @Mock
+ private UiEventLogger mUiEventLogger;
private QSFooterViewController mController;
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
+ mFalsingManager = new FalsingManagerFake();
injectLeakCheckedDependencies(ALL_SUPPORTED_CLASSES);
@@ -121,7 +127,8 @@
mController = new QSFooterViewController(mView, mUserManager, mUserInfoController,
mActivityStarter, mDeviceProvisionedController, mUserTracker, mQSPanelController,
mMultiUserSwitchController, mQuickQSPanelController, mFakeTunerService,
- mMetricsLogger, new FalsingManagerFake(), false, mGlobalActionsDialog);
+ mMetricsLogger, mFalsingManager, false, mGlobalActionsDialog,
+ mUiEventLogger);
mController.init();
}
@@ -154,4 +161,27 @@
// Verify Settings wasn't launched.
verify(mActivityStarter, never()).startActivity(any(), anyBoolean());
}
+
+ @Test
+ public void testLogPowerMenuClick() {
+ // Enable power menu button
+ mController = new QSFooterViewController(mView, mUserManager, mUserInfoController,
+ mActivityStarter, mDeviceProvisionedController, mUserTracker, mQSPanelController,
+ mMultiUserSwitchController, mQuickQSPanelController, mFakeTunerService,
+ mMetricsLogger, new FalsingManagerFake(), true, mGlobalActionsDialog,
+ mUiEventLogger);
+ mController.init();
+ mController.setExpanded(true);
+ mFalsingManager.setFalseTap(false);
+
+ ArgumentCaptor<View.OnClickListener> onClickCaptor =
+ ArgumentCaptor.forClass(View.OnClickListener.class);
+ verify(mPowerMenuLiteView).setOnClickListener(onClickCaptor.capture());
+
+ onClickCaptor.getValue().onClick(mPowerMenuLiteView);
+
+ // Verify clicks are logged
+ verify(mUiEventLogger, times(1))
+ .log(GlobalActionsDialogLite.GlobalActionsEvent.GA_OPEN_QS);
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java
index 234dec2..7caf0dd 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java
@@ -21,6 +21,7 @@
import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -189,6 +190,29 @@
}
@Test
+ public void testUntappableView_profileOwnerOfOrgOwnedDevice() {
+ when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true);
+
+ mFooter.refreshState();
+
+ TestableLooper.get(this).processAllMessages();
+ assertFalse(mRootView.isClickable());
+ assertEquals(View.GONE, mRootView.findViewById(R.id.footer_icon).getVisibility());
+ }
+
+ @Test
+ public void testTappableView_profileOwnerOfOrgOwnedDevice_networkLoggingEnabled() {
+ when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true);
+ when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true);
+
+ mFooter.refreshState();
+
+ TestableLooper.get(this).processAllMessages();
+ assertTrue(mRootView.isClickable());
+ assertEquals(View.VISIBLE, mRootView.findViewById(R.id.footer_icon).getVisibility());
+ }
+
+ @Test
public void testNetworkLoggingEnabled_deviceOwner() {
when(mSecurityController.isDeviceManaged()).thenReturn(true);
when(mSecurityController.isNetworkLoggingEnabled()).thenReturn(true);
@@ -435,10 +459,7 @@
@Test
public void testGetManagementMessage_noManagement() {
assertEquals(null, mFooter.getManagementMessage(
- /* isDeviceManaged= */ false,
- MANAGING_ORGANIZATION,
- /* isProfileOwnerOfOrganizationOwnedDevice= */ false,
- MANAGING_ORGANIZATION));
+ /* isDeviceManaged= */ false, MANAGING_ORGANIZATION));
}
@Test
@@ -446,16 +467,11 @@
assertEquals(mContext.getString(R.string.monitoring_description_named_management,
MANAGING_ORGANIZATION),
mFooter.getManagementMessage(
- /* isDeviceManaged= */ true,
- MANAGING_ORGANIZATION,
- /* isProfileOwnerOfOrganizationOwnedDevice= */ false,
- /* workProfileOrganizationName= */ null));
+ /* isDeviceManaged= */ true, MANAGING_ORGANIZATION));
assertEquals(mContext.getString(R.string.monitoring_description_management),
mFooter.getManagementMessage(
/* isDeviceManaged= */ true,
- /* organizationName= */ null,
- /* isProfileOwnerOfOrganizationOwnedDevice= */ false,
- /* workProfileOrganizationName= */ null));
+ /* organizationName= */ null));
}
@Test
@@ -467,27 +483,7 @@
assertEquals(mContext.getString(R.string.monitoring_financed_description_named_management,
MANAGING_ORGANIZATION, MANAGING_ORGANIZATION),
mFooter.getManagementMessage(
- /* isDeviceManaged= */ true,
- MANAGING_ORGANIZATION,
- /* isProfileOwnerOfOrganizationOwnedDevice= */ false,
- /* workProfileOrganizationName= */ null));
- }
-
- @Test
- public void testGetManagementMessage_profileOwnerOfOrganizationOwnedDevice() {
- assertEquals(mContext.getString(R.string.monitoring_description_named_management,
- MANAGING_ORGANIZATION),
- mFooter.getManagementMessage(
- /* isDeviceManaged= */ false,
- /* organizationName= */ null,
- /* isProfileOwnerOfOrganizationOwnedDevice= */ true,
- MANAGING_ORGANIZATION));
- assertEquals(mContext.getString(R.string.monitoring_description_management),
- mFooter.getManagementMessage(
- /* isDeviceManaged= */ false,
- /* organizationName= */ null,
- /* isProfileOwnerOfOrganizationOwnedDevice= */ true,
- /* workProfileOrganizationName= */ null));
+ /* isDeviceManaged= */ true, MANAGING_ORGANIZATION));
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt
index e5e2e53..126dca5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileViewImplTest.kt
@@ -20,6 +20,7 @@
import android.graphics.drawable.Drawable
import android.service.quicksettings.Tile
import android.testing.AndroidTestingRunner
+import android.testing.TestableLooper
import android.text.TextUtils
import android.view.View
import androidx.test.filters.SmallTest
@@ -36,6 +37,7 @@
@RunWith(AndroidTestingRunner::class)
@SmallTest
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
class QSTileViewImplTest : SysuiTestCase() {
@Mock
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt
new file mode 100644
index 0000000..5366858
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt
@@ -0,0 +1,518 @@
+/*
+ * Copyright (C) 2021 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.lockscreen
+
+
+import android.app.smartspace.SmartspaceManager
+import android.app.smartspace.SmartspaceSession
+import android.app.smartspace.SmartspaceSession.OnTargetsAvailableListener
+import android.app.smartspace.SmartspaceTarget
+import android.content.ComponentName
+import android.content.ContentResolver
+import android.content.pm.UserInfo
+import android.database.ContentObserver
+import android.graphics.drawable.Drawable
+import android.net.Uri
+import android.os.Handler
+import android.os.UserHandle
+import android.provider.Settings
+import android.view.View
+import android.widget.FrameLayout
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.plugins.ActivityStarter
+import com.android.systemui.plugins.BcSmartspaceDataPlugin
+import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceTargetListener
+import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceView
+import com.android.systemui.plugins.FalsingManager
+import com.android.systemui.plugins.statusbar.StatusBarStateController
+import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener
+import com.android.systemui.settings.UserTracker
+import com.android.systemui.statusbar.FeatureFlags
+import com.android.systemui.statusbar.policy.ConfigurationController
+import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener
+import com.android.systemui.util.concurrency.FakeExecution
+import com.android.systemui.util.concurrency.FakeExecutor
+import com.android.systemui.util.mockito.any
+import com.android.systemui.util.mockito.capture
+import com.android.systemui.util.mockito.eq
+import com.android.systemui.util.settings.SecureSettings
+import com.android.systemui.util.time.FakeSystemClock
+import org.junit.Assert.assertEquals
+import org.junit.Before
+import org.junit.Test
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mock
+import org.mockito.Mockito.`when`
+import org.mockito.Mockito.anyInt
+import org.mockito.Mockito.clearInvocations
+import org.mockito.Mockito.mock
+import org.mockito.Mockito.never
+import org.mockito.Mockito.spy
+import org.mockito.Mockito.verify
+import org.mockito.MockitoAnnotations
+import java.util.Optional
+
+@SmallTest
+class LockscreenSmartspaceControllerTest : SysuiTestCase() {
+ @Mock
+ private lateinit var featureFlags: FeatureFlags
+ @Mock
+ private lateinit var smartspaceManager: SmartspaceManager
+ @Mock
+ private lateinit var smartspaceSession: SmartspaceSession
+ @Mock
+ private lateinit var activityStarter: ActivityStarter
+ @Mock
+ private lateinit var falsingManager: FalsingManager
+ @Mock
+ private lateinit var secureSettings: SecureSettings
+ @Mock
+ private lateinit var userTracker: UserTracker
+ @Mock
+ private lateinit var contentResolver: ContentResolver
+ @Mock
+ private lateinit var configurationController: ConfigurationController
+ @Mock
+ private lateinit var statusBarStateController: StatusBarStateController
+ @Mock
+ private lateinit var handler: Handler
+
+ @Mock
+ private lateinit var plugin: BcSmartspaceDataPlugin
+ @Mock
+ private lateinit var controllerListener: SmartspaceTargetListener
+
+ @Captor
+ private lateinit var sessionListenerCaptor: ArgumentCaptor<OnTargetsAvailableListener>
+ @Captor
+ private lateinit var userTrackerCaptor: ArgumentCaptor<UserTracker.Callback>
+ @Captor
+ private lateinit var settingsObserverCaptor: ArgumentCaptor<ContentObserver>
+ @Captor
+ private lateinit var configChangeListenerCaptor: ArgumentCaptor<ConfigurationListener>
+ @Captor
+ private lateinit var statusBarStateListenerCaptor: ArgumentCaptor<StateListener>
+
+ private lateinit var sessionListener: OnTargetsAvailableListener
+ private lateinit var userListener: UserTracker.Callback
+ private lateinit var settingsObserver: ContentObserver
+ private lateinit var configChangeListener: ConfigurationListener
+ private lateinit var statusBarStateListener: StateListener
+
+ private val clock = FakeSystemClock()
+ private val executor = FakeExecutor(clock)
+ private val execution = FakeExecution()
+ private val fakeParent = FrameLayout(context)
+ private val fakePrivateLockscreenSettingUri = Uri.Builder().appendPath("test").build()
+
+ private val userHandlePrimary: UserHandle = UserHandle(0)
+ private val userHandleManaged: UserHandle = UserHandle(2)
+ private val userHandleSecondary: UserHandle = UserHandle(3)
+
+ private val userList = listOf(
+ mockUserInfo(userHandlePrimary, isManagedProfile = false),
+ mockUserInfo(userHandleManaged, isManagedProfile = true),
+ mockUserInfo(userHandleSecondary, isManagedProfile = false)
+ )
+
+ private lateinit var controller: LockscreenSmartspaceController
+
+ @Before
+ fun setUp() {
+ MockitoAnnotations.initMocks(this)
+
+ `when`(featureFlags.isSmartspaceEnabled).thenReturn(true)
+
+ `when`(secureSettings.getUriFor(PRIVATE_LOCKSCREEN_SETTING))
+ .thenReturn(fakePrivateLockscreenSettingUri)
+ `when`(smartspaceManager.createSmartspaceSession(any())).thenReturn(smartspaceSession)
+ `when`(plugin.getView(any())).thenReturn(fakeSmartspaceView)
+ `when`(userTracker.userProfiles).thenReturn(userList)
+ `when`(statusBarStateController.dozeAmount).thenReturn(0.5f)
+
+ setActiveUser(userHandlePrimary)
+ setAllowPrivateNotifications(userHandlePrimary, true)
+ setAllowPrivateNotifications(userHandleManaged, true)
+ setAllowPrivateNotifications(userHandleSecondary, true)
+
+ controller = LockscreenSmartspaceController(
+ context,
+ featureFlags,
+ smartspaceManager,
+ activityStarter,
+ falsingManager,
+ secureSettings,
+ userTracker,
+ contentResolver,
+ configurationController,
+ statusBarStateController,
+ execution,
+ executor,
+ handler,
+ Optional.of(plugin)
+ )
+ }
+
+ @Test(expected = RuntimeException::class)
+ fun testThrowsIfFlagIsDisabled() {
+ // GIVEN the feature flag is disabled
+ `when`(featureFlags.isSmartspaceEnabled).thenReturn(false)
+
+ // WHEN we try to build the view
+ controller.buildAndConnectView(fakeParent)
+
+ // THEN an exception is thrown
+ }
+
+ @Test
+ fun testListenersAreRegistered() {
+ // GIVEN a listener is added after a session is created
+ connectSession()
+
+ // WHEN a listener is registered
+ controller.addListener(controllerListener)
+
+ // THEN the listener is registered to the underlying plugin
+ verify(plugin).registerListener(controllerListener)
+ }
+
+ @Test
+ fun testEarlyRegisteredListenersAreAttachedAfterConnected() {
+ // GIVEN a listener that is registered before the session is created
+ controller.addListener(controllerListener)
+
+ // WHEN the session is created
+ connectSession()
+
+ // THEN the listener is subsequently registered
+ verify(plugin).registerListener(controllerListener)
+ }
+
+ @Test
+ fun testEmptyListIsEmittedAfterDisconnect() {
+ // GIVEN a registered listener on an active session
+ connectSession()
+ clearInvocations(plugin)
+
+ // WHEN the session is closed
+ controller.disconnect()
+
+ // THEN the listener receives an empty list of targets
+ verify(plugin).onTargetsAvailable(emptyList())
+ }
+
+ @Test
+ fun testUserChangeReloadsSmartspace() {
+ // GIVEN a connected smartspace session
+ connectSession()
+
+ // WHEN the active user changes
+ userListener.onUserChanged(-1, context)
+
+ // THEN we request a new smartspace update
+ verify(smartspaceSession).requestSmartspaceUpdate()
+ }
+
+ @Test
+ fun testSettingsChangeReloadsSmartspace() {
+ // GIVEN a connected smartspace session
+ connectSession()
+
+ // WHEN the lockscreen privacy setting changes
+ settingsObserver.onChange(true, null)
+
+ // THEN we request a new smartspace update
+ verify(smartspaceSession).requestSmartspaceUpdate()
+ }
+
+ @Test
+ fun testThemeChangeUpdatesTextColor() {
+ // GIVEN a connected smartspace session
+ connectSession()
+
+ // WHEN the theme changes
+ configChangeListener.onThemeChanged()
+
+ // We update the new text color to match the wallpaper color
+ verify(fakeSmartspaceView).setPrimaryTextColor(anyInt())
+ }
+
+ @Test
+ fun testDozeAmountChangeUpdatesView() {
+ // GIVEN a connected smartspace session
+ connectSession()
+
+ // WHEN the doze amount changes
+ statusBarStateListener.onDozeAmountChanged(0.1f, 0.7f)
+
+ // We pass that along to the view
+ verify(fakeSmartspaceView).setDozeAmount(0.7f)
+ }
+
+ @Test
+ fun testSensitiveTargetsAreNotFilteredIfAllowed() {
+ // GIVEN the active and managed users allow sensitive content
+ connectSession()
+
+ // WHEN we receive a list of targets
+ val targets = listOf(
+ makeTarget(1, userHandlePrimary, isSensitive = true),
+ makeTarget(2, userHandleManaged, isSensitive = true),
+ makeTarget(3, userHandlePrimary, isSensitive = true)
+ )
+ sessionListener.onTargetsAvailable(targets)
+
+ // THEN all sensitive content is still shown
+ verify(plugin).onTargetsAvailable(eq(targets))
+ }
+
+ @Test
+ fun testNonSensitiveTargetsAreNeverFiltered() {
+ // GIVEN the active user doesn't allow sensitive lockscreen content
+ setAllowPrivateNotifications(userHandlePrimary, false)
+ connectSession()
+
+ // WHEN we receive a list of targets
+ val targets = listOf(
+ makeTarget(1, userHandlePrimary),
+ makeTarget(2, userHandlePrimary),
+ makeTarget(3, userHandlePrimary)
+ )
+ sessionListener.onTargetsAvailable(targets)
+
+ // THEN all non-sensitive content is still shown
+ verify(plugin).onTargetsAvailable(eq(targets))
+ }
+
+ @Test
+ fun testSensitiveTargetsAreFilteredOutForAppropriateUsers() {
+ // GIVEN the active and managed users don't allow sensitive lockscreen content
+ setAllowPrivateNotifications(userHandlePrimary, false)
+ setAllowPrivateNotifications(userHandleManaged, false)
+ connectSession()
+
+ // WHEN we receive a list of targets
+ val targets = listOf(
+ makeTarget(0, userHandlePrimary),
+ makeTarget(1, userHandlePrimary, isSensitive = true),
+ makeTarget(2, userHandleManaged, isSensitive = true),
+ makeTarget(3, userHandleManaged),
+ makeTarget(4, userHandlePrimary, isSensitive = true),
+ makeTarget(5, userHandlePrimary),
+ makeTarget(6, userHandleSecondary, isSensitive = true)
+ )
+ sessionListener.onTargetsAvailable(targets)
+
+ // THEN only non-sensitive content from those accounts is shown
+ verify(plugin).onTargetsAvailable(eq(listOf(
+ targets[0],
+ targets[3],
+ targets[5]
+ )))
+ }
+
+ @Test
+ fun testSettingsAreReloaded() {
+ // GIVEN a connected session where the privacy settings later flip to false
+ connectSession()
+ setAllowPrivateNotifications(userHandlePrimary, false)
+ setAllowPrivateNotifications(userHandleManaged, false)
+ settingsObserver.onChange(true, fakePrivateLockscreenSettingUri)
+
+ // WHEN we receive a new list of targets
+ val targets = listOf(
+ makeTarget(1, userHandlePrimary, isSensitive = true),
+ makeTarget(2, userHandleManaged, isSensitive = true),
+ makeTarget(4, userHandlePrimary, isSensitive = true)
+ )
+ sessionListener.onTargetsAvailable(targets)
+
+ // THEN we filter based on the new settings values
+ verify(plugin).onTargetsAvailable(emptyList())
+ }
+
+ @Test
+ fun testRecognizeSwitchToSecondaryUser() {
+ // GIVEN an inactive secondary user that doesn't allow sensitive content
+ setAllowPrivateNotifications(userHandleSecondary, false)
+ connectSession()
+
+ // WHEN the secondary user becomes the active user
+ setActiveUser(userHandleSecondary)
+ userListener.onUserChanged(userHandleSecondary.identifier, context)
+
+ // WHEN we receive a new list of targets
+ val targets = listOf(
+ makeTarget(0, userHandlePrimary),
+ makeTarget(1, userHandleSecondary),
+ makeTarget(2, userHandleSecondary, isSensitive = true),
+ makeTarget(3, userHandleManaged),
+ makeTarget(4, userHandleSecondary),
+ makeTarget(5, userHandleManaged),
+ makeTarget(6, userHandlePrimary)
+ )
+ sessionListener.onTargetsAvailable(targets)
+
+ // THEN only non-sensitive content from the secondary user is shown
+ verify(plugin).onTargetsAvailable(listOf(
+ targets[1],
+ targets[4]
+ ))
+ }
+
+ @Test
+ fun testUnregisterListenersOnCleanup() {
+ // GIVEN a connected session
+ connectSession()
+
+ // WHEN we are told to cleanup
+ controller.disconnect()
+
+ // THEN we disconnect from the session and unregister any listeners
+ verify(smartspaceSession).removeOnTargetsAvailableListener(sessionListener)
+ verify(smartspaceSession).close()
+ verify(userTracker).removeCallback(userListener)
+ verify(contentResolver).unregisterContentObserver(settingsObserver)
+ verify(configurationController).removeCallback(configChangeListener)
+ verify(statusBarStateController).removeCallback(statusBarStateListener)
+ }
+
+ @Test
+ fun testBuildViewIsIdempotent() {
+ // GIVEN a connected session
+ connectSession()
+ clearInvocations(plugin)
+
+ // WHEN we disconnect and then reconnect
+ controller.disconnect()
+ controller.buildAndConnectView(fakeParent)
+
+ // THEN the view is not rebuilt
+ verify(plugin, never()).getView(any())
+ assertEquals(fakeSmartspaceView, controller.view)
+ }
+
+ @Test
+ fun testDoubleConnectIsIgnored() {
+ // GIVEN a connected session
+ connectSession()
+ clearInvocations(smartspaceManager)
+ clearInvocations(plugin)
+
+ // WHEN we're asked to connect a second time
+ controller.buildAndConnectView(fakeParent)
+
+ // THEN the existing view and session are reused
+ verify(smartspaceManager, never()).createSmartspaceSession(any())
+ verify(plugin, never()).getView(any())
+ assertEquals(fakeSmartspaceView, controller.view)
+ }
+
+ private fun connectSession(): View {
+ val view = controller.buildAndConnectView(fakeParent)
+
+ verify(smartspaceSession)
+ .addOnTargetsAvailableListener(any(), capture(sessionListenerCaptor))
+ sessionListener = sessionListenerCaptor.value
+
+ verify(userTracker).addCallback(capture(userTrackerCaptor), any())
+ userListener = userTrackerCaptor.value
+
+ verify(contentResolver).registerContentObserver(
+ eq(fakePrivateLockscreenSettingUri),
+ eq(true),
+ capture(settingsObserverCaptor),
+ eq(UserHandle.USER_ALL))
+ settingsObserver = settingsObserverCaptor.value
+
+ verify(configurationController).addCallback(configChangeListenerCaptor.capture())
+ configChangeListener = configChangeListenerCaptor.value
+
+ verify(statusBarStateController).addCallback(statusBarStateListenerCaptor.capture())
+ statusBarStateListener = statusBarStateListenerCaptor.value
+
+ verify(smartspaceSession).requestSmartspaceUpdate()
+ clearInvocations(smartspaceSession)
+
+ verify(fakeSmartspaceView).setPrimaryTextColor(anyInt())
+ verify(fakeSmartspaceView).setDozeAmount(0.5f)
+ clearInvocations(fakeSmartspaceView)
+
+ return view
+ }
+
+ private fun setActiveUser(userHandle: UserHandle) {
+ `when`(userTracker.userId).thenReturn(userHandle.identifier)
+ `when`(userTracker.userHandle).thenReturn(userHandle)
+ }
+
+ private fun mockUserInfo(userHandle: UserHandle, isManagedProfile: Boolean): UserInfo {
+ val userInfo = mock(UserInfo::class.java)
+ `when`(userInfo.userHandle).thenReturn(userHandle)
+ `when`(userInfo.isManagedProfile).thenReturn(isManagedProfile)
+ return userInfo
+ }
+
+ fun makeTarget(
+ id: Int,
+ userHandle: UserHandle,
+ isSensitive: Boolean = false
+ ): SmartspaceTarget {
+ return SmartspaceTarget.Builder(
+ "target$id",
+ ComponentName("testpackage", "testclass$id"),
+ userHandle)
+ .setSensitive(isSensitive)
+ .build()
+ }
+
+ private fun setAllowPrivateNotifications(user: UserHandle, value: Boolean) {
+ `when`(secureSettings.getIntForUser(
+ eq(PRIVATE_LOCKSCREEN_SETTING),
+ anyInt(),
+ eq(user.identifier))
+ ).thenReturn(if (value) 1 else 0)
+ }
+
+ private val fakeSmartspaceView = spy(object : View(context), SmartspaceView {
+ override fun registerDataProvider(plugin: BcSmartspaceDataPlugin?) {
+ }
+
+ override fun setPrimaryTextColor(color: Int) {
+ }
+
+ override fun setDozeAmount(amount: Float) {
+ }
+
+ override fun setIntentStarter(intentStarter: BcSmartspaceDataPlugin.IntentStarter?) {
+ }
+
+ override fun setFalsingManager(falsingManager: FalsingManager?) {
+ }
+
+ override fun setDnd(image: Drawable?, description: String?) {
+ }
+
+ override fun setNextAlarm(image: Drawable?, description: String?) {
+ }
+ })
+}
+
+private const val PRIVATE_LOCKSCREEN_SETTING =
+ Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS
\ No newline at end of file
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java
index 7c8b413..88852f1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupAlertTransferHelperTest.java
@@ -74,6 +74,7 @@
private HeadsUpManager mHeadsUpManager;
@Mock private NotificationEntryManager mNotificationEntryManager;
@Mock private RowContentBindStage mBindStage;
+ @Mock PeopleNotificationIdentifier mPeopleNotificationIdentifier;
@Captor private ArgumentCaptor<NotificationEntryListener> mListenerCaptor;
private NotificationEntryListener mNotificationEntryListener;
private final HashMap<String, NotificationEntry> mPendingEntries = new HashMap<>();
@@ -91,7 +92,7 @@
mGroupManager = new NotificationGroupManagerLegacy(
mock(StatusBarStateController.class),
- () -> mock(PeopleNotificationIdentifier.class),
+ () -> mPeopleNotificationIdentifier,
Optional.of(mock(Bubbles.class)));
mDependency.injectTestDependency(NotificationGroupManagerLegacy.class, mGroupManager);
mGroupManager.setHeadsUpManager(mHeadsUpManager);
@@ -107,15 +108,31 @@
mHeadsUpManager.addListener(mGroupAlertTransferHelper);
}
+ private void mockHasHeadsUpContentView(NotificationEntry entry,
+ boolean hasHeadsUpContentView) {
+ RowContentBindParams params = new RowContentBindParams();
+ if (hasHeadsUpContentView) {
+ params.requireContentViews(FLAG_CONTENT_VIEW_HEADS_UP);
+ }
+ when(mBindStage.getStageParams(eq(entry))).thenReturn(params);
+ }
+
+ private void mockHasHeadsUpContentView(NotificationEntry entry) {
+ mockHasHeadsUpContentView(entry, true);
+ }
+
+ private void mockIsPriority(NotificationEntry priorityEntry) {
+ when(mPeopleNotificationIdentifier.getPeopleNotificationType(eq(priorityEntry)))
+ .thenReturn(PeopleNotificationIdentifier.TYPE_IMPORTANT_PERSON);
+ }
+
@Test
public void testSuppressedSummaryHeadsUpTransfersToChild() {
NotificationEntry summaryEntry = mGroupTestHelper.createSummaryNotification();
mHeadsUpManager.showNotification(summaryEntry);
NotificationEntry childEntry = mGroupTestHelper.createChildNotification();
- RowContentBindParams params = new RowContentBindParams();
- params.requireContentViews(FLAG_CONTENT_VIEW_HEADS_UP);
- when(mBindStage.getStageParams(eq(childEntry))).thenReturn(params);
+ mockHasHeadsUpContentView(childEntry);
// Summary will be suppressed because there is only one child.
mGroupManager.onEntryAdded(summaryEntry);
@@ -180,8 +197,7 @@
NotificationEntry summaryEntry = mGroupTestHelper.createSummaryNotification();
mHeadsUpManager.showNotification(summaryEntry);
NotificationEntry childEntry = mGroupTestHelper.createChildNotification();
- RowContentBindParams params = new RowContentBindParams();
- when(mBindStage.getStageParams(eq(childEntry))).thenReturn(params);
+ mockHasHeadsUpContentView(childEntry, false);
mGroupManager.onEntryAdded(summaryEntry);
mGroupManager.onEntryAdded(childEntry);
@@ -198,8 +214,7 @@
NotificationEntry summaryEntry = mGroupTestHelper.createSummaryNotification();
mHeadsUpManager.showNotification(summaryEntry);
NotificationEntry childEntry = mGroupTestHelper.createChildNotification();
- RowContentBindParams params = new RowContentBindParams();
- when(mBindStage.getStageParams(eq(childEntry))).thenReturn(params);
+ mockHasHeadsUpContentView(childEntry, false);
mGroupManager.onEntryAdded(summaryEntry);
mGroupManager.onEntryAdded(childEntry);
@@ -250,8 +265,7 @@
mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY);
NotificationEntry childEntry =
mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY);
- RowContentBindParams params = new RowContentBindParams();
- when(mBindStage.getStageParams(eq(childEntry))).thenReturn(params);
+ mockHasHeadsUpContentView(childEntry, false);
mHeadsUpManager.showNotification(summaryEntry);
// Trigger a transfer of alert state from summary to child.
@@ -270,8 +284,7 @@
mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY);
NotificationEntry childEntry =
mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY);
- RowContentBindParams params = new RowContentBindParams();
- when(mBindStage.getStageParams(eq(childEntry))).thenReturn(params);
+ mockHasHeadsUpContentView(childEntry, false);
mHeadsUpManager.showNotification(summaryEntry);
// Trigger a transfer of alert state from summary to child.
@@ -294,8 +307,7 @@
mGroupTestHelper.createSummaryNotification(Notification.GROUP_ALERT_SUMMARY);
NotificationEntry childEntry =
mGroupTestHelper.createChildNotification(Notification.GROUP_ALERT_SUMMARY, 47);
- RowContentBindParams params = new RowContentBindParams();
- when(mBindStage.getStageParams(eq(childEntry))).thenReturn(params);
+ mockHasHeadsUpContentView(childEntry, false);
mHeadsUpManager.showNotification(summaryEntry);
// Trigger a transfer of alert state from summary to child.
@@ -311,4 +323,160 @@
assertFalse(mGroupAlertTransferHelper.isAlertTransferPending(childEntry));
}
+
+ @Test
+ public void testOverriddenSummaryHeadsUpTransfersToPriority() {
+ // Creation order is oldest to newest, meaning the priority will be deemed newest
+ int groupAlert = Notification.GROUP_ALERT_SUMMARY;
+ NotificationEntry summaryEntry = mGroupTestHelper.createSummaryNotification(groupAlert);
+ NotificationEntry childEntry = mGroupTestHelper.createChildNotification(groupAlert);
+ NotificationEntry priorityEntry = mGroupTestHelper.createChildNotification(groupAlert);
+ mockIsPriority(priorityEntry);
+
+ // summary gets heads up
+ mHeadsUpManager.showNotification(summaryEntry);
+
+ mockHasHeadsUpContentView(summaryEntry);
+ mockHasHeadsUpContentView(priorityEntry);
+ mockHasHeadsUpContentView(childEntry);
+
+ // Summary will have an alertOverride.
+ mGroupManager.onEntryAdded(summaryEntry);
+ mGroupManager.onEntryAdded(priorityEntry);
+ mGroupManager.onEntryAdded(childEntry);
+
+ // An overridden summary should transfer its alert state to the priority.
+ assertFalse(mHeadsUpManager.isAlerting(summaryEntry.getKey()));
+ assertFalse(mHeadsUpManager.isAlerting(childEntry.getKey()));
+ assertTrue(mHeadsUpManager.isAlerting(priorityEntry.getKey()));
+ }
+
+ @Test
+ public void testOverriddenSummaryHeadsUpTransferDoesNotAlertPriorityIfUninflated() {
+ // Creation order is oldest to newest, meaning the priority will be deemed newest
+ int groupAlert = Notification.GROUP_ALERT_SUMMARY;
+ NotificationEntry summaryEntry = mGroupTestHelper.createSummaryNotification(groupAlert);
+ NotificationEntry childEntry = mGroupTestHelper.createChildNotification(groupAlert);
+ NotificationEntry priorityEntry = mGroupTestHelper.createChildNotification(groupAlert);
+ mockIsPriority(priorityEntry);
+
+ // summary gets heads up
+ mHeadsUpManager.showNotification(summaryEntry);
+
+ mockHasHeadsUpContentView(summaryEntry);
+ mockHasHeadsUpContentView(priorityEntry, false);
+ mockHasHeadsUpContentView(childEntry);
+
+ // Summary will have an alertOverride.
+ mGroupManager.onEntryAdded(summaryEntry);
+ mGroupManager.onEntryAdded(priorityEntry);
+ mGroupManager.onEntryAdded(childEntry);
+
+ // Alert is immediately removed from summary, but we do not show priority yet either as its
+ // content is not inflated.
+ assertFalse(mHeadsUpManager.isAlerting(summaryEntry.getKey()));
+ assertFalse(mHeadsUpManager.isAlerting(childEntry.getKey()));
+ assertFalse(mHeadsUpManager.isAlerting(priorityEntry.getKey()));
+ assertTrue(mGroupAlertTransferHelper.isAlertTransferPending(priorityEntry));
+ }
+
+ @Test
+ public void testOverriddenSummaryHeadsUpTransfersToPriorityButBackAgain() {
+ // Creation order is oldest to newest, meaning the child2 will ultimately be deemed newest
+ int groupAlert = Notification.GROUP_ALERT_SUMMARY;
+ NotificationEntry summaryEntry = mGroupTestHelper.createSummaryNotification(groupAlert);
+ NotificationEntry childEntry = mGroupTestHelper.createChildNotification(groupAlert);
+ NotificationEntry priorityEntry = mGroupTestHelper.createChildNotification(groupAlert);
+ NotificationEntry childEntry2 = mGroupTestHelper.createChildNotification(groupAlert);
+ mockIsPriority(priorityEntry);
+
+ // summary gets heads up
+ mHeadsUpManager.showNotification(summaryEntry);
+
+ mockHasHeadsUpContentView(summaryEntry);
+ mockHasHeadsUpContentView(priorityEntry);
+ mockHasHeadsUpContentView(childEntry);
+ mockHasHeadsUpContentView(childEntry2);
+
+ // Summary will have an alertOverride.
+ mGroupManager.onEntryAdded(summaryEntry);
+ mGroupManager.onEntryAdded(priorityEntry);
+ mGroupManager.onEntryAdded(childEntry);
+
+ // An overridden summary should transfer its alert state to the priority.
+ assertFalse(mHeadsUpManager.isAlerting(summaryEntry.getKey()));
+ assertFalse(mHeadsUpManager.isAlerting(childEntry.getKey()));
+ assertTrue(mHeadsUpManager.isAlerting(priorityEntry.getKey()));
+
+ mGroupManager.onEntryAdded(childEntry2);
+
+ // An overridden summary should transfer its alert state to the priority.
+ assertTrue(mHeadsUpManager.isAlerting(summaryEntry.getKey()));
+ assertFalse(mHeadsUpManager.isAlerting(childEntry.getKey()));
+ assertFalse(mHeadsUpManager.isAlerting(childEntry2.getKey()));
+ assertFalse(mHeadsUpManager.isAlerting(priorityEntry.getKey()));
+ }
+
+ @Test
+ public void testOverriddenSuppressedSummaryHeadsUpTransfersToChildThenToPriority() {
+ // Creation order is oldest to newest, meaning the priority will ultimately be deemed newest
+ int groupAlert = Notification.GROUP_ALERT_SUMMARY;
+ NotificationEntry summaryEntry = mGroupTestHelper.createSummaryNotification(groupAlert);
+ NotificationEntry childEntry = mGroupTestHelper.createChildNotification(groupAlert);
+ NotificationEntry priorityEntry = mGroupTestHelper.createChildNotification(groupAlert);
+ mockIsPriority(priorityEntry);
+
+ // summary gets heads up
+ mHeadsUpManager.showNotification(summaryEntry);
+
+ mockHasHeadsUpContentView(summaryEntry);
+ mockHasHeadsUpContentView(priorityEntry);
+ mockHasHeadsUpContentView(childEntry);
+
+ // Summary will be suppressed, and the child will receive the alert
+ mGroupManager.onEntryAdded(summaryEntry);
+ mGroupManager.onEntryAdded(childEntry);
+
+ assertFalse(mHeadsUpManager.isAlerting(summaryEntry.getKey()));
+ assertTrue(mHeadsUpManager.isAlerting(childEntry.getKey()));
+
+ // Alert should be transferred "back" from the child to the priority
+ mGroupManager.onEntryAdded(priorityEntry);
+
+ assertFalse(mHeadsUpManager.isAlerting(summaryEntry.getKey()));
+ assertFalse(mHeadsUpManager.isAlerting(childEntry.getKey()));
+ assertTrue(mHeadsUpManager.isAlerting(priorityEntry.getKey()));
+ }
+
+ @Test
+ public void testOverriddenSuppressedSummaryHeadsUpTransfersToPriorityThenToChild() {
+ // Creation order is oldest to newest, meaning the child will ultimately be deemed newest
+ int groupAlert = Notification.GROUP_ALERT_SUMMARY;
+ NotificationEntry summaryEntry = mGroupTestHelper.createSummaryNotification(groupAlert);
+ NotificationEntry priorityEntry = mGroupTestHelper.createChildNotification(groupAlert);
+ NotificationEntry childEntry = mGroupTestHelper.createChildNotification(groupAlert);
+ mockIsPriority(priorityEntry);
+
+ // summary gets heads up
+ mHeadsUpManager.showNotification(summaryEntry);
+
+ mockHasHeadsUpContentView(summaryEntry);
+ mockHasHeadsUpContentView(priorityEntry);
+ mockHasHeadsUpContentView(childEntry);
+
+ // Summary will have alert override of the priority
+ mGroupManager.onEntryAdded(summaryEntry);
+ mGroupManager.onEntryAdded(priorityEntry);
+
+ assertFalse(mHeadsUpManager.isAlerting(summaryEntry.getKey()));
+ assertTrue(mHeadsUpManager.isAlerting(priorityEntry.getKey()));
+
+ // Alert should be transferred "back" from the priority to the child (which is newer)
+ mGroupManager.onEntryAdded(childEntry);
+
+ assertFalse(mHeadsUpManager.isAlerting(summaryEntry.getKey()));
+ assertTrue(mHeadsUpManager.isAlerting(childEntry.getKey()));
+ assertFalse(mHeadsUpManager.isAlerting(priorityEntry.getKey()));
+ }
+
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerLegacyTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerLegacyTest.java
index 3e9fd51..0110d7b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerLegacyTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationGroupManagerLegacyTest.java
@@ -21,9 +21,12 @@
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.Notification;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
@@ -33,6 +36,8 @@
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy;
+import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy.NotificationGroup;
+import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy.OnGroupChangeListener;
import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.wm.shell.bubbles.Bubbles;
@@ -58,6 +63,7 @@
private final NotificationGroupTestHelper mGroupTestHelper =
new NotificationGroupTestHelper(mContext);
+ @Mock PeopleNotificationIdentifier mPeopleNotificationIdentifier;
@Mock HeadsUpManager mHeadsUpManager;
@Before
@@ -69,7 +75,7 @@
private void initializeGroupManager() {
mGroupManager = new NotificationGroupManagerLegacy(
mock(StatusBarStateController.class),
- () -> mock(PeopleNotificationIdentifier.class),
+ () -> mPeopleNotificationIdentifier,
Optional.of(mock(Bubbles.class)));
mGroupManager.setHeadsUpManager(mHeadsUpManager);
}
@@ -153,4 +159,72 @@
assertEquals(childEntry, mGroupManager.getGroupSummary(childEntry));
assertEquals(summaryEntry, mGroupManager.getLogicalGroupSummary(childEntry));
}
+
+ @Test
+ public void testAlertOverrideWithSiblings_0() {
+ helpTestAlertOverrideWithSiblings(0);
+ }
+
+ @Test
+ public void testAlertOverrideWithSiblings_1() {
+ helpTestAlertOverrideWithSiblings(1);
+ }
+
+ @Test
+ public void testAlertOverrideWithSiblings_2() {
+ helpTestAlertOverrideWithSiblings(2);
+ }
+
+ /**
+ * This tests, for a group with a priority entry and the given number of siblings, that:
+ * 1) the priority entry is identified as the alertOverride for the group
+ * 2) the onAlertOverrideChanged method is called at that time
+ * 3) when the priority entry is removed, these are reversed
+ */
+ private void helpTestAlertOverrideWithSiblings(int numSiblings) {
+ int groupAlert = Notification.GROUP_ALERT_SUMMARY;
+ // Create entries in an order so that the priority entry can be deemed the newest child.
+ NotificationEntry[] siblings = new NotificationEntry[numSiblings];
+ for (int i = 0; i < numSiblings; i++) {
+ siblings[i] = mGroupTestHelper.createChildNotification(groupAlert);
+ }
+ NotificationEntry priorityEntry = mGroupTestHelper.createChildNotification(groupAlert);
+ NotificationEntry summaryEntry = mGroupTestHelper.createSummaryNotification(groupAlert);
+
+ // The priority entry is an important conversation.
+ when(mPeopleNotificationIdentifier.getPeopleNotificationType(eq(priorityEntry)))
+ .thenReturn(PeopleNotificationIdentifier.TYPE_IMPORTANT_PERSON);
+
+ // Register a listener so we can verify that the event is sent.
+ OnGroupChangeListener groupChangeListener = mock(OnGroupChangeListener.class);
+ mGroupManager.registerGroupChangeListener(groupChangeListener);
+
+ // Add all the entries. The order here shouldn't matter.
+ mGroupManager.onEntryAdded(summaryEntry);
+ for (int i = 0; i < numSiblings; i++) {
+ mGroupManager.onEntryAdded(siblings[i]);
+ }
+ mGroupManager.onEntryAdded(priorityEntry);
+
+ // Verify that the summary group has the priority child as its alertOverride
+ NotificationGroup summaryGroup = mGroupManager.getGroupForSummary(summaryEntry.getSbn());
+ assertEquals(priorityEntry, summaryGroup.alertOverride);
+ verify(groupChangeListener).onGroupAlertOverrideChanged(summaryGroup, null, priorityEntry);
+
+ // Verify that only the priority notification is isolated from the group
+ assertEquals(priorityEntry, mGroupManager.getGroupSummary(priorityEntry));
+ assertEquals(summaryEntry, mGroupManager.getLogicalGroupSummary(priorityEntry));
+ // Verify that the siblings are NOT isolated from the group
+ for (int i = 0; i < numSiblings; i++) {
+ assertEquals(summaryEntry, mGroupManager.getGroupSummary(siblings[i]));
+ assertEquals(summaryEntry, mGroupManager.getLogicalGroupSummary(siblings[i]));
+ }
+
+ // Remove the priority notification to validate that it is removed as the alertOverride
+ mGroupManager.onEntryRemoved(priorityEntry);
+
+ // verify that the alertOverride is removed when the priority notification is
+ assertNull(summaryGroup.alertOverride);
+ verify(groupChangeListener).onGroupAlertOverrideChanged(summaryGroup, null, priorityEntry);
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java
index 4bac762..45761df 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java
@@ -89,6 +89,7 @@
import com.android.systemui.statusbar.StatusBarStateControllerImpl;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.VibratorHelper;
+import com.android.systemui.statusbar.events.PrivacyDotViewController;
import com.android.systemui.statusbar.notification.ConversationNotificationManager;
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
@@ -243,6 +244,8 @@
private QuickAccessWalletClient mQuickAccessWalletClient;
@Mock
private KeyguardMediaController mKeyguardMediaController;
+ @Mock
+ private PrivacyDotViewController mPrivacyDotViewController;
private SysuiStatusBarStateController mStatusBarStateController;
private NotificationPanelViewController mNotificationPanelViewController;
@@ -351,6 +354,7 @@
mFeatureFlags,
mQuickAccessWalletClient,
mKeyguardMediaController,
+ mPrivacyDotViewController,
new FakeExecutor(new FakeSystemClock()));
mNotificationPanelViewController.initDependencies(
mStatusBar,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt
index 896e330..9a7ab28 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallControllerTest.kt
@@ -29,6 +29,7 @@
import android.view.LayoutInflater
import android.widget.LinearLayout
import androidx.test.filters.SmallTest
+import com.android.internal.logging.testing.UiEventLoggerFake
import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.plugins.ActivityStarter
@@ -70,6 +71,7 @@
private val clock = FakeSystemClock()
private val mainExecutor = FakeExecutor(clock)
+ private val uiEventLoggerFake = UiEventLoggerFake()
private lateinit var controller: OngoingCallController
private lateinit var notifCollectionListener: NotifCollectionListener
@@ -99,7 +101,8 @@
clock,
mockActivityStarter,
mainExecutor,
- mockIActivityManager)
+ mockIActivityManager,
+ OngoingCallLogger(uiEventLoggerFake))
controller.init()
controller.addCallback(mockOngoingCallListener)
controller.setChipView(chipView)
@@ -256,6 +259,28 @@
.onOngoingCallStateChanged(anyBoolean())
}
+ @Test
+ fun chipClicked_clickEventLogged() {
+ notifCollectionListener.onEntryUpdated(createOngoingCallNotifEntry())
+
+ chipView.performClick()
+
+ assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1)
+ assertThat(uiEventLoggerFake.eventId(0))
+ .isEqualTo(OngoingCallLogger.OngoingCallEvents.ONGOING_CALL_CLICKED.id)
+ }
+
+ @Test
+ fun notifyChipVisibilityChanged_visibleEventLogged() {
+ controller.notifyChipVisibilityChanged(true)
+
+ assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1)
+ assertThat(uiEventLoggerFake.eventId(0))
+ .isEqualTo(OngoingCallLogger.OngoingCallEvents.ONGOING_CALL_VISIBLE.id)
+ }
+ // Other tests for notifyChipVisibilityChanged are in [OngoingCallLogger], since
+ // [OngoingCallController.notifyChipVisibilityChanged] just delegates to that class.
+
private fun createOngoingCallNotifEntry(): NotificationEntry {
val notificationEntryBuilder = NotificationEntryBuilder()
notificationEntryBuilder.modifyNotification(context).style = ongoingCallStyle
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallLoggerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallLoggerTest.kt
new file mode 100644
index 0000000..ecec124
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ongoingcall/OngoingCallLoggerTest.kt
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2021 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.phone.ongoingcall
+
+import androidx.test.filters.SmallTest
+import com.android.internal.logging.testing.UiEventLoggerFake
+import com.android.systemui.SysuiTestCase
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+
+@SmallTest
+class OngoingCallLoggerTest : SysuiTestCase() {
+ private val uiEventLoggerFake = UiEventLoggerFake()
+ private val ongoingCallLogger = OngoingCallLogger(uiEventLoggerFake)
+
+ @Test
+ fun logChipClicked_clickEventLogged() {
+ ongoingCallLogger.logChipClicked()
+
+ assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1)
+ assertThat(uiEventLoggerFake.eventId(0))
+ .isEqualTo(OngoingCallLogger.OngoingCallEvents.ONGOING_CALL_CLICKED.id)
+ }
+
+ @Test
+ fun logChipVisibilityChanged_changeFromInvisibleToVisible_visibleEventLogged() {
+ ongoingCallLogger.logChipVisibilityChanged(false)
+ ongoingCallLogger.logChipVisibilityChanged(true)
+
+ assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1)
+ assertThat(uiEventLoggerFake.eventId(0))
+ .isEqualTo(OngoingCallLogger.OngoingCallEvents.ONGOING_CALL_VISIBLE.id)
+ }
+
+ @Test
+ fun logChipVisibilityChanged_changeFromVisibleToInvisible_eventNotLogged() {
+ // Setting the chip to visible here will trigger a log
+ ongoingCallLogger.logChipVisibilityChanged(true)
+ assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1)
+
+ ongoingCallLogger.logChipVisibilityChanged(false)
+
+ // Expect that there were no new logs
+ assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1)
+ }
+
+ @Test
+ fun logChipVisibilityChanged_visibleThenVisibleAgain_eventNotLogged() {
+ // Setting the chip to visible here will trigger a log
+ ongoingCallLogger.logChipVisibilityChanged(true)
+ assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1)
+
+ ongoingCallLogger.logChipVisibilityChanged(true)
+
+ // Expect that there were no new logs
+ assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1)
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java
index 0e4b053..d72f432 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HeadsUpManagerTest.java
@@ -18,6 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
+import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
@@ -25,12 +26,16 @@
import static org.mockito.Mockito.doReturn;
import android.app.Notification;
+import android.app.PendingIntent;
import android.content.Context;
+import android.content.Intent;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import androidx.test.filters.SmallTest;
+import com.android.internal.logging.UiEventLogger;
+import com.android.internal.logging.testing.UiEventLoggerFake;
import com.android.systemui.statusbar.AlertingNotificationManager;
import com.android.systemui.statusbar.AlertingNotificationManagerTest;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
@@ -49,6 +54,7 @@
private AccessibilityManagerWrapper mAccessibilityMgr;
private HeadsUpManager mHeadsUpManager;
private boolean mLivesPastNormalTime;
+ private UiEventLoggerFake mUiEventLoggerFake = new UiEventLoggerFake();
private final class TestableHeadsUpManager extends HeadsUpManager {
TestableHeadsUpManager(Context context) {
@@ -65,6 +71,7 @@
@Before
public void setUp() {
mAccessibilityMgr = mDependency.injectMockDependency(AccessibilityManagerWrapper.class);
+ mDependency.injectTestDependency(UiEventLogger.class, mUiEventLoggerFake);
mHeadsUpManager = new TestableHeadsUpManager(mContext);
super.setUp();
@@ -108,5 +115,28 @@
assertThat(ongoingCall.compareTo(activeRemoteInput)).isLessThan(0);
assertThat(activeRemoteInput.compareTo(ongoingCall)).isGreaterThan(0);
}
-}
+ @Test
+ public void testPinEntry_logsPeek() {
+ // Needs full screen intent in order to be pinned
+ final PendingIntent fullScreenIntent = PendingIntent.getActivity(mContext, 0,
+ new Intent(), PendingIntent.FLAG_MUTABLE);
+
+ HeadsUpManager.HeadsUpEntry entryToPin = mHeadsUpManager.new HeadsUpEntry();
+ entryToPin.setEntry(new NotificationEntryBuilder()
+ .setSbn(createNewSbn(0,
+ new Notification.Builder(mContext, "")
+ .setFullScreenIntent(fullScreenIntent, true)))
+ .build());
+ // Note: the standard way to show a notification would be calling showNotification rather
+ // than onAlertEntryAdded. However, in practice showNotification in effect adds
+ // the notification and then updates it; in order to not log twice, the entry needs
+ // to have a functional ExpandableNotificationRow that can keep track of whether it's
+ // pinned or not (via isRowPinned()). That feels like a lot to pull in to test this one bit.
+ mHeadsUpManager.onAlertEntryAdded(entryToPin);
+
+ assertEquals(1, mUiEventLoggerFake.numLogs());
+ assertEquals(HeadsUpManager.NotificationPeekEvent.NOTIFICATION_PEEK.getId(),
+ mUiEventLoggerFake.eventId(0));
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java
index 3d07eb1..e5b7e3f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java
@@ -20,7 +20,6 @@
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
@@ -100,8 +99,6 @@
private Icon mActionIcon;
- private int mSingleLinePaddingHorizontal;
- private int mDoubleLinePaddingHorizontal;
private int mSpacing;
private NotificationEntry mEntry;
@@ -141,10 +138,6 @@
mView = SmartReplyView.inflate(mContext, mConstants);
final Resources res = mContext.getResources();
- mSingleLinePaddingHorizontal = res.getDimensionPixelSize(
- R.dimen.smart_reply_button_padding_horizontal_single_line);
- mDoubleLinePaddingHorizontal = res.getDimensionPixelSize(
- R.dimen.smart_reply_button_padding_horizontal_double_line);
mSpacing = res.getDimensionPixelSize(R.dimen.smart_reply_button_spacing);
mNotification = new Notification.Builder(mContext, "")
@@ -588,18 +581,6 @@
layout.setBaselineAligned(false);
final boolean isRtl = mView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
- final int paddingHorizontal;
- switch (lineCount) {
- case 1:
- paddingHorizontal = mSingleLinePaddingHorizontal;
- break;
- case 2:
- paddingHorizontal = mDoubleLinePaddingHorizontal;
- break;
- default:
- fail("Invalid line count " + lineCount);
- return null;
- }
// Add smart replies
Button previous = null;
@@ -617,8 +598,6 @@
true /* delayOnClickListener */))
.iterator()));
for (Button current : inflatedReplies) {
- current.setPadding(paddingHorizontal, current.getPaddingTop(), paddingHorizontal,
- current.getPaddingBottom());
if (previous != null) {
ViewGroup.MarginLayoutParams lp =
(ViewGroup.MarginLayoutParams) previous.getLayoutParams();
@@ -647,8 +626,6 @@
// Add smart actions
for (Button current : inflatedSmartActions) {
- current.setPadding(paddingHorizontal, current.getPaddingTop(), paddingHorizontal,
- current.getPaddingBottom());
if (previous != null) {
ViewGroup.MarginLayoutParams lp =
(ViewGroup.MarginLayoutParams) previous.getLayoutParams();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
index 2d9d715..9f1dad8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java
@@ -185,7 +185,8 @@
Color.valueOf(Color.BLUE), null);
String jsonString =
- "{\"android.theme.customization.system_palette\":\"override.package.name\"}";
+ "{\"android.theme.customization.system_palette\":\"override.package.name\","
+ + "\"android.theme.customization.color_source\":\"preset\"}";
when(mSecureSettings.getStringForUser(
eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), anyInt()))
.thenReturn(jsonString);
@@ -203,6 +204,32 @@
}
@Test
+ public void onWallpaperColorsChanged_resetThemeIfNotPreset() {
+ // Should ask for a new theme when wallpaper colors change
+ WallpaperColors mainColors = new WallpaperColors(Color.valueOf(Color.RED),
+ Color.valueOf(Color.BLUE), null);
+
+ String jsonString =
+ "{\"android.theme.customization.system_palette\":\"override.package.name\","
+ + "\"android.theme.customization.color_source\":\"home_wallpaper\"}";
+ when(mSecureSettings.getStringForUser(
+ eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), anyInt()))
+ .thenReturn(jsonString);
+
+ mColorsListener.getValue().onColorsChanged(mainColors, WallpaperManager.FLAG_SYSTEM);
+
+ ArgumentCaptor<String> updatedSetting = ArgumentCaptor.forClass(String.class);
+ verify(mSecureSettings).putString(
+ eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), updatedSetting.capture());
+
+ assertThat(updatedSetting.getValue().contains("android.theme.customization.system_palette"))
+ .isFalse();
+
+ verify(mThemeOverlayApplier)
+ .applyCurrentUserOverlays(any(), any(), anyInt(), any());
+ }
+
+ @Test
public void onProfileAdded_setsTheme() {
mBroadcastReceiver.getValue().onReceive(null,
new Intent(Intent.ACTION_MANAGED_PROFILE_ADDED));
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/concurrency/FakeThreadFactory.java b/packages/SystemUI/tests/src/com/android/systemui/util/concurrency/FakeThreadFactory.java
index ce71ac8..570e1d8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/util/concurrency/FakeThreadFactory.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/util/concurrency/FakeThreadFactory.java
@@ -16,6 +16,7 @@
package com.android.systemui.util.concurrency;
+import android.os.Handler;
import android.os.Looper;
import java.util.concurrent.Executor;
@@ -25,11 +26,21 @@
*/
public class FakeThreadFactory implements ThreadFactory {
private final FakeExecutor mFakeExecutor;
+ private Handler mHandler;
public FakeThreadFactory(FakeExecutor fakeExecutor) {
mFakeExecutor = fakeExecutor;
}
+ public void setHandler(Handler handler) {
+ mHandler = handler;
+ }
+
+ @Override
+ public Handler builderHandlerOnNewThread(String threadName) {
+ return mHandler;
+ }
+
@Override
public Executor buildExecutorOnNewThread(String threadName) {
return mFakeExecutor;
@@ -41,6 +52,11 @@
}
@Override
+ public DelayableExecutor buildDelayableExecutorOnHandler(Handler handler) {
+ return mFakeExecutor;
+ }
+
+ @Override
public DelayableExecutor buildDelayableExecutorOnLooper(Looper looper) {
return mFakeExecutor;
}
diff --git a/packages/services/CameraExtensionsProxy/AndroidManifest.xml b/packages/services/CameraExtensionsProxy/AndroidManifest.xml
index 7416cba..e5f460e 100644
--- a/packages/services/CameraExtensionsProxy/AndroidManifest.xml
+++ b/packages/services/CameraExtensionsProxy/AndroidManifest.xml
@@ -2,8 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.camera">
- <uses-permission android:name="android.permission.CAMERA" />
-
<application
android:label="@string/app_name"
android:defaultToDeviceProtectedStorage="true"
diff --git a/packages/services/CameraExtensionsProxy/src/com/android/camera/CameraExtensionsProxyService.java b/packages/services/CameraExtensionsProxy/src/com/android/camera/CameraExtensionsProxyService.java
index 0f05019..d44a417 100644
--- a/packages/services/CameraExtensionsProxy/src/com/android/camera/CameraExtensionsProxyService.java
+++ b/packages/services/CameraExtensionsProxy/src/com/android/camera/CameraExtensionsProxyService.java
@@ -25,19 +25,36 @@
import android.hardware.camera2.CameraExtensionCharacteristics;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CaptureRequest;
+import android.hardware.camera2.CaptureResult;
+import android.hardware.camera2.extension.CameraOutputConfig;
+import android.hardware.camera2.extension.CameraSessionConfig;
import android.hardware.camera2.extension.CaptureBundle;
+import android.hardware.camera2.extension.CaptureFailure;
import android.hardware.camera2.extension.CaptureStageImpl;
+import android.hardware.camera2.extension.IAdvancedExtenderImpl;
import android.hardware.camera2.extension.ICameraExtensionsProxyService;
+import android.hardware.camera2.extension.ICaptureCallback;
import android.hardware.camera2.extension.ICaptureProcessorImpl;
import android.hardware.camera2.extension.IPreviewExtenderImpl;
import android.hardware.camera2.extension.IPreviewImageProcessorImpl;
+import android.hardware.camera2.extension.IRequestCallback;
+import android.hardware.camera2.extension.IRequestProcessorImpl;
import android.hardware.camera2.extension.IRequestUpdateProcessorImpl;
-import android.hardware.camera2.extension.ParcelImage;
import android.hardware.camera2.extension.IImageCaptureExtenderImpl;
+import android.hardware.camera2.extension.IImageProcessorImpl;
+import android.hardware.camera2.extension.ISessionProcessorImpl;
+import android.hardware.camera2.extension.LatencyRange;
+import android.hardware.camera2.extension.OutputConfigId;
+import android.hardware.camera2.extension.OutputSurface;
+import android.hardware.camera2.extension.ParcelCaptureResult;
+import android.hardware.camera2.extension.ParcelImage;
+import android.hardware.camera2.extension.ParcelTotalCaptureResult;
+import android.hardware.camera2.extension.Request;
import android.hardware.camera2.extension.SizeList;
import android.hardware.camera2.impl.CameraMetadataNative;
import android.hardware.camera2.TotalCaptureResult;
import android.hardware.HardwareBuffer;
+import android.hardware.camera2.impl.PhysicalCaptureResultInfo;
import android.media.Image;
import android.media.ImageReader;
import android.os.ConditionVariable;
@@ -45,9 +62,11 @@
import android.os.HandlerExecutor;
import android.os.HandlerThread;
import android.os.IBinder;
+import android.os.RemoteException;
import android.util.ArraySet;
import android.util.Log;
import android.util.Pair;
+import android.util.Range;
import android.util.Size;
import android.view.Surface;
@@ -69,10 +88,26 @@
import androidx.camera.extensions.impl.PreviewExtenderImpl.ProcessorType;
import androidx.camera.extensions.impl.PreviewImageProcessorImpl;
import androidx.camera.extensions.impl.RequestUpdateProcessorImpl;
+import androidx.camera.extensions.impl.advanced.AdvancedExtenderImpl;
+import androidx.camera.extensions.impl.advanced.AutoAdvancedExtenderImpl;
+import androidx.camera.extensions.impl.advanced.BeautyAdvancedExtenderImpl;
+import androidx.camera.extensions.impl.advanced.BokehAdvancedExtenderImpl;
+import androidx.camera.extensions.impl.advanced.Camera2OutputConfigImpl;
+import androidx.camera.extensions.impl.advanced.Camera2SessionConfigImpl;
+import androidx.camera.extensions.impl.advanced.HdrAdvancedExtenderImpl;
+import androidx.camera.extensions.impl.advanced.ImageProcessorImpl;
+import androidx.camera.extensions.impl.advanced.ImageReaderOutputConfigImpl;
+import androidx.camera.extensions.impl.advanced.MultiResolutionImageReaderOutputConfigImpl;
+import androidx.camera.extensions.impl.advanced.NightAdvancedExtenderImpl;
+import androidx.camera.extensions.impl.advanced.OutputSurfaceImpl;
+import androidx.camera.extensions.impl.advanced.RequestProcessorImpl;
+import androidx.camera.extensions.impl.advanced.SessionProcessorImpl;
+import androidx.camera.extensions.impl.advanced.SurfaceOutputConfigImpl;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@@ -83,13 +118,20 @@
private static final String CAMERA_EXTENSION_VERSION_NAME =
"androidx.camera.extensions.impl.ExtensionVersionImpl";
- private static final String LATEST_VERSION = "1.1.0";
- private static final String[] SUPPORTED_VERSION_PREFIXES = {"1.1.", "1.0."};
+ private static final String LATEST_VERSION = "1.2.0";
+ private static final String LEGACY_VERSION_PREFIX = "1.1";
+ private static final String ADVANCED_VERSION_PREFIX = "1.2";
+ private static final String[] SUPPORTED_VERSION_PREFIXES = {ADVANCED_VERSION_PREFIX,
+ LEGACY_VERSION_PREFIX, "1.0."};
private static final boolean EXTENSIONS_PRESENT = checkForExtensions();
private static final String EXTENSIONS_VERSION = EXTENSIONS_PRESENT ?
(new ExtensionVersionImpl()).checkApiVersion(LATEST_VERSION) : null;
- private static final boolean LATEST_VERSION_SUPPORTED =
- EXTENSIONS_PRESENT && EXTENSIONS_VERSION.startsWith(SUPPORTED_VERSION_PREFIXES[0]);
+ private static final boolean LEGACY_VERSION_SUPPORTED =
+ EXTENSIONS_PRESENT && EXTENSIONS_VERSION.startsWith(LEGACY_VERSION_PREFIX);
+ private static final boolean ADVANCED_VERSION_SUPPORTED =
+ EXTENSIONS_PRESENT && EXTENSIONS_VERSION.startsWith(ADVANCED_VERSION_PREFIX);
+
+ private HashMap<String, CameraCharacteristics> mCharacteristicsHashMap = new HashMap<>();
private static boolean checkForExtensions() {
try {
@@ -223,7 +265,7 @@
public long registerClient(Context ctx) {
synchronized (mLock) {
- if (LATEST_VERSION_SUPPORTED) {
+ if (LEGACY_VERSION_SUPPORTED) {
if (mActiveClients.isEmpty()) {
InitializerFuture status = new InitializerFuture();
InitializerImpl.init(EXTENSIONS_VERSION, ctx, new InitializeHandler(status),
@@ -257,7 +299,7 @@
public void unregisterClient(long clientId) {
synchronized (mLock) {
if (mActiveClients.remove(clientId) && mActiveClients.isEmpty() &&
- LATEST_VERSION_SUPPORTED) {
+ LEGACY_VERSION_SUPPORTED) {
InitializerFuture status = new InitializerFuture();
InitializerImpl.deinit(new ReleaseHandler(status),
new HandlerExecutor(mHandler));
@@ -321,17 +363,39 @@
}
}
+ /**
+ * @hide
+ */
+ public static AdvancedExtenderImpl initializeAdvancedExtensionImpl(int extensionType) {
+ switch (extensionType) {
+ case CameraExtensionCharacteristics.EXTENSION_AUTOMATIC:
+ return new AutoAdvancedExtenderImpl();
+ case CameraExtensionCharacteristics.EXTENSION_BEAUTY:
+ return new BeautyAdvancedExtenderImpl();
+ case CameraExtensionCharacteristics.EXTENSION_BOKEH:
+ return new BokehAdvancedExtenderImpl();
+ case CameraExtensionCharacteristics.EXTENSION_HDR:
+ return new HdrAdvancedExtenderImpl();
+ case CameraExtensionCharacteristics.EXTENSION_NIGHT:
+ return new NightAdvancedExtenderImpl();
+ default:
+ throw new IllegalArgumentException("Unknown extension: " + extensionType);
+ }
+ }
+
@Override
public void onCreate() {
super.onCreate();
// This will setup the camera vendor tag descriptor in the service process
+ // along with all camera characteristics.
try {
CameraManager manager = getSystemService(CameraManager.class);
String [] cameraIds = manager.getCameraIdListNoLazy();
if (cameraIds != null) {
for (String cameraId : cameraIds) {
- CameraCharacteristics ch = manager.getCameraCharacteristics(cameraId);
+ mCharacteristicsHashMap.put(cameraId,
+ manager.getCameraCharacteristics(cameraId));
}
}
} catch (CameraAccessException e) {
@@ -372,6 +436,29 @@
return ret;
}
+ private static List<SizeList> initializeParcelable(
+ Map<Integer, List<android.util.Size>> sizes) {
+ if (sizes == null) {
+ return null;
+ }
+ ArrayList<SizeList> ret = new ArrayList<>(sizes.size());
+ for (Map.Entry<Integer, List<android.util.Size>> entry : sizes.entrySet()) {
+ SizeList sizeList = new SizeList();
+ sizeList.format = entry.getKey();
+ sizeList.sizes = new ArrayList<>();
+ for (android.util.Size size : entry.getValue()) {
+ android.hardware.camera2.extension.Size sz =
+ new android.hardware.camera2.extension.Size();
+ sz.width = size.getWidth();
+ sz.height = size.getHeight();
+ sizeList.sizes.add(sz);
+ }
+ ret.add(sizeList);
+ }
+
+ return ret;
+ }
+
private static CameraMetadataNative initializeParcelableMetadata(
List<Pair<CaptureRequest.Key, Object>> paramList) {
if (paramList == null) {
@@ -386,6 +473,20 @@
return ret;
}
+ private static CameraMetadataNative initializeParcelableMetadata(
+ Map<CaptureRequest.Key<?>, Object> paramMap) {
+ if (paramMap == null) {
+ return null;
+ }
+
+ CameraMetadataNative ret = new CameraMetadataNative();
+ for (Map.Entry<CaptureRequest.Key<?>, Object> param : paramMap.entrySet()) {
+ ret.set(((CaptureRequest.Key) param.getKey()), param.getValue());
+ }
+
+ return ret;
+ }
+
private static android.hardware.camera2.extension.CaptureStageImpl initializeParcelable(
androidx.camera.extensions.impl.CaptureStageImpl captureStage) {
if (captureStage == null) {
@@ -400,6 +501,20 @@
return ret;
}
+ private Request initializeParcelable(RequestProcessorImpl.Request request, int requestId) {
+ Request ret = new Request();
+ ret.targetOutputConfigIds = new ArrayList<>();
+ for (int id : request.getTargetOutputConfigIds()) {
+ OutputConfigId configId = new OutputConfigId();
+ configId.id = id;
+ ret.targetOutputConfigIds.add(configId);
+ }
+ ret.templateId = request.getTemplateId();
+ ret.parameters = initializeParcelableMetadata(request.getParameters());
+ ret.requestId = requestId;
+ return ret;
+ }
+
private class CameraExtensionsProxyServiceStub extends ICameraExtensionsProxyService.Stub {
@Override
public long registerClient() {
@@ -412,6 +527,23 @@
}
@Override
+ public boolean advancedExtensionsSupported() {
+ return ADVANCED_VERSION_SUPPORTED;
+ }
+
+ @Override
+ public IAdvancedExtenderImpl initializeAdvancedExtension(int extensionType) {
+ AdvancedExtenderImpl extension;
+ try {
+ extension = initializeAdvancedExtensionImpl(extensionType);
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+
+ return new AdvancedExtenderImplStub(extension);
+ }
+
+ @Override
public IPreviewExtenderImpl initializePreviewExtension(int extensionType) {
Pair<PreviewExtenderImpl, ImageCaptureExtenderImpl> extension;
try {
@@ -436,6 +568,475 @@
}
}
+ private class AdvancedExtenderImplStub extends IAdvancedExtenderImpl.Stub {
+ private final AdvancedExtenderImpl mAdvancedExtender;
+
+ public AdvancedExtenderImplStub(AdvancedExtenderImpl advancedExtender) {
+ mAdvancedExtender = advancedExtender;
+ }
+
+ @Override
+ public boolean isExtensionAvailable(String cameraId) {
+ return mAdvancedExtender.isExtensionAvailable(cameraId, mCharacteristicsHashMap);
+ }
+
+ @Override
+ public void init(String cameraId) {
+ mAdvancedExtender.init(cameraId, mCharacteristicsHashMap);
+ }
+
+ @Override
+ public List<SizeList> getSupportedPreviewOutputResolutions(String cameraId) {
+ Map<Integer, List<Size>> supportedSizesMap =
+ mAdvancedExtender.getSupportedPreviewOutputResolutions(cameraId);
+ if (supportedSizesMap != null) {
+ return initializeParcelable(supportedSizesMap);
+ }
+
+ return null;
+ }
+
+ @Override
+ public List<SizeList> getSupportedCaptureOutputResolutions(String cameraId) {
+ Map<Integer, List<Size>> supportedSizesMap =
+ mAdvancedExtender.getSupportedCaptureOutputResolutions(cameraId);
+ if (supportedSizesMap != null) {
+ return initializeParcelable(supportedSizesMap);
+ }
+
+ return null;
+ }
+
+ @Override
+ public LatencyRange getEstimatedCaptureLatencyRange(String cameraId,
+ android.hardware.camera2.extension.Size outputSize, int format) {
+ Size sz = new Size(outputSize.width, outputSize.height);
+ Range<Long> latencyRange = mAdvancedExtender.getEstimatedCaptureLatencyRange(cameraId,
+ sz, format);
+ if (latencyRange != null) {
+ LatencyRange ret = new LatencyRange();
+ ret.min = latencyRange.getLower();
+ ret.max = latencyRange.getUpper();
+ return ret;
+ }
+
+ return null;
+ }
+
+ @Override
+ public ISessionProcessorImpl getSessionProcessor() {
+ return new SessionProcessorImplStub(mAdvancedExtender.createSessionProcessor());
+ }
+ }
+
+ private class CaptureCallbackStub implements SessionProcessorImpl.CaptureCallback {
+ private final ICaptureCallback mCaptureCallback;
+
+ private CaptureCallbackStub(ICaptureCallback captureCallback) {
+ mCaptureCallback = captureCallback;
+ }
+
+ @Override
+ public void onCaptureStarted(int captureSequenceId, long timestamp) {
+ if (mCaptureCallback != null) {
+ try {
+ mCaptureCallback.onCaptureStarted(captureSequenceId, timestamp);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to notify capture start due to remote " +
+ "exception!");
+ }
+ }
+ }
+
+ @Override
+ public void onCaptureProcessStarted(int captureSequenceId) {
+ if (mCaptureCallback != null) {
+ try {
+ mCaptureCallback.onCaptureProcessStarted(captureSequenceId);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to notify capture process start due to remote " +
+ "exception!");
+ }
+ }
+ }
+
+ @Override
+ public void onCaptureFailed(int captureSequenceId) {
+ if (mCaptureCallback != null) {
+ try {
+ mCaptureCallback.onCaptureFailed(captureSequenceId);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to notify capture failure due to remote " +
+ "exception!");
+ }
+ }
+ }
+
+ @Override
+ public void onCaptureSequenceCompleted(int captureSequenceId) {
+ if (mCaptureCallback != null) {
+ try {
+ mCaptureCallback.onCaptureSequenceCompleted(captureSequenceId);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to notify capture sequence end due to remote " +
+ "exception!");
+ }
+ }
+ }
+
+ @Override
+ public void onCaptureSequenceAborted(int captureSequenceId) {
+ if (mCaptureCallback != null) {
+ try {
+ mCaptureCallback.onCaptureSequenceAborted(captureSequenceId);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to notify capture sequence abort due to remote " +
+ "exception!");
+ }
+ }
+ }
+ }
+
+ private class RequestCallbackStub extends IRequestCallback.Stub {
+ private final List<RequestProcessorImpl.Request> mRequests;
+ private final RequestProcessorImpl.Callback mCallback;
+
+ public RequestCallbackStub(List<RequestProcessorImpl.Request> requests,
+ RequestProcessorImpl.Callback callback) {
+ mCallback = callback;
+ if (mCallback != null) {
+ mRequests = requests;
+ } else {
+ Log.w(TAG, "No valid request callbacks!");
+ mRequests = new ArrayList<>();
+ }
+ }
+
+ @Override
+ public void onCaptureStarted(int requestId, long frameNumber, long timestamp) {
+ if (mCallback != null) {
+ if (mRequests.get(requestId) != null) {
+ mCallback.onCaptureStarted(mRequests.get(requestId), frameNumber, timestamp);
+ } else {
+ Log.e(TAG,"Request id: " + requestId + " not found!");
+ }
+ }
+ }
+
+ @Override
+ public void onCaptureProgressed(int requestId, ParcelCaptureResult partialResult) {
+ if (mCallback != null) {
+ if (mRequests.get(requestId) != null) {
+ CaptureResult result = new CaptureResult(partialResult.cameraId,
+ partialResult.results, partialResult.parent, partialResult.sequenceId,
+ partialResult.frameNumber);
+ mCallback.onCaptureProgressed(mRequests.get(requestId), result);
+ } else {
+ Log.e(TAG,"Request id: " + requestId + " not found!");
+ }
+ }
+ }
+
+ @Override
+ public void onCaptureCompleted(int requestId, ParcelTotalCaptureResult totalCaptureResult) {
+ if (mCallback != null) {
+ if (mRequests.get(requestId) != null) {
+ PhysicalCaptureResultInfo[] physicalResults = new PhysicalCaptureResultInfo[0];
+ if ((totalCaptureResult.physicalResult != null) &&
+ (!totalCaptureResult.physicalResult.isEmpty())) {
+ int count = totalCaptureResult.physicalResult.size();
+ physicalResults = new PhysicalCaptureResultInfo[count];
+ physicalResults = totalCaptureResult.physicalResult.toArray(
+ physicalResults);
+ }
+ ArrayList<CaptureResult> partials = new ArrayList<>(
+ totalCaptureResult.partials.size());
+ for (ParcelCaptureResult parcelResult : totalCaptureResult.partials) {
+ partials.add(new CaptureResult(parcelResult.cameraId, parcelResult.results,
+ parcelResult.parent, parcelResult.sequenceId,
+ parcelResult.frameNumber));
+ }
+ TotalCaptureResult result = new TotalCaptureResult(
+ totalCaptureResult.logicalCameraId, totalCaptureResult.results,
+ totalCaptureResult.parent, totalCaptureResult.sequenceId,
+ totalCaptureResult.frameNumber, partials, totalCaptureResult.sessionId,
+ physicalResults);
+ mCallback.onCaptureCompleted(mRequests.get(requestId), result);
+ } else {
+ Log.e(TAG,"Request id: " + requestId + " not found!");
+ }
+ }
+ }
+
+ @Override
+ public void onCaptureFailed(int requestId, CaptureFailure captureFailure) {
+ if (mCallback != null) {
+ if (mRequests.get(requestId) != null) {
+ android.hardware.camera2.CaptureFailure failure =
+ new android.hardware.camera2.CaptureFailure(captureFailure.request,
+ captureFailure.reason, captureFailure.dropped,
+ captureFailure.sequenceId, captureFailure.frameNumber,
+ captureFailure.errorPhysicalCameraId);
+ mCallback.onCaptureFailed(mRequests.get(requestId), failure);
+ } else {
+ Log.e(TAG,"Request id: " + requestId + " not found!");
+ }
+ }
+ }
+
+ @Override
+ public void onCaptureBufferLost(int requestId, long frameNumber, int outputStreamId) {
+ if (mCallback != null) {
+ if (mRequests.get(requestId) != null) {
+ mCallback.onCaptureBufferLost(mRequests.get(requestId), frameNumber,
+ outputStreamId);
+ } else {
+ Log.e(TAG,"Request id: " + requestId + " not found!");
+ }
+ }
+ }
+
+ @Override
+ public void onCaptureSequenceCompleted(int sequenceId, long frameNumber) {
+ if (mCallback != null) {
+ mCallback.onCaptureSequenceCompleted(sequenceId, frameNumber);
+ }
+ }
+
+ @Override
+ public void onCaptureSequenceAborted(int sequenceId) {
+ if (mCallback != null) {
+ mCallback.onCaptureSequenceAborted(sequenceId);
+ }
+ }
+ }
+
+ private class ImageProcessorImplStub extends IImageProcessorImpl.Stub {
+ private final ImageProcessorImpl mImageProcessor;
+
+ public ImageProcessorImplStub(ImageProcessorImpl imageProcessor) {
+ mImageProcessor = imageProcessor;
+ }
+
+ @Override
+ public void onNextImageAvailable(OutputConfigId outputConfigId, ParcelImage img) {
+ if (mImageProcessor != null) {
+ mImageProcessor.onNextImageAvailable(outputConfigId.id, img.timestamp,
+ new ImageReferenceImpl(img));
+ }
+ }
+ }
+
+ private class RequestProcessorStub implements RequestProcessorImpl {
+ private final IRequestProcessorImpl mRequestProcessor;
+
+ public RequestProcessorStub(IRequestProcessorImpl requestProcessor) {
+ mRequestProcessor = requestProcessor;
+ }
+
+ @Override
+ public void setImageProcessor(int outputConfigId,
+ ImageProcessorImpl imageProcessor) {
+ OutputConfigId configId = new OutputConfigId();
+ configId.id = outputConfigId;
+ try {
+ mRequestProcessor.setImageProcessor(configId,
+ new ImageProcessorImplStub(imageProcessor));
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to set image processor due to remote exception!");
+ }
+ }
+
+ @Override
+ public boolean submit(Request request, Callback callback) {
+ ArrayList<Request> requests = new ArrayList<>();
+ requests.add(request);
+ return submit(requests, callback);
+ }
+
+ @Override
+ public boolean submit(List<Request> requests, Callback callback) {
+ ArrayList<android.hardware.camera2.extension.Request> captureRequests =
+ new ArrayList<>();
+ int requestId = 0;
+ for (Request request : requests) {
+ captureRequests.add(initializeParcelable(request, requestId));
+ requestId++;
+ }
+
+ try {
+ return mRequestProcessor.submitBurst(captureRequests,
+ new RequestCallbackStub(requests, callback));
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to submit request due to remote exception!");
+ }
+ return false;
+ }
+
+ @Override
+ public boolean setRepeating(Request request, Callback callback) {
+ try {
+ ArrayList<Request> requests = new ArrayList<>();
+ requests.add(request);
+ return mRequestProcessor.setRepeating(initializeParcelable(request, 0),
+ new RequestCallbackStub(requests, callback));
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to submit repeating request due to remote exception!");
+ }
+
+ return false;
+ }
+
+ @Override
+ public void abortCaptures() {
+ try {
+ mRequestProcessor.abortCaptures();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to abort requests due to remote exception!");
+ }
+ }
+
+ @Override
+ public void stopRepeating() {
+ try {
+ mRequestProcessor.stopRepeating();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to stop repeating request due to remote exception!");
+ }
+ }
+ }
+
+ private class SessionProcessorImplStub extends ISessionProcessorImpl.Stub {
+ private final SessionProcessorImpl mSessionProcessor;
+
+ public SessionProcessorImplStub(SessionProcessorImpl sessionProcessor) {
+ mSessionProcessor = sessionProcessor;
+ }
+
+ @Override
+ public CameraSessionConfig initSession(String cameraId, OutputSurface previewSurface,
+ OutputSurface burstSurface) {
+ OutputSurfaceImplStub outputPreviewSurfaceImpl =
+ new OutputSurfaceImplStub(previewSurface);
+ OutputSurfaceImplStub outputBurstSurfaceImpl =
+ new OutputSurfaceImplStub(burstSurface);
+
+ Camera2SessionConfigImpl sessionConfig = mSessionProcessor.initSession(cameraId,
+ mCharacteristicsHashMap, getApplicationContext(), outputPreviewSurfaceImpl,
+ outputBurstSurfaceImpl, null /*imageAnalysisSurfaceConfig*/);
+
+ List<Camera2OutputConfigImpl> outputConfigs = sessionConfig.getOutputConfigs();
+ CameraSessionConfig ret = new CameraSessionConfig();
+ ret.outputConfigs = new ArrayList<>();
+ for (Camera2OutputConfigImpl output : outputConfigs) {
+ CameraOutputConfig entry = new CameraOutputConfig();
+ entry.outputId = new OutputConfigId();
+ entry.outputId.id = output.getId();
+ entry.physicalCameraId = output.getPhysicalCameraId();
+ entry.surfaceGroupId = output.getSurfaceGroupId();
+ if (output instanceof SurfaceOutputConfigImpl) {
+ SurfaceOutputConfigImpl surfaceConfig = (SurfaceOutputConfigImpl) output;
+ entry.type = CameraOutputConfig.TYPE_SURFACE;
+ entry.surface = surfaceConfig.getSurface();
+ } else if (output instanceof ImageReaderOutputConfigImpl) {
+ ImageReaderOutputConfigImpl imageReaderOutputConfig =
+ (ImageReaderOutputConfigImpl) output;
+ entry.type = CameraOutputConfig.TYPE_IMAGEREADER;
+ entry.size = new android.hardware.camera2.extension.Size();
+ entry.size.width = imageReaderOutputConfig.getSize().getWidth();
+ entry.size.height = imageReaderOutputConfig.getSize().getHeight();
+ entry.imageFormat = imageReaderOutputConfig.getImageFormat();
+ entry.capacity = imageReaderOutputConfig.getMaxImages();
+ } else if (output instanceof MultiResolutionImageReaderOutputConfigImpl) {
+ MultiResolutionImageReaderOutputConfigImpl multiResReaderConfig =
+ (MultiResolutionImageReaderOutputConfigImpl) output;
+ entry.type = CameraOutputConfig.TYPE_MULTIRES_IMAGEREADER;
+ entry.imageFormat = multiResReaderConfig.getImageFormat();
+ entry.capacity = multiResReaderConfig.getMaxImages();
+ } else {
+ throw new IllegalStateException("Unknown output config type!");
+ }
+ List<Camera2OutputConfigImpl> sharedOutputs =
+ output.getSurfaceSharingOutputConfigs();
+ if ((sharedOutputs != null) && (!sharedOutputs.isEmpty())) {
+ entry.surfaceSharingOutputConfigs = new ArrayList<>();
+ for (Camera2OutputConfigImpl sharedOutput : sharedOutputs) {
+ OutputConfigId outputId = new OutputConfigId();
+ outputId.id = sharedOutput.getId();
+ entry.surfaceSharingOutputConfigs.add(outputId);
+ }
+ }
+ ret.outputConfigs.add(entry);
+ }
+ ret.sessionTemplateId = sessionConfig.getSessionTemplateId();
+ ret.sessionParameter = initializeParcelableMetadata(
+ sessionConfig.getSessionParameters());
+
+ return ret;
+ }
+
+ @Override
+ public void deInitSession() {
+ mSessionProcessor.deInitSession();
+ }
+
+ @Override
+ public void onCaptureSessionStart(IRequestProcessorImpl requestProcessor) {
+ mSessionProcessor.onCaptureSessionStart(new RequestProcessorStub(requestProcessor));
+ }
+
+ @Override
+ public void onCaptureSessionEnd() {
+ mSessionProcessor.onCaptureSessionEnd();
+ }
+
+ @Override
+ public int startRepeating(ICaptureCallback callback) {
+ return mSessionProcessor.startRepeating(new CaptureCallbackStub(callback));
+ }
+
+ @Override
+ public void stopRepeating() {
+ mSessionProcessor.stopRepeating();
+ }
+
+ @Override
+ public int startCapture(ICaptureCallback callback, int jpegRotation, int jpegQuality) {
+ HashMap<CaptureRequest.Key<?>, Object> paramMap = new HashMap<>();
+ paramMap.put(CaptureRequest.JPEG_ORIENTATION, jpegRotation);
+ paramMap.put(CaptureRequest.JPEG_QUALITY, jpegQuality);
+ mSessionProcessor.setParameters(paramMap);
+ return mSessionProcessor.startCapture(new CaptureCallbackStub(callback));
+ }
+ }
+
+ private class OutputSurfaceImplStub implements OutputSurfaceImpl {
+ private final Surface mSurface;
+ private final Size mSize;
+ private final int mImageFormat;
+
+ public OutputSurfaceImplStub(OutputSurface outputSurface) {
+ mSurface = outputSurface.surface;
+ mSize = new Size(outputSurface.size.width, outputSurface.size.height);
+ mImageFormat = outputSurface.imageFormat;
+ }
+
+ @Override
+ public Surface getSurface() {
+ return mSurface;
+ }
+
+ @Override
+ public Size getSize() {
+ return mSize;
+ }
+
+ @Override
+ public int getImageFormat() {
+ return mImageFormat;
+ }
+ }
+
private class PreviewExtenderImplStub extends IPreviewExtenderImpl.Stub {
private final PreviewExtenderImpl mPreviewExtender;
@@ -471,7 +1072,7 @@
@Override
public void init(String cameraId, CameraMetadataNative chars) {
- if (LATEST_VERSION_SUPPORTED) {
+ if (LEGACY_VERSION_SUPPORTED) {
mPreviewExtender.init(cameraId, new CameraCharacteristics(chars));
}
}
@@ -535,7 +1136,7 @@
@Override
public List<SizeList> getSupportedResolutions() {
- if (LATEST_VERSION_SUPPORTED) {
+ if (LEGACY_VERSION_SUPPORTED) {
List<Pair<Integer, android.util.Size[]>> sizes =
mPreviewExtender.getSupportedResolutions();
if ((sizes != null) && !sizes.isEmpty()) {
@@ -581,7 +1182,7 @@
@Override
public void init(String cameraId, CameraMetadataNative chars) {
- if (LATEST_VERSION_SUPPORTED) {
+ if (LEGACY_VERSION_SUPPORTED) {
mImageExtender.init(cameraId, new CameraCharacteristics(chars));
}
}
@@ -627,7 +1228,7 @@
@Override
public List<SizeList> getSupportedResolutions() {
- if (LATEST_VERSION_SUPPORTED) {
+ if (LEGACY_VERSION_SUPPORTED) {
List<Pair<Integer, android.util.Size[]>> sizes =
mImageExtender.getSupportedResolutions();
if ((sizes != null) && !sizes.isEmpty()) {
@@ -737,6 +1338,51 @@
}
}
+ private class ImageReferenceImpl extends ExtensionImage
+ implements androidx.camera.extensions.impl.advanced.ImageReferenceImpl {
+
+ private final Object mImageLock = new Object();
+ private int mReferenceCount;
+
+ private ImageReferenceImpl(ParcelImage parcelImage) {
+ super(parcelImage);
+ mReferenceCount = 1;
+ }
+
+ @Override
+ public boolean increment() {
+ synchronized (mImageLock) {
+ if (mReferenceCount <= 0) {
+ return false;
+ }
+ mReferenceCount++;
+ }
+
+ return true;
+ }
+
+ @Override
+ public boolean decrement() {
+ synchronized (mImageLock) {
+ if (mReferenceCount <= 0) {
+ return false;
+ }
+ mReferenceCount--;
+
+ if (mReferenceCount <= 0) {
+ close();
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public Image get() {
+ return this;
+ }
+ }
+
private class ExtensionImage extends android.media.Image {
private final android.hardware.camera2.extension.ParcelImage mParcelImage;
private GraphicBuffer mGraphicBuffer;
diff --git a/services/api/current.txt b/services/api/current.txt
index 475dcf5..50f0052 100644
--- a/services/api/current.txt
+++ b/services/api/current.txt
@@ -60,6 +60,20 @@
}
+package com.android.server.usage {
+
+ public interface StorageStatsManagerLocal {
+ method public void registerStorageStatsAugmenter(@NonNull com.android.server.usage.StorageStatsManagerLocal.StorageStatsAugmenter, @NonNull String);
+ }
+
+ public static interface StorageStatsManagerLocal.StorageStatsAugmenter {
+ method public void augmentStatsForPackageForUser(@NonNull android.content.pm.PackageStats, @NonNull String, @NonNull android.os.UserHandle, boolean);
+ method public void augmentStatsForUid(@NonNull android.content.pm.PackageStats, int, boolean);
+ method public void augmentStatsForUser(@NonNull android.content.pm.PackageStats, @NonNull android.os.UserHandle);
+ }
+
+}
+
package com.android.server.wifi {
public class SupplicantManager {
diff --git a/services/core/java/com/android/server/IpSecService.java b/services/core/java/com/android/server/IpSecService.java
index d574e74..d6ee951 100644
--- a/services/core/java/com/android/server/IpSecService.java
+++ b/services/core/java/com/android/server/IpSecService.java
@@ -1112,7 +1112,7 @@
case IpSecManager.DIRECTION_IN:
return;
case IpSecManager.DIRECTION_FWD:
- // Only NETWORK_STACK or PERMISSION_NETWORK_STACK allowed to use forward policies
+ // Only NETWORK_STACK or MAINLINE_NETWORK_STACK allowed to use forward policies
PermissionUtils.enforceNetworkStackPermission(mContext);
return;
}
@@ -1358,6 +1358,16 @@
ikey,
0xffffffff,
resourceId);
+
+ // Add a forwarding policy on the tunnel interface. In order to support forwarding
+ // the IpSecTunnelInterface must have a forwarding policy matching the incoming SA.
+ //
+ // Unless a IpSecTransform is also applied against this interface in DIRECTION_FWD,
+ // forwarding will be blocked by default (as would be the case if this policy was
+ // absent).
+ //
+ // This is necessary only on the tunnel interface, and not any the interface to
+ // which traffic will be forwarded to.
netd.ipSecAddSecurityPolicy(
callerUid,
selAddrFamily,
diff --git a/services/core/java/com/android/server/RescueParty.java b/services/core/java/com/android/server/RescueParty.java
index db36e62..c3543e7 100644
--- a/services/core/java/com/android/server/RescueParty.java
+++ b/services/core/java/com/android/server/RescueParty.java
@@ -361,10 +361,13 @@
try {
executeRescueLevelInternal(context, level, failedPackage);
EventLogTags.writeRescueSuccess(level);
- logCriticalInfo(Log.DEBUG,
- "Finished rescue level " + levelToString(level));
+ String successMsg = "Finished rescue level " + levelToString(level);
+ if (!TextUtils.isEmpty(failedPackage)) {
+ successMsg += " for package " + failedPackage;
+ }
+ logCriticalInfo(Log.DEBUG, successMsg);
} catch (Throwable t) {
- logRescueException(level, t);
+ logRescueException(level, failedPackage, t);
}
}
@@ -427,7 +430,7 @@
pm.reboot(TAG);
}
} catch (Throwable t) {
- logRescueException(level, t);
+ logRescueException(level, failedPackage, t);
}
};
thread = new Thread(runnable);
@@ -441,7 +444,7 @@
try {
RecoverySystem.rebootPromptAndWipeUserData(context, TAG);
} catch (Throwable t) {
- logRescueException(level, t);
+ logRescueException(level, failedPackage, t);
}
}
};
@@ -455,11 +458,15 @@
}
}
- private static void logRescueException(int level, Throwable t) {
+ private static void logRescueException(int level, @Nullable String failedPackageName,
+ Throwable t) {
final String msg = ExceptionUtils.getCompleteMessage(t);
EventLogTags.writeRescueFailure(level, msg);
- logCriticalInfo(Log.ERROR,
- "Failed rescue level " + levelToString(level) + ": " + msg);
+ String failureMsg = "Failed rescue level " + levelToString(level);
+ if (!TextUtils.isEmpty(failedPackageName)) {
+ failureMsg += " for package " + failedPackageName;
+ }
+ logCriticalInfo(Log.ERROR, failureMsg + ": " + msg);
}
private static int mapRescueLevelToUserImpact(int rescueLevel) {
diff --git a/services/core/java/com/android/server/SensorPrivacyService.java b/services/core/java/com/android/server/SensorPrivacyService.java
index 7763ad9..ca59ce3 100644
--- a/services/core/java/com/android/server/SensorPrivacyService.java
+++ b/services/core/java/com/android/server/SensorPrivacyService.java
@@ -20,12 +20,17 @@
import static android.app.ActivityManager.RunningServiceInfo;
import static android.app.ActivityManager.RunningTaskInfo;
import static android.app.ActivityManager.getCurrentUser;
+import static android.app.AppOpsManager.MODE_ALLOWED;
import static android.app.AppOpsManager.MODE_IGNORED;
import static android.app.AppOpsManager.OP_CAMERA;
+import static android.app.AppOpsManager.OP_PHONE_CALL_CAMERA;
+import static android.app.AppOpsManager.OP_PHONE_CALL_MICROPHONE;
import static android.app.AppOpsManager.OP_RECORD_AUDIO;
import static android.app.AppOpsManager.OP_RECORD_AUDIO_HOTWORD;
import static android.content.Intent.EXTRA_PACKAGE_NAME;
+import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
+import static android.hardware.SensorPrivacyManager.EXTRA_ALL_SENSORS;
import static android.hardware.SensorPrivacyManager.EXTRA_SENSOR;
import static android.hardware.SensorPrivacyManager.Sensors.CAMERA;
import static android.hardware.SensorPrivacyManager.Sensors.MICROPHONE;
@@ -60,6 +65,7 @@
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
+import android.os.Process;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.ResultReceiver;
@@ -141,6 +147,7 @@
private static final int VER0_INDIVIDUAL_ENABLED = 1;
private static final int VER1_ENABLED = 0;
private static final int VER1_INDIVIDUAL_ENABLED = 1;
+ public static final int REMINDER_DIALOG_DELAY_MILLIS = 500;
private final Context mContext;
private final SensorPrivacyServiceImpl mSensorPrivacyServiceImpl;
@@ -206,6 +213,36 @@
private ArrayMap<Pair<String, UserHandle>, ArrayList<IBinder>> mSuppressReminders =
new ArrayMap<>();
+ private final ArrayMap<SensorUseReminderDialogInfo, ArraySet<Integer>>
+ mQueuedSensorUseReminderDialogs = new ArrayMap<>();
+
+ private class SensorUseReminderDialogInfo {
+ private int mTaskId;
+ private UserHandle mUser;
+ private String mPackageName;
+
+ SensorUseReminderDialogInfo(int taskId, UserHandle user, String packageName) {
+ mTaskId = taskId;
+ mUser = user;
+ mPackageName = packageName;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || !(o instanceof SensorUseReminderDialogInfo)) return false;
+ SensorUseReminderDialogInfo that = (SensorUseReminderDialogInfo) o;
+ return mTaskId == that.mTaskId
+ && Objects.equals(mUser, that.mUser)
+ && Objects.equals(mPackageName, that.mPackageName);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mTaskId, mUser, mPackageName);
+ }
+ }
+
SensorPrivacyServiceImpl() {
mHandler = new SensorPrivacyHandler(FgThread.get().getLooper(), mContext);
File sensorPrivacyFile = new File(Environment.getDataSystemDirectory(),
@@ -228,7 +265,8 @@
}
}
- int[] micAndCameraOps = new int[]{OP_RECORD_AUDIO, OP_CAMERA};
+ int[] micAndCameraOps = new int[]{OP_RECORD_AUDIO, OP_PHONE_CALL_MICROPHONE,
+ OP_CAMERA, OP_PHONE_CALL_CAMERA};
mAppOpsManager.startWatchingNoted(micAndCameraOps, this);
mAppOpsManager.startWatchingStarted(micAndCameraOps, this);
@@ -254,15 +292,29 @@
public void onOpNoted(int code, int uid, String packageName,
String attributionTag, @AppOpsManager.OpFlags int flags,
@AppOpsManager.Mode int result) {
- if (result != MODE_IGNORED || (flags & AppOpsManager.OP_FLAGS_ALL_TRUSTED) == 0) {
+ if ((flags & AppOpsManager.OP_FLAGS_ALL_TRUSTED) == 0) {
return;
}
int sensor;
- if (code == OP_RECORD_AUDIO) {
- sensor = MICROPHONE;
+ if (result == MODE_IGNORED) {
+ if (code == OP_RECORD_AUDIO) {
+ sensor = MICROPHONE;
+ } else if (code == OP_CAMERA) {
+ sensor = CAMERA;
+ } else {
+ return;
+ }
+ } else if (result == MODE_ALLOWED) {
+ if (code == OP_PHONE_CALL_MICROPHONE) {
+ sensor = MICROPHONE;
+ } else if (code == OP_PHONE_CALL_CAMERA) {
+ sensor = CAMERA;
+ } else {
+ return;
+ }
} else {
- sensor = CAMERA;
+ return;
}
long token = Binder.clearCallingIdentity();
@@ -294,6 +346,11 @@
}
}
+ if (uid == Process.SYSTEM_UID) {
+ enqueueSensorUseReminderDialogAsync(-1, user, packageName, sensor);
+ return;
+ }
+
// TODO: Handle reminders with multiple sensors
// - If we have a likely activity that triggered the sensor use overlay a dialog over
@@ -312,7 +369,7 @@
if (task.isVisible && task.topActivity.getPackageName().equals(packageName)) {
if (task.isFocused) {
// There is the one focused activity
- showSensorUseReminderDialog(task.taskId, user, packageName, sensor);
+ enqueueSensorUseReminderDialogAsync(task.taskId, user, packageName, sensor);
return;
}
@@ -323,7 +380,7 @@
// TODO: Test this case
// There is one or more non-focused activity
if (tasksOfPackageUsingSensor.size() == 1) {
- showSensorUseReminderDialog(tasksOfPackageUsingSensor.get(0).taskId, user,
+ enqueueSensorUseReminderDialogAsync(tasksOfPackageUsingSensor.get(0).taskId, user,
packageName, sensor);
return;
} else if (tasksOfPackageUsingSensor.size() > 1) {
@@ -360,21 +417,60 @@
* @param packageName The name of the package using the sensor.
* @param sensor The sensor that is being used.
*/
- private void showSensorUseReminderDialog(int taskId, @NonNull UserHandle user,
+ private void enqueueSensorUseReminderDialogAsync(int taskId, @NonNull UserHandle user,
@NonNull String packageName, int sensor) {
+ mHandler.sendMessage(PooledLambda.obtainMessage(
+ this:: enqueueSensorUseReminderDialog, taskId, user, packageName, sensor));
+ }
+
+ private void enqueueSensorUseReminderDialog(int taskId, @NonNull UserHandle user,
+ @NonNull String packageName, int sensor) {
+ SensorUseReminderDialogInfo info =
+ new SensorUseReminderDialogInfo(taskId, user, packageName);
+ if (!mQueuedSensorUseReminderDialogs.containsKey(info)) {
+ ArraySet<Integer> sensors = new ArraySet<Integer>();
+ sensors.add(sensor);
+ mQueuedSensorUseReminderDialogs.put(info, sensors);
+ mHandler.sendMessageDelayed(
+ PooledLambda.obtainMessage(this::showSensorUserReminderDialog, info),
+ REMINDER_DIALOG_DELAY_MILLIS);
+ return;
+ }
+ ArraySet<Integer> sensors = mQueuedSensorUseReminderDialogs.get(info);
+ sensors.add(sensor);
+ }
+
+ private void showSensorUserReminderDialog(@NonNull SensorUseReminderDialogInfo info) {
+ ArraySet<Integer> sensors = mQueuedSensorUseReminderDialogs.get(info);
+ mQueuedSensorUseReminderDialogs.remove(info);
+ if (sensors == null) {
+ Log.e(TAG, "Unable to show sensor use dialog because sensor set is null."
+ + " Was the dialog queue modified from outside the handler thread?");
+ return;
+ }
Intent dialogIntent = new Intent();
dialogIntent.setComponent(ComponentName.unflattenFromString(
mContext.getResources().getString(
R.string.config_sensorUseStartedActivity)));
ActivityOptions options = ActivityOptions.makeBasic();
- options.setLaunchTaskId(taskId);
+ options.setLaunchTaskId(info.mTaskId);
options.setTaskOverlay(true, true);
- dialogIntent.putExtra(EXTRA_PACKAGE_NAME, packageName);
- dialogIntent.putExtra(EXTRA_SENSOR, sensor);
+ dialogIntent.addFlags(FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
- mContext.startActivityAsUser(dialogIntent, options.toBundle(), user);
+ dialogIntent.putExtra(EXTRA_PACKAGE_NAME, info.mPackageName);
+ if (sensors.size() == 1) {
+ dialogIntent.putExtra(EXTRA_SENSOR, sensors.valueAt(0));
+ } else if (sensors.size() == 2) {
+ dialogIntent.putExtra(EXTRA_ALL_SENSORS, true);
+ } else {
+ // Currently the only cases can be 1 or two
+ Log.e(TAG, "Attempted to show sensor use dialog for " + sensors.size()
+ + " sensors");
+ return;
+ }
+ mContext.startActivityAsUser(dialogIntent, options.toBundle(), info.mUser);
}
/**
@@ -469,7 +565,7 @@
@Override
public void setIndividualSensorPrivacy(@UserIdInt int userId, int sensor, boolean enable) {
enforceManageSensorPrivacyPermission();
- if (!canChangeIndividualSensorPrivacy(sensor)) {
+ if (!canChangeIndividualSensorPrivacy(userId, sensor)) {
return;
}
@@ -500,14 +596,14 @@
mHandler.onSensorPrivacyChanged(userId, sensor, enable);
}
- private boolean canChangeIndividualSensorPrivacy(int sensor) {
+ private boolean canChangeIndividualSensorPrivacy(@UserIdInt int userId, int sensor) {
if (sensor == MICROPHONE && mEmergencyCallHelper.isInEmergencyCall()) {
// During emergency call the microphone toggle managed automatically
Log.i(TAG, "Can't change mic toggle during an emergency call");
return false;
}
- if (mKeyguardManager != null && mKeyguardManager.isDeviceLocked()) {
+ if (mKeyguardManager != null && mKeyguardManager.isDeviceLocked(userId)) {
Log.i(TAG, "Can't change mic/cam toggle while device is locked");
return false;
}
diff --git a/services/core/java/com/android/server/VcnManagementService.java b/services/core/java/com/android/server/VcnManagementService.java
index 2bb9084..f625843 100644
--- a/services/core/java/com/android/server/VcnManagementService.java
+++ b/services/core/java/com/android/server/VcnManagementService.java
@@ -167,7 +167,6 @@
@NonNull private final VcnNetworkProvider mNetworkProvider;
@NonNull private final TelephonySubscriptionTrackerCallback mTelephonySubscriptionTrackerCb;
@NonNull private final TelephonySubscriptionTracker mTelephonySubscriptionTracker;
- @NonNull private final VcnContext mVcnContext;
@NonNull private final BroadcastReceiver mPkgChangeReceiver;
@NonNull
@@ -212,7 +211,6 @@
mContext, mLooper, mTelephonySubscriptionTrackerCb);
mConfigDiskRwHelper = mDeps.newPersistableBundleLockingReadWriteHelper(VCN_CONFIG_FILE);
- mVcnContext = mDeps.newVcnContext(mContext, mLooper, mNetworkProvider);
mPkgChangeReceiver = new BroadcastReceiver() {
@Override
@@ -336,8 +334,9 @@
public VcnContext newVcnContext(
@NonNull Context context,
@NonNull Looper looper,
- @NonNull VcnNetworkProvider vcnNetworkProvider) {
- return new VcnContext(context, looper, vcnNetworkProvider);
+ @NonNull VcnNetworkProvider vcnNetworkProvider,
+ boolean getIsInTestMode) {
+ return new VcnContext(context, looper, vcnNetworkProvider, getIsInTestMode);
}
/** Creates a new Vcn instance using the provided configuration */
@@ -419,6 +418,14 @@
"Carrier privilege required for subscription group to set VCN Config");
}
+ private void enforceManageTestNetworksForTestMode(@NonNull VcnConfig vcnConfig) {
+ if (vcnConfig.isTestModeProfile()) {
+ mContext.enforceCallingPermission(
+ android.Manifest.permission.MANAGE_TEST_NETWORKS,
+ "Test-mode require the MANAGE_TEST_NETWORKS permission");
+ }
+ }
+
private class VcnSubscriptionTrackerCallback implements TelephonySubscriptionTrackerCallback {
/**
* Handles subscription group changes, as notified by {@link TelephonySubscriptionTracker}
@@ -542,8 +549,11 @@
final VcnCallbackImpl vcnCallback = new VcnCallbackImpl(subscriptionGroup);
+ final VcnContext vcnContext =
+ mDeps.newVcnContext(
+ mContext, mLooper, mNetworkProvider, config.isTestModeProfile());
final Vcn newInstance =
- mDeps.newVcn(mVcnContext, subscriptionGroup, config, mLastSnapshot, vcnCallback);
+ mDeps.newVcn(vcnContext, subscriptionGroup, config, mLastSnapshot, vcnCallback);
mVcns.put(subscriptionGroup, newInstance);
// Now that a new VCN has started, notify all registered listeners to refresh their
@@ -587,6 +597,7 @@
mContext.getSystemService(AppOpsManager.class)
.checkPackage(mDeps.getBinderCallingUid(), config.getProvisioningPackageName());
+ enforceManageTestNetworksForTestMode(config);
enforceCallingUserAndCarrierPrivilege(subscriptionGroup, opPkgName);
Binder.withCleanCallingIdentity(() -> {
diff --git a/services/core/java/com/android/server/Watchdog.java b/services/core/java/com/android/server/Watchdog.java
index 9835a9a..7a0a3a7 100644
--- a/services/core/java/com/android/server/Watchdog.java
+++ b/services/core/java/com/android/server/Watchdog.java
@@ -97,6 +97,7 @@
"/system/bin/audioserver",
"/system/bin/cameraserver",
"/system/bin/drmserver",
+ "/system/bin/keystore2",
"/system/bin/mediadrmserver",
"/system/bin/mediaserver",
"/system/bin/netd",
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index 1bd53ae..aadb25c 100644
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -24,6 +24,7 @@
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST;
import static android.os.PowerExemptionManager.REASON_ACTIVITY_VISIBILITY_GRACE_PERIOD;
+import static android.os.PowerExemptionManager.REASON_OPT_OUT_REQUESTED;
import static android.os.PowerExemptionManager.REASON_OP_ACTIVATE_PLATFORM_VPN;
import static android.os.PowerExemptionManager.REASON_OP_ACTIVATE_VPN;
import static android.os.PowerExemptionManager.REASON_TEMP_ALLOWED_WHILE_IN_USE;
@@ -5874,7 +5875,12 @@
ret = REASON_OP_ACTIVATE_PLATFORM_VPN;
}
}
-
+ if (ret == REASON_DENIED) {
+ if (mAm.mConstants.mFgsAllowOptOut
+ && targetService.appInfo.hasRequestForegroundServiceExemption()) {
+ ret = REASON_OPT_OUT_REQUESTED;
+ }
+ }
return ret;
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerConstants.java b/services/core/java/com/android/server/am/ActivityManagerConstants.java
index 0979585..0fff8be 100644
--- a/services/core/java/com/android/server/am/ActivityManagerConstants.java
+++ b/services/core/java/com/android/server/am/ActivityManagerConstants.java
@@ -110,6 +110,7 @@
static final String KEY_FGS_START_FOREGROUND_TIMEOUT = "fgs_start_foreground_timeout";
static final String KEY_FGS_ATOM_SAMPLE_RATE = "fgs_atom_sample_rate";
static final String KEY_KILL_FAS_CACHED_IDLE = "kill_fas_cached_idle";
+ static final String KEY_FGS_ALLOW_OPT_OUT = "fgs_allow_opt_out";
private static final int DEFAULT_MAX_CACHED_PROCESSES = 32;
private static final long DEFAULT_FGSERVICE_MIN_SHOWN_TIME = 2*1000;
@@ -161,6 +162,7 @@
*/
private static final int
DEFAULT_PUSH_MESSAGING_OVER_QUOTA_BEHAVIOR = 1;
+ private static final boolean DEFAULT_FGS_ALLOW_OPT_OUT = false;
// Flag stored in the DeviceConfig API.
/**
@@ -493,6 +495,12 @@
*/
volatile boolean mKillForceAppStandByAndCachedIdle = DEFAULT_KILL_FAS_CACHED_IDLE;
+ /**
+ * Whether to allow "opt-out" from the foreground service restrictions.
+ * (https://developer.android.com/about/versions/12/foreground-services)
+ */
+ volatile boolean mFgsAllowOptOut = DEFAULT_FGS_ALLOW_OPT_OUT;
+
private final ActivityManagerService mService;
private ContentResolver mResolver;
private final KeyValueListParser mParser = new KeyValueListParser(',');
@@ -701,6 +709,9 @@
case KEY_KILL_FAS_CACHED_IDLE:
updateKillFasCachedIdle();
break;
+ case KEY_FGS_ALLOW_OPT_OUT:
+ updateFgsAllowOptOut();
+ break;
default:
break;
}
@@ -1040,6 +1051,13 @@
DEFAULT_KILL_FAS_CACHED_IDLE);
}
+ private void updateFgsAllowOptOut() {
+ mFgsAllowOptOut = DeviceConfig.getBoolean(
+ DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
+ KEY_FGS_ALLOW_OPT_OUT,
+ DEFAULT_FGS_ALLOW_OPT_OUT);
+ }
+
private void updateImperceptibleKillExemptions() {
IMPERCEPTIBLE_KILL_EXEMPT_PACKAGES.clear();
IMPERCEPTIBLE_KILL_EXEMPT_PACKAGES.addAll(mDefaultImperceptibleKillExemptPackages);
@@ -1260,6 +1278,8 @@
pw.print("="); pw.println(mFgsAtomSampleRate);
pw.print(" "); pw.print(KEY_PUSH_MESSAGING_OVER_QUOTA_BEHAVIOR);
pw.print("="); pw.println(mPushMessagingOverQuotaBehavior);
+ pw.print(" "); pw.print(KEY_FGS_ALLOW_OPT_OUT);
+ pw.print("="); pw.println(mFgsAllowOptOut);
pw.println();
if (mOverrideMaxCachedProcesses >= 0) {
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 70538bb..83cff15 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -9335,7 +9335,7 @@
pw.println(" mFgsStartTempAllowList:");
final long currentTimeNow = System.currentTimeMillis();
final long elapsedRealtimeNow = SystemClock.elapsedRealtime();
- final Set<Integer> uids = mFgsStartTempAllowList.keySet();
+ final Set<Integer> uids = new ArraySet<>(mFgsStartTempAllowList.keySet());
for (Integer uid : uids) {
final Pair<Long, FgsTempAllowListItem> entry = mFgsStartTempAllowList.get(uid);
if (entry == null) {
diff --git a/services/core/java/com/android/server/am/BroadcastQueue.java b/services/core/java/com/android/server/am/BroadcastQueue.java
index f0b116c..de2c11b 100644
--- a/services/core/java/com/android/server/am/BroadcastQueue.java
+++ b/services/core/java/com/android/server/am/BroadcastQueue.java
@@ -828,6 +828,7 @@
} else {
r.receiverTime = SystemClock.uptimeMillis();
maybeAddAllowBackgroundActivityStartsToken(filter.receiverList.app, r);
+ maybeScheduleTempAllowlistLocked(filter.owningUid, r, r.options);
performReceiveLocked(filter.receiverList.app, filter.receiverList.receiver,
new Intent(r.intent), r.resultCode, r.resultData,
r.resultExtras, r.ordered, r.initialSticky, r.userId);
@@ -911,9 +912,16 @@
return false;
}
- final void scheduleTempAllowlistLocked(int uid, long duration, BroadcastRecord r,
- @TempAllowListType int type, @ReasonCode int reasonCode,
- @Nullable String reason) {
+ void maybeScheduleTempAllowlistLocked(int uid, BroadcastRecord r,
+ @Nullable BroadcastOptions brOptions) {
+ if (brOptions == null || brOptions.getTemporaryAppAllowlistDuration() <= 0) {
+ return;
+ }
+ long duration = brOptions.getTemporaryAppAllowlistDuration();
+ final @TempAllowListType int type = brOptions.getTemporaryAppAllowlistType();
+ final @ReasonCode int reasonCode = brOptions.getTemporaryAppAllowlistReasonCode();
+ final String reason = brOptions.getTemporaryAppAllowlistReason();
+
if (duration > Integer.MAX_VALUE) {
duration = Integer.MAX_VALUE;
}
@@ -1344,13 +1352,6 @@
// r is guaranteed ordered at this point, so we know finishReceiverLocked()
// will get a callback and handle the activity start token lifecycle.
}
- if (brOptions != null && brOptions.getTemporaryAppAllowlistDuration() > 0) {
- scheduleTempAllowlistLocked(filter.owningUid,
- brOptions.getTemporaryAppAllowlistDuration(), r,
- brOptions.getTemporaryAppAllowlistType(),
- brOptions.getTemporaryAppAllowlistReasonCode(),
- brOptions.getTemporaryAppAllowlistReason());
- }
}
return;
}
@@ -1646,16 +1647,9 @@
+ info.activityInfo + ", callingUid = " + r.callingUid + ", uid = "
+ receiverUid);
}
-
final boolean isActivityCapable =
(brOptions != null && brOptions.getTemporaryAppAllowlistDuration() > 0);
- if (isActivityCapable) {
- scheduleTempAllowlistLocked(receiverUid,
- brOptions.getTemporaryAppAllowlistDuration(), r,
- brOptions.getTemporaryAppAllowlistType(),
- brOptions.getTemporaryAppAllowlistReasonCode(),
- brOptions.getTemporaryAppAllowlistReason());
- }
+ maybeScheduleTempAllowlistLocked(receiverUid, r, brOptions);
// Report that a component is used for explicit broadcasts.
if (!r.intent.isExcludingStopped() && r.curComponent != null
diff --git a/services/core/java/com/android/server/am/CachedAppOptimizer.java b/services/core/java/com/android/server/am/CachedAppOptimizer.java
index cc750ce..709139e 100644
--- a/services/core/java/com/android/server/am/CachedAppOptimizer.java
+++ b/services/core/java/com/android/server/am/CachedAppOptimizer.java
@@ -838,7 +838,7 @@
KEY_FREEZER_DEBOUNCE_TIMEOUT, DEFAULT_FREEZER_DEBOUNCE_TIMEOUT);
if (mFreezerDebounceTimeout < 0) {
- mFullDeltaRssThrottleKb = DEFAULT_FREEZER_DEBOUNCE_TIMEOUT;
+ mFreezerDebounceTimeout = DEFAULT_FREEZER_DEBOUNCE_TIMEOUT;
}
}
diff --git a/services/core/java/com/android/server/am/OomAdjuster.java b/services/core/java/com/android/server/am/OomAdjuster.java
index 40db086..01bbb03 100644
--- a/services/core/java/com/android/server/am/OomAdjuster.java
+++ b/services/core/java/com/android/server/am/OomAdjuster.java
@@ -394,6 +394,10 @@
mProcessGroupHandler = new Handler(adjusterThread.getLooper(), msg -> {
final int pid = msg.arg1;
final int group = msg.arg2;
+ if (pid == ActivityManagerService.MY_PID) {
+ // Skip setting the process group for system_server, keep it as default.
+ return true;
+ }
if (Trace.isTagEnabled(Trace.TRACE_TAG_ACTIVITY_MANAGER)) {
Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "setProcessGroup "
+ msg.obj + " to " + group);
diff --git a/services/core/java/com/android/server/am/ProcessCachedOptimizerRecord.java b/services/core/java/com/android/server/am/ProcessCachedOptimizerRecord.java
index a33e7e5..408c7cb 100644
--- a/services/core/java/com/android/server/am/ProcessCachedOptimizerRecord.java
+++ b/services/core/java/com/android/server/am/ProcessCachedOptimizerRecord.java
@@ -171,7 +171,7 @@
return mFreezeExempt;
}
- @GuardedBy("mPreLock")
+ @GuardedBy("mProcLock")
void setFreezeExempt(boolean exempt) {
mFreezeExempt = exempt;
}
diff --git a/services/core/java/com/android/server/apphibernation/AppHibernationService.java b/services/core/java/com/android/server/apphibernation/AppHibernationService.java
index 78ff67a..05c4431 100644
--- a/services/core/java/com/android/server/apphibernation/AppHibernationService.java
+++ b/services/core/java/com/android/server/apphibernation/AppHibernationService.java
@@ -296,9 +296,7 @@
FrameworkStatsLog.USER_LEVEL_HIBERNATION_STATE_CHANGED,
stateSnapshot.packageName,
userIdSnapshot,
- stateSnapshot.hibernated,
- // TODO(b/187224817): This isn't the expected value right now.
- stateSnapshot.lastUnhibernatedMs);
+ stateSnapshot.hibernated);
});
List<UserLevelState> states = new ArrayList<>(mUserStates.get(userId).values());
mUserDiskStores.get(userId).scheduleWriteHibernationStates(states);
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index 99b0d81..a23b5eb 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -30,6 +30,7 @@
import static android.app.AppOpsManager.KEY_TOP_STATE_SETTLE_TIME;
import static android.app.AppOpsManager.MODE_ALLOWED;
import static android.app.AppOpsManager.MODE_DEFAULT;
+import static android.app.AppOpsManager.MODE_ERRORED;
import static android.app.AppOpsManager.MODE_FOREGROUND;
import static android.app.AppOpsManager.MODE_IGNORED;
import static android.app.AppOpsManager.NoteOpEvent;
@@ -827,6 +828,14 @@
@GuardedBy("AppOpsService.this")
private @Nullable ArrayMap<IBinder, InProgressStartOpEvent> mInProgressEvents;
+ /**
+ * Currently paused startOp events
+ *
+ * <p>Key is clientId
+ */
+ @GuardedBy("AppOpsService.this")
+ private @Nullable ArrayMap<IBinder, InProgressStartOpEvent> mPausedInProgressEvents;
+
AttributedOp(@Nullable String tag, @NonNull Op parent) {
this.tag = tag;
this.parent = parent;
@@ -944,23 +953,36 @@
@Nullable String proxyPackageName, @Nullable String proxyAttributionTag,
@AppOpsManager.UidState int uidState, @OpFlags int flags,
boolean triggerCallbackIfNeeded) throws RemoteException {
- if (triggerCallbackIfNeeded && !parent.isRunning()) {
+ startedOrPaused(clientId, proxyUid, proxyPackageName, proxyAttributionTag,
+ uidState, flags, triggerCallbackIfNeeded, true);
+ }
+
+ private void startedOrPaused(@NonNull IBinder clientId, int proxyUid,
+ @Nullable String proxyPackageName, @Nullable String proxyAttributionTag,
+ @AppOpsManager.UidState int uidState, @OpFlags int flags,
+ boolean triggerCallbackIfNeeded, boolean isStarted) throws RemoteException {
+ if (triggerCallbackIfNeeded && !parent.isRunning() && isStarted) {
scheduleOpActiveChangedIfNeededLocked(parent.op, parent.uid,
parent.packageName, true);
}
- if (mInProgressEvents == null) {
+
+ if (isStarted && mInProgressEvents == null) {
mInProgressEvents = new ArrayMap<>(1);
+ } else if (mPausedInProgressEvents == null) {
+ mPausedInProgressEvents = new ArrayMap<>(1);
}
+ ArrayMap<IBinder, InProgressStartOpEvent> events = isStarted
+ ? mInProgressEvents : mPausedInProgressEvents;
long startTime = System.currentTimeMillis();
- InProgressStartOpEvent event = mInProgressEvents.get(clientId);
+ InProgressStartOpEvent event = events.get(clientId);
if (event == null) {
event = mInProgressStartOpEventPool.acquire(startTime,
SystemClock.elapsedRealtime(), clientId,
PooledLambda.obtainRunnable(AppOpsService::onClientDeath, this, clientId),
proxyUid, proxyPackageName, proxyAttributionTag, uidState, flags);
- mInProgressEvents.put(clientId, event);
+ events.put(clientId, event);
} else {
if (uidState != event.mUidState) {
onUidStateChanged(uidState);
@@ -969,12 +991,15 @@
event.numUnfinishedStarts++;
- mHistoricalRegistry.incrementOpAccessedCount(parent.op, parent.uid, parent.packageName,
- tag, uidState, flags, startTime);
+ if (isStarted) {
+ mHistoricalRegistry.incrementOpAccessedCount(parent.op, parent.uid,
+ parent.packageName, tag, uidState, flags, startTime);
+ }
+
}
/**
- * Update state when finishOp was called
+ * Update state when finishOp was called. Will finish started ops, and delete paused ops.
*
* @param clientId Id of the finishOp caller
*/
@@ -983,22 +1008,32 @@
}
private void finished(@NonNull IBinder clientId, boolean triggerCallbackIfNeeded) {
- if (mInProgressEvents == null) {
- Slog.wtf(TAG, "No ops running");
- return;
- }
+ finishOrPause(clientId, triggerCallbackIfNeeded, false);
+ }
- int indexOfToken = mInProgressEvents.indexOfKey(clientId);
+ /**
+ * Update state when paused or finished is called. If pausing, it records the op as
+ * stopping in the HistoricalRegistry, but does not delete it.
+ */
+ private void finishOrPause(@NonNull IBinder clientId, boolean triggerCallbackIfNeeded,
+ boolean isPausing) {
+ int indexOfToken = mInProgressEvents != null
+ ? mInProgressEvents.indexOfKey(clientId) : -1;
if (indexOfToken < 0) {
- Slog.wtf(TAG, "No op running for the client");
+ finishPossiblyPaused(clientId, isPausing);
return;
}
InProgressStartOpEvent event = mInProgressEvents.valueAt(indexOfToken);
- event.numUnfinishedStarts--;
- if (event.numUnfinishedStarts == 0) {
- event.finish();
- mInProgressEvents.removeAt(indexOfToken);
+ if (!isPausing) {
+ event.numUnfinishedStarts--;
+ }
+ // If we are pausing, create a NoteOpEvent, but don't change the InProgress event
+ if (event.numUnfinishedStarts == 0 || isPausing) {
+ if (!isPausing) {
+ event.finish();
+ mInProgressEvents.removeAt(indexOfToken);
+ }
if (mAccessEvents == null) {
mAccessEvents = new LongSparseArray<>(1);
@@ -1018,20 +1053,112 @@
parent.packageName, tag, event.getUidState(),
event.getFlags(), finishedEvent.getNoteTime(), finishedEvent.getDuration());
- mInProgressStartOpEventPool.release(event);
+ if (!isPausing) {
+ mInProgressStartOpEventPool.release(event);
+ if (mInProgressEvents.isEmpty()) {
+ mInProgressEvents = null;
- if (mInProgressEvents.isEmpty()) {
- mInProgressEvents = null;
-
- // TODO moltmann: Also callback for single attribution tag activity changes
- if (triggerCallbackIfNeeded && !parent.isRunning()) {
- scheduleOpActiveChangedIfNeededLocked(parent.op, parent.uid,
- parent.packageName, false);
+ // TODO ntmyren: Also callback for single attribution tag activity changes
+ if (triggerCallbackIfNeeded && !parent.isRunning()) {
+ scheduleOpActiveChangedIfNeededLocked(parent.op, parent.uid,
+ parent.packageName, false);
+ }
}
}
}
}
+ // Finish or pause (no-op) an already paused op
+ private void finishPossiblyPaused(@NonNull IBinder clientId, boolean isPausing) {
+ if (mPausedInProgressEvents == null) {
+ Slog.wtf(TAG, "No ops running or paused");
+ return;
+ }
+
+ int indexOfToken = mPausedInProgressEvents.indexOfKey(clientId);
+ if (indexOfToken < 0) {
+ Slog.wtf(TAG, "No op running or paused for the client");
+ return;
+ } else if (isPausing) {
+ // already paused
+ return;
+ }
+
+ // no need to record a paused event finishing.
+ InProgressStartOpEvent event = mInProgressEvents.valueAt(indexOfToken);
+ event.numUnfinishedStarts--;
+ if (event.numUnfinishedStarts == 0) {
+ mPausedInProgressEvents.removeAt(indexOfToken);
+ mInProgressStartOpEventPool.release(event);
+ if (mPausedInProgressEvents.isEmpty()) {
+ mPausedInProgressEvents = null;
+ }
+ }
+ }
+
+ /**
+ * Create an event that will be started, if the op is unpaused.
+ */
+ public void createPaused(@NonNull IBinder clientId, int proxyUid,
+ @Nullable String proxyPackageName, @Nullable String proxyAttributionTag,
+ @AppOpsManager.UidState int uidState, @OpFlags int flags) throws RemoteException {
+ startedOrPaused(clientId, proxyUid, proxyPackageName, proxyAttributionTag,
+ uidState, flags, true, false);
+ }
+
+ /**
+ * Pause all currently started ops. This will create a HistoricalRegistry
+ */
+ public void pause() {
+ if (mInProgressEvents == null) {
+ return;
+ }
+
+ if (mPausedInProgressEvents == null) {
+ mPausedInProgressEvents = new ArrayMap<>(1);
+ }
+
+ for (int i = 0; i < mInProgressEvents.size(); i++) {
+ InProgressStartOpEvent event = mInProgressEvents.valueAt(i);
+ mPausedInProgressEvents.put(event.mClientId, event);
+ finishOrPause(event.mClientId, true, true);
+ }
+ scheduleOpActiveChangedIfNeededLocked(parent.op, parent.uid,
+ parent.packageName, false);
+ mInProgressEvents = null;
+ }
+
+ /**
+ * Unpause all currently paused ops. This will reinitialize their start and duration
+ * times, but keep all other values the same
+ */
+ public void resume() {
+ if (mPausedInProgressEvents == null) {
+ return;
+ }
+
+ if (mInProgressEvents == null) {
+ mInProgressEvents = new ArrayMap<>(mPausedInProgressEvents.size());
+ }
+ boolean shouldSendActive = !mPausedInProgressEvents.isEmpty()
+ && mInProgressEvents.isEmpty();
+
+ long startTime = System.currentTimeMillis();
+ for (int i = 0; i < mPausedInProgressEvents.size(); i++) {
+ InProgressStartOpEvent event = mPausedInProgressEvents.valueAt(i);
+ mInProgressEvents.put(event.mClientId, event);
+ event.mStartElapsedTime = SystemClock.elapsedRealtime();
+ event.mStartTime = startTime;
+ mHistoricalRegistry.incrementOpAccessedCount(parent.op, parent.uid,
+ parent.packageName, tag, event.mUidState, event.mFlags, startTime);
+ }
+ if (shouldSendActive) {
+ scheduleOpActiveChangedIfNeededLocked(parent.op, parent.uid,
+ parent.packageName, true);
+ }
+ mPausedInProgressEvents = null;
+ }
+
/**
* Called in the case the client dies without calling finish first
*
@@ -2303,6 +2430,9 @@
scheduleWriteLocked();
}
uidState.evalForegroundOps(mOpModeWatchers);
+ if (mode != MODE_ERRORED && mode != previousMode) {
+ updateStartedOpModeForUidLocked(code, mode == MODE_IGNORED, uid);
+ }
}
notifyOpChangedForAllPkgsInUid(code, uid, false, permissionPolicyCallback);
@@ -2556,6 +2686,9 @@
pruneOpLocked(op, uid, packageName);
}
scheduleFastWriteLocked();
+ if (mode != MODE_ERRORED) {
+ updateStartedOpModeForUidLocked(code, mode == MODE_IGNORED, uid);
+ }
}
}
}
@@ -3161,7 +3294,7 @@
boolean shouldCollectMessage) {
RestrictionBypass bypass;
try {
- bypass = verifyAndGetBypass(uid, packageName, attributionTag);
+ bypass = verifyAndGetBypass(uid, packageName, attributionTag, proxyPackageName);
} catch (SecurityException e) {
Slog.e(TAG, "noteOperation", e);
return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag,
@@ -3653,13 +3786,14 @@
boolean shouldCollectMessage, boolean dryRun) {
RestrictionBypass bypass;
try {
- bypass = verifyAndGetBypass(uid, packageName, attributionTag);
+ bypass = verifyAndGetBypass(uid, packageName, attributionTag, proxyPackageName);
} catch (SecurityException e) {
Slog.e(TAG, "startOperation", e);
return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag,
packageName);
}
+ boolean isRestricted = false;
synchronized (this) {
final Ops ops = getOpsLocked(uid, packageName, attributionTag, bypass, true /* edit */);
if (ops == null) {
@@ -3673,18 +3807,10 @@
packageName);
}
final Op op = getOpLocked(ops, code, uid, true);
- if (isOpRestrictedLocked(uid, code, packageName, bypass)) {
- if (!dryRun) {
- scheduleOpStartedIfNeededLocked(code, uid, packageName, attributionTag,
- flags, AppOpsManager.MODE_IGNORED);
- }
- return new SyncNotedAppOp(AppOpsManager.MODE_IGNORED, code, attributionTag,
- packageName);
- }
-
final AttributedOp attributedOp = op.getOrCreateAttribution(op, attributionTag);
- final int switchCode = AppOpsManager.opToSwitch(code);
final UidState uidState = ops.uidState;
+ isRestricted = isOpRestrictedLocked(uid, code, packageName, bypass);
+ final int switchCode = AppOpsManager.opToSwitch(code);
// If there is a non-default per UID policy (we set UID op mode only if
// non-default) it takes over, otherwise use the per package policy.
if (uidState.opModes != null && uidState.opModes.indexOfKey(switchCode) >= 0) {
@@ -3720,25 +3846,30 @@
}
}
if (DEBUG) Slog.d(TAG, "startOperation: allowing code " + code + " uid " + uid
- + " package " + packageName);
+ + " package " + packageName + " restricted: " + isRestricted);
if (!dryRun) {
- scheduleOpStartedIfNeededLocked(code, uid, packageName, attributionTag, flags,
- AppOpsManager.MODE_ALLOWED);
try {
- attributedOp.started(clientId, proxyUid, proxyPackageName, proxyAttributionTag,
- uidState.state, flags);
+ if (isRestricted) {
+ attributedOp.createPaused(clientId, proxyUid, proxyPackageName,
+ proxyAttributionTag, uidState.state, flags);
+ } else {
+ attributedOp.started(clientId, proxyUid, proxyPackageName,
+ proxyAttributionTag, uidState.state, flags);
+ }
} catch (RemoteException e) {
throw new RuntimeException(e);
}
+ scheduleOpStartedIfNeededLocked(code, uid, packageName, attributionTag, flags,
+ isRestricted ? MODE_IGNORED : MODE_ALLOWED);
}
}
- if (shouldCollectAsyncNotedOp && !dryRun) {
+ if (shouldCollectAsyncNotedOp && !dryRun && !isRestricted) {
collectAsyncNotedOp(uid, packageName, code, attributionTag, AppOpsManager.OP_FLAG_SELF,
message, shouldCollectMessage);
}
- return new SyncNotedAppOp(AppOpsManager.MODE_ALLOWED, code, attributionTag,
+ return new SyncNotedAppOp(isRestricted ? MODE_IGNORED : MODE_ALLOWED, code, attributionTag,
packageName);
}
@@ -4187,17 +4318,26 @@
}
/**
+ * @see verifyAndGetBypass(int, String, String, String)
+ */
+ private @Nullable RestrictionBypass verifyAndGetBypass(int uid, String packageName,
+ @Nullable String attributionTag) {
+ return verifyAndGetBypass(uid, packageName, attributionTag, null);
+ }
+
+ /**
* Verify that package belongs to uid and return the {@link RestrictionBypass bypass
* description} for the package.
*
* @param uid The uid the package belongs to
* @param packageName The package the might belong to the uid
* @param attributionTag attribution tag or {@code null} if no need to verify
+ * @param proxyPackageName The proxy package, from which the attribution tag is to be pulled
*
* @return {@code true} iff the package is privileged
*/
private @Nullable RestrictionBypass verifyAndGetBypass(int uid, String packageName,
- @Nullable String attributionTag) {
+ @Nullable String attributionTag, @Nullable String proxyPackageName) {
if (uid == Process.ROOT_UID) {
// For backwards compatibility, don't check package name for root UID.
return null;
@@ -4235,34 +4375,36 @@
final long ident = Binder.clearCallingIdentity();
try {
boolean isAttributionTagValid = false;
- AndroidPackage pkg = LocalServices.getService(PackageManagerInternal.class)
- .getPackage(packageName);
+ PackageManagerInternal pmInt = LocalServices.getService(PackageManagerInternal.class);
+ AndroidPackage pkg = pmInt.getPackage(packageName);
if (pkg != null) {
- if (attributionTag == null) {
- isAttributionTagValid = true;
- } else {
- if (pkg.getAttributions() != null) {
- int numAttributions = pkg.getAttributions().size();
- for (int i = 0; i < numAttributions; i++) {
- if (pkg.getAttributions().get(i).tag.equals(attributionTag)) {
- isAttributionTagValid = true;
- }
- }
- }
- }
+ isAttributionTagValid = isAttributionInPackage(pkg, attributionTag);
pkgUid = UserHandle.getUid(userId, UserHandle.getAppId(pkg.getUid()));
bypass = getBypassforPackage(pkg);
}
if (!isAttributionTagValid) {
- String msg = "attributionTag " + attributionTag + " not declared in"
- + " manifest of " + packageName;
+ AndroidPackage proxyPkg = proxyPackageName != null
+ ? pmInt.getPackage(proxyPackageName) : null;
+ boolean foundInProxy = isAttributionInPackage(proxyPkg, attributionTag);
+ String msg;
+ if (pkg != null && foundInProxy) {
+ msg = "attributionTag " + attributionTag + " declared in manifest of the proxy"
+ + " package " + proxyPackageName + ", this is not advised";
+ } else if (pkg != null) {
+ msg = "attributionTag " + attributionTag + " not declared in manifest of "
+ + packageName;
+ } else {
+ msg = "package " + packageName + " not found, can't check for "
+ + "attributionTag " + attributionTag;
+ }
+
try {
if (mPlatformCompat.isChangeEnabledByPackageName(
SECURITY_EXCEPTION_ON_INVALID_ATTRIBUTION_TAG_CHANGE, packageName,
userId) && mPlatformCompat.isChangeEnabledByUid(
SECURITY_EXCEPTION_ON_INVALID_ATTRIBUTION_TAG_CHANGE,
- callingUid)) {
+ callingUid) && !foundInProxy) {
throw new SecurityException(msg);
} else {
Slog.e(TAG, msg);
@@ -4282,6 +4424,25 @@
return bypass;
}
+ private boolean isAttributionInPackage(@Nullable AndroidPackage pkg,
+ @Nullable String attributionTag) {
+ if (pkg == null) {
+ return false;
+ } else if (attributionTag == null) {
+ return true;
+ }
+ if (pkg.getAttributions() != null) {
+ int numAttributions = pkg.getAttributions().size();
+ for (int i = 0; i < numAttributions; i++) {
+ if (pkg.getAttributions().get(i).tag.equals(attributionTag)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
/**
* Get (and potentially create) ops.
*
@@ -6116,6 +6277,9 @@
if (restrictionState.setRestriction(code, restricted, exceptionPackages, userHandle)) {
mHandler.sendMessage(PooledLambda.obtainMessage(
AppOpsService::notifyWatchersOfChange, this, code, UID_ANY));
+ mHandler.sendMessage(PooledLambda.obtainMessage(
+ AppOpsService::updateStartedOpModeForUser, this, code, restricted,
+ userHandle));
}
if (restrictionState.isDefault()) {
@@ -6125,6 +6289,44 @@
}
}
+ private void updateStartedOpModeForUser(int code, boolean restricted, int userId) {
+ synchronized (AppOpsService.this) {
+ int numUids = mUidStates.size();
+ for (int uidNum = 0; uidNum < numUids; uidNum++) {
+ int uid = mUidStates.keyAt(uidNum);
+ if (userId != UserHandle.USER_ALL && UserHandle.getUserId(uid) != userId) {
+ continue;
+ }
+ updateStartedOpModeForUidLocked(code, restricted, uid);
+ }
+ }
+ }
+
+ private void updateStartedOpModeForUidLocked(int code, boolean restricted, int uid) {
+ UidState uidState = mUidStates.get(uid);
+ if (uidState == null || uidState.pkgOps == null) {
+ return;
+ }
+
+ int numPkgOps = uidState.pkgOps.size();
+ for (int pkgNum = 0; pkgNum < numPkgOps; pkgNum++) {
+ Ops ops = uidState.pkgOps.valueAt(pkgNum);
+ Op op = ops != null ? ops.get(code) : null;
+ if (op == null || (op.mode != MODE_ALLOWED && op.mode != MODE_FOREGROUND)) {
+ continue;
+ }
+ int numAttrTags = op.mAttributions.size();
+ for (int attrNum = 0; attrNum < numAttrTags; attrNum++) {
+ AttributedOp attrOp = op.mAttributions.valueAt(attrNum);
+ if (restricted) {
+ attrOp.pause();
+ } else {
+ attrOp.resume();
+ }
+ }
+ }
+ }
+
private void notifyWatchersOfChange(int code, int uid) {
final ArraySet<ModeCallback> clonedCallbacks;
synchronized (this) {
diff --git a/services/core/java/com/android/server/appop/HistoricalRegistry.java b/services/core/java/com/android/server/appop/HistoricalRegistry.java
index 5556015..35e8d34 100644
--- a/services/core/java/com/android/server/appop/HistoricalRegistry.java
+++ b/services/core/java/com/android/server/appop/HistoricalRegistry.java
@@ -555,8 +555,6 @@
}
if (mMode == AppOpsManager.HISTORICAL_MODE_ENABLED_PASSIVE) {
mDiscreteRegistry.setDebugMode(true);
- } else {
- mDiscreteRegistry.setDebugMode(false);
}
}
if (mBaseSnapshotInterval != baseSnapshotInterval) {
@@ -627,6 +625,7 @@
}
setHistoryParameters(DEFAULT_MODE, DEFAULT_SNAPSHOT_INTERVAL_MILLIS,
DEFAULT_COMPRESSION_STEP);
+ mDiscreteRegistry.setDebugMode(false);
}
void clearHistory(int uid, String packageName) {
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 098ce7c..a2722cb 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -6535,6 +6535,10 @@
if (index == -1) {
continue;
}
+ if (mPublicStreamType == AudioSystem.STREAM_SYSTEM_ENFORCED
+ && mCameraSoundForced) {
+ index = mIndexMax;
+ }
if (DEBUG_VOL) {
Log.v(TAG, "readSettings: found stored index " + getValidIndex(index)
+ " for group " + mAudioVolumeGroup.name() + ", device: " + name
diff --git a/services/core/java/com/android/server/biometrics/sensors/BaseClientMonitor.java b/services/core/java/com/android/server/biometrics/sensors/BaseClientMonitor.java
index 677ea5d..6482a2e 100644
--- a/services/core/java/com/android/server/biometrics/sensors/BaseClientMonitor.java
+++ b/services/core/java/com/android/server/biometrics/sensors/BaseClientMonitor.java
@@ -46,6 +46,7 @@
* Interface that ClientMonitor holders should use to receive callbacks.
*/
public interface Callback {
+
/**
* Invoked when the ClientMonitor operation has been started (e.g. reached the head of
* the queue and becomes the current operation).
@@ -222,6 +223,7 @@
+ this.getClass().getSimpleName()
+ ", " + getProtoEnum()
+ ", " + getOwnerString()
- + ", " + getCookie() + "}";
+ + ", " + getCookie()
+ + ", " + getTargetUserId() + "}";
}
}
diff --git a/services/core/java/com/android/server/biometrics/sensors/ClientMonitorCallbackConverter.java b/services/core/java/com/android/server/biometrics/sensors/ClientMonitorCallbackConverter.java
index 62a9769..f1c786b49 100644
--- a/services/core/java/com/android/server/biometrics/sensors/ClientMonitorCallbackConverter.java
+++ b/services/core/java/com/android/server/biometrics/sensors/ClientMonitorCallbackConverter.java
@@ -132,11 +132,13 @@
}
}
- public void onChallengeGenerated(int sensorId, long challenge) throws RemoteException {
+ /** Called when a challenged has been generated. */
+ public void onChallengeGenerated(int sensorId, int userId, long challenge)
+ throws RemoteException {
if (mFaceServiceReceiver != null) {
- mFaceServiceReceiver.onChallengeGenerated(sensorId, challenge);
+ mFaceServiceReceiver.onChallengeGenerated(sensorId, userId, challenge);
} else if (mFingerprintServiceReceiver != null) {
- mFingerprintServiceReceiver.onChallengeGenerated(sensorId, challenge);
+ mFingerprintServiceReceiver.onChallengeGenerated(sensorId, userId, challenge);
}
}
@@ -153,18 +155,6 @@
}
}
- public void onChallengeInterrupted(int sensorId) throws RemoteException {
- if (mFaceServiceReceiver != null) {
- mFaceServiceReceiver.onChallengeInterrupted(sensorId);
- }
- }
-
- public void onChallengeInterruptFinished(int sensorId) throws RemoteException {
- if (mFaceServiceReceiver != null) {
- mFaceServiceReceiver.onChallengeInterruptFinished(sensorId);
- }
- }
-
// Fingerprint-specific callbacks for FingerprintManager only
public void onUdfpsPointerDown(int sensorId) throws RemoteException {
diff --git a/services/core/java/com/android/server/biometrics/sensors/GenerateChallengeClient.java b/services/core/java/com/android/server/biometrics/sensors/GenerateChallengeClient.java
index 1fcad62..3d74f36 100644
--- a/services/core/java/com/android/server/biometrics/sensors/GenerateChallengeClient.java
+++ b/services/core/java/com/android/server/biometrics/sensors/GenerateChallengeClient.java
@@ -40,7 +40,7 @@
@Override
public void unableToStart() {
try {
- getListener().onChallengeGenerated(getSensorId(), 0L);
+ getListener().onChallengeGenerated(getSensorId(), getTargetUserId(), 0L);
} catch (RemoteException e) {
Slog.e(TAG, "Unable to send error", e);
}
diff --git a/services/core/java/com/android/server/biometrics/sensors/face/aidl/BiometricTestSessionImpl.java b/services/core/java/com/android/server/biometrics/sensors/face/aidl/BiometricTestSessionImpl.java
index 8726923..57c1c74 100644
--- a/services/core/java/com/android/server/biometrics/sensors/face/aidl/BiometricTestSessionImpl.java
+++ b/services/core/java/com/android/server/biometrics/sensors/face/aidl/BiometricTestSessionImpl.java
@@ -110,17 +110,7 @@
}
@Override
- public void onChallengeGenerated(int sensorId, long challenge) {
-
- }
-
- @Override
- public void onChallengeInterrupted(int sensorId) {
-
- }
-
- @Override
- public void onChallengeInterruptFinished(int sensorId) {
+ public void onChallengeGenerated(int sensorId, int userId, long challenge) {
}
diff --git a/services/core/java/com/android/server/biometrics/sensors/face/aidl/FaceGenerateChallengeClient.java b/services/core/java/com/android/server/biometrics/sensors/face/aidl/FaceGenerateChallengeClient.java
index 904c399..d76036b 100644
--- a/services/core/java/com/android/server/biometrics/sensors/face/aidl/FaceGenerateChallengeClient.java
+++ b/services/core/java/com/android/server/biometrics/sensors/face/aidl/FaceGenerateChallengeClient.java
@@ -52,7 +52,7 @@
void onChallengeGenerated(int sensorId, int userId, long challenge) {
try {
- getListener().onChallengeGenerated(sensorId, challenge);
+ getListener().onChallengeGenerated(sensorId, userId, challenge);
mCallback.onClientFinished(this, true /* success */);
} catch (RemoteException e) {
Slog.e(TAG, "Unable to send challenge", e);
diff --git a/services/core/java/com/android/server/biometrics/sensors/face/hidl/BiometricTestSessionImpl.java b/services/core/java/com/android/server/biometrics/sensors/face/hidl/BiometricTestSessionImpl.java
index f806767..d0580c7 100644
--- a/services/core/java/com/android/server/biometrics/sensors/face/hidl/BiometricTestSessionImpl.java
+++ b/services/core/java/com/android/server/biometrics/sensors/face/hidl/BiometricTestSessionImpl.java
@@ -99,17 +99,7 @@
}
@Override
- public void onChallengeGenerated(int sensorId, long challenge) {
-
- }
-
- @Override
- public void onChallengeInterrupted(int sensorId) {
-
- }
-
- @Override
- public void onChallengeInterruptFinished(int sensorId) {
+ public void onChallengeGenerated(int sensorId, int userId, long challenge) {
}
diff --git a/services/core/java/com/android/server/biometrics/sensors/face/hidl/Face10.java b/services/core/java/com/android/server/biometrics/sensors/face/hidl/Face10.java
index f908fba..a5bb0f4 100644
--- a/services/core/java/com/android/server/biometrics/sensors/face/hidl/Face10.java
+++ b/services/core/java/com/android/server/biometrics/sensors/face/hidl/Face10.java
@@ -80,6 +80,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
+import java.time.Clock;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -93,7 +94,13 @@
public class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
private static final String TAG = "Face10";
+
private static final int ENROLL_TIMEOUT_SEC = 75;
+ private static final int GENERATE_CHALLENGE_REUSE_INTERVAL_MILLIS = 60 * 1000;
+ private static final int GENERATE_CHALLENGE_COUNTER_TTL_MILLIS =
+ FaceGenerateChallengeClient.CHALLENGE_TIMEOUT_SEC * 1000;
+ @VisibleForTesting
+ public static Clock sSystemClock = Clock.systemUTC();
private boolean mTestHalEnabled;
@@ -102,19 +109,15 @@
@NonNull private final BiometricScheduler mScheduler;
@NonNull private final Handler mHandler;
@NonNull private final HalClientMonitor.LazyDaemon<IBiometricsFace> mLazyDaemon;
- @NonNull private final LockoutResetDispatcher mLockoutResetDispatcher;
@NonNull private final LockoutHalImpl mLockoutTracker;
@NonNull private final UsageStats mUsageStats;
@NonNull private final Map<Integer, Long> mAuthenticatorIds;
@Nullable private IBiometricsFace mDaemon;
@NonNull private final HalResultController mHalResultController;
- // If a challenge is generated, keep track of its owner. Since IBiometricsFace@1.0 only
- // supports a single in-flight challenge, we must notify the interrupted owner that its
- // challenge is no longer valid. The interrupted owner will be notified when the interrupter
- // has finished.
- @Nullable private FaceGenerateChallengeClient mCurrentChallengeOwner;
private int mCurrentUserId = UserHandle.USER_NULL;
private final int mSensorId;
+ private final List<Long> mGeneratedChallengeCount = new ArrayList<>();
+ private FaceGenerateChallengeClient mGeneratedChallengeCache = null;
private final UserSwitchObserver mUserSwitchObserver = new SynchronousUserSwitchObserver() {
@Override
@@ -335,7 +338,6 @@
mAuthenticatorIds = new HashMap<>();
mLazyDaemon = Face10.this::getDaemon;
mLockoutTracker = new LockoutHalImpl();
- mLockoutResetDispatcher = lockoutResetDispatcher;
mHalResultController = new HalResultController(sensorProps.sensorId, context, mHandler,
mScheduler, mLockoutTracker, lockoutResetDispatcher);
mHalResultController.setCallback(() -> {
@@ -480,56 +482,56 @@
return getDaemon() != null;
}
+ private boolean isGeneratedChallengeCacheValid() {
+ return mGeneratedChallengeCache != null
+ && sSystemClock.millis() - mGeneratedChallengeCache.getCreatedAt()
+ < GENERATE_CHALLENGE_REUSE_INTERVAL_MILLIS;
+ }
+
+ private void incrementChallengeCount() {
+ mGeneratedChallengeCount.add(0, sSystemClock.millis());
+ }
+
+ private int decrementChallengeCount() {
+ final long now = sSystemClock.millis();
+ // ignore values that are old in case generate/revoke calls are not matched
+ // this doesn't ensure revoke if calls are mismatched but it keeps the list from growing
+ mGeneratedChallengeCount.removeIf(x -> now - x > GENERATE_CHALLENGE_COUNTER_TTL_MILLIS);
+ if (!mGeneratedChallengeCount.isEmpty()) {
+ mGeneratedChallengeCount.remove(0);
+ }
+ return mGeneratedChallengeCount.size();
+ }
+
/**
- * {@link IBiometricsFace} only supports a single in-flight challenge. In cases where two
- * callers both need challenges (e.g. resetLockout right before enrollment), we need to ensure
- * that either:
- * 1) generateChallenge/operation/revokeChallenge is complete before the next generateChallenge
- * is processed by the scheduler, or
- * 2) the generateChallenge callback provides a mechanism for notifying the caller that its
- * challenge has been invalidated by a subsequent caller, as well as a mechanism for
- * notifying the previous caller that the interrupting operation is complete (e.g. the
- * interrupting client's challenge has been revoked, so that the interrupted client can
- * start retry logic if necessary). See
- * {@link
- *android.hardware.face.FaceManager.GenerateChallengeCallback#onChallengeInterruptFinished(int)}
- * The only case of conflicting challenges is currently resetLockout --> enroll. So, the second
- * option seems better as it prioritizes the new operation, which is user-facing.
+ * {@link IBiometricsFace} only supports a single in-flight challenge but there are cases where
+ * two callers both need challenges (e.g. resetLockout right before enrollment).
*/
@Override
public void scheduleGenerateChallenge(int sensorId, int userId, @NonNull IBinder token,
@NonNull IFaceServiceReceiver receiver, @NonNull String opPackageName) {
mHandler.post(() -> {
- if (mCurrentChallengeOwner != null) {
- final ClientMonitorCallbackConverter listener =
- mCurrentChallengeOwner.getListener();
- Slog.w(TAG, "Current challenge owner: " + mCurrentChallengeOwner
- + ", listener: " + listener
- + ", interrupted by: " + opPackageName);
- if (listener != null) {
- try {
- listener.onChallengeInterrupted(mSensorId);
- } catch (RemoteException e) {
- Slog.e(TAG, "Unable to notify challenge interrupted", e);
- }
- }
+ incrementChallengeCount();
+
+ if (isGeneratedChallengeCacheValid()) {
+ Slog.d(TAG, "Current challenge is cached and will be reused");
+ mGeneratedChallengeCache.reuseResult(receiver);
+ return;
}
scheduleUpdateActiveUserWithoutHandler(userId);
final FaceGenerateChallengeClient client = new FaceGenerateChallengeClient(mContext,
mLazyDaemon, token, new ClientMonitorCallbackConverter(receiver), userId,
- opPackageName, mSensorId, mCurrentChallengeOwner);
+ opPackageName, mSensorId, sSystemClock.millis());
+ mGeneratedChallengeCache = client;
mScheduler.scheduleClientMonitor(client, new BaseClientMonitor.Callback() {
@Override
public void onClientStarted(@NonNull BaseClientMonitor clientMonitor) {
if (client != clientMonitor) {
Slog.e(TAG, "scheduleGenerateChallenge onClientStarted, mismatched client."
+ " Expecting: " + client + ", received: " + clientMonitor);
- return;
}
- Slog.d(TAG, "Current challenge owner: " + client);
- mCurrentChallengeOwner = client;
}
});
});
@@ -539,14 +541,16 @@
public void scheduleRevokeChallenge(int sensorId, int userId, @NonNull IBinder token,
@NonNull String opPackageName, long challenge) {
mHandler.post(() -> {
- if (mCurrentChallengeOwner != null
- && !mCurrentChallengeOwner.getOwnerString().contentEquals(opPackageName)) {
- Slog.e(TAG, "scheduleRevokeChallenge, package: " + opPackageName
- + " attempting to revoke challenge owned by: "
- + mCurrentChallengeOwner.getOwnerString());
+ final boolean shouldRevoke = decrementChallengeCount() == 0;
+ if (!shouldRevoke) {
+ Slog.w(TAG, "scheduleRevokeChallenge skipped - challenge still in use: "
+ + mGeneratedChallengeCount);
return;
}
+ Slog.d(TAG, "scheduleRevokeChallenge executing - no active clients");
+ mGeneratedChallengeCache = null;
+
final FaceRevokeChallengeClient client = new FaceRevokeChallengeClient(mContext,
mLazyDaemon, token, userId, opPackageName, mSensorId);
mScheduler.scheduleClientMonitor(client, new BaseClientMonitor.Callback() {
@@ -556,33 +560,6 @@
if (client != clientMonitor) {
Slog.e(TAG, "scheduleRevokeChallenge, mismatched client."
+ "Expecting: " + client + ", received: " + clientMonitor);
- return;
- }
-
- if (mCurrentChallengeOwner == null) {
- // Can happen if revoke is incorrectly called, for example without a
- // preceding generateChallenge
- Slog.w(TAG, "Current challenge owner is null");
- return;
- }
-
- final FaceGenerateChallengeClient previousChallengeOwner =
- mCurrentChallengeOwner.getInterruptedClient();
- mCurrentChallengeOwner = null;
-
- Slog.d(TAG, "Previous challenge owner: " + previousChallengeOwner);
- if (previousChallengeOwner != null) {
- final ClientMonitorCallbackConverter listener =
- previousChallengeOwner.getListener();
- if (listener == null) {
- Slog.w(TAG, "Listener is null");
- } else {
- try {
- listener.onChallengeInterruptFinished(mSensorId);
- } catch (RemoteException e) {
- Slog.e(TAG, "Unable to notify interrupt finished", e);
- }
- }
}
}
});
diff --git a/services/core/java/com/android/server/biometrics/sensors/face/hidl/FaceGenerateChallengeClient.java b/services/core/java/com/android/server/biometrics/sensors/face/hidl/FaceGenerateChallengeClient.java
index 3e0064e..f418104 100644
--- a/services/core/java/com/android/server/biometrics/sensors/face/hidl/FaceGenerateChallengeClient.java
+++ b/services/core/java/com/android/server/biometrics/sensors/face/hidl/FaceGenerateChallengeClient.java
@@ -17,16 +17,20 @@
package com.android.server.biometrics.sensors.face.hidl;
import android.annotation.NonNull;
-import android.annotation.Nullable;
import android.content.Context;
import android.hardware.biometrics.face.V1_0.IBiometricsFace;
+import android.hardware.face.IFaceServiceReceiver;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Slog;
+import com.android.internal.util.Preconditions;
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
import com.android.server.biometrics.sensors.GenerateChallengeClient;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Face-specific generateChallenge client supporting the
* {@link android.hardware.biometrics.face.V1_0} HIDL interface.
@@ -34,40 +38,70 @@
public class FaceGenerateChallengeClient extends GenerateChallengeClient<IBiometricsFace> {
private static final String TAG = "FaceGenerateChallengeClient";
- private static final int CHALLENGE_TIMEOUT_SEC = 600; // 10 minutes
+ static final int CHALLENGE_TIMEOUT_SEC = 600; // 10 minutes
+ private static final Callback EMPTY_CALLBACK = new Callback() {
+ };
- // If `this` FaceGenerateChallengeClient was invoked while an existing in-flight challenge
- // was not revoked yet, store a reference to the interrupted client here. Notify the interrupted
- // client when `this` challenge is revoked.
- @Nullable private final FaceGenerateChallengeClient mInterruptedClient;
+ private final long mCreatedAt;
+ private List<IFaceServiceReceiver> mWaiting;
+ private Long mChallengeResult;
FaceGenerateChallengeClient(@NonNull Context context,
@NonNull LazyDaemon<IBiometricsFace> lazyDaemon, @NonNull IBinder token,
@NonNull ClientMonitorCallbackConverter listener, int userId, @NonNull String owner,
- int sensorId, @Nullable FaceGenerateChallengeClient interruptedClient) {
+ int sensorId, long now) {
super(context, lazyDaemon, token, listener, userId, owner, sensorId);
- mInterruptedClient = interruptedClient;
- }
-
- @Nullable
- public FaceGenerateChallengeClient getInterruptedClient() {
- return mInterruptedClient;
+ mCreatedAt = now;
+ mWaiting = new ArrayList<>();
}
@Override
protected void startHalOperation() {
+ mChallengeResult = null;
try {
- final long challenge = getFreshDaemon().generateChallenge(CHALLENGE_TIMEOUT_SEC).value;
- try {
- getListener().onChallengeGenerated(getSensorId(), challenge);
- mCallback.onClientFinished(this, true /* success */);
- } catch (RemoteException e) {
- Slog.e(TAG, "Remote exception", e);
- mCallback.onClientFinished(this, false /* success */);
+ mChallengeResult = getFreshDaemon().generateChallenge(CHALLENGE_TIMEOUT_SEC).value;
+ // send the result to the original caller via mCallback and any waiting callers
+ // that called reuseResult
+ sendChallengeResult(getListener(), mCallback);
+ for (IFaceServiceReceiver receiver : mWaiting) {
+ sendChallengeResult(new ClientMonitorCallbackConverter(receiver), EMPTY_CALLBACK);
}
} catch (RemoteException e) {
Slog.e(TAG, "generateChallenge failed", e);
mCallback.onClientFinished(this, false /* success */);
+ } finally {
+ mWaiting = null;
+ }
+ }
+
+ /** @return An arbitrary time value for caching provided to the constructor. */
+ public long getCreatedAt() {
+ return mCreatedAt;
+ }
+
+ /**
+ * Reuse the result of this operation when it is available. The receiver will be notified
+ * immediately if a challenge has already been generated.
+ *
+ * @param receiver receiver to be notified of challenge result
+ */
+ public void reuseResult(@NonNull IFaceServiceReceiver receiver) {
+ if (mWaiting != null) {
+ mWaiting.add(receiver);
+ } else {
+ sendChallengeResult(new ClientMonitorCallbackConverter(receiver), EMPTY_CALLBACK);
+ }
+ }
+
+ private void sendChallengeResult(@NonNull ClientMonitorCallbackConverter receiver,
+ @NonNull Callback ownerCallback) {
+ Preconditions.checkState(mChallengeResult != null, "result not available");
+ try {
+ receiver.onChallengeGenerated(getSensorId(), getTargetUserId(), mChallengeResult);
+ ownerCallback.onClientFinished(this, true /* success */);
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Remote exception", e);
+ ownerCallback.onClientFinished(this, false /* success */);
}
}
}
diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/BiometricTestSessionImpl.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/BiometricTestSessionImpl.java
index e34afc0..29f2f20 100644
--- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/BiometricTestSessionImpl.java
+++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/BiometricTestSessionImpl.java
@@ -100,7 +100,7 @@
}
@Override
- public void onChallengeGenerated(int sensorId, long challenge) {
+ public void onChallengeGenerated(int sensorId, int userId, long challenge) {
}
diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintGenerateChallengeClient.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintGenerateChallengeClient.java
index 293b57d..6d01481 100644
--- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintGenerateChallengeClient.java
+++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintGenerateChallengeClient.java
@@ -53,7 +53,7 @@
void onChallengeGenerated(int sensorId, int userId, long challenge) {
try {
- getListener().onChallengeGenerated(sensorId, challenge);
+ getListener().onChallengeGenerated(sensorId, userId, challenge);
mCallback.onClientFinished(this, true /* success */);
} catch (RemoteException e) {
Slog.e(TAG, "Unable to send challenge", e);
diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/hidl/BiometricTestSessionImpl.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/hidl/BiometricTestSessionImpl.java
index ad4f679..c00daff 100644
--- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/hidl/BiometricTestSessionImpl.java
+++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/hidl/BiometricTestSessionImpl.java
@@ -101,7 +101,7 @@
}
@Override
- public void onChallengeGenerated(int sensorId, long challenge) {
+ public void onChallengeGenerated(int sensorId, int userId, long challenge) {
}
diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/hidl/FingerprintGenerateChallengeClient.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/hidl/FingerprintGenerateChallengeClient.java
index 3584397..db2f045 100644
--- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/hidl/FingerprintGenerateChallengeClient.java
+++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/hidl/FingerprintGenerateChallengeClient.java
@@ -48,7 +48,7 @@
try {
final long challenge = getFreshDaemon().preEnroll();
try {
- getListener().onChallengeGenerated(getSensorId(), challenge);
+ getListener().onChallengeGenerated(getSensorId(), getTargetUserId(), challenge);
mCallback.onClientFinished(this, true /* success */);
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
diff --git a/services/core/java/com/android/server/connectivity/PermissionMonitor.java b/services/core/java/com/android/server/connectivity/PermissionMonitor.java
index 28f208b..5886b1a 100644
--- a/services/core/java/com/android/server/connectivity/PermissionMonitor.java
+++ b/services/core/java/com/android/server/connectivity/PermissionMonitor.java
@@ -338,7 +338,8 @@
return currentPermission;
}
try {
- final PackageInfo app = mPackageManager.getPackageInfo(name, GET_PERMISSIONS);
+ final PackageInfo app = mPackageManager.getPackageInfo(name,
+ GET_PERMISSIONS | MATCH_ANY_USER);
final boolean isNetwork = hasNetworkPermission(app);
final boolean hasRestrictedPermission = hasRestrictedNetworkPermission(app);
if (isNetwork || hasRestrictedPermission) {
@@ -664,6 +665,7 @@
break;
case INetd.PERMISSION_UNINSTALLED:
uninstalledAppIds.add(netdPermissionsAppIds.keyAt(i));
+ break;
default:
Log.e(TAG, "unknown permission type: " + permissions + "for uid: "
+ netdPermissionsAppIds.keyAt(i));
diff --git a/services/core/java/com/android/server/display/BrightnessTracker.java b/services/core/java/com/android/server/display/BrightnessTracker.java
index 1261296..2c2a2bf 100644
--- a/services/core/java/com/android/server/display/BrightnessTracker.java
+++ b/services/core/java/com/android/server/display/BrightnessTracker.java
@@ -567,7 +567,11 @@
out.attributeLong(null, ATTR_TIMESTAMP, toWrite[i].timeStamp);
out.attribute(null, ATTR_PACKAGE_NAME, toWrite[i].packageName);
out.attributeInt(null, ATTR_USER, userSerialNo);
- out.attribute(null, ATTR_UNIQUE_DISPLAY_ID, toWrite[i].uniqueDisplayId);
+ String uniqueDisplayId = toWrite[i].uniqueDisplayId;
+ if (uniqueDisplayId == null) {
+ uniqueDisplayId = "";
+ }
+ out.attribute(null, ATTR_UNIQUE_DISPLAY_ID, uniqueDisplayId);
out.attributeFloat(null, ATTR_BATTERY_LEVEL, toWrite[i].batteryLevel);
out.attributeBoolean(null, ATTR_NIGHT_MODE, toWrite[i].nightMode);
out.attributeInt(null, ATTR_COLOR_TEMPERATURE,
diff --git a/services/core/java/com/android/server/display/DisplayDeviceConfig.java b/services/core/java/com/android/server/display/DisplayDeviceConfig.java
index 0f9e604..314955b 100644
--- a/services/core/java/com/android/server/display/DisplayDeviceConfig.java
+++ b/services/core/java/com/android/server/display/DisplayDeviceConfig.java
@@ -689,6 +689,8 @@
if (sensorDetails != null) {
mAmbientLightSensor.type = sensorDetails.getType();
mAmbientLightSensor.name = sensorDetails.getName();
+ } else {
+ loadAmbientLightSensorFromConfigXml();
}
}
diff --git a/services/core/java/com/android/server/graphics/fonts/FontManagerService.java b/services/core/java/com/android/server/graphics/fonts/FontManagerService.java
index 609bd8b..0949ddd 100644
--- a/services/core/java/com/android/server/graphics/fonts/FontManagerService.java
+++ b/services/core/java/com/android/server/graphics/fonts/FontManagerService.java
@@ -20,6 +20,8 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
import android.graphics.Typeface;
import android.graphics.fonts.Font;
import android.graphics.fonts.FontFamily;
@@ -32,6 +34,9 @@
import android.os.ShellCallback;
import android.system.ErrnoException;
import android.text.FontConfig;
+import android.text.Layout;
+import android.text.StaticLayout;
+import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AndroidException;
import android.util.IndentingPrintWriter;
@@ -196,10 +201,32 @@
}
@Override
- public void tryToCreateTypeface(File file) throws IOException {
+ public void tryToCreateTypeface(File file) throws Throwable {
Font font = new Font.Builder(file).build();
FontFamily family = new FontFamily.Builder(font).build();
- new Typeface.CustomFallbackBuilder(family).build();
+ Typeface typeface = new Typeface.CustomFallbackBuilder(family).build();
+
+ TextPaint p = new TextPaint();
+ p.setTextSize(24f);
+ p.setTypeface(typeface);
+
+ // Test string to try with the passed font.
+ // TODO: Good to extract from font file.
+ String testTextToDraw = "abcXYZ@- "
+ + "\uD83E\uDED6" // Emoji E13.0
+ + "\uD83C\uDDFA\uD83C\uDDF8" // Emoji Flags
+ + "\uD83D\uDC8F\uD83C\uDFFB" // Emoji Skin tone Sequence
+ // ZWJ Sequence
+ + "\uD83D\uDC68\uD83C\uDFFC\u200D\u2764\uFE0F\u200D\uD83D\uDC8B\u200D"
+ + "\uD83D\uDC68\uD83C\uDFFF";
+
+ int width = (int) Math.ceil(Layout.getDesiredWidth(testTextToDraw, p));
+ StaticLayout layout = StaticLayout.Builder.obtain(
+ testTextToDraw, 0, testTextToDraw.length(), p, width).build();
+ Bitmap bmp = Bitmap.createBitmap(
+ layout.getWidth(), layout.getHeight(), Bitmap.Config.ALPHA_8);
+ Canvas canvas = new Canvas(bmp);
+ layout.draw(canvas);
}
private static ByteBuffer mmap(File file) throws IOException {
diff --git a/services/core/java/com/android/server/graphics/fonts/UpdatableFontDir.java b/services/core/java/com/android/server/graphics/fonts/UpdatableFontDir.java
index e74dac5..981cc838 100644
--- a/services/core/java/com/android/server/graphics/fonts/UpdatableFontDir.java
+++ b/services/core/java/com/android/server/graphics/fonts/UpdatableFontDir.java
@@ -69,7 +69,7 @@
long getRevision(File file) throws IOException;
- void tryToCreateTypeface(File file) throws IOException;
+ void tryToCreateTypeface(File file) throws Throwable;
}
/** Interface to mock fs-verity in tests. */
@@ -378,10 +378,10 @@
// Try to create Typeface and treat as failure something goes wrong.
try {
mParser.tryToCreateTypeface(fontFileInfo.getFile());
- } catch (IOException e) {
+ } catch (Throwable t) {
throw new SystemFontException(
FontManager.RESULT_ERROR_INVALID_FONT_FILE,
- "Failed to create Typeface from file", e);
+ "Failed to create Typeface from file", t);
}
FontConfig fontConfig = getSystemFontConfig();
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecConfig.java b/services/core/java/com/android/server/hdmi/HdmiCecConfig.java
index cb05f8f..fefe953 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecConfig.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecConfig.java
@@ -221,7 +221,7 @@
}
}
- private class Setting {
+ protected class Setting {
@NonNull private final Context mContext;
@NonNull private final @CecSettingName String mName;
private final boolean mUserConfigurable;
@@ -566,7 +566,7 @@
}
}
- private String retrieveValue(@NonNull Setting setting, @NonNull String defaultValue) {
+ protected String retrieveValue(@NonNull Setting setting, @NonNull String defaultValue) {
@Storage int storage = getStorage(setting);
String storageKey = getStorageKey(setting);
if (storage == STORAGE_SYSPROPS) {
@@ -582,7 +582,7 @@
return null;
}
- private void storeValue(@NonNull Setting setting, @NonNull String value) {
+ protected void storeValue(@NonNull Setting setting, @NonNull String value) {
@Storage int storage = getStorage(setting);
String storageKey = getStorageKey(setting);
if (storage == STORAGE_SYSPROPS) {
@@ -626,7 +626,7 @@
notifySettingChanged(setting);
}
- private void notifySettingChanged(@NonNull Setting setting) {
+ protected void notifySettingChanged(@NonNull Setting setting) {
synchronized (mLock) {
ArrayMap<SettingChangeListener, Executor> listeners =
mSettingChangeListeners.get(setting);
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java
index 10f6948f..dcd0eb8 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevicePlayback.java
@@ -136,18 +136,19 @@
if (!mService.isControlEnabled()) {
return;
}
- if (isActiveSource()) {
- mService.sendCecCommand(HdmiCecMessageBuilder.buildInactiveSource(
- mAddress, mService.getPhysicalAddress()));
- }
boolean wasActiveSource = isActiveSource();
- // Invalidate the internal active source record when goes to standby
+ // Invalidate the internal active source record when going to standby
mService.setActiveSource(Constants.ADDR_INVALID, Constants.INVALID_PHYSICAL_ADDRESS,
"HdmiCecLocalDevicePlayback#onStandby()");
boolean mTvSendStandbyOnSleep = mService.getHdmiCecConfig().getIntValue(
HdmiControlManager.CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP)
== HdmiControlManager.TV_SEND_STANDBY_ON_SLEEP_ENABLED;
- if (initiatedByCec || !mTvSendStandbyOnSleep || !wasActiveSource) {
+ if (!wasActiveSource) {
+ return;
+ }
+ if (initiatedByCec || !mTvSendStandbyOnSleep) {
+ mService.sendCecCommand(HdmiCecMessageBuilder.buildInactiveSource(mAddress,
+ mService.getPhysicalAddress()));
return;
}
switch (standbyAction) {
@@ -167,6 +168,9 @@
Constants.ADDR_BROADCAST));
break;
case HdmiControlManager.POWER_CONTROL_MODE_NONE:
+ mService.sendCecCommand(
+ HdmiCecMessageBuilder.buildInactiveSource(mAddress,
+ mService.getPhysicalAddress()));
break;
}
break;
diff --git a/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java b/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java
index 7226cc2..e52e32a 100644
--- a/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java
+++ b/services/core/java/com/android/server/hdmi/HdmiControlShellCommand.java
@@ -90,6 +90,8 @@
pw.println(" Set the value of a CEC setting");
pw.println(" setsystemaudiomode, setsam [on|off]");
pw.println(" Sets the System Audio Mode feature on or off on TV devices");
+ pw.println(" setarc [on|off]");
+ pw.println(" Sets the ARC feature on or off on TV devices");
}
private int handleShellCommand(String cmd) throws RemoteException {
@@ -106,6 +108,8 @@
case "setsystemaudiomode":
case "setsam":
return setSystemAudioMode(pw);
+ case "setarc":
+ return setArcMode(pw);
}
getErrPrintWriter().println("Unhandled command: " + cmd);
@@ -229,6 +233,27 @@
return mCecResult.get() == HdmiControlManager.RESULT_SUCCESS ? 0 : 1;
}
+ private int setArcMode(PrintWriter pw) throws RemoteException {
+ if (1 > getRemainingArgsCount()) {
+ throw new IllegalArgumentException(
+ "Please indicate if ARC mode should be turned \"on\" or \"off\".");
+ }
+
+ String arg = getNextArg();
+ if (arg.equals("on")) {
+ pw.println("Setting ARC mode on");
+ mBinderService.setArcMode(true);
+ } else if (arg.equals("off")) {
+ pw.println("Setting ARC mode off");
+ mBinderService.setArcMode(false);
+ } else {
+ throw new IllegalArgumentException(
+ "Please indicate if ARC mode should be turned \"on\" or \"off\".");
+ }
+
+ return 0;
+ }
+
private boolean receiveCallback(String command) {
try {
if (!mLatch.await(HdmiConfig.TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java
index 1c27c65..61107b2 100644
--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -313,6 +313,7 @@
private static native void nativeSetFocusedDisplay(long ptr, int displayId);
private static native boolean nativeTransferTouchFocus(long ptr,
IBinder fromChannelToken, IBinder toChannelToken, boolean isDragDrop);
+ private static native boolean nativeTransferTouch(long ptr, IBinder destChannelToken);
private static native void nativeSetPointerSpeed(long ptr, int speed);
private static native void nativeSetShowTouches(long ptr, boolean enabled);
private static native void nativeSetInteractive(long ptr, boolean interactive);
@@ -676,6 +677,19 @@
}
/**
+ * Transfer the current touch gesture to the provided window.
+ *
+ * @param destChannelToken The token of the window or input channel that should receive the
+ * gesture
+ * @return True if the transfer succeeded, false if there was no active touch gesture happening
+ */
+ public boolean transferTouch(IBinder destChannelToken) {
+ // TODO(b/162194035): Replace this with a SPY window
+ Objects.requireNonNull(destChannelToken, "destChannelToken must not be null.");
+ return nativeTransferTouch(mPtr, destChannelToken);
+ }
+
+ /**
* Creates an input channel that will receive all input from the input dispatcher.
* @param inputChannelName The input channel name.
* @param displayId Target display id.
diff --git a/services/core/java/com/android/server/location/LocationManagerService.java b/services/core/java/com/android/server/location/LocationManagerService.java
index 172a68a..c55cf51 100644
--- a/services/core/java/com/android/server/location/LocationManagerService.java
+++ b/services/core/java/com/android/server/location/LocationManagerService.java
@@ -269,6 +269,13 @@
mInjector.getSettingsHelper().addOnLocationEnabledChangedListener(
this::onLocationModeChanged);
+ mInjector.getSettingsHelper().addOnIgnoreSettingsPackageWhitelistChangedListener(
+ () -> refreshAppOpsRestrictions(UserHandle.USER_ALL));
+ mInjector.getUserInfoHelper().addListener((userId, change) -> {
+ if (change == UserInfoHelper.UserListener.USER_STARTED) {
+ refreshAppOpsRestrictions(userId);
+ }
+ });
// set up passive provider first since it will be required for all other location providers,
// which are loaded later once the system is ready.
@@ -482,6 +489,8 @@
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY)
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
mContext.sendBroadcastAsUser(intent, UserHandle.of(userId));
+
+ refreshAppOpsRestrictions(userId);
}
@Override
@@ -1347,6 +1356,43 @@
ipw.decreaseIndent();
}
+ private void refreshAppOpsRestrictions(int userId) {
+ if (userId == UserHandle.USER_ALL) {
+ final int[] runningUserIds = mInjector.getUserInfoHelper().getRunningUserIds();
+ for (int i = 0; i < runningUserIds.length; i++) {
+ refreshAppOpsRestrictions(runningUserIds[i]);
+ }
+ return;
+ }
+
+ Preconditions.checkArgument(userId >= 0);
+
+ ArraySet<String> packages = new ArraySet<>();
+ for (LocationProviderManager manager : mProviderManagers) {
+ packages.add(manager.getIdentity().getPackageName());
+ }
+ packages.add(mContext.getPackageName());
+ packages.addAll(mInjector.getSettingsHelper().getIgnoreSettingsPackageWhitelist());
+ String[] allowedPackages = packages.toArray(new String[0]);
+
+ boolean enabled = mInjector.getSettingsHelper().isLocationEnabled(userId);
+
+ AppOpsManager appOpsManager = Objects.requireNonNull(
+ mContext.getSystemService(AppOpsManager.class));
+ appOpsManager.setUserRestrictionForUser(
+ AppOpsManager.OP_COARSE_LOCATION,
+ enabled,
+ LocationManagerService.this,
+ allowedPackages,
+ userId);
+ appOpsManager.setUserRestrictionForUser(
+ AppOpsManager.OP_FINE_LOCATION,
+ enabled,
+ LocationManagerService.this,
+ allowedPackages,
+ userId);
+ }
+
private class LocalService extends LocationManagerInternal {
LocalService() {}
diff --git a/services/core/java/com/android/server/locksettings/BiometricDeferredQueue.java b/services/core/java/com/android/server/locksettings/BiometricDeferredQueue.java
index 5abc438..2bdeab4 100644
--- a/services/core/java/com/android/server/locksettings/BiometricDeferredQueue.java
+++ b/services/core/java/com/android/server/locksettings/BiometricDeferredQueue.java
@@ -98,19 +98,7 @@
}
@Override
- public void onChallengeInterrupted(int sensorId) {
- Slog.w(TAG, "Challenge interrupted, sensor: " + sensorId);
- // Consider re-attempting generateChallenge/resetLockout/revokeChallenge
- // when onChallengeInterruptFinished is invoked
- }
-
- @Override
- public void onChallengeInterruptFinished(int sensorId) {
- Slog.w(TAG, "Challenge interrupt finished, sensor: " + sensorId);
- }
-
- @Override
- public void onGenerateChallengeResult(int sensorId, long challenge) {
+ public void onGenerateChallengeResult(int sensorId, int userId, long challenge) {
if (!sensorIds.contains(sensorId)) {
Slog.e(TAG, "Unknown sensorId received: " + sensorId);
return;
@@ -128,10 +116,6 @@
}
sensorIds.remove(sensorId);
- // Challenge is only required for IBiometricsFace@1.0 (and not IFace AIDL). The
- // IBiometricsFace@1.0 HAL does not require userId to revokeChallenge, so passing
- // in 0 is OK.
- final int userId = 0;
faceManager.revokeChallenge(sensorId, userId, challenge);
if (sensorIds.isEmpty()) {
@@ -234,18 +218,12 @@
}
}
- /**
- * For devices on {@link android.hardware.biometrics.face.V1_0} which only support a single
- * in-flight challenge, we generate a single challenge to reset lockout for all profiles. This
- * hopefully reduces/eliminates issues such as overwritten challenge, incorrectly revoked
- * challenge, or other race conditions.
- */
private void processPendingLockoutsForFace(List<UserAuthInfo> pendingResetLockouts) {
if (mFaceManager != null) {
if (mFaceResetLockoutTask != null) {
// This code will need to be updated if this problem ever occurs.
- Slog.w(TAG, "mFaceGenerateChallengeCallback not null, previous operation may be"
- + " stuck");
+ Slog.w(TAG,
+ "mFaceGenerateChallengeCallback not null, previous operation may be stuck");
}
final List<FaceSensorPropertiesInternal> faceSensorProperties =
mFaceManager.getSensorPropertiesInternal();
@@ -258,12 +236,13 @@
mSpManager, sensorIds, pendingResetLockouts);
for (final FaceSensorPropertiesInternal prop : faceSensorProperties) {
if (prop.resetLockoutRequiresHardwareAuthToken) {
- if (prop.resetLockoutRequiresChallenge) {
- // Generate a challenge for each sensor. The challenge does not need to be
- // per-user, since the HAT returned by gatekeeper contains userId.
- mFaceManager.generateChallenge(prop.sensorId, mFaceResetLockoutTask);
- } else {
- for (UserAuthInfo user : pendingResetLockouts) {
+ for (UserAuthInfo user : pendingResetLockouts) {
+ if (prop.resetLockoutRequiresChallenge) {
+ Slog.d(TAG, "Generating challenge for sensor: " + prop.sensorId
+ + ", user: " + user.userId);
+ mFaceManager.generateChallenge(prop.sensorId, user.userId,
+ mFaceResetLockoutTask);
+ } else {
Slog.d(TAG, "Resetting face lockout for sensor: " + prop.sensorId
+ ", user: " + user.userId);
final byte[] hat = requestHatFromGatekeeperPassword(mSpManager, user,
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index 805f395..8c1fd36 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -1511,7 +1511,8 @@
builder.setSmallIcon(R.drawable.stat_notify_error);
- final Intent snoozeIntent = buildSnoozeWarningIntent(policy.template);
+ final Intent snoozeIntent = buildSnoozeWarningIntent(policy.template,
+ mContext.getPackageName());
builder.setDeleteIntent(PendingIntent.getBroadcast(
mContext, 0, snoozeIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
@@ -1597,7 +1598,8 @@
builder.setSmallIcon(R.drawable.stat_notify_error);
- final Intent snoozeIntent = buildSnoozeRapidIntent(policy.template);
+ final Intent snoozeIntent = buildSnoozeRapidIntent(policy.template,
+ mContext.getPackageName());
builder.setDeleteIntent(PendingIntent.getBroadcast(
mContext, 0, snoozeIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
@@ -5478,17 +5480,19 @@
return new Intent(ACTION_ALLOW_BACKGROUND);
}
- private static Intent buildSnoozeWarningIntent(NetworkTemplate template) {
+ private static Intent buildSnoozeWarningIntent(NetworkTemplate template, String targetPackage) {
final Intent intent = new Intent(ACTION_SNOOZE_WARNING);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
intent.putExtra(EXTRA_NETWORK_TEMPLATE, template);
+ intent.setPackage(targetPackage);
return intent;
}
- private static Intent buildSnoozeRapidIntent(NetworkTemplate template) {
+ private static Intent buildSnoozeRapidIntent(NetworkTemplate template, String targetPackage) {
final Intent intent = new Intent(ACTION_SNOOZE_RAPID);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
intent.putExtra(EXTRA_NETWORK_TEMPLATE, template);
+ intent.setPackage(targetPackage);
return intent;
}
diff --git a/services/core/java/com/android/server/notification/ManagedServices.java b/services/core/java/com/android/server/notification/ManagedServices.java
index 202b315..a3daae4 100644
--- a/services/core/java/com/android/server/notification/ManagedServices.java
+++ b/services/core/java/com/android/server/notification/ManagedServices.java
@@ -101,6 +101,7 @@
protected static final String ENABLED_SERVICES_SEPARATOR = ":";
private static final String DB_VERSION_1 = "1";
private static final String DB_VERSION_2 = "2";
+ private static final String DB_VERSION_3 = "3";
/**
@@ -113,8 +114,9 @@
static final String ATT_VERSION = "version";
static final String ATT_DEFAULTS = "defaults";
static final String ATT_USER_SET = "user_set_services";
+ static final String ATT_USER_CHANGED = "user_changed";
- static final int DB_VERSION = 3;
+ static final int DB_VERSION = 4;
static final int APPROVAL_BY_PACKAGE = 0;
static final int APPROVAL_BY_COMPONENT = 1;
@@ -160,6 +162,8 @@
@GuardedBy("mApproved")
protected ArrayMap<Integer, ArraySet<String>> mUserSetServices = new ArrayMap<>();
+ protected ArrayMap<Integer, Boolean> mIsUserChanged = new ArrayMap<>();
+
// True if approved services are stored in xml, not settings.
private boolean mUseXml;
@@ -338,6 +342,7 @@
for (int i = 0; i < N; i++) {
final int userId = mApproved.keyAt(i);
final ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.valueAt(i);
+ final Boolean userChanged = mIsUserChanged.get(userId);
if (approvedByType != null) {
final int M = approvedByType.size();
for (int j = 0; j < M; j++) {
@@ -345,16 +350,20 @@
final ArraySet<String> approved = approvedByType.valueAt(j);
if (approvedByType != null && approvedByType.size() > 0) {
pw.println(" " + String.join(ENABLED_SERVICES_SEPARATOR, approved)
- + " (user: " + userId + " isPrimary: " + isPrimary + ")");
+ + " (user: " + userId + " isPrimary: " + isPrimary
+ + (userChanged == null ? "" : " isUserChanged: "
+ + userChanged) + ")");
}
}
}
}
-
pw.println(" Has user set:");
Set<Integer> userIds = mUserSetServices.keySet();
for (int userId : userIds) {
- pw.println(" userId=" + userId + " value=" + mUserSetServices.get(userId));
+ if (mIsUserChanged.get(userId) == null) {
+ pw.println(" userId=" + userId + " value="
+ + (mUserSetServices.get(userId)));
+ }
}
}
@@ -489,13 +498,14 @@
continue;
}
final ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.valueAt(i);
+ final Boolean isUserChanged = mIsUserChanged.get(approvedUserId);
if (approvedByType != null) {
final int M = approvedByType.size();
for (int j = 0; j < M; j++) {
final boolean isPrimary = approvedByType.keyAt(j);
final Set<String> approved = approvedByType.valueAt(j);
final Set<String> userSet = mUserSetServices.get(approvedUserId);
- if (approved != null || userSet != null) {
+ if (approved != null || userSet != null || isUserChanged != null) {
String allowedItems = approved == null
? ""
: String.join(ENABLED_SERVICES_SEPARATOR, approved);
@@ -503,7 +513,9 @@
out.attribute(null, ATT_APPROVED_LIST, allowedItems);
out.attributeInt(null, ATT_USER_ID, approvedUserId);
out.attributeBoolean(null, ATT_IS_PRIMARY, isPrimary);
- if (userSet != null) {
+ if (isUserChanged != null) {
+ out.attributeBoolean(null, ATT_USER_CHANGED, isUserChanged);
+ } else if (userSet != null) {
String userSetItems =
String.join(ENABLED_SERVICES_SEPARATOR, userSet);
out.attribute(null, ATT_USER_SET, userSetItems);
@@ -618,12 +630,21 @@
? userId : parser.getAttributeInt(null, ATT_USER_ID, 0);
final boolean isPrimary =
parser.getAttributeBoolean(null, ATT_IS_PRIMARY, true);
- final String userSet = XmlUtils.readStringAttribute(parser, ATT_USER_SET);
+
+ final String isUserChanged = XmlUtils.readStringAttribute(parser,
+ ATT_USER_CHANGED);
+ String userSetComponent = null;
+ if (isUserChanged == null) {
+ userSetComponent = XmlUtils.readStringAttribute(parser, ATT_USER_SET);
+ } else {
+ mIsUserChanged.put(resolvedUserId, Boolean.valueOf(isUserChanged));
+ }
readExtraAttributes(tag, parser, resolvedUserId);
if (allowedManagedServicePackages == null || allowedManagedServicePackages.test(
- getPackageName(approved), resolvedUserId, getRequiredPermission())) {
+ getPackageName(approved), resolvedUserId, getRequiredPermission())
+ || approved.isEmpty()) {
if (mUm.getUserInfo(resolvedUserId) != null) {
- addApprovedList(approved, resolvedUserId, isPrimary, userSet);
+ addApprovedList(approved, resolvedUserId, isPrimary, userSetComponent);
}
mUseXml = true;
}
@@ -634,10 +655,16 @@
}
boolean isOldVersion = TextUtils.isEmpty(version)
|| DB_VERSION_1.equals(version)
- || DB_VERSION_2.equals(version);
+ || DB_VERSION_2.equals(version)
+ || DB_VERSION_3.equals(version);
+ boolean needUpgradeUserset = DB_VERSION_3.equals(version);
if (isOldVersion) {
upgradeDefaultsXmlVersion();
}
+ if (needUpgradeUserset) {
+ upgradeUserSet();
+ }
+
rebindServices(false, USER_ALL);
}
@@ -666,6 +693,8 @@
}
}
+ protected void upgradeUserSet() {};
+
/**
* Read extra attributes in the {@link #TAG_MANAGED_SERVICES} tag.
*/
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 67fd09b3..19c717d 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -106,7 +106,6 @@
import static android.service.notification.NotificationListenerService.TRIM_LIGHT;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
-import static com.android.internal.util.CollectionUtils.emptyIfNull;
import static com.android.internal.util.FrameworkStatsLog.DND_MODE_RULE;
import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES;
import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_CHANNEL_PREFERENCES;
@@ -324,7 +323,6 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
@@ -832,7 +830,7 @@
learnNASPendingIntent).build();
- return new Notification.Builder(getContext(), SystemNotificationChannels.ALERTS)
+ return new Notification.Builder(getContext(), SystemNotificationChannels.SYSTEM_CHANGES)
.setAutoCancel(false)
.setOngoing(true)
.setTicker(getContext().getResources().getString(title))
@@ -9467,6 +9465,27 @@
return mDefaultFromConfig;
}
+ @Override
+ protected void upgradeUserSet() {
+ for (int userId: mApproved.keySet()) {
+ ArraySet<String> userSetServices = mUserSetServices.get(userId);
+ mIsUserChanged.put(userId, (userSetServices != null && userSetServices.size() > 0));
+ }
+ }
+
+ @Override
+ protected void addApprovedList(String approved, int userId, boolean isPrimary,
+ String userSet) {
+ if (!TextUtils.isEmpty(approved)) {
+ String[] approvedArray = approved.split(ENABLED_SERVICES_SEPARATOR);
+ if (approvedArray.length > 1) {
+ Slog.d(TAG, "More than one approved assistants");
+ approved = approvedArray[0];
+ }
+ }
+ super.addApprovedList(approved, userId, isPrimary, userSet);
+ }
+
public NotificationAssistants(Context context, Object lock, UserProfiles up,
IPackageManager pm) {
super(context, lock, up, pm);
@@ -9641,47 +9660,12 @@
}
boolean hasUserSet(int userId) {
- synchronized (mLock) {
- ArraySet<String> userSetServices = mUserSetServices.get(userId);
- if (userSetServices == null) {
- // Legacy case - no data means user-set, unless no assistant is set
- return !mApproved.isEmpty();
- }
- Map<Boolean, ArraySet<String>> approvedByType = emptyIfNull(mApproved.get(userId));
- return userSetServices.containsAll(emptyIfNull(approvedByType.get(true)))
- && userSetServices.containsAll(emptyIfNull(approvedByType.get(false)));
- }
+ Boolean userSet = mIsUserChanged.get(userId);
+ return (userSet != null && userSet);
}
void setUserSet(int userId, boolean set) {
- synchronized (mLock) {
- ArraySet<String> userSetServices = new ArraySet<>();
- if (set) {
- ArrayMap<Boolean, ArraySet<String>> approvedByType = mApproved.get(userId);
- if (approvedByType != null) {
- for (int i = 0; i < approvedByType.size(); i++) {
- userSetServices.addAll(approvedByType.valueAt(i));
- }
- }
- }
- mUserSetServices.put(userId, userSetServices);
- }
- }
-
- @Override
- protected void readExtraAttributes(String tag, TypedXmlPullParser parser, int userId)
- throws IOException {
- // TODO: this logic looks broken, since it's trying to convert a
- // list into a boolean; for now we preserve the old parsing behavior
- // to avoid a performance regression, but someone should investigate
- final String value = parser.getAttributeValue(null, ATT_USER_SET);
- final boolean userSet;
- if (TextUtils.isEmpty(value)) {
- userSet = false;
- } else {
- userSet = Boolean.parseBoolean(value);
- }
- setUserSet(userId, userSet);
+ mIsUserChanged.put(userId, set);
}
private void notifyCapabilitiesChanged(final ManagedServiceInfo info) {
diff --git a/services/core/java/com/android/server/pm/BackgroundDexOptService.java b/services/core/java/com/android/server/pm/BackgroundDexOptService.java
index af0aa76..77c1c1d 100644
--- a/services/core/java/com/android/server/pm/BackgroundDexOptService.java
+++ b/services/core/java/com/android/server/pm/BackgroundDexOptService.java
@@ -16,7 +16,6 @@
package com.android.server.pm;
-import static com.android.server.pm.PackageManagerService.DEBUG_DEXOPT;
import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;
import android.annotation.Nullable;
@@ -24,8 +23,11 @@
import android.app.job.JobParameters;
import android.app.job.JobScheduler;
import android.app.job.JobService;
+import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.os.BatteryManagerInternal;
import android.os.Environment;
@@ -35,6 +37,7 @@
import android.os.storage.StorageManager;
import android.util.ArraySet;
import android.util.Log;
+import android.util.Slog;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.FrameworkStatsLog;
@@ -63,9 +66,7 @@
private static final int JOB_IDLE_OPTIMIZE = 800;
private static final int JOB_POST_BOOT_UPDATE = 801;
- private static final long IDLE_OPTIMIZATION_PERIOD = DEBUG
- ? TimeUnit.MINUTES.toMillis(1)
- : TimeUnit.DAYS.toMillis(1);
+ private static final long IDLE_OPTIMIZATION_PERIOD = TimeUnit.DAYS.toMillis(1);
private static ComponentName sDexoptServiceName = new ComponentName(
"android",
@@ -113,14 +114,24 @@
return;
}
- JobScheduler js = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
+ final JobScheduler js = context.getSystemService(JobScheduler.class);
// Schedule a one-off job which scans installed packages and updates
- // out-of-date oat files.
- js.schedule(new JobInfo.Builder(JOB_POST_BOOT_UPDATE, sDexoptServiceName)
- .setMinimumLatency(TimeUnit.MINUTES.toMillis(10))
- .setOverrideDeadline(TimeUnit.MINUTES.toMillis(60))
- .build());
+ // out-of-date oat files. Schedule it 10 minutes after the boot complete event,
+ // so that we don't overload the boot with additional dex2oat compilations.
+ context.registerReceiver(new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ js.schedule(new JobInfo.Builder(JOB_POST_BOOT_UPDATE, sDexoptServiceName)
+ .setMinimumLatency(TimeUnit.MINUTES.toMillis(10))
+ .setOverrideDeadline(TimeUnit.MINUTES.toMillis(60))
+ .build());
+ context.unregisterReceiver(this);
+ if (DEBUG) {
+ Slog.i(TAG, "BootBgDexopt scheduled");
+ }
+ }
+ }, new IntentFilter(Intent.ACTION_BOOT_COMPLETED));
// Schedule a daily job which scans installed packages and compiles
// those with fresh profiling data.
@@ -130,8 +141,8 @@
.setPeriodic(IDLE_OPTIMIZATION_PERIOD)
.build());
- if (DEBUG_DEXOPT) {
- Log.i(TAG, "Jobs scheduled");
+ if (DEBUG) {
+ Slog.d(TAG, "BgDexopt scheduled");
}
}
@@ -151,7 +162,7 @@
@SuppressWarnings("deprecation")
final long lowThreshold = StorageManager.from(context).getStorageLowBytes(mDataDir);
if (lowThreshold == 0) {
- Log.e(TAG, "Invalid low storage threshold");
+ Slog.e(TAG, "Invalid low storage threshold");
}
return lowThreshold;
@@ -198,13 +209,12 @@
long usableSpace = mDataDir.getUsableSpace();
if (usableSpace < lowThreshold) {
// Rather bail than completely fill up the disk.
- Log.w(TAG, "Aborting background dex opt job due to low storage: " +
+ Slog.w(TAG, "Aborting background dex opt job due to low storage: " +
usableSpace);
break;
}
-
- if (DEBUG_DEXOPT) {
- Log.i(TAG, "Updating package " + pkg);
+ if (DEBUG) {
+ Slog.i(TAG, "Updating package " + pkg);
}
// Update package if needed. Note that there can be no race between concurrent
@@ -236,13 +246,13 @@
public void run() {
int result = idleOptimization(pm, pkgs, BackgroundDexOptService.this);
if (result == OPTIMIZE_PROCESSED) {
- Log.i(TAG, "Idle optimizations completed.");
+ Slog.i(TAG, "Idle optimizations completed.");
} else if (result == OPTIMIZE_ABORT_NO_SPACE_LEFT) {
- Log.w(TAG, "Idle optimizations aborted because of space constraints.");
+ Slog.w(TAG, "Idle optimizations aborted because of space constraints.");
} else if (result == OPTIMIZE_ABORT_BY_JOB_SCHEDULER) {
- Log.w(TAG, "Idle optimizations aborted by job scheduler.");
+ Slog.w(TAG, "Idle optimizations aborted by job scheduler.");
} else {
- Log.w(TAG, "Idle optimizations ended with unexpected code: " + result);
+ Slog.w(TAG, "Idle optimizations ended with unexpected code: " + result);
}
if (result != OPTIMIZE_ABORT_BY_JOB_SCHEDULER) {
// Abandon our timeslice and do not reschedule.
@@ -256,7 +266,7 @@
// Optimize the given packages and return the optimization result (one of the OPTIMIZE_* codes).
private int idleOptimization(PackageManagerService pm, ArraySet<String> pkgs,
Context context) {
- Log.i(TAG, "Performing idle optimizations");
+ Slog.i(TAG, "Performing idle optimizations");
// If post-boot update is still running, request that it exits early.
mExitPostBootUpdate.set(true);
mAbortIdleOptimization.set(false);
@@ -331,11 +341,15 @@
final long lowStorageThresholdForDowngrade = LOW_THRESHOLD_MULTIPLIER_FOR_DOWNGRADE
* lowStorageThreshold;
boolean shouldDowngrade = shouldDowngrade(lowStorageThresholdForDowngrade);
- Log.d(TAG, "Should Downgrade " + shouldDowngrade);
+ if (DEBUG) {
+ Slog.d(TAG, "Should Downgrade " + shouldDowngrade);
+ }
if (shouldDowngrade) {
Set<String> unusedPackages =
pm.getUnusedPackages(mDowngradeUnusedAppsThresholdInMillis);
- Log.d(TAG, "Unsused Packages " + String.join(",", unusedPackages));
+ if (DEBUG) {
+ Slog.d(TAG, "Unsused Packages " + String.join(",", unusedPackages));
+ }
if (!unusedPackages.isEmpty()) {
for (String pkg : unusedPackages) {
@@ -407,7 +421,9 @@
*/
private boolean downgradePackage(PackageManagerService pm, String pkg,
boolean isForPrimaryDex) {
- Log.d(TAG, "Downgrading " + pkg);
+ if (DEBUG) {
+ Slog.d(TAG, "Downgrading " + pkg);
+ }
boolean dex_opt_performed = false;
int reason = PackageManagerService.REASON_INACTIVE_PACKAGE_DOWNGRADE;
int dexoptFlags = DexoptOptions.DEXOPT_BOOT_COMPLETE
@@ -529,7 +545,7 @@
long usableSpace = mDataDir.getUsableSpace();
if (usableSpace < lowStorageThreshold) {
// Rather bail than completely fill up the disk.
- Log.w(TAG, "Aborting background dex opt job due to low storage: " + usableSpace);
+ Slog.w(TAG, "Aborting background dex opt job due to low storage: " + usableSpace);
return OPTIMIZE_ABORT_NO_SPACE_LEFT;
}
@@ -568,8 +584,8 @@
@Override
public boolean onStartJob(JobParameters params) {
- if (DEBUG_DEXOPT) {
- Log.i(TAG, "onStartJob");
+ if (DEBUG) {
+ Slog.i(TAG, "onStartJob");
}
// NOTE: PackageManagerService.isStorageLow uses a different set of criteria from
@@ -577,17 +593,13 @@
// restart with a period of ~1 minute.
PackageManagerService pm = (PackageManagerService)ServiceManager.getService("package");
if (pm.isStorageLow()) {
- if (DEBUG_DEXOPT) {
- Log.i(TAG, "Low storage, skipping this run");
- }
+ Slog.i(TAG, "Low storage, skipping this run");
return false;
}
final ArraySet<String> pkgs = pm.getOptimizablePackages();
if (pkgs.isEmpty()) {
- if (DEBUG_DEXOPT) {
- Log.i(TAG, "No packages to optimize");
- }
+ Slog.i(TAG, "No packages to optimize");
return false;
}
@@ -603,8 +615,8 @@
@Override
public boolean onStopJob(JobParameters params) {
- if (DEBUG_DEXOPT) {
- Log.i(TAG, "onStopJob");
+ if (DEBUG) {
+ Slog.d(TAG, "onStopJob");
}
if (params.getJobId() == JOB_POST_BOOT_UPDATE) {
@@ -625,7 +637,7 @@
private void notifyPinService(ArraySet<String> updatedPackages) {
PinnerService pinnerService = LocalServices.getService(PinnerService.class);
if (pinnerService != null) {
- Log.i(TAG, "Pinning optimized code " + updatedPackages);
+ Slog.i(TAG, "Pinning optimized code " + updatedPackages);
pinnerService.update(updatedPackages, false /* force */);
}
}
@@ -660,7 +672,7 @@
final String sysPropKey = "pm.dexopt.downgrade_after_inactive_days";
String sysPropValue = SystemProperties.get(sysPropKey);
if (sysPropValue == null || sysPropValue.isEmpty()) {
- Log.w(TAG, "SysProp " + sysPropKey + " not set");
+ Slog.w(TAG, "SysProp " + sysPropKey + " not set");
return Long.MAX_VALUE;
}
return TimeUnit.DAYS.toMillis(Long.parseLong(sysPropValue));
diff --git a/services/core/java/com/android/server/pm/DumpState.java b/services/core/java/com/android/server/pm/DumpState.java
index ec79483..ed00609 100644
--- a/services/core/java/com/android/server/pm/DumpState.java
+++ b/services/core/java/com/android/server/pm/DumpState.java
@@ -58,6 +58,7 @@
private boolean mTitlePrinted;
private boolean mFullPreferred;
private boolean mCheckIn;
+ private boolean mBrief;
private String mTargetPackageName;
@@ -128,4 +129,12 @@
public void setCheckIn(boolean checkIn) {
mCheckIn = checkIn;
}
+
+ public boolean isBrief() {
+ return mBrief;
+ }
+
+ public void setBrief(boolean brief) {
+ mBrief = brief;
+ }
}
diff --git a/services/core/java/com/android/server/pm/KeySetManagerService.java b/services/core/java/com/android/server/pm/KeySetManagerService.java
index 2015c78..34caaf5 100644
--- a/services/core/java/com/android/server/pm/KeySetManagerService.java
+++ b/services/core/java/com/android/server/pm/KeySetManagerService.java
@@ -30,6 +30,7 @@
import android.util.TypedXmlSerializer;
import com.android.server.pm.parsing.pkg.AndroidPackage;
+import com.android.server.utils.WatchedArrayMap;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -65,7 +66,7 @@
protected final LongSparseArray<ArraySet<Long>> mKeySetMapping;
- private final ArrayMap<String, PackageSetting> mPackages;
+ private final WatchedArrayMap<String, PackageSetting> mPackages;
private long lastIssuedKeySetId = 0;
@@ -114,7 +115,7 @@
}
}
- public KeySetManagerService(ArrayMap<String, PackageSetting> packages) {
+ public KeySetManagerService(WatchedArrayMap<String, PackageSetting> packages) {
mKeySets = new LongSparseArray<KeySetHandle>();
mPublicKeys = new LongSparseArray<PublicKeyHandle>();
mKeySetMapping = new LongSparseArray<ArraySet<Long>>();
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index fc36378..427bb2d 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -404,6 +404,7 @@
import com.android.server.rollback.RollbackManagerInternal;
import com.android.server.storage.DeviceStorageMonitorInternal;
import com.android.server.uri.UriGrantsManagerInternal;
+import com.android.server.utils.SnapshotCache;
import com.android.server.utils.TimingsTraceAndSlog;
import com.android.server.utils.Watchable;
import com.android.server.utils.Watched;
@@ -557,6 +558,7 @@
private static final int SHELL_UID = Process.SHELL_UID;
private static final int SE_UID = Process.SE_UID;
private static final int NETWORKSTACK_UID = Process.NETWORK_STACK_UID;
+ private static final int UWB_UID = Process.UWB_UID;
static final int SCAN_NO_DEX = 1 << 0;
static final int SCAN_UPDATE_SIGNATURE = 1 << 1;
@@ -870,12 +872,17 @@
@Watched
@GuardedBy("mLock")
final WatchedArrayMap<String, AndroidPackage> mPackages = new WatchedArrayMap<>();
+ private final SnapshotCache<WatchedArrayMap<String, AndroidPackage>> mPackagesSnapshot =
+ new SnapshotCache.Auto(mPackages, mPackages, "PackageManagerService.mPackages");
// Keys are isolated uids and values are the uid of the application
// that created the isolated process.
@Watched
@GuardedBy("mLock")
final WatchedSparseIntArray mIsolatedOwners = new WatchedSparseIntArray();
+ private final SnapshotCache<WatchedSparseIntArray> mIsolatedOwnersSnapshot =
+ new SnapshotCache.Auto(mIsolatedOwners, mIsolatedOwners,
+ "PackageManagerService.mIsolatedOwners");
/**
* Tracks new system packages [received in an OTA] that we expect to
@@ -1308,14 +1315,17 @@
// Avoid invalidation-thrashing by preventing cache invalidations from causing property
// writes if the cache isn't enabled yet. We re-enable writes later when we're
// done initializing.
- sSnapshotCorked = true;
+ sSnapshotCorked.incrementAndGet();
PackageManager.corkPackageInfoCache();
}
@Override
public void enablePackageCaches() {
// Uncork cache invalidations and allow clients to cache package information.
- sSnapshotCorked = false;
+ int corking = sSnapshotCorked.decrementAndGet();
+ if (TRACE_SNAPSHOTS && corking == 0) {
+ Log.i(TAG, "snapshot: corking returns to 0");
+ }
PackageManager.uncorkPackageInfoCache();
}
}
@@ -1394,14 +1404,27 @@
@Watched
final WatchedArrayMap<String, WatchedLongSparseArray<SharedLibraryInfo>>
mSharedLibraries = new WatchedArrayMap<>();
+ private final SnapshotCache<WatchedArrayMap<String, WatchedLongSparseArray<SharedLibraryInfo>>>
+ mSharedLibrariesSnapshot =
+ new SnapshotCache.Auto<>(mSharedLibraries, mSharedLibraries,
+ "PackageManagerService.mSharedLibraries");
@Watched
final WatchedArrayMap<String, WatchedLongSparseArray<SharedLibraryInfo>>
mStaticLibsByDeclaringPackage = new WatchedArrayMap<>();
+ private final SnapshotCache<WatchedArrayMap<String, WatchedLongSparseArray<SharedLibraryInfo>>>
+ mStaticLibsByDeclaringPackageSnapshot =
+ new SnapshotCache.Auto<>(mSharedLibraries, mSharedLibraries,
+ "PackageManagerService.mSharedLibraries");
// Mapping from instrumentation class names to info about them.
@Watched
final WatchedArrayMap<ComponentName, ParsedInstrumentation> mInstrumentation =
new WatchedArrayMap<>();
+ private final SnapshotCache<WatchedArrayMap<ComponentName, ParsedInstrumentation>>
+ mInstrumentationSnapshot =
+ new SnapshotCache.Auto<>(mInstrumentation, mInstrumentation,
+ "PackageManagerService.mInstrumentation");
+
// Packages whose data we have transfered into another package, thus
// should no longer exist.
@@ -1587,6 +1610,7 @@
static final int INTEGRITY_VERIFICATION_COMPLETE = 25;
static final int CHECK_PENDING_INTEGRITY_VERIFICATION = 26;
static final int DOMAIN_VERIFICATION = 27;
+ static final int SNAPSHOT_UNCORK = 28;
static final int DEFERRED_NO_KILL_POST_DELETE_DELAY_MS = 3 * 1000;
static final int DEFERRED_NO_KILL_INSTALL_OBSERVER_DELAY_MS = 500;
@@ -1833,11 +1857,11 @@
Snapshot(int type) {
if (type == Snapshot.SNAPPED) {
settings = mSettings.snapshot();
- isolatedOwners = mIsolatedOwners.snapshot();
- packages = mPackages.snapshot();
- sharedLibs = mSharedLibraries.snapshot();
- staticLibs = mStaticLibsByDeclaringPackage.snapshot();
- instrumentation = mInstrumentation.snapshot();
+ isolatedOwners = mIsolatedOwnersSnapshot.snapshot();
+ packages = mPackagesSnapshot.snapshot();
+ sharedLibs = mSharedLibrariesSnapshot.snapshot();
+ staticLibs = mStaticLibsByDeclaringPackageSnapshot.snapshot();
+ instrumentation = mInstrumentationSnapshot.snapshot();
resolveComponentName = mResolveComponentName.clone();
resolveActivity = new ActivityInfo(mResolveActivity);
instantAppInstallerActivity =
@@ -4873,12 +4897,16 @@
// A lock-free cache for frequently called functions.
private volatile Computer mSnapshotComputer;
// If true, the snapshot is invalid (stale). The attribute is static since it may be
- // set from outside classes.
- private static volatile boolean sSnapshotInvalid = true;
+ // set from outside classes. The attribute may be set to true anywhere, although it
+ // should only be set true while holding mLock. However, the attribute id guaranteed
+ // to be set false only while mLock and mSnapshotLock are both held.
+ private static AtomicBoolean sSnapshotInvalid = new AtomicBoolean(true);
+ // The package manager that is using snapshots.
+ private static PackageManagerService sSnapshotConsumer = null;
// If true, the snapshot is corked. Do not create a new snapshot but use the live
// computer. This throttles snapshot creation during periods of churn in Package
// Manager.
- private static volatile boolean sSnapshotCorked = false;
+ private static AtomicInteger sSnapshotCorked = new AtomicInteger(0);
/**
* This lock is used to make reads from {@link #sSnapshotInvalid} and
@@ -4896,7 +4924,10 @@
// The snapshot disable/enable switch. An image with the flag set true uses snapshots
// and an image with the flag set false does not use snapshots.
- private static final boolean SNAPSHOT_ENABLED = false;
+ private static final boolean SNAPSHOT_ENABLED = true;
+
+ // The default auto-cork delay for snapshots. This is 1s.
+ private static final long SNAPSHOT_AUTOCORK_DELAY_MS = TimeUnit.SECONDS.toMillis(1);
// The per-instance snapshot disable/enable flag. This is generally set to false in
// test instances and set to SNAPSHOT_ENABLED in operational instances.
@@ -4921,15 +4952,16 @@
// If the current thread holds mLock then it may have modified state but not
// yet invalidated the snapshot. Always give the thread the live computer.
return mLiveComputer;
+ } else if (sSnapshotCorked.get() > 0) {
+ // Snapshots are corked, which means new ones should not be built right now.
+ mSnapshotStatistics.corked();
+ return mLiveComputer;
}
synchronized (mSnapshotLock) {
+ // This synchronization block serializes access to the snapshot computer and
+ // to the code that samples mSnapshotInvalid.
Computer c = mSnapshotComputer;
- if (sSnapshotCorked && (c != null)) {
- // Snapshots are corked, which means new ones should not be built right now.
- c.use();
- return c;
- }
- if (sSnapshotInvalid || (c == null)) {
+ if (sSnapshotInvalid.getAndSet(false) || (c == null)) {
// The snapshot is invalid if it is marked as invalid or if it is null. If it
// is null, then it is currently being rebuilt by rebuildSnapshot().
synchronized (mLock) {
@@ -4937,9 +4969,7 @@
// invalidated as it is rebuilt. However, the snapshot is still
// self-consistent (the lock is being held) and is current as of the time
// this function is entered.
- if (sSnapshotInvalid) {
- rebuildSnapshot();
- }
+ rebuildSnapshot();
// Guaranteed to be non-null. mSnapshotComputer is only be set to null
// temporarily in rebuildSnapshot(), which is guarded by mLock(). Since
@@ -4957,12 +4987,11 @@
* Rebuild the cached computer. mSnapshotComputer is temporarily set to null to block other
* threads from using the invalid computer until it is rebuilt.
*/
- @GuardedBy("mLock")
+ @GuardedBy({ "mLock", "mSnapshotLock"})
private void rebuildSnapshot() {
final long now = SystemClock.currentTimeMicro();
final int hits = mSnapshotComputer == null ? -1 : mSnapshotComputer.getUsed();
mSnapshotComputer = null;
- sSnapshotInvalid = false;
final Snapshot args = new Snapshot(Snapshot.SNAPPED);
mSnapshotComputer = new ComputerEngine(args);
final long done = SystemClock.currentTimeMicro();
@@ -4971,6 +5000,30 @@
}
/**
+ * Create a new snapshot. Used for testing only. This does collect statistics or
+ * update the snapshot used by other actors. It does not alter the invalidation
+ * flag. This method takes the mLock internally.
+ */
+ private Computer createNewSnapshot() {
+ synchronized (mLock) {
+ final Snapshot args = new Snapshot(Snapshot.SNAPPED);
+ return new ComputerEngine(args);
+ }
+ }
+
+ /**
+ * Cork snapshots. This times out after the programmed delay.
+ */
+ private void corkSnapshots(int multiplier) {
+ int corking = sSnapshotCorked.getAndIncrement();
+ if (TRACE_SNAPSHOTS && corking == 0) {
+ Log.i(TAG, "snapshot: corking goes positive");
+ }
+ Message message = mHandler.obtainMessage(SNAPSHOT_UNCORK);
+ mHandler.sendMessageDelayed(message, SNAPSHOT_AUTOCORK_DELAY_MS * multiplier);
+ }
+
+ /**
* Create a live computer
*/
private ComputerLocked createLiveComputer() {
@@ -4985,9 +5038,9 @@
*/
public static void onChange(@Nullable Watchable what) {
if (TRACE_SNAPSHOTS) {
- Log.e(TAG, "snapshot: onChange(" + what + ")");
+ Log.i(TAG, "snapshot: onChange(" + what + ")");
}
- sSnapshotInvalid = true;
+ sSnapshotInvalid.set(true);
}
/**
@@ -5366,6 +5419,13 @@
mDomainVerificationManager.runMessage(messageCode, object);
break;
}
+ case SNAPSHOT_UNCORK: {
+ int corking = sSnapshotCorked.decrementAndGet();
+ if (TRACE_SNAPSHOTS && corking == 0) {
+ Log.e(TAG, "snapshot: corking goes to zero in message handler");
+ }
+ break;
+ }
}
}
}
@@ -6313,6 +6373,8 @@
ApplicationInfo.FLAG_SYSTEM, ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
mSettings.addSharedUserLPw("android.uid.networkstack", NETWORKSTACK_UID,
ApplicationInfo.FLAG_SYSTEM, ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
+ mSettings.addSharedUserLPw("android.uid.uwb", UWB_UID,
+ ApplicationInfo.FLAG_SYSTEM, ApplicationInfo.PRIVATE_FLAG_PRIVILEGED);
t.traceEnd();
String separateProcesses = SystemProperties.get("debug.separate_processes");
@@ -6380,12 +6442,13 @@
// constructor, at which time the invalidation method updates it. The cache is
// corked initially to ensure a cached computer is not built until the end of the
// constructor.
- mSnapshotEnabled = SNAPSHOT_ENABLED;
- sSnapshotCorked = true;
- sSnapshotInvalid = true;
mSnapshotStatistics = new SnapshotStatistics();
+ sSnapshotConsumer = this;
+ sSnapshotCorked.set(1);
+ sSnapshotInvalid.set(true);
mLiveComputer = createLiveComputer();
mSnapshotComputer = null;
+ mSnapshotEnabled = SNAPSHOT_ENABLED;
registerObserver();
}
@@ -18518,7 +18581,7 @@
}
}
- @GuardedBy({"mInstallLock", "mLock"})
+ @GuardedBy("mInstallLock")
private void installPackagesTracedLI(List<InstallRequest> requests) {
try {
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "installPackages");
@@ -24015,6 +24078,15 @@
dumpState.setDump(DumpState.DUMP_PER_UID_READ_TIMEOUTS);
} else if ("snapshot".equals(cmd)) {
dumpState.setDump(DumpState.DUMP_SNAPSHOT_STATISTICS);
+ if (opti < args.length) {
+ if ("--full".equals(args[opti])) {
+ dumpState.setBrief(false);
+ opti++;
+ } else if ("--brief".equals(args[opti])) {
+ dumpState.setBrief(true);
+ opti++;
+ }
+ }
} else if ("write".equals(cmd)) {
synchronized (mLock) {
writeSettingsLPrTEMP();
@@ -24350,13 +24422,14 @@
pw.println(" Snapshots disabled");
} else {
int hits = 0;
+ int level = sSnapshotCorked.get();
synchronized (mSnapshotLock) {
if (mSnapshotComputer != null) {
hits = mSnapshotComputer.getUsed();
}
}
final long now = SystemClock.currentTimeMicro();
- mSnapshotStatistics.dump(pw, " ", now, hits, true);
+ mSnapshotStatistics.dump(pw, " ", now, hits, level, dumpState.isBrief());
}
}
}
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index 1b8eee3..f5a13d5 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -351,6 +351,7 @@
private final PackageManagerTracedLock mLock;
+ @Watched(manual = true)
private final RuntimePermissionPersistence mRuntimePermissionsPersistence;
private final File mSettingsFilename;
@@ -364,19 +365,21 @@
/** Map from package name to settings */
@Watched
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
- final WatchedArrayMap<String, PackageSetting> mPackages = new WatchedArrayMap<>();
+ final WatchedArrayMap<String, PackageSetting> mPackages;
+ private final SnapshotCache<WatchedArrayMap<String, PackageSetting>> mPackagesSnapshot;
/**
* List of packages that were involved in installing other packages, i.e. are listed
* in at least one app's InstallSource.
*/
@Watched
- private final WatchedArraySet<String> mInstallerPackages = new WatchedArraySet<>();
+ private final WatchedArraySet<String> mInstallerPackages;
+ private final SnapshotCache<WatchedArraySet<String>> mInstallerPackagesSnapshot;
/** Map from package name to appId and excluded userids */
@Watched
- private final WatchedArrayMap<String, KernelPackageState> mKernelMapping =
- new WatchedArrayMap<>();
+ private final WatchedArrayMap<String, KernelPackageState> mKernelMapping;
+ private final SnapshotCache<WatchedArrayMap<String, KernelPackageState>> mKernelMappingSnapshot;
// List of replaced system applications
@Watched
@@ -397,7 +400,7 @@
/** Map from volume UUID to {@link VersionInfo} */
@Watched
- private WatchedArrayMap<String, VersionInfo> mVersion = new WatchedArrayMap<>();
+ private final WatchedArrayMap<String, VersionInfo> mVersion = new WatchedArrayMap<>();
/**
* Version details for a storage volume that may hold apps.
@@ -435,6 +438,7 @@
}
/** Device identity for the purpose of package verification. */
+ @Watched(manual = true)
private VerifierDeviceIdentity mVerifierDeviceIdentity;
// The user's preferred activities associated with particular intent
@@ -462,10 +466,12 @@
private final WatchedSparseArray<SettingBase> mOtherAppIds;
// For reading/writing settings file.
- private final ArrayList<Signature> mPastSignatures =
- new ArrayList<Signature>();
- private final ArrayMap<Long, Integer> mKeySetRefs =
- new ArrayMap<Long, Integer>();
+ @Watched
+ private final WatchedArrayList<Signature> mPastSignatures =
+ new WatchedArrayList<Signature>();
+ @Watched
+ private final WatchedArrayMap<Long, Integer> mKeySetRefs =
+ new WatchedArrayMap<Long, Integer>();
// Packages that have been renamed since they were first installed.
// Keys are the new names of the packages, values are the original
@@ -495,18 +501,21 @@
* TODO: make this just a local variable that is passed in during package
* scanning to make it less confusing.
*/
- private final ArrayList<PackageSetting> mPendingPackages = new ArrayList<>();
+ @Watched
+ private final WatchedArrayList<PackageSetting> mPendingPackages = new WatchedArrayList<>();
private final File mSystemDir;
- public final KeySetManagerService mKeySetManagerService =
- new KeySetManagerService(mPackages.untrackedStorage());
+ private final KeySetManagerService mKeySetManagerService;
/** Settings and other information about permissions */
+ @Watched(manual = true)
final LegacyPermissionSettings mPermissions;
+ @Watched(manual = true)
private final LegacyPermissionDataProvider mPermissionDataProvider;
+ @Watched(manual = true)
private final DomainVerificationManagerInternal mDomainVerificationManager;
/**
@@ -532,23 +541,7 @@
}};
}
- @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
- public Settings(Map<String, PackageSetting> pkgSettings) {
- mLock = new PackageManagerTracedLock();
- mPackages.putAll(pkgSettings);
- mAppIds = new WatchedArrayList<>();
- mOtherAppIds = new WatchedSparseArray<>();
- mSystemDir = null;
- mPermissions = null;
- mRuntimePermissionsPersistence = null;
- mPermissionDataProvider = null;
- mSettingsFilename = null;
- mBackupSettingsFilename = null;
- mPackageListFilename = null;
- mStoppedPackagesFilename = null;
- mBackupStoppedPackagesFilename = null;
- mKernelMappingFilename = null;
- mDomainVerificationManager = null;
+ private void registerObservers() {
mPackages.registerObserver(mObserver);
mInstallerPackages.registerObserver(mObserver);
mKernelMapping.registerObserver(mObserver);
@@ -564,7 +557,43 @@
mRenamedPackages.registerObserver(mObserver);
mNextAppLinkGeneration.registerObserver(mObserver);
mDefaultBrowserApp.registerObserver(mObserver);
+ mPendingPackages.registerObserver(mObserver);
+ mPastSignatures.registerObserver(mObserver);
+ mKeySetRefs.registerObserver(mObserver);
+ }
+ // CONSTRUCTOR
+ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
+ public Settings(Map<String, PackageSetting> pkgSettings) {
+ mPackages = new WatchedArrayMap<>();
+ mPackagesSnapshot =
+ new SnapshotCache.Auto<>(mPackages, mPackages, "Settings.mPackages");
+ mKernelMapping = new WatchedArrayMap<>();
+ mKernelMappingSnapshot =
+ new SnapshotCache.Auto<>(mKernelMapping, mKernelMapping, "Settings.mKernelMapping");
+ mInstallerPackages = new WatchedArraySet<>();
+ mInstallerPackagesSnapshot =
+ new SnapshotCache.Auto<>(mInstallerPackages, mInstallerPackages,
+ "Settings.mInstallerPackages");
+ mKeySetManagerService = new KeySetManagerService(mPackages);
+
+ mLock = new PackageManagerTracedLock();
+ mPackages.putAll(pkgSettings);
+ mAppIds = new WatchedArrayList<>();
+ mOtherAppIds = new WatchedSparseArray<>();
+ mSystemDir = null;
+ mPermissions = null;
+ mRuntimePermissionsPersistence = null;
+ mPermissionDataProvider = null;
+ mSettingsFilename = null;
+ mBackupSettingsFilename = null;
+ mPackageListFilename = null;
+ mStoppedPackagesFilename = null;
+ mBackupStoppedPackagesFilename = null;
+ mKernelMappingFilename = null;
+ mDomainVerificationManager = null;
+
+ registerObservers();
Watchable.verifyWatchedAttributes(this, mObserver);
mSnapshot = makeCache();
@@ -574,6 +603,18 @@
LegacyPermissionDataProvider permissionDataProvider,
@NonNull DomainVerificationManagerInternal domainVerificationManager,
@NonNull PackageManagerTracedLock lock) {
+ mPackages = new WatchedArrayMap<>();
+ mPackagesSnapshot =
+ new SnapshotCache.Auto<>(mPackages, mPackages, "Settings.mPackages");
+ mKernelMapping = new WatchedArrayMap<>();
+ mKernelMappingSnapshot =
+ new SnapshotCache.Auto<>(mKernelMapping, mKernelMapping, "Settings.mKernelMapping");
+ mInstallerPackages = new WatchedArraySet<>();
+ mInstallerPackagesSnapshot =
+ new SnapshotCache.Auto<>(mInstallerPackages, mInstallerPackages,
+ "Settings.mInstallerPackages");
+ mKeySetManagerService = new KeySetManagerService(mPackages);
+
mLock = lock;
mAppIds = new WatchedArrayList<>();
mOtherAppIds = new WatchedSparseArray<>();
@@ -602,22 +643,7 @@
mDomainVerificationManager = domainVerificationManager;
- mPackages.registerObserver(mObserver);
- mInstallerPackages.registerObserver(mObserver);
- mKernelMapping.registerObserver(mObserver);
- mDisabledSysPackages.registerObserver(mObserver);
- mBlockUninstallPackages.registerObserver(mObserver);
- mVersion.registerObserver(mObserver);
- mPreferredActivities.registerObserver(mObserver);
- mPersistentPreferredActivities.registerObserver(mObserver);
- mCrossProfileIntentResolvers.registerObserver(mObserver);
- mSharedUsers.registerObserver(mObserver);
- mAppIds.registerObserver(mObserver);
- mOtherAppIds.registerObserver(mObserver);
- mRenamedPackages.registerObserver(mObserver);
- mNextAppLinkGeneration.registerObserver(mObserver);
- mDefaultBrowserApp.registerObserver(mObserver);
-
+ registerObservers();
Watchable.verifyWatchedAttributes(this, mObserver);
mSnapshot = makeCache();
@@ -629,8 +655,13 @@
* are changed by PackageManagerService APIs are deep-copied
*/
private Settings(Settings r) {
- final int mPackagesSize = r.mPackages.size();
- mPackages.putAll(r.mPackages);
+ mPackages = r.mPackagesSnapshot.snapshot();
+ mPackagesSnapshot = new SnapshotCache.Sealed<>();
+ mKernelMapping = r.mKernelMappingSnapshot.snapshot();
+ mKernelMappingSnapshot = new SnapshotCache.Sealed<>();
+ mInstallerPackages = r.mInstallerPackagesSnapshot.snapshot();
+ mInstallerPackagesSnapshot = new SnapshotCache.Sealed<>();
+ mKeySetManagerService = new KeySetManagerService(mPackages);
// The following assignments satisfy Java requirements but are not
// needed by the read-only methods. Note especially that the lock
@@ -647,9 +678,7 @@
mDomainVerificationManager = r.mDomainVerificationManager;
- mInstallerPackages.addAll(r.mInstallerPackages);
- mKernelMapping.putAll(r.mKernelMapping);
- mDisabledSysPackages.putAll(r.mDisabledSysPackages);
+ mDisabledSysPackages.snapshot(r.mDisabledSysPackages);
mBlockUninstallPackages.snapshot(r.mBlockUninstallPackages);
mVersion.putAll(r.mVersion);
mVerifierDeviceIdentity = r.mVerifierDeviceIdentity;
@@ -659,23 +688,26 @@
mPersistentPreferredActivities, r.mPersistentPreferredActivities);
WatchedSparseArray.snapshot(
mCrossProfileIntentResolvers, r.mCrossProfileIntentResolvers);
- mSharedUsers.putAll(r.mSharedUsers);
+ mSharedUsers.snapshot(r.mSharedUsers);
mAppIds = r.mAppIds.snapshot();
mOtherAppIds = r.mOtherAppIds.snapshot();
- mPastSignatures.addAll(r.mPastSignatures);
- mKeySetRefs.putAll(r.mKeySetRefs);
+ WatchedArrayList.snapshot(
+ mPastSignatures, r.mPastSignatures);
+ WatchedArrayMap.snapshot(
+ mKeySetRefs, r.mKeySetRefs);
mRenamedPackages.snapshot(r.mRenamedPackages);
mNextAppLinkGeneration.snapshot(r.mNextAppLinkGeneration);
mDefaultBrowserApp.snapshot(r.mDefaultBrowserApp);
// mReadMessages
- mPendingPackages.addAll(r.mPendingPackages);
+ WatchedArrayList.snapshot(
+ mPendingPackages, r.mPendingPackages);
mSystemDir = null;
// mKeySetManagerService;
mPermissions = r.mPermissions;
mPermissionDataProvider = r.mPermissionDataProvider;
// Do not register any Watchables and do not create a snapshot cache.
- mSnapshot = null;
+ mSnapshot = new SnapshotCache.Sealed();
}
/**
@@ -2326,7 +2358,7 @@
serializer.startTag(null, "shared-user");
serializer.attribute(null, ATTR_NAME, usr.name);
serializer.attributeInt(null, "userId", usr.userId);
- usr.signatures.writeXml(serializer, "sigs", mPastSignatures);
+ usr.signatures.writeXml(serializer, "sigs", mPastSignatures.untrackedStorage());
serializer.endTag(null, "shared-user");
}
@@ -2736,11 +2768,11 @@
writeUsesStaticLibLPw(serializer, pkg.usesStaticLibraries, pkg.usesStaticLibrariesVersions);
- pkg.signatures.writeXml(serializer, "sigs", mPastSignatures);
+ pkg.signatures.writeXml(serializer, "sigs", mPastSignatures.untrackedStorage());
if (installSource.initiatingPackageSignatures != null) {
installSource.initiatingPackageSignatures.writeXml(
- serializer, "install-initiator-sigs", mPastSignatures);
+ serializer, "install-initiator-sigs", mPastSignatures.untrackedStorage());
}
writeSigningKeySetLPr(serializer, pkg.keySetData);
@@ -2909,7 +2941,7 @@
} else if (TAG_READ_EXTERNAL_STORAGE.equals(tagName)) {
// No longer used.
} else if (tagName.equals("keyset-settings")) {
- mKeySetManagerService.readKeySetsLPw(parser, mKeySetRefs);
+ mKeySetManagerService.readKeySetsLPw(parser, mKeySetRefs.untrackedStorage());
} else if (TAG_VERSION.equals(tagName)) {
final String volumeUuid = XmlUtils.readStringAttribute(parser,
ATTR_VOLUME_UUID);
@@ -3697,7 +3729,7 @@
} else if (tagName.equals(TAG_ENABLED_COMPONENTS)) {
readEnabledComponentsLPw(packageSetting, parser, 0);
} else if (tagName.equals("sigs")) {
- packageSetting.signatures.readXml(parser, mPastSignatures);
+ packageSetting.signatures.readXml(parser, mPastSignatures.untrackedStorage());
} else if (tagName.equals(TAG_PERMISSIONS)) {
readInstallPermissionsLPr(parser,
packageSetting.getLegacyPermissionState(), users);
@@ -3728,7 +3760,7 @@
packageSetting.keySetData.addDefinedKeySet(id, alias);
} else if (tagName.equals("install-initiator-sigs")) {
final PackageSignatures signatures = new PackageSignatures();
- signatures.readXml(parser, mPastSignatures);
+ signatures.readXml(parser, mPastSignatures.untrackedStorage());
packageSetting.installSource =
packageSetting.installSource.setInitiatingPackageSignatures(signatures);
} else if (tagName.equals(TAG_DOMAIN_VERIFICATION)) {
@@ -3923,7 +3955,7 @@
String tagName = parser.getName();
if (tagName.equals("sigs")) {
- su.signatures.readXml(parser, mPastSignatures);
+ su.signatures.readXml(parser, mPastSignatures.untrackedStorage());
} else if (tagName.equals("perms")) {
readInstallPermissionsLPr(parser, su.getLegacyPermissionState(), users);
} else {
diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java
index 7f18c4b..20f35f2 100644
--- a/services/core/java/com/android/server/pm/ShortcutService.java
+++ b/services/core/java/com/android/server/pm/ShortcutService.java
@@ -2254,24 +2254,6 @@
}
@Override
- public AndroidFuture updateShortcutVisibility(String callingPkg, String packageName,
- byte[] certificate, boolean visible, int userId) {
- final AndroidFuture<Void> ret = new AndroidFuture<>();
- injectPostToHandlerIfAppSearch(() -> {
- try {
- synchronized (mLock) {
- getPackageShortcutsForPublisherLocked(callingPkg, userId)
- .updateVisibility(packageName, certificate, visible);
- }
- ret.complete(null);
- } catch (Exception e) {
- ret.completeExceptionally(e);
- }
- });
- return ret;
- }
-
- @Override
public AndroidFuture requestPinShortcut(String packageName, ShortcutInfo shortcut,
IntentSender resultIntent, int userId) {
final AndroidFuture<Boolean> ret = new AndroidFuture<>();
diff --git a/services/core/java/com/android/server/pm/SnapshotStatistics.java b/services/core/java/com/android/server/pm/SnapshotStatistics.java
index c425bad5..7bf00603 100644
--- a/services/core/java/com/android/server/pm/SnapshotStatistics.java
+++ b/services/core/java/com/android/server/pm/SnapshotStatistics.java
@@ -23,6 +23,7 @@
import android.os.SystemClock;
import android.text.TextUtils;
+import com.android.internal.annotations.GuardedBy;
import com.android.server.EventLogTags;
import java.io.PrintWriter;
@@ -239,6 +240,11 @@
public int mTotalUsed = 0;
/**
+ * The total number of times a snapshot was bypassed because corking was in effect.
+ */
+ public int mTotalCorked = 0;
+
+ /**
* The total number of builds that count as big, which means they took longer than
* SNAPSHOT_BIG_BUILD_TIME_NS.
*/
@@ -291,6 +297,13 @@
}
}
+ /**
+ * Record a cork.
+ */
+ private void corked() {
+ mTotalCorked++;
+ }
+
private Stats(long now) {
mStartTimeUs = now;
mTimes = new int[mTimeBins.count()];
@@ -308,6 +321,7 @@
mUsed = Arrays.copyOf(orig.mUsed, orig.mUsed.length);
mTotalBuilds = orig.mTotalBuilds;
mTotalUsed = orig.mTotalUsed;
+ mTotalCorked = orig.mTotalCorked;
mBigBuilds = orig.mBigBuilds;
mShortLived = orig.mShortLived;
mTotalTimeUs = orig.mTotalTimeUs;
@@ -365,6 +379,7 @@
* Dump the summary statistics record. Choose the header or the data.
* number of builds
* number of uses
+ * number of corks
* number of big builds
* number of short lifetimes
* cumulative build time, in seconds
@@ -373,13 +388,13 @@
private void dumpStats(PrintWriter pw, String indent, long now, boolean header) {
dumpPrefix(pw, indent, now, header, "Summary stats");
if (header) {
- pw.format(Locale.US, " %10s %10s %10s %10s %10s %10s",
- "TotBlds", "TotUsed", "BigBlds", "ShortLvd",
+ pw.format(Locale.US, " %10s %10s %10s %10s %10s %10s %10s",
+ "TotBlds", "TotUsed", "TotCork", "BigBlds", "ShortLvd",
"TotTime", "MaxTime");
} else {
pw.format(Locale.US,
- " %10d %10d %10d %10d %10d %10d",
- mTotalBuilds, mTotalUsed, mBigBuilds, mShortLived,
+ " %10d %10d %10d %10d %10d %10d %10d",
+ mTotalBuilds, mTotalUsed, mTotalCorked, mBigBuilds, mShortLived,
mTotalTimeUs / 1000, mMaxBuildTimeUs / 1000);
}
pw.println();
@@ -516,7 +531,7 @@
* @param done The time at which the snapshot rebuild completed, in ns.
* @param hits The number of times the previous snapshot was used.
*/
- public void rebuild(long now, long done, int hits) {
+ public final void rebuild(long now, long done, int hits) {
// The duration has a span of about 2000s
final int duration = (int) (done - now);
boolean reportEvent = false;
@@ -544,9 +559,20 @@
}
/**
+ * Record a corked snapshot request.
+ */
+ public final void corked() {
+ synchronized (mLock) {
+ mShort[0].corked();
+ mLong[0].corked();
+ }
+ }
+
+ /**
* Roll a stats array. Shift the elements up an index and create a new element at
* index zero. The old element zero is completed with the specified time.
*/
+ @GuardedBy("mLock")
private void shift(Stats[] s, long now) {
s[0].complete(now);
for (int i = s.length - 1; i > 0; i--) {
@@ -598,7 +624,8 @@
* Dump the statistics. The format is compatible with the PackageManager dumpsys
* output.
*/
- public void dump(PrintWriter pw, String indent, long now, int unrecorded, boolean full) {
+ public void dump(PrintWriter pw, String indent, long now, int unrecorded,
+ int corkLevel, boolean full) {
// Grab the raw statistics under lock, but print them outside of the lock.
Stats[] l;
Stats[] s;
@@ -608,7 +635,8 @@
s = Arrays.copyOf(mShort, mShort.length);
s[0] = new Stats(s[0]);
}
- pw.format(Locale.US, "%s Unrecorded hits %d", indent, unrecorded);
+ pw.format(Locale.US, "%s Unrecorded-hits: %d Cork-level: %d", indent,
+ unrecorded, corkLevel);
pw.println();
dump(pw, indent, now, l, s, "stats");
if (!full) {
diff --git a/services/core/java/com/android/server/pm/TEST_MAPPING b/services/core/java/com/android/server/pm/TEST_MAPPING
index 90a3c58..f86eb60 100644
--- a/services/core/java/com/android/server/pm/TEST_MAPPING
+++ b/services/core/java/com/android/server/pm/TEST_MAPPING
@@ -94,6 +94,9 @@
"include-filter": "com.android.server.pm.test.OverlayActorVisibilityTest"
}
]
+ },
+ {
+ "name": "CtsPackageManagerBootTestCases"
}
],
"postsubmit": [
diff --git a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
index 50f958f..a7bac20 100644
--- a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
+++ b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
@@ -37,6 +37,7 @@
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
import android.media.RingtoneManager;
+import android.media.midi.MidiManager;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
@@ -866,6 +867,11 @@
grantPermissionsToSystemPackage(pm, systemCaptionsServicePackageName, userId,
MICROPHONE_PERMISSIONS);
}
+
+ // Bluetooth MIDI Service
+ grantSystemFixedPermissionsToSystemPackage(pm,
+ MidiManager.BLUETOOTH_MIDI_SERVICE_PACKAGE, userId,
+ NEARBY_DEVICES_PERMISSIONS);
}
private String getDefaultSystemHandlerActivityPackageForCategory(PackageManagerWrapper pm,
diff --git a/services/core/java/com/android/server/power/batterysaver/BatterySaverPolicy.java b/services/core/java/com/android/server/power/batterysaver/BatterySaverPolicy.java
index 68e7bdb..09f8941 100644
--- a/services/core/java/com/android/server/power/batterysaver/BatterySaverPolicy.java
+++ b/services/core/java/com/android/server/power/batterysaver/BatterySaverPolicy.java
@@ -179,7 +179,7 @@
true, /* enableQuickDoze */
true, /* forceAllAppsStandby */
true, /* forceBackgroundCheck */
- PowerManager.LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF, /* locationMode */
+ PowerManager.LOCATION_MODE_FOREGROUND_ONLY, /* locationMode */
PowerManager.SOUND_TRIGGER_MODE_CRITICAL_ONLY /* soundTriggerMode */
);
diff --git a/services/core/java/com/android/server/utils/SnapshotCache.java b/services/core/java/com/android/server/utils/SnapshotCache.java
index b4b8835..42b9b23 100644
--- a/services/core/java/com/android/server/utils/SnapshotCache.java
+++ b/services/core/java/com/android/server/utils/SnapshotCache.java
@@ -19,6 +19,9 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
+import java.util.WeakHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
/**
* A class that caches snapshots. Instances are instantiated on a {@link Watchable}; when the
* {@link Watchable} reports a change, the cache is cleared. The snapshot() method fetches the
@@ -35,25 +38,65 @@
*/
private static final boolean ENABLED = true;
+ /**
+ * The statistics for a single cache. The object records the number of times a
+ * snapshot was reused and the number of times a snapshot was rebuilt.
+ */
+ private static class Statistics {
+ final String mName;
+ private final AtomicInteger mReused = new AtomicInteger(0);
+ private final AtomicInteger mRebuilt = new AtomicInteger(0);
+ Statistics(@NonNull String n) {
+ mName = n;
+ }
+ }
+
// The source object from which snapshots are created. This may be null if createSnapshot()
// does not require it.
protected final T mSource;
// The cached snapshot
- private T mSnapshot = null;
+ private volatile T mSnapshot = null;
// True if the snapshot is sealed and may not be modified.
- private boolean mSealed = false;
+ private volatile boolean mSealed = false;
+
+ // The statistics for this cache. This may be null.
+ private final Statistics mStatistics;
+
+ /**
+ * The global list of caches.
+ */
+ private static final WeakHashMap<SnapshotCache, Void> sCaches = new WeakHashMap<>();
/**
* Create a cache with a source object for rebuilding snapshots and a
- * {@link Watchable} that notifies when the cache is invalid.
+ * {@link Watchable} that notifies when the cache is invalid. If the name is null
+ * then statistics are not collected for this cache.
+ * @param source Source data for rebuilding snapshots.
+ * @param watchable The object that notifies when the cache is invalid.
+ * @param name The name of the cache, for statistics reporting.
+ */
+ public SnapshotCache(@Nullable T source, @NonNull Watchable watchable, @Nullable String name) {
+ mSource = source;
+ watchable.registerObserver(this);
+ if (name != null) {
+ mStatistics = new Statistics(name);
+ sCaches.put(this, null);
+ } else {
+ mStatistics = null;
+ }
+ }
+
+ /**
+ * Create a cache with a source object for rebuilding snapshots and a
+ * {@link Watchable} that notifies when the cache is invalid. The name is null in
+ * this API.
* @param source Source data for rebuilding snapshots.
* @param watchable The object that notifies when the cache is invalid.
*/
public SnapshotCache(@Nullable T source, @NonNull Watchable watchable) {
- mSource = source;
- watchable.registerObserver(this);
+ this(source, watchable, null);
}
/**
@@ -63,13 +106,14 @@
public SnapshotCache() {
mSource = null;
mSealed = true;
+ mStatistics = null;
}
/**
* Notify the object that the source object has changed. If the local object is sealed then
* IllegalStateException is thrown. Otherwise, the cache is cleared.
*/
- public void onChange(@Nullable Watchable what) {
+ public final void onChange(@Nullable Watchable what) {
if (mSealed) {
throw new IllegalStateException("attempt to change a sealed object");
}
@@ -79,7 +123,7 @@
/**
* Seal the cache. Attempts to modify the cache will generate an exception.
*/
- public void seal() {
+ public final void seal() {
mSealed = true;
}
@@ -88,11 +132,14 @@
* new snapshot and saves it in the cache.
* @return A snapshot as returned by createSnapshot() and possibly cached.
*/
- public T snapshot() {
+ public final T snapshot() {
T s = mSnapshot;
if (s == null || !ENABLED) {
s = createSnapshot();
mSnapshot = s;
+ if (mStatistics != null) mStatistics.mRebuilt.incrementAndGet();
+ } else {
+ if (mStatistics != null) mStatistics.mReused.incrementAndGet();
}
return s;
}
@@ -123,4 +170,25 @@
throw new UnsupportedOperationException("cannot snapshot a sealed snaphot");
}
}
+
+ /**
+ * A snapshot cache suitable for Snappable types. The key is that Snappable types
+ * have a known implementation of createSnapshot() so that this class is concrete.
+ * @param <T> The class whose snapshot is being cached.
+ */
+ public static class Auto<T extends Snappable<T>> extends SnapshotCache<T> {
+ public Auto(@NonNull T source, @NonNull Watchable watchable, @Nullable String name) {
+ super(source, watchable, name);
+ }
+ public Auto(@NonNull T source, @NonNull Watchable watchable) {
+ this(source, watchable, null);
+ }
+ /**
+ * Concrete createSnapshot() using the snapshot() method of <T>.
+ */
+ public T createSnapshot() {
+ return mSource.snapshot();
+ }
+ }
+
}
diff --git a/services/core/java/com/android/server/vcn/UnderlyingNetworkTracker.java b/services/core/java/com/android/server/vcn/UnderlyingNetworkTracker.java
index 8818023..3c6bb64 100644
--- a/services/core/java/com/android/server/vcn/UnderlyingNetworkTracker.java
+++ b/services/core/java/com/android/server/vcn/UnderlyingNetworkTracker.java
@@ -158,8 +158,15 @@
* carrier owned networks may be selected, as the request specifies only subIds in the VCN's
* subscription group, while the VCN networks are excluded by virtue of not having subIds set on
* the VCN-exposed networks.
+ *
+ * <p>If the VCN that this UnderlyingNetworkTracker belongs to is in test-mode, this will return
+ * a NetworkRequest that only matches Test Networks.
*/
private NetworkRequest getRouteSelectionRequest() {
+ if (mVcnContext.isInTestMode()) {
+ return getTestNetworkRequest(mLastSnapshot.getAllSubIdsInGroup(mSubscriptionGroup));
+ }
+
return getBaseNetworkRequestBuilder()
.setSubscriptionIds(mLastSnapshot.getAllSubIdsInGroup(mSubscriptionGroup))
.build();
@@ -210,6 +217,16 @@
.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED);
}
+ /** Builds and returns a NetworkRequest for the given subIds to match Test Networks. */
+ private NetworkRequest getTestNetworkRequest(@NonNull Set<Integer> subIds) {
+ return getBaseNetworkRequestBuilder()
+ .addTransportType(NetworkCapabilities.TRANSPORT_TEST)
+ .removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
+ .removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
+ .setSubscriptionIds(subIds)
+ .build();
+ }
+
/**
* Update this UnderlyingNetworkTracker's TelephonySubscriptionSnapshot.
*
diff --git a/services/core/java/com/android/server/vcn/VcnContext.java b/services/core/java/com/android/server/vcn/VcnContext.java
index 7399e56..d958222 100644
--- a/services/core/java/com/android/server/vcn/VcnContext.java
+++ b/services/core/java/com/android/server/vcn/VcnContext.java
@@ -31,14 +31,17 @@
@NonNull private final Context mContext;
@NonNull private final Looper mLooper;
@NonNull private final VcnNetworkProvider mVcnNetworkProvider;
+ private final boolean mIsInTestMode;
public VcnContext(
@NonNull Context context,
@NonNull Looper looper,
- @NonNull VcnNetworkProvider vcnNetworkProvider) {
+ @NonNull VcnNetworkProvider vcnNetworkProvider,
+ boolean isInTestMode) {
mContext = Objects.requireNonNull(context, "Missing context");
mLooper = Objects.requireNonNull(looper, "Missing looper");
mVcnNetworkProvider = Objects.requireNonNull(vcnNetworkProvider, "Missing networkProvider");
+ mIsInTestMode = isInTestMode;
}
@NonNull
@@ -56,6 +59,10 @@
return mVcnNetworkProvider;
}
+ public boolean isInTestMode() {
+ return mIsInTestMode;
+ }
+
/**
* Verifies that the caller is running on the VcnContext Thread.
*
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 8f3702a..9f51d97 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -115,8 +115,6 @@
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_OPEN_BEHIND;
-import static android.view.WindowManager.TRANSIT_OLD_ACTIVITY_CLOSE;
-import static android.view.WindowManager.TRANSIT_OLD_TASK_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_UNSET;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
@@ -325,7 +323,6 @@
import com.android.internal.protolog.common.ProtoLog;
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;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.server.LocalServices;
@@ -2385,7 +2382,8 @@
return occludesParent(false /* includingFinishing */);
}
- private boolean occludesParent(boolean includingFinishing) {
+ @VisibleForTesting
+ boolean occludesParent(boolean includingFinishing) {
if (!includingFinishing && finishing) {
return false;
}
@@ -2843,7 +2841,6 @@
final boolean endTask = task.getTopNonFinishingActivity() == null
&& !task.isClearingToReuseTask();
- final int transit = endTask ? TRANSIT_OLD_TASK_CLOSE : TRANSIT_OLD_ACTIVITY_CLOSE;
if (newTransition != null) {
mAtmService.getTransitionController().requestStartTransition(newTransition,
endTask ? task : null, null /* remote */);
@@ -2900,7 +2897,7 @@
} else if (!isState(PAUSING)) {
if (mVisibleRequested) {
// Prepare and execute close transition.
- prepareActivityHideTransitionAnimation(transit);
+ prepareActivityHideTransitionAnimation();
}
final boolean removedActivity = completeFinishing("finishIfPossible") == null;
@@ -2918,11 +2915,9 @@
// In this case, we can set the visibility of all the task overlay activities when
// we detect the last one is finishing to keep them in sync.
if (task.onlyHasTaskOverlayActivities(false /* includeFinishing */)) {
- final PooledConsumer c = PooledLambda.obtainConsumer(
- ActivityRecord::prepareActivityHideTransitionAnimationIfOvarlay,
- PooledLambda.__(ActivityRecord.class), transit);
- task.forAllActivities(c);
- c.recycle();
+ task.forAllActivities((r) -> {
+ r.prepareActivityHideTransitionAnimationIfOvarlay();
+ });
}
return removedActivity ? FINISH_RESULT_REMOVED : FINISH_RESULT_REQUESTED;
} else {
@@ -2935,28 +2930,33 @@
}
}
- private void prepareActivityHideTransitionAnimationIfOvarlay(@TransitionOldType int transit) {
+ private void prepareActivityHideTransitionAnimationIfOvarlay() {
if (mTaskOverlay) {
- prepareActivityHideTransitionAnimation(transit);
+ prepareActivityHideTransitionAnimation();
}
}
- private void prepareActivityHideTransitionAnimation(@TransitionOldType int transit) {
+ private void prepareActivityHideTransitionAnimation() {
final DisplayContent dc = mDisplayContent;
dc.prepareAppTransition(TRANSIT_CLOSE);
setVisibility(false);
dc.executeAppTransition();
}
+ ActivityRecord completeFinishing(String reason) {
+ return completeFinishing(true /* updateVisibility */, reason);
+ }
+
/**
* Complete activity finish request that was initiated earlier. If the activity is still
* pausing we will wait for it to complete its transition. If the activity that should appear in
* place of this one is not visible yet - we'll wait for it first. Otherwise - activity can be
* destroyed right away.
+ * @param updateVisibility Indicate if need to update activity visibility.
* @param reason Reason for finishing the activity.
* @return Flag indicating whether the activity was removed from history.
*/
- ActivityRecord completeFinishing(String reason) {
+ ActivityRecord completeFinishing(boolean updateVisibility, String reason) {
if (!finishing || isState(RESUMED)) {
throw new IllegalArgumentException(
"Activity must be finishing and not resumed to complete, r=" + this
@@ -2968,13 +2968,11 @@
return this;
}
- final boolean isCurrentVisible = mVisibleRequested || isState(PAUSED);
- if (isCurrentVisible) {
- final Task rootTask = getRootTask();
- final ActivityRecord activity = rootTask.getResumedActivity();
+ final boolean isCurrentVisible = mVisibleRequested || isState(PAUSED, STARTED);
+ if (updateVisibility && isCurrentVisible) {
boolean ensureVisibility = false;
- if (activity != null && !activity.occludesParent()) {
- // If the resume activity is not opaque, we need to make sure the visibilities of
+ if (occludesParent(true /* includingFinishing */)) {
+ // If the current activity is not opaque, we need to make sure the visibilities of
// activities be updated, they may be seen by users.
ensureVisibility = true;
} else if (mTaskSupervisor.getKeyguardController().isKeyguardLocked()
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 411059d..8800a9e 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -1562,6 +1562,10 @@
// If the transition has not started yet, the activity must be the top.
return false;
}
+ if (mLastWallpaperVisible && r.windowsCanBeWallpaperTarget()) {
+ // Use normal rotation animation for orientation change of visible wallpaper.
+ return false;
+ }
final int rotation = rotationForActivityInDifferentOrientation(r);
if (rotation == ROTATION_UNDEFINED) {
// The display rotation won't be changed by current top activity. The client side
@@ -2449,6 +2453,10 @@
setWindowingMode(windowingMode);
}
+ /**
+ * See {@code WindowState#applyImeWindowsIfNeeded} for the details that we won't traverse the
+ * IME window in some cases.
+ */
boolean forAllImeWindows(ToBooleanFunction<WindowState> callback, boolean traverseTopToBottom) {
return mImeWindowsContainer.forAllWindowForce(callback, traverseTopToBottom);
}
@@ -4566,6 +4574,8 @@
private boolean skipImeWindowsDuringTraversal(DisplayContent dc) {
// We skip IME windows so they're processed just above their target, except
// in split-screen mode where we process the IME containers above the docked divider.
+ // Note that this method check should align with {@link
+ // WindowState#applyImeWindowsIfNeeded} in case of any state mismatch.
return dc.getImeTarget(IME_TARGET_LAYERING) != null
&& !dc.getDefaultTaskDisplayArea().isSplitScreenModeActivated();
}
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index 30f69dd..37e15c7 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -92,6 +92,7 @@
import static android.view.WindowManagerPolicyConstants.NAV_BAR_INVALID;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_LEFT;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_RIGHT;
+import static android.window.DisplayAreaOrganizer.FEATURE_UNDEFINED;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_SCREEN_ON;
import static com.android.server.policy.PhoneWindowManager.TOAST_WINDOW_TIMEOUT;
@@ -2667,7 +2668,8 @@
if (oldImmersiveMode != newImmersiveMode) {
mLastImmersiveMode = newImmersiveMode;
// The immersive confirmation window should be attached to the immersive window root.
- final int rootDisplayAreaId = win.getRootDisplayArea().mFeatureId;
+ final RootDisplayArea root = win.getRootDisplayArea();
+ final int rootDisplayAreaId = root == null ? FEATURE_UNDEFINED : root.mFeatureId;
mImmersiveModeConfirmation.immersiveModeChangedLw(rootDisplayAreaId, newImmersiveMode,
mService.mPolicy.isUserSetupComplete(),
isNavBarEmpty(disableFlags));
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index e5e1a7a..be01173 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -5842,8 +5842,13 @@
final boolean wasStopping = prev.isState(STOPPING);
prev.setState(PAUSED, "completePausedLocked");
if (prev.finishing) {
+ // We will update the activity visibility later, no need to do in
+ // completeFinishing(). Updating visibility here might also making the next
+ // activities to be resumed, and could result in wrong app transition due to
+ // lack of previous activity information.
ProtoLog.v(WM_DEBUG_STATES, "Executing finish of activity: %s", prev);
- prev = prev.completeFinishing("completePausedLocked");
+ prev = prev.completeFinishing(false /* updateVisibility */,
+ "completePausedLocked");
} else if (prev.hasProcess()) {
ProtoLog.v(WM_DEBUG_STATES, "Enqueue pending stop if needed: %s "
+ "wasStopping=%b visibleRequested=%b", prev, wasStopping,
diff --git a/services/core/java/com/android/server/wm/TaskOrganizerController.java b/services/core/java/com/android/server/wm/TaskOrganizerController.java
index fb481b4..a4c8db6 100644
--- a/services/core/java/com/android/server/wm/TaskOrganizerController.java
+++ b/services/core/java/com/android/server/wm/TaskOrganizerController.java
@@ -38,6 +38,7 @@
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
+import android.os.SystemProperties;
import android.util.Slog;
import android.util.proto.ProtoOutputStream;
import android.view.SurfaceControl;
@@ -75,6 +76,9 @@
private static final int REPORT_CONFIGS = CONTROLLABLE_CONFIGS;
private static final int REPORT_WINDOW_CONFIGS = CONTROLLABLE_WINDOW_CONFIGS;
+ private static final boolean DEBUG_ENABLE_REVEAL_ANIMATION =
+ SystemProperties.getBoolean("persist.debug.enable_reveal_animation", false);
+
// The set of modes that are currently supports
// TODO: Remove once the task organizer can support all modes
@VisibleForTesting
@@ -183,7 +187,7 @@
SurfaceControl windowAnimationLeash = null;
Rect mainFrame = null;
final boolean playShiftUpAnimation = !task.inMultiWindowMode();
- if (prepareAnimation && playShiftUpAnimation) {
+ if (prepareAnimation && playShiftUpAnimation && DEBUG_ENABLE_REVEAL_ANIMATION) {
final ActivityRecord topActivity = task.topActivityWithStartingWindow();
if (topActivity != null) {
final WindowState mainWindow =
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index b40223f..9e6f56d 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -2682,6 +2682,13 @@
}
}
+ /**
+ * Move the touch gesture from the currently touched window on this display to this window.
+ */
+ public boolean transferTouch() {
+ return mWmService.mInputManager.transferTouch(mInputChannelToken);
+ }
+
void disposeInputChannel() {
if (mDeadWindowEventReceiver != null) {
mDeadWindowEventReceiver.dispose();
@@ -4842,7 +4849,10 @@
// directly above it. The exception is if we are in split screen
// in which case we process the IME at the DisplayContent level to
// ensure it is above the docked divider.
- if (isImeLayeringTarget() && !inSplitScreenWindowingMode()) {
+ // (i.e. Like {@link DisplayContent.ImeContainer#skipImeWindowsDuringTraversal}, the IME
+ // window will be ignored to traverse when the IME target is still in split-screen mode).
+ if (isImeLayeringTarget()
+ && !getDisplayContent().getDefaultTaskDisplayArea().isSplitScreenModeActivated()) {
if (getDisplayContent().forAllImeWindows(callback, traverseTopToBottom)) {
return true;
}
diff --git a/services/core/jni/com_android_server_SystemServer.cpp b/services/core/jni/com_android_server_SystemServer.cpp
index 6721ecf..bfd8005 100644
--- a/services/core/jni/com_android_server_SystemServer.cpp
+++ b/services/core/jni/com_android_server_SystemServer.cpp
@@ -66,7 +66,7 @@
android::sp<IStats> statsHal = new StatsHal();
const android::status_t err = statsHal->registerAsService();
- LOG_ALWAYS_FATAL_IF(err != android::OK, "Cannot register HIDL %s: %d", IStats::descriptor, err);
+ ALOGW_IF(err != android::OK, "Cannot register HIDL %s: %d", IStats::descriptor, err);
}
} // namespace
diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp
index cca62b9..eb9c8db 100644
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -1834,8 +1834,19 @@
}
}
-static void nativeSetPointerSpeed(JNIEnv* /* env */,
- jclass /* clazz */, jlong ptr, jint speed) {
+static jboolean nativeTransferTouch(JNIEnv* env, jclass /* clazz */, jlong ptr,
+ jobject destChannelTokenObj) {
+ sp<IBinder> destChannelToken = ibinderForJavaObject(env, destChannelTokenObj);
+
+ NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
+ if (im->getInputManager()->getDispatcher()->transferTouch(destChannelToken)) {
+ return JNI_TRUE;
+ } else {
+ return JNI_FALSE;
+ }
+}
+
+static void nativeSetPointerSpeed(JNIEnv* /* env */, jclass /* clazz */, jlong ptr, jint speed) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
im->setPointerSpeed(speed);
@@ -2308,6 +2319,7 @@
{"nativeSetSystemUiLightsOut", "(JZ)V", (void*)nativeSetSystemUiLightsOut},
{"nativeTransferTouchFocus", "(JLandroid/os/IBinder;Landroid/os/IBinder;Z)Z",
(void*)nativeTransferTouchFocus},
+ {"nativeTransferTouch", "(JLandroid/os/IBinder;)Z", (void*)nativeTransferTouch},
{"nativeSetPointerSpeed", "(JI)V", (void*)nativeSetPointerSpeed},
{"nativeSetShowTouches", "(JZ)V", (void*)nativeSetShowTouches},
{"nativeSetInteractive", "(JZ)V", (void*)nativeSetInteractive},
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index ef7360d..23a67b7 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -28,6 +28,7 @@
import static android.app.admin.DevicePolicyManager.ACTION_PROVISION_MANAGED_DEVICE;
import static android.app.admin.DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE;
import static android.app.admin.DevicePolicyManager.ACTION_PROVISION_MANAGED_USER;
+import static android.app.admin.DevicePolicyManager.ACTION_SYSTEM_UPDATE_POLICY_CHANGED;
import static android.app.admin.DevicePolicyManager.CODE_ACCOUNTS_NOT_EMPTY;
import static android.app.admin.DevicePolicyManager.CODE_CANNOT_ADD_MANAGED_PROFILE;
import static android.app.admin.DevicePolicyManager.CODE_DEVICE_ADMIN_NOT_SUPPORTED;
@@ -883,12 +884,6 @@
synchronized (getLockObject()) {
// Check whether the user is affiliated, *before* removing its data.
boolean isRemovedUserAffiliated = isUserAffiliatedWithDeviceLocked(userHandle);
- if (isProfileOwnerOfOrganizationOwnedDevice(userHandle)) {
- // Disable network and security logging
- mInjector.securityLogSetLoggingEnabledProperty(false);
- mSecurityLogMonitor.stop();
- setNetworkLoggingActiveInternal(false);
- }
removeUserData(userHandle);
if (!isRemovedUserAffiliated) {
// We discard the logs when unaffiliated users are deleted (so that the
@@ -1779,6 +1774,7 @@
}
void removeUserData(int userHandle) {
+ final boolean isOrgOwned;
synchronized (getLockObject()) {
if (userHandle == UserHandle.USER_SYSTEM) {
Slogf.w(LOG_TAG, "Tried to remove device policy file for user 0! Ignoring.");
@@ -1786,6 +1782,9 @@
}
updatePasswordQualityCacheForUserGroup(userHandle);
mPolicyCache.onUserRemoved(userHandle);
+
+ isOrgOwned = mOwners.isProfileOwnerOfOrganizationOwnedDevice(userHandle);
+
mOwners.removeProfileOwner(userHandle);
mOwners.writeProfileOwner(userHandle);
@@ -1799,6 +1798,14 @@
policyFile.delete();
Slogf.i(LOG_TAG, "Removed device policy file " + policyFile.getAbsolutePath());
}
+ if (isOrgOwned) {
+ final UserInfo primaryUser = mUserManager.getPrimaryUser();
+ if (primaryUser != null) {
+ clearOrgOwnedProfileOwnerDeviceWidePolicies(primaryUser.id);
+ } else {
+ Slogf.wtf(LOG_TAG, "Was unable to get primary user.");
+ }
+ }
}
/**
@@ -3537,6 +3544,7 @@
"Caller must be shell or hold MANAGE_PROFILE_AND_DEVICE_OWNERS to call "
+ "forceRemoveActiveAdmin");
mInjector.binderWithCleanCallingIdentity(() -> {
+ boolean isOrgOwnedProfile = false;
synchronized (getLockObject()) {
if (!isAdminTestOnlyLocked(adminReceiver, userHandle)) {
throw new SecurityException("Attempt to remove non-test admin "
@@ -3548,13 +3556,7 @@
clearDeviceOwnerLocked(getDeviceOwnerAdminLocked(), userHandle);
}
if (isProfileOwner(adminReceiver, userHandle)) {
- if (isProfileOwnerOfOrganizationOwnedDevice(userHandle)) {
- UserHandle parentUserHandle = UserHandle.of(getProfileParentId(userHandle));
- mUserManager.setUserRestriction(UserManager.DISALLOW_REMOVE_MANAGED_PROFILE,
- false, parentUserHandle);
- mUserManager.setUserRestriction(UserManager.DISALLOW_ADD_USER,
- false, parentUserHandle);
- }
+ isOrgOwnedProfile = isProfileOwnerOfOrganizationOwnedDevice(userHandle);
final ActiveAdmin admin = getActiveAdminUncheckedLocked(adminReceiver,
userHandle, /* parent */ false);
clearProfileOwnerLocked(admin, userHandle);
@@ -3562,11 +3564,26 @@
}
// Remove the admin skipping sending the broadcast.
removeAdminArtifacts(adminReceiver, userHandle);
+
+ // In case of PO on org owned device, clean device-wide policies and restrictions.
+ if (isOrgOwnedProfile) {
+ final UserHandle parentUser = UserHandle.of(getProfileParentId(userHandle));
+ clearOrgOwnedProfileOwnerUserRestrictions(parentUser);
+ clearOrgOwnedProfileOwnerDeviceWidePolicies(parentUser.getIdentifier());
+ }
+
Slogf.i(LOG_TAG, "Admin " + adminReceiver + " removed from user " + userHandle);
});
}
- private void clearDeviceOwnerUserRestrictionLocked(UserHandle userHandle) {
+ private void clearOrgOwnedProfileOwnerUserRestrictions(UserHandle parentUserHandle) {
+ mUserManager.setUserRestriction(
+ UserManager.DISALLOW_REMOVE_MANAGED_PROFILE, false, parentUserHandle);
+ mUserManager.setUserRestriction(
+ UserManager.DISALLOW_ADD_USER, false, parentUserHandle);
+ }
+
+ private void clearDeviceOwnerUserRestriction(UserHandle userHandle) {
// ManagedProvisioning/DPC sets DISALLOW_ADD_USER. Clear to recover to the original state
if (mUserManager.hasUserRestriction(UserManager.DISALLOW_ADD_USER, userHandle)) {
mUserManager.setUserRestriction(UserManager.DISALLOW_ADD_USER, false, userHandle);
@@ -6710,25 +6727,16 @@
// when wipeData is _not_ called on the parent instance, it implies relinquishing
// control over the device, wiping only the work profile. So the user restriction
// on profile removal needs to be removed first.
-
- mInjector.binderWithCleanCallingIdentity(() -> {
- // Clear restriction as user.
- mUserManager.setUserRestriction(
- UserManager.DISALLOW_REMOVE_MANAGED_PROFILE, false,
- UserHandle.SYSTEM);
- mUserManager.setUserRestriction(
- UserManager.DISALLOW_ADD_USER, false, UserHandle.SYSTEM);
-
- // Device-wide policies set by the profile owner need to be cleaned up here.
- mLockPatternUtils.setDeviceOwnerInfo(null);
- });
+ final UserHandle parentUser = UserHandle.of(getProfileParentId(userId));
+ mInjector.binderWithCleanCallingIdentity(
+ () -> clearOrgOwnedProfileOwnerUserRestrictions(parentUser));
}
}
DevicePolicyEventLogger event = DevicePolicyEventLogger
.createEvent(DevicePolicyEnums.WIPE_DATA_WITH_REASON)
.setInt(flags)
- .setStrings(calledOnParentInstance ? CALLED_FROM_PARENT : NOT_CALLED_FROM_PARENT)
- ;
+ .setStrings(calledOnParentInstance ? CALLED_FROM_PARENT : NOT_CALLED_FROM_PARENT);
+
final String adminName;
final ComponentName adminComp;
if (admin != null) {
@@ -6755,6 +6763,55 @@
wipeDataNoLock(adminComp, flags, internalReason, wipeReasonForUser, userId);
}
+ /**
+ * Clears device wide policies enforced by COPE PO when relinquishing the device. This method
+ * should be invoked once the admin is gone, so that all methods that rely on calculating
+ * aggregate policy (e.g. strong auth timeout) from all admins aren't affected by its policies.
+ * This method assumes that there is no other device or profile owners left on the device.
+ * Shouldn't be called from binder thread without clearing identity.
+ */
+ private void clearOrgOwnedProfileOwnerDeviceWidePolicies(@UserIdInt int parentId) {
+ Slogf.i(LOG_TAG, "Cleaning up device-wide policies left over from org-owned profile...");
+ // Lockscreen message
+ mLockPatternUtils.setDeviceOwnerInfo(null);
+ // Wifi config lockdown
+ mInjector.settingsGlobalPutInt(Global.WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN, 0);
+ // Security logging
+ if (mInjector.securityLogGetLoggingEnabledProperty()) {
+ mSecurityLogMonitor.stop();
+ mInjector.securityLogSetLoggingEnabledProperty(false);
+ }
+ // Network logging
+ setNetworkLoggingActiveInternal(false);
+
+ // System update policy.
+ final boolean hasSystemUpdatePolicy;
+ synchronized (getLockObject()) {
+ hasSystemUpdatePolicy = mOwners.getSystemUpdatePolicy() != null;
+ if (hasSystemUpdatePolicy) {
+ mOwners.clearSystemUpdatePolicy();
+ mOwners.writeDeviceOwner();
+ }
+ }
+ if (hasSystemUpdatePolicy) {
+ mContext.sendBroadcastAsUser(
+ new Intent(ACTION_SYSTEM_UPDATE_POLICY_CHANGED), UserHandle.SYSTEM);
+ }
+
+ // Unsuspend personal apps if needed.
+ suspendPersonalAppsInternal(parentId, false);
+
+ // Notify FRP agent, LSS and WindowManager to ensure they don't hold on to stale policies.
+ final int frpAgentUid = getFrpManagementAgentUid();
+ if (frpAgentUid > 0) {
+ notifyResetProtectionPolicyChanged(frpAgentUid);
+ }
+ mLockSettingsInternal.refreshStrongAuthTimeout(parentId);
+ updateScreenCaptureDisabled(parentId, getScreenCaptureDisabled(null, parentId, false));
+
+ Slogf.i(LOG_TAG, "Cleaning up device-wide policies done.");
+ }
+
private void wipeDataNoLock(ComponentName admin, int flags, String internalReason,
String wipeReasonForUser, int userId) {
wtfIfInLock();
@@ -6822,13 +6879,8 @@
saveSettingsLocked(caller.getUserId());
}
- final Intent intent = new Intent(
- DevicePolicyManager.ACTION_RESET_PROTECTION_POLICY_CHANGED).addFlags(
- Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND | Intent.FLAG_RECEIVER_FOREGROUND);
-
- mInjector.binderWithCleanCallingIdentity(() -> mContext.sendBroadcastAsUser(intent,
- UserHandle.getUserHandleForUid(frpManagementAgentUid),
- android.Manifest.permission.MANAGE_FACTORY_RESET_PROTECTION));
+ mInjector.binderWithCleanCallingIdentity(
+ () -> notifyResetProtectionPolicyChanged(frpManagementAgentUid));
DevicePolicyEventLogger
.createEvent(DevicePolicyEnums.SET_FACTORY_RESET_PROTECTION)
@@ -6836,6 +6888,16 @@
.write();
}
+ // Shouldn't be called from binder thread without clearing identity.
+ private void notifyResetProtectionPolicyChanged(int frpManagementAgentUid) {
+ final Intent intent = new Intent(
+ DevicePolicyManager.ACTION_RESET_PROTECTION_POLICY_CHANGED).addFlags(
+ Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND | Intent.FLAG_RECEIVER_FOREGROUND);
+ mContext.sendBroadcastAsUser(intent,
+ UserHandle.getUserHandleForUid(frpManagementAgentUid),
+ permission.MANAGE_FACTORY_RESET_PROTECTION);
+ }
+
@Override
public FactoryResetProtectionPolicy getFactoryResetProtectionPolicy(
@Nullable ComponentName who) {
@@ -8506,7 +8568,7 @@
mOwners.writeDeviceOwner();
updateDeviceOwnerLocked();
- clearDeviceOwnerUserRestrictionLocked(UserHandle.of(userId));
+ clearDeviceOwnerUserRestriction(UserHandle.of(userId));
mInjector.securityLogSetLoggingEnabledProperty(false);
mSecurityLogMonitor.stop();
setNetworkLoggingActiveInternal(false);
@@ -12936,8 +12998,7 @@
mOwners.writeDeviceOwner();
}
mInjector.binderWithCleanCallingIdentity(() -> mContext.sendBroadcastAsUser(
- new Intent(DevicePolicyManager.ACTION_SYSTEM_UPDATE_POLICY_CHANGED),
- UserHandle.SYSTEM));
+ new Intent(ACTION_SYSTEM_UPDATE_POLICY_CHANGED), UserHandle.SYSTEM));
DevicePolicyEventLogger
.createEvent(DevicePolicyEnums.SET_SYSTEM_UPDATE_POLICY)
.setAdmin(who)
@@ -14513,14 +14574,10 @@
* apps.
*/
@Override
- public void forceUpdateUserSetupComplete() {
- final CallerIdentity caller = getCallerIdentity();
+ public void forceUpdateUserSetupComplete(@UserIdInt int userId) {
Preconditions.checkCallAuthorization(
hasCallingOrSelfPermission(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS));
- Preconditions.checkCallAuthorization(caller.getUserHandle().isSystem(),
- "Caller has to be in user 0");
- final int userId = UserHandle.USER_SYSTEM;
boolean isUserCompleted = mInjector.settingsSecureGetIntForUser(
Settings.Secure.USER_SETUP_COMPLETE, 0, userId) != 0;
DevicePolicyData policy = getUserData(userId);
diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp
index 51b270c..24699d9 100644
--- a/services/incremental/IncrementalService.cpp
+++ b/services/incremental/IncrementalService.cpp
@@ -983,7 +983,8 @@
bool enableReadTimeouts = ifs.readTimeoutsRequested();
std::lock_guard l(mMountOperationLock);
- auto status = mVold->setIncFsMountOptions(control, enableReadLogs, enableReadTimeouts);
+ auto status = mVold->setIncFsMountOptions(control, enableReadLogs, enableReadTimeouts,
+ ifs.metricsKey);
if (status.isOk()) {
// Store states.
ifs.setReadLogsEnabled(enableReadLogs);
diff --git a/services/incremental/ServiceWrappers.cpp b/services/incremental/ServiceWrappers.cpp
index 68a28b2..ce3d514 100644
--- a/services/incremental/ServiceWrappers.cpp
+++ b/services/incremental/ServiceWrappers.cpp
@@ -56,8 +56,10 @@
}
binder::Status setIncFsMountOptions(
const ::android::os::incremental::IncrementalFileSystemControlParcel& control,
- bool enableReadLogs, bool enableReadTimeouts) const final {
- return mInterface->setIncFsMountOptions(control, enableReadLogs, enableReadTimeouts);
+ bool enableReadLogs, bool enableReadTimeouts,
+ const std::string& sysfsName) const final {
+ return mInterface->setIncFsMountOptions(control, enableReadLogs, enableReadTimeouts,
+ sysfsName);
}
private:
diff --git a/services/incremental/ServiceWrappers.h b/services/incremental/ServiceWrappers.h
index c0ef7ba..39e2ee3 100644
--- a/services/incremental/ServiceWrappers.h
+++ b/services/incremental/ServiceWrappers.h
@@ -58,7 +58,7 @@
const std::string& targetDir) const = 0;
virtual binder::Status setIncFsMountOptions(
const os::incremental::IncrementalFileSystemControlParcel& control, bool enableReadLogs,
- bool enableReadTimeouts) const = 0;
+ bool enableReadTimeouts, const std::string& sysfsName) const = 0;
};
class DataLoaderManagerWrapper {
diff --git a/services/incremental/test/IncrementalServiceTest.cpp b/services/incremental/test/IncrementalServiceTest.cpp
index 6c9310b..fae654e 100644
--- a/services/incremental/test/IncrementalServiceTest.cpp
+++ b/services/incremental/test/IncrementalServiceTest.cpp
@@ -56,10 +56,10 @@
MOCK_CONST_METHOD1(unmountIncFs, binder::Status(const std::string& dir));
MOCK_CONST_METHOD2(bindMount,
binder::Status(const std::string& sourceDir, const std::string& argetDir));
- MOCK_CONST_METHOD3(
+ MOCK_CONST_METHOD4(
setIncFsMountOptions,
binder::Status(const ::android::os::incremental::IncrementalFileSystemControlParcel&,
- bool, bool));
+ bool, bool, const std::string&));
void mountIncFsFails() {
ON_CALL(*this, mountIncFs(_, _, _, _, _))
@@ -83,12 +83,12 @@
ON_CALL(*this, bindMount(_, _)).WillByDefault(Return(binder::Status::ok()));
}
void setIncFsMountOptionsFails() const {
- ON_CALL(*this, setIncFsMountOptions(_, _, _))
+ ON_CALL(*this, setIncFsMountOptions(_, _, _, _))
.WillByDefault(Return(
binder::Status::fromExceptionCode(1, String8("failed to set options"))));
}
void setIncFsMountOptionsSuccess() {
- ON_CALL(*this, setIncFsMountOptions(_, _, _))
+ ON_CALL(*this, setIncFsMountOptions(_, _, _, _))
.WillByDefault(Invoke(this, &MockVoldService::setIncFsMountOptionsOk));
}
binder::Status getInvalidControlParcel(const std::string& imagePath,
@@ -108,7 +108,7 @@
}
binder::Status setIncFsMountOptionsOk(
const ::android::os::incremental::IncrementalFileSystemControlParcel& control,
- bool enableReadLogs, bool enableReadTimeouts) {
+ bool enableReadLogs, bool enableReadTimeouts, const std::string& sysfsName) {
mReadLogsEnabled = enableReadLogs;
mReadTimeoutsEnabled = enableReadTimeouts;
return binder::Status::ok();
@@ -1451,9 +1451,9 @@
EXPECT_CALL(*mDataLoaderManager, unbindFromDataLoader(_));
EXPECT_CALL(*mVold, unmountIncFs(_)).Times(2);
// on startLoading
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _)).Times(1);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _, _)).Times(1);
// We are calling setIncFsMountOptions(true).
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _)).Times(1);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _, _)).Times(1);
// After setIncFsMountOptions succeeded expecting to start watching.
EXPECT_CALL(*mAppOpsManager, startWatchingMode(_, _, _)).Times(1);
// Not expecting callback removal.
@@ -1475,8 +1475,8 @@
EXPECT_CALL(*mDataLoaderManager, unbindFromDataLoader(_));
EXPECT_CALL(*mVold, unmountIncFs(_)).Times(2);
// Enabling and then disabling readlogs.
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _)).Times(1);
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _)).Times(2);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _, _)).Times(1);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _, _)).Times(2);
// After setIncFsMountOptions succeeded expecting to start watching.
EXPECT_CALL(*mAppOpsManager, startWatchingMode(_, _, _)).Times(1);
// Not expecting callback removal.
@@ -1503,8 +1503,8 @@
EXPECT_CALL(*mDataLoaderManager, unbindFromDataLoader(_));
EXPECT_CALL(*mVold, unmountIncFs(_)).Times(2);
// Enabling and then disabling readlogs.
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _)).Times(2);
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _)).Times(2);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _, _)).Times(2);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _, _)).Times(2);
// After setIncFsMountOptions succeeded expecting to start watching.
EXPECT_CALL(*mAppOpsManager, startWatchingMode(_, _, _)).Times(1);
// Not expecting callback removal.
@@ -1544,8 +1544,8 @@
EXPECT_CALL(*mDataLoaderManager, unbindFromDataLoader(_));
EXPECT_CALL(*mVold, unmountIncFs(_)).Times(2);
// Enabling and then disabling readlogs.
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _)).Times(3);
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _)).Times(1);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _, _)).Times(3);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _, _)).Times(1);
// After setIncFsMountOptions succeeded expecting to start watching.
EXPECT_CALL(*mAppOpsManager, startWatchingMode(_, _, _)).Times(1);
// Not expecting callback removal.
@@ -1585,8 +1585,8 @@
EXPECT_CALL(*mDataLoaderManager, unbindFromDataLoader(_)).Times(2);
EXPECT_CALL(*mVold, unmountIncFs(_)).Times(2);
// Enabling and then disabling readlogs.
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _)).Times(5);
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _)).Times(3);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _, _)).Times(5);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _, _)).Times(3);
// After setIncFsMountOptions succeeded expecting to start watching.
EXPECT_CALL(*mAppOpsManager, startWatchingMode(_, _, _)).Times(1);
// Not expecting callback removal.
@@ -1660,9 +1660,9 @@
EXPECT_CALL(*mDataLoaderManager, unbindFromDataLoader(_));
EXPECT_CALL(*mVold, unmountIncFs(_)).Times(2);
// We are calling setIncFsMountOptions(true).
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _)).Times(1);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _, _)).Times(1);
// setIncFsMountOptions(false) is called on the callback.
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _)).Times(2);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _, _)).Times(2);
// After setIncFsMountOptions succeeded expecting to start watching.
EXPECT_CALL(*mAppOpsManager, startWatchingMode(_, _, _)).Times(1);
// After callback is called, disable read logs and remove callback.
@@ -1685,8 +1685,8 @@
EXPECT_CALL(*mDataLoaderManager, unbindFromDataLoader(_));
EXPECT_CALL(*mVold, unmountIncFs(_)).Times(2);
// checkPermission fails, no calls to set opitions, start or stop WatchingMode.
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _)).Times(0);
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _)).Times(1);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _, _)).Times(0);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _, _)).Times(1);
EXPECT_CALL(*mAppOpsManager, startWatchingMode(_, _, _)).Times(0);
EXPECT_CALL(*mAppOpsManager, stopWatchingMode(_)).Times(0);
TemporaryDir tempDir;
@@ -1705,8 +1705,8 @@
EXPECT_CALL(*mDataLoaderManager, unbindFromDataLoader(_));
EXPECT_CALL(*mVold, unmountIncFs(_)).Times(2);
// checkPermission fails, no calls to set opitions, start or stop WatchingMode.
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _)).Times(0);
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _)).Times(1);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _, _)).Times(0);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _, _)).Times(1);
EXPECT_CALL(*mAppOpsManager, startWatchingMode(_, _, _)).Times(0);
EXPECT_CALL(*mAppOpsManager, stopWatchingMode(_)).Times(0);
TemporaryDir tempDir;
@@ -1726,8 +1726,8 @@
EXPECT_CALL(*mDataLoaderManager, unbindFromDataLoader(_));
EXPECT_CALL(*mVold, unmountIncFs(_)).Times(2);
// We are calling setIncFsMountOptions.
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _)).Times(1);
- EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _)).Times(1);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, true, _, _)).Times(1);
+ EXPECT_CALL(*mVold, setIncFsMountOptions(_, false, _, _)).Times(1);
// setIncFsMountOptions fails, no calls to start or stop WatchingMode.
EXPECT_CALL(*mAppOpsManager, startWatchingMode(_, _, _)).Times(0);
EXPECT_CALL(*mAppOpsManager, stopWatchingMode(_)).Times(0);
diff --git a/services/net/TEST_MAPPING b/services/net/TEST_MAPPING
index 7025dd1..7eca1f9 100644
--- a/services/net/TEST_MAPPING
+++ b/services/net/TEST_MAPPING
@@ -2,6 +2,9 @@
"imports": [
{
"path": "frameworks/base/core/java/android/net"
+ },
+ {
+ "path": "packages/modules/Wifi/framework"
}
]
-}
\ No newline at end of file
+}
diff --git a/services/tests/servicestests/src/com/android/server/appsearch/external/localstorage/converter/SnippetTest.java b/services/tests/servicestests/src/com/android/server/appsearch/external/localstorage/converter/SnippetTest.java
index 8fe1139..d3feb12 100644
--- a/services/tests/servicestests/src/com/android/server/appsearch/external/localstorage/converter/SnippetTest.java
+++ b/services/tests/servicestests/src/com/android/server/appsearch/external/localstorage/converter/SnippetTest.java
@@ -75,10 +75,14 @@
.setPropertyName(propertyKeyString)
.addSnippetMatches(
SnippetMatchProto.newBuilder()
- .setExactMatchPosition(29)
- .setExactMatchBytes(3)
- .setWindowPosition(26)
- .setWindowBytes(6)))
+ .setExactMatchBytePosition(29)
+ .setExactMatchByteLength(3)
+ .setExactMatchUtf16Position(29)
+ .setExactMatchUtf16Length(3)
+ .setWindowBytePosition(26)
+ .setWindowByteLength(6)
+ .setWindowUtf16Position(26)
+ .setWindowUtf16Length(6)))
.build();
SearchResultProto searchResultProto =
SearchResultProto.newBuilder()
@@ -168,19 +172,27 @@
.setPropertyName("senderName")
.addSnippetMatches(
SnippetMatchProto.newBuilder()
- .setExactMatchPosition(0)
- .setExactMatchBytes(4)
- .setWindowPosition(0)
- .setWindowBytes(9)))
+ .setExactMatchBytePosition(0)
+ .setExactMatchByteLength(4)
+ .setExactMatchUtf16Position(0)
+ .setExactMatchUtf16Length(4)
+ .setWindowBytePosition(0)
+ .setWindowByteLength(9)
+ .setWindowUtf16Position(0)
+ .setWindowUtf16Length(9)))
.addEntries(
SnippetProto.EntryProto.newBuilder()
.setPropertyName("senderEmail")
.addSnippetMatches(
SnippetMatchProto.newBuilder()
- .setExactMatchPosition(0)
- .setExactMatchBytes(20)
- .setWindowPosition(0)
- .setWindowBytes(20)))
+ .setExactMatchBytePosition(0)
+ .setExactMatchByteLength(20)
+ .setExactMatchUtf16Position(0)
+ .setExactMatchUtf16Length(20)
+ .setWindowBytePosition(0)
+ .setWindowByteLength(20)
+ .setWindowUtf16Position(0)
+ .setWindowUtf16Length(20)))
.build();
SearchResultProto searchResultProto =
SearchResultProto.newBuilder()
@@ -251,19 +263,27 @@
.setPropertyName("sender.name")
.addSnippetMatches(
SnippetMatchProto.newBuilder()
- .setExactMatchPosition(0)
- .setExactMatchBytes(4)
- .setWindowPosition(0)
- .setWindowBytes(9)))
+ .setExactMatchBytePosition(0)
+ .setExactMatchByteLength(4)
+ .setExactMatchUtf16Position(0)
+ .setExactMatchUtf16Length(4)
+ .setWindowBytePosition(0)
+ .setWindowByteLength(9)
+ .setWindowUtf16Position(0)
+ .setWindowUtf16Length(9)))
.addEntries(
SnippetProto.EntryProto.newBuilder()
.setPropertyName("sender.email[1]")
.addSnippetMatches(
SnippetMatchProto.newBuilder()
- .setExactMatchPosition(0)
- .setExactMatchBytes(21)
- .setWindowPosition(0)
- .setWindowBytes(21)))
+ .setExactMatchBytePosition(0)
+ .setExactMatchByteLength(21)
+ .setExactMatchUtf16Position(0)
+ .setExactMatchUtf16Length(21)
+ .setWindowBytePosition(0)
+ .setWindowByteLength(21)
+ .setWindowUtf16Position(0)
+ .setWindowUtf16Length(21)))
.build();
SearchResultProto searchResultProto =
SearchResultProto.newBuilder()
diff --git a/services/tests/servicestests/src/com/android/server/appsearch/stats/PlatformLoggerTest.java b/services/tests/servicestests/src/com/android/server/appsearch/stats/PlatformLoggerTest.java
index 5de8a7a..217430c 100644
--- a/services/tests/servicestests/src/com/android/server/appsearch/stats/PlatformLoggerTest.java
+++ b/services/tests/servicestests/src/com/android/server/appsearch/stats/PlatformLoggerTest.java
@@ -89,7 +89,7 @@
CallStats.CALL_TYPE_INITIALIZE).mSamplingRatio).isEqualTo(
TEST_DEFAULT_SAMPLING_RATIO);
assertThat(logger.createExtraStatsLocked(TEST_PACKAGE_NAME,
- CallStats.CALL_TYPE_QUERY).mSamplingRatio).isEqualTo(
+ CallStats.CALL_TYPE_SEARCH).mSamplingRatio).isEqualTo(
TEST_DEFAULT_SAMPLING_RATIO);
assertThat(logger.createExtraStatsLocked(TEST_PACKAGE_NAME,
CallStats.CALL_TYPE_FLUSH).mSamplingRatio).isEqualTo(
@@ -103,7 +103,7 @@
int querySamplingRatio = 2;
final SparseIntArray samplingRatios = new SparseIntArray();
samplingRatios.put(CallStats.CALL_TYPE_PUT_DOCUMENT, putDocumentSamplingRatio);
- samplingRatios.put(CallStats.CALL_TYPE_QUERY, querySamplingRatio);
+ samplingRatios.put(CallStats.CALL_TYPE_SEARCH, querySamplingRatio);
PlatformLogger logger = new PlatformLogger(
ApplicationProvider.getApplicationContext(),
UserHandle.USER_NULL,
@@ -127,7 +127,7 @@
CallStats.CALL_TYPE_PUT_DOCUMENT).mSamplingRatio).isEqualTo(
putDocumentSamplingRatio);
assertThat(logger.createExtraStatsLocked(TEST_PACKAGE_NAME,
- CallStats.CALL_TYPE_QUERY).mSamplingRatio).isEqualTo(
+ CallStats.CALL_TYPE_SEARCH).mSamplingRatio).isEqualTo(
querySamplingRatio);
}
diff --git a/services/tests/servicestests/src/com/android/server/biometrics/sensors/face/hidl/Face10Test.java b/services/tests/servicestests/src/com/android/server/biometrics/sensors/face/hidl/Face10Test.java
index 0b59be6..39c51d5 100644
--- a/services/tests/servicestests/src/com/android/server/biometrics/sensors/face/hidl/Face10Test.java
+++ b/services/tests/servicestests/src/com/android/server/biometrics/sensors/face/hidl/Face10Test.java
@@ -18,6 +18,10 @@
import static junit.framework.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -26,6 +30,7 @@
import android.hardware.biometrics.SensorProperties;
import android.hardware.face.FaceSensorProperties;
import android.hardware.face.FaceSensorPropertiesInternal;
+import android.hardware.face.IFaceServiceReceiver;
import android.os.Binder;
import android.os.IBinder;
import android.os.UserManager;
@@ -42,8 +47,12 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.time.Clock;
+import java.time.Instant;
+import java.time.ZoneId;
import java.util.ArrayList;
import java.util.List;
+import java.util.stream.IntStream;
@Presubmit
@SmallTest
@@ -51,6 +60,7 @@
private static final String TAG = "Face10Test";
private static final int SENSOR_ID = 1;
+ private static final int USER_ID = 20;
@Mock
private Context mContext;
@@ -86,10 +96,18 @@
FaceSensorProperties.TYPE_UNKNOWN, supportsFaceDetection, supportsSelfIllumination,
resetLockoutRequiresChallenge);
+ Face10.sSystemClock = Clock.fixed(Instant.ofEpochMilli(100), ZoneId.of("PST"));
mFace10 = new Face10(mContext, sensorProps, mLockoutResetDispatcher, mScheduler);
mBinder = new Binder();
}
+ private void tick(long seconds) {
+ waitForIdle();
+ Face10.sSystemClock = Clock.fixed(Instant.ofEpochSecond(
+ Face10.sSystemClock.instant().getEpochSecond() + seconds),
+ ZoneId.of("PST"));
+ }
+
@Test
public void getAuthenticatorId_doesNotCrashWhenIdNotFound() {
assertEquals(0, mFace10.getAuthenticatorId(0 /* sensorId */, 111 /* userId */));
@@ -104,6 +122,59 @@
}
@Test
+ public void scheduleGenerateChallenge_cachesResult() {
+ final IFaceServiceReceiver[] mocks = IntStream.range(0, 3)
+ .mapToObj(i -> mock(IFaceServiceReceiver.class))
+ .toArray(IFaceServiceReceiver[]::new);
+ for (IFaceServiceReceiver mock : mocks) {
+ mFace10.scheduleGenerateChallenge(SENSOR_ID, USER_ID, mBinder, mock, TAG);
+ tick(10);
+ }
+ tick(120);
+ mFace10.scheduleGenerateChallenge(
+ SENSOR_ID, USER_ID, mBinder, mock(IFaceServiceReceiver.class), TAG);
+ waitForIdle();
+
+ verify(mScheduler, times(2))
+ .scheduleClientMonitor(isA(FaceGenerateChallengeClient.class), any());
+ }
+
+ @Test
+ public void scheduleRevokeChallenge_waitsUntilEmpty() {
+ final long challenge = 22;
+ final IFaceServiceReceiver[] mocks = IntStream.range(0, 3)
+ .mapToObj(i -> mock(IFaceServiceReceiver.class))
+ .toArray(IFaceServiceReceiver[]::new);
+ for (IFaceServiceReceiver mock : mocks) {
+ mFace10.scheduleGenerateChallenge(SENSOR_ID, USER_ID, mBinder, mock, TAG);
+ tick(10);
+ }
+ for (IFaceServiceReceiver mock : mocks) {
+ mFace10.scheduleRevokeChallenge(SENSOR_ID, USER_ID, mBinder, TAG, challenge);
+ tick(10);
+ }
+ waitForIdle();
+
+ verify(mScheduler).scheduleClientMonitor(isA(FaceRevokeChallengeClient.class), any());
+ }
+
+ @Test
+ public void scheduleRevokeChallenge_doesNotWaitForever() {
+ mFace10.scheduleGenerateChallenge(
+ SENSOR_ID, USER_ID, mBinder, mock(IFaceServiceReceiver.class), TAG);
+ mFace10.scheduleGenerateChallenge(
+ SENSOR_ID, USER_ID, mBinder, mock(IFaceServiceReceiver.class), TAG);
+ tick(10000);
+ mFace10.scheduleGenerateChallenge(
+ SENSOR_ID, USER_ID, mBinder, mock(IFaceServiceReceiver.class), TAG);
+ mFace10.scheduleRevokeChallenge(
+ SENSOR_ID, USER_ID, mBinder, TAG, 8 /* challenge */);
+ waitForIdle();
+
+ verify(mScheduler).scheduleClientMonitor(isA(FaceRevokeChallengeClient.class), any());
+ }
+
+ @Test
public void halServiceDied_resetsScheduler() {
// It's difficult to test the linkToDeath --> serviceDied path, so let's just invoke
// serviceDied directly.
diff --git a/services/tests/servicestests/src/com/android/server/biometrics/sensors/face/hidl/FaceGenerateChallengeClientTest.java b/services/tests/servicestests/src/com/android/server/biometrics/sensors/face/hidl/FaceGenerateChallengeClientTest.java
new file mode 100644
index 0000000..55dc035
--- /dev/null
+++ b/services/tests/servicestests/src/com/android/server/biometrics/sensors/face/hidl/FaceGenerateChallengeClientTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2021 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.sensors.face.hidl;
+
+import static junit.framework.Assert.assertEquals;
+
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.hardware.biometrics.face.V1_0.IBiometricsFace;
+import android.hardware.biometrics.face.V1_0.OptionalUint64;
+import android.hardware.face.IFaceServiceReceiver;
+import android.os.Binder;
+import android.platform.test.annotations.Presubmit;
+
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.filters.SmallTest;
+
+import com.android.server.biometrics.sensors.BaseClientMonitor;
+import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+@Presubmit
+@SmallTest
+public class FaceGenerateChallengeClientTest {
+
+ private static final String TAG = "FaceGenerateChallengeClientTest";
+ private static final int USER_ID = 2;
+ private static final int SENSOR_ID = 4;
+ private static final long START_TIME = 5000;
+ private static final long CHALLENGE = 200;
+
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+
+ @Mock
+ private IBiometricsFace mIBiometricsFace;
+ @Mock
+ private IFaceServiceReceiver mClientReceiver;
+ @Mock
+ private IFaceServiceReceiver mOtherReceiver;
+ @Mock
+ private BaseClientMonitor.Callback mMonitorCallback;
+
+ private FaceGenerateChallengeClient mClient;
+
+ @Before
+ public void setup() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ final OptionalUint64 challenge = new OptionalUint64();
+ challenge.value = CHALLENGE;
+ when(mIBiometricsFace.generateChallenge(anyInt())).thenReturn(challenge);
+
+ mClient = new FaceGenerateChallengeClient(mContext, () -> mIBiometricsFace, new Binder(),
+ new ClientMonitorCallbackConverter(mClientReceiver), USER_ID,
+ TAG, SENSOR_ID, START_TIME);
+ }
+
+ @Test
+ public void getCreatedAt() {
+ assertEquals(START_TIME, mClient.getCreatedAt());
+ }
+
+ @Test
+ public void reuseResult_whenNotReady() throws Exception {
+ mClient.reuseResult(mOtherReceiver);
+ verify(mOtherReceiver, never()).onChallengeGenerated(anyInt(), anyInt(), anyInt());
+ }
+
+ @Test
+ public void reuseResult_whenReady() throws Exception {
+ mClient.start(mMonitorCallback);
+ mClient.reuseResult(mOtherReceiver);
+ verify(mOtherReceiver).onChallengeGenerated(eq(SENSOR_ID), eq(USER_ID), eq(CHALLENGE));
+ }
+
+ @Test
+ public void reuseResult_whenReallyReady() throws Exception {
+ mClient.reuseResult(mOtherReceiver);
+ mClient.start(mMonitorCallback);
+ verify(mOtherReceiver).onChallengeGenerated(eq(SENSOR_ID), eq(USER_ID), eq(CHALLENGE));
+ }
+}
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 c54dffc..2270943 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
@@ -41,6 +41,7 @@
import static com.android.server.devicepolicy.DevicePolicyManagerService.ACTION_PROFILE_OFF_DEADLINE;
import static com.android.server.devicepolicy.DevicePolicyManagerService.ACTION_TURN_PROFILE_ON_NOTIFICATION;
import static com.android.server.devicepolicy.DpmMockContext.CALLER_USER_HANDLE;
+import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;
import static com.android.server.testutils.TestUtils.assertExpectException;
import static com.google.common.truth.Truth.assertThat;
@@ -82,6 +83,7 @@
import android.app.admin.DevicePolicyManagerInternal;
import android.app.admin.FactoryResetProtectionPolicy;
import android.app.admin.PasswordMetrics;
+import android.app.admin.SystemUpdatePolicy;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Intent;
@@ -3888,37 +3890,28 @@
public void testForceUpdateUserSetupComplete_permission() {
// GIVEN the permission MANAGE_PROFILE_AND_DEVICE_OWNERS is not granted
assertExpectException(SecurityException.class, /* messageRegex =*/ null,
- () -> dpm.forceUpdateUserSetupComplete());
- }
-
- @Test
- public void testForceUpdateUserSetupComplete_systemUser() {
- mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
- // GIVEN calling from user 20
- mContext.binder.callingUid = DpmMockContext.CALLER_UID;
- assertExpectException(SecurityException.class, /* messageRegex =*/ null,
- () -> dpm.forceUpdateUserSetupComplete());
+ () -> dpm.forceUpdateUserSetupComplete(UserHandle.USER_SYSTEM));
}
@Test
public void testForceUpdateUserSetupComplete_forcesUpdate() {
mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
+ final int userId = UserHandle.getUserId(mContext.binder.callingUid);
- final int userId = UserHandle.USER_SYSTEM;
// GIVEN userComplete is false in SettingsProvider
setUserSetupCompleteForUser(false, userId);
// GIVEN userComplete is true in DPM
DevicePolicyData userData = new DevicePolicyData(userId);
userData.mUserSetupComplete = true;
- dpms.mUserData.put(UserHandle.USER_SYSTEM, userData);
+ dpms.mUserData.put(userId, userData);
assertThat(dpms.hasUserSetupCompleted()).isTrue();
- dpm.forceUpdateUserSetupComplete();
+ dpm.forceUpdateUserSetupComplete(userId);
- // THEN the state in dpms is not changed
+ // THEN the state in dpms is changed
assertThat(dpms.hasUserSetupCompleted()).isFalse();
}
@@ -3948,10 +3941,9 @@
// Enabling logging should not change the timestamp.
dpm.setSecurityLoggingEnabled(admin1, true);
- verify(getServices().settings)
- .securityLogSetLoggingEnabledProperty(true);
- when(getServices().settings.securityLogGetLoggingEnabledProperty())
- .thenReturn(true);
+ verify(getServices().settings).securityLogSetLoggingEnabledProperty(true);
+
+ when(getServices().settings.securityLogGetLoggingEnabledProperty()).thenReturn(true);
assertThat(dpm.getLastSecurityLogRetrievalTime()).isEqualTo(-1);
// Retrieving the logs should update the timestamp.
@@ -4776,8 +4768,8 @@
when(getServices().iactivityManager.getCurrentUser())
.thenReturn(new UserInfo(UserHandle.USER_SYSTEM, "user system", 0));
// Get mock reason string since we throw an IAE with empty string input.
- when(mContext.getResources().getString(R.string.work_profile_deleted_description_dpm_wipe)).
- thenReturn("Just a test string.");
+ when(mContext.getResources().getString(R.string.work_profile_deleted_description_dpm_wipe))
+ .thenReturn("Just a test string.");
dpm.wipeData(0);
verify(getServices().userManagerInternal).removeUserEvenWhenDisallowed(
@@ -4785,6 +4777,68 @@
}
@Test
+ public void testWipeDataManagedProfileOnOrganizationOwnedDevice() throws Exception {
+ setupProfileOwner();
+ configureProfileOwnerOfOrgOwnedDevice(admin1, CALLER_USER_HANDLE);
+
+ // Even if the caller is the managed profile, the current user is the user 0
+ when(getServices().iactivityManager.getCurrentUser())
+ .thenReturn(new UserInfo(UserHandle.USER_SYSTEM, "user system", 0));
+ // Get mock reason string since we throw an IAE with empty string input.
+ when(mContext.getResources().getString(R.string.work_profile_deleted_description_dpm_wipe))
+ .thenReturn("Just a test string.");
+ when(getServices().userManager.getProfileParent(CALLER_USER_HANDLE))
+ .thenReturn(new UserInfo(UserHandle.USER_SYSTEM, "user system", 0));
+ when(getServices().userManager.getPrimaryUser())
+ .thenReturn(new UserInfo(UserHandle.USER_SYSTEM, "user system", 0));
+
+ // Set some device-wide policies:
+ // Security logging
+ when(getServices().settings.securityLogGetLoggingEnabledProperty()).thenReturn(true);
+ // System update policy
+ dpms.mOwners.setSystemUpdatePolicy(SystemUpdatePolicy.createAutomaticInstallPolicy());
+ // Make it look as if FRP agent is present.
+ when(dpms.mMockInjector.getPersistentDataBlockManagerInternal().getAllowedUid())
+ .thenReturn(12345 /* some UID in user 0 */);
+ // Make personal apps look suspended
+ dpms.getUserData(UserHandle.USER_SYSTEM).mAppsSuspended = true;
+
+ clearInvocations(getServices().iwindowManager);
+
+ dpm.wipeData(0);
+ verify(getServices().userManagerInternal).removeUserEvenWhenDisallowed(CALLER_USER_HANDLE);
+
+ // Make sure COPE restrictions are lifted:
+ verify(getServices().userManager).setUserRestriction(
+ UserManager.DISALLOW_REMOVE_MANAGED_PROFILE, false, UserHandle.SYSTEM);
+ verify(getServices().userManager).setUserRestriction(
+ UserManager.DISALLOW_ADD_USER, false, UserHandle.SYSTEM);
+
+ // Some device-wide policies are getting cleaned-up after the user is removed.
+ mContext.binder.callingUid = DpmMockContext.SYSTEM_UID;
+ sendBroadcastWithUser(dpms, Intent.ACTION_USER_REMOVED, CALLER_USER_HANDLE);
+
+ // Screenlock info should be removed
+ verify(getServices().lockPatternUtils).setDeviceOwnerInfo(null);
+ // Wifi config lockdown should be lifted
+ verify(getServices().settings).settingsGlobalPutInt(
+ Settings.Global.WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN, 0);
+ // System update policy should be removed
+ assertThat(dpms.mOwners.getSystemUpdatePolicy()).isNull();
+ // FRP agent should be notified
+ verify(mContext.spiedContext, times(0)).sendBroadcastAsUser(
+ MockUtils.checkIntentAction(
+ DevicePolicyManager.ACTION_RESET_PROTECTION_POLICY_CHANGED),
+ MockUtils.checkUserHandle(UserHandle.USER_SYSTEM));
+ // Refresh strong auth timeout and screen capture
+ verify(getServices().lockSettingsInternal).refreshStrongAuthTimeout(UserHandle.USER_SYSTEM);
+ verify(getServices().iwindowManager).refreshScreenCaptureDisabled(UserHandle.USER_SYSTEM);
+ // Unsuspend personal apps
+ verify(getServices().packageManagerInternal)
+ .unsuspendForSuspendingPackage(PLATFORM_PACKAGE_NAME, UserHandle.USER_SYSTEM);
+ }
+
+ @Test
public void testWipeDataManagedProfileDisallowed() throws Exception {
final int MANAGED_PROFILE_USER_ID = 15;
final int MANAGED_PROFILE_ADMIN_UID = UserHandle.getUid(MANAGED_PROFILE_USER_ID, 19436);
diff --git a/services/tests/servicestests/src/com/android/server/graphics/fonts/UpdatableFontDirTest.java b/services/tests/servicestests/src/com/android/server/graphics/fonts/UpdatableFontDirTest.java
index 5caff3d..7003ef7 100644
--- a/services/tests/servicestests/src/com/android/server/graphics/fonts/UpdatableFontDirTest.java
+++ b/services/tests/servicestests/src/com/android/server/graphics/fonts/UpdatableFontDirTest.java
@@ -92,7 +92,7 @@
}
@Override
- public void tryToCreateTypeface(File file) throws IOException {
+ public void tryToCreateTypeface(File file) throws Throwable {
}
}
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/ActiveSourceActionTest.java b/services/tests/servicestests/src/com/android/server/hdmi/ActiveSourceActionTest.java
index c08857c..6cc8d471 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/ActiveSourceActionTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/ActiveSourceActionTest.java
@@ -68,10 +68,12 @@
mContextSpy = spy(new ContextWrapper(InstrumentationRegistry.getTargetContext()));
- PowerManager powerManager = new PowerManager(mContextSpy, mIPowerManagerMock,
- mIThermalServiceMock, new Handler(mTestLooper.getLooper()));
- when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenReturn(powerManager);
- when(mContextSpy.getSystemService(PowerManager.class)).thenReturn(powerManager);
+ when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper())));
+ when(mContextSpy.getSystemService(PowerManager.class)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper())));
when(mIPowerManagerMock.isInteractive()).thenReturn(true);
mHdmiControlService = new HdmiControlService(mContextSpy) {
@@ -97,7 +99,8 @@
@Override
protected PowerManager getPowerManager() {
- return powerManager;
+ return new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper()));
}
@Override
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/ArcInitiationActionFromAvrTest.java b/services/tests/servicestests/src/com/android/server/hdmi/ArcInitiationActionFromAvrTest.java
index ee9de07..97bd066 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/ArcInitiationActionFromAvrTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/ArcInitiationActionFromAvrTest.java
@@ -70,10 +70,12 @@
mContextSpy = spy(new ContextWrapper(InstrumentationRegistry.getTargetContext()));
- PowerManager powerManager = new PowerManager(mContextSpy, mIPowerManagerMock,
- mIThermalServiceMock, new Handler(mTestLooper.getLooper()));
- when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenReturn(powerManager);
- when(mContextSpy.getSystemService(PowerManager.class)).thenReturn(powerManager);
+ when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper())));
+ when(mContextSpy.getSystemService(PowerManager.class)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper())));
when(mIPowerManagerMock.isInteractive()).thenReturn(true);
HdmiControlService hdmiControlService =
@@ -89,7 +91,8 @@
@Override
protected PowerManager getPowerManager() {
- return powerManager;
+ return new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper()));
}
@Override
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/ArcTerminationActionFromAvrTest.java b/services/tests/servicestests/src/com/android/server/hdmi/ArcTerminationActionFromAvrTest.java
index d5df071..29c9b40 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/ArcTerminationActionFromAvrTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/ArcTerminationActionFromAvrTest.java
@@ -71,10 +71,12 @@
mContextSpy = spy(new ContextWrapper(InstrumentationRegistry.getTargetContext()));
- PowerManager powerManager = new PowerManager(mContextSpy, mIPowerManagerMock,
- mIThermalServiceMock, new Handler(mTestLooper.getLooper()));
- when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenReturn(powerManager);
- when(mContextSpy.getSystemService(PowerManager.class)).thenReturn(powerManager);
+ when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper())));
+ when(mContextSpy.getSystemService(PowerManager.class)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper())));
when(mIPowerManagerMock.isInteractive()).thenReturn(true);
HdmiControlService hdmiControlService =
@@ -85,7 +87,8 @@
@Override
protected PowerManager getPowerManager() {
- return powerManager;
+ return new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper()));
}
@Override
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/DevicePowerStatusActionTest.java b/services/tests/servicestests/src/com/android/server/hdmi/DevicePowerStatusActionTest.java
index 4f97c26..650ffe9 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/DevicePowerStatusActionTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/DevicePowerStatusActionTest.java
@@ -80,10 +80,12 @@
mContextSpy = spy(new ContextWrapper(InstrumentationRegistry.getTargetContext()));
- PowerManager powerManager = new PowerManager(mContextSpy, mIPowerManagerMock,
- mIThermalServiceMock, new Handler(mTestLooper.getLooper()));
- when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenReturn(powerManager);
- when(mContextSpy.getSystemService(PowerManager.class)).thenReturn(powerManager);
+ when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper())));
+ when(mContextSpy.getSystemService(PowerManager.class)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper())));
when(mIPowerManagerMock.isInteractive()).thenReturn(true);
mHdmiControlService = new HdmiControlService(mContextSpy) {
@@ -109,7 +111,8 @@
@Override
protected PowerManager getPowerManager() {
- return powerManager;
+ return new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper()));
}
@Override
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/DeviceSelectActionTest.java b/services/tests/servicestests/src/com/android/server/hdmi/DeviceSelectActionTest.java
index 678f8b2..fa5cb67 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/DeviceSelectActionTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/DeviceSelectActionTest.java
@@ -103,8 +103,6 @@
Context context = InstrumentationRegistry.getTargetContext();
mMyLooper = mTestLooper.getLooper();
- PowerManager powerManager = new PowerManager(context, mIPowerManagerMock,
- mIThermalServiceMock, new Handler(mMyLooper));
mHdmiControlService =
new HdmiControlService(InstrumentationRegistry.getTargetContext()) {
@@ -129,7 +127,8 @@
@Override
protected PowerManager getPowerManager() {
- return powerManager;
+ return new PowerManager(context, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mMyLooper));
}
};
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/FakeHdmiCecConfig.java b/services/tests/servicestests/src/com/android/server/hdmi/FakeHdmiCecConfig.java
index e2b6a99..41946fb 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/FakeHdmiCecConfig.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/FakeHdmiCecConfig.java
@@ -26,6 +26,8 @@
import com.android.internal.R;
+import java.util.HashMap;
+
/**
* Fake class which stubs default system configuration with user-configurable
* settings (useful for testing).
@@ -33,6 +35,8 @@
final class FakeHdmiCecConfig extends HdmiCecConfig {
private static final String TAG = "FakeHdmiCecConfig";
+ private final HashMap<String, String> mSettings = new HashMap<>();
+
public static Context buildContext(Context context) {
Context contextSpy = spy(new ContextWrapper(context));
doReturn(buildResources(context)).when(contextSpy).getResources();
@@ -218,4 +222,15 @@
FakeHdmiCecConfig(@NonNull Context context) {
super(buildContext(context), new StorageAdapter(context));
}
+
+ @Override
+ protected String retrieveValue(@NonNull Setting setting, @NonNull String defaultValue) {
+ return mSettings.getOrDefault(setting.getName(), defaultValue);
+ }
+
+ @Override
+ protected void storeValue(@NonNull Setting setting, @NonNull String value) {
+ mSettings.put(setting.getName(), value);
+ notifySettingChanged(setting);
+ }
}
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecAtomLoggingTest.java b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecAtomLoggingTest.java
index 45409c8..29f62b5 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecAtomLoggingTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecAtomLoggingTest.java
@@ -30,6 +30,7 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.ContextWrapper;
@@ -96,9 +97,10 @@
mContextSpy = spy(new ContextWrapper(
InstrumentationRegistry.getInstrumentation().getTargetContext()));
- PowerManager powerManager = new PowerManager(
- mContextSpy, mIPowerManagerMock, mIThermalServiceMock, new Handler(mLooper));
- doReturn(powerManager).when(mContextSpy).getSystemService(Context.POWER_SERVICE);
+
+ when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mLooper)));
doReturn(true).when(mIPowerManagerMock).isInteractive();
mHdmiControlServiceSpy = spy(new HdmiControlService(mContextSpy));
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystemTest.java b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystemTest.java
index 38a44c6..7911c40 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystemTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystemTest.java
@@ -94,8 +94,6 @@
Context context = InstrumentationRegistry.getTargetContext();
mMyLooper = mTestLooper.getLooper();
- PowerManager powerManager = new PowerManager(context, mIPowerManagerMock,
- mIThermalServiceMock, new Handler(mMyLooper));
mHdmiControlService =
new HdmiControlService(InstrumentationRegistry.getTargetContext()) {
@@ -183,7 +181,8 @@
@Override
protected PowerManager getPowerManager() {
- return powerManager;
+ return new PowerManager(context, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mMyLooper));
}
};
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDevicePlaybackTest.java b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDevicePlaybackTest.java
index 1ac0150..5fbf8de 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDevicePlaybackTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDevicePlaybackTest.java
@@ -92,8 +92,6 @@
Context context = InstrumentationRegistry.getTargetContext();
mMyLooper = mTestLooper.getLooper();
- PowerManager powerManager = new PowerManager(context, mIPowerManagerMock,
- mIThermalServiceMock, new Handler(mMyLooper));
mHdmiControlService =
new HdmiControlService(InstrumentationRegistry.getTargetContext()) {
@@ -140,7 +138,8 @@
@Override
protected PowerManager getPowerManager() {
- return powerManager;
+ return new PowerManager(context, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mMyLooper));
}
};
@@ -168,6 +167,8 @@
mPlaybackLogicalAddress = mHdmiCecLocalDevicePlayback.getDeviceInfo().getLogicalAddress();
mHdmiControlService.getHdmiCecNetwork().addCecDevice(INFO_TV);
mNativeWrapper.clearResultMessages();
+ mHdmiCecLocalDevicePlayback.mPlaybackDeviceActionOnRoutingControl =
+ HdmiProperties.playback_device_action_on_routing_control_values.NONE;
}
@Test
@@ -698,9 +699,12 @@
mHdmiCecLocalDevicePlayback.mAddress, ADDR_TV);
HdmiCecMessage standbyMessageBroadcast = HdmiCecMessageBuilder.buildStandby(
mHdmiCecLocalDevicePlayback.mAddress, ADDR_BROADCAST);
+ HdmiCecMessage inactiveSource = HdmiCecMessageBuilder.buildInactiveSource(
+ mPlaybackLogicalAddress, mPlaybackPhysicalAddress);
assertThat(mNativeWrapper.getResultMessages()).doesNotContain(standbyMessageToTv);
assertThat(mNativeWrapper.getResultMessages()).doesNotContain(standbyMessageBroadcast);
+ assertThat(mNativeWrapper.getResultMessages()).doesNotContain(inactiveSource);
}
@Test
@@ -720,9 +724,12 @@
mHdmiCecLocalDevicePlayback.mAddress, ADDR_TV);
HdmiCecMessage standbyMessageBroadcast = HdmiCecMessageBuilder.buildStandby(
mHdmiCecLocalDevicePlayback.mAddress, ADDR_BROADCAST);
+ HdmiCecMessage inactiveSource = HdmiCecMessageBuilder.buildInactiveSource(
+ mPlaybackLogicalAddress, mPlaybackPhysicalAddress);
assertThat(mNativeWrapper.getResultMessages()).doesNotContain(standbyMessageToTv);
assertThat(mNativeWrapper.getResultMessages()).doesNotContain(standbyMessageBroadcast);
+ assertThat(mNativeWrapper.getResultMessages()).doesNotContain(inactiveSource);
}
@Test
@@ -742,9 +749,12 @@
mHdmiCecLocalDevicePlayback.mAddress, ADDR_TV);
HdmiCecMessage standbyMessageBroadcast = HdmiCecMessageBuilder.buildStandby(
mHdmiCecLocalDevicePlayback.mAddress, ADDR_BROADCAST);
+ HdmiCecMessage inactiveSource = HdmiCecMessageBuilder.buildInactiveSource(
+ mPlaybackLogicalAddress, mPlaybackPhysicalAddress);
assertThat(mNativeWrapper.getResultMessages()).doesNotContain(standbyMessageToTv);
assertThat(mNativeWrapper.getResultMessages()).doesNotContain(standbyMessageBroadcast);
+ assertThat(mNativeWrapper.getResultMessages()).doesNotContain(inactiveSource);
}
@Test
@@ -764,9 +774,12 @@
mHdmiCecLocalDevicePlayback.mAddress, ADDR_TV);
HdmiCecMessage standbyMessageBroadcast = HdmiCecMessageBuilder.buildStandby(
mHdmiCecLocalDevicePlayback.mAddress, ADDR_BROADCAST);
+ HdmiCecMessage inactiveSource = HdmiCecMessageBuilder.buildInactiveSource(
+ mPlaybackLogicalAddress, mPlaybackPhysicalAddress);
assertThat(mNativeWrapper.getResultMessages()).contains(standbyMessageToTv);
assertThat(mNativeWrapper.getResultMessages()).doesNotContain(standbyMessageBroadcast);
+ assertThat(mNativeWrapper.getResultMessages()).doesNotContain(inactiveSource);
}
@Test
@@ -786,9 +799,12 @@
mHdmiCecLocalDevicePlayback.mAddress, ADDR_TV);
HdmiCecMessage standbyMessageBroadcast = HdmiCecMessageBuilder.buildStandby(
mHdmiCecLocalDevicePlayback.mAddress, ADDR_BROADCAST);
+ HdmiCecMessage inactiveSource = HdmiCecMessageBuilder.buildInactiveSource(
+ mPlaybackLogicalAddress, mPlaybackPhysicalAddress);
assertThat(mNativeWrapper.getResultMessages()).doesNotContain(standbyMessageToTv);
assertThat(mNativeWrapper.getResultMessages()).contains(standbyMessageBroadcast);
+ assertThat(mNativeWrapper.getResultMessages()).doesNotContain(inactiveSource);
}
@Test
@@ -808,9 +824,37 @@
mHdmiCecLocalDevicePlayback.mAddress, ADDR_TV);
HdmiCecMessage standbyMessageBroadcast = HdmiCecMessageBuilder.buildStandby(
mHdmiCecLocalDevicePlayback.mAddress, ADDR_BROADCAST);
+ HdmiCecMessage inactiveSource = HdmiCecMessageBuilder.buildInactiveSource(
+ mPlaybackLogicalAddress, mPlaybackPhysicalAddress);
assertThat(mNativeWrapper.getResultMessages()).doesNotContain(standbyMessageToTv);
assertThat(mNativeWrapper.getResultMessages()).doesNotContain(standbyMessageBroadcast);
+ assertThat(mNativeWrapper.getResultMessages()).contains(inactiveSource);
+ }
+
+ @Test
+ public void handleOnStandby_CecMessageReceived() {
+ mHdmiCecLocalDevicePlayback.mService.getHdmiCecConfig().setStringValue(
+ HdmiControlManager.CEC_SETTING_NAME_POWER_CONTROL_MODE,
+ HdmiControlManager.POWER_CONTROL_MODE_TV);
+ mHdmiCecLocalDevicePlayback.setActiveSource(mPlaybackLogicalAddress,
+ mPlaybackPhysicalAddress, "HdmiCecLocalDevicePlaybackTest");
+ mHdmiCecLocalDevicePlayback.mService.getHdmiCecConfig().setIntValue(
+ HdmiControlManager.CEC_SETTING_NAME_TV_SEND_STANDBY_ON_SLEEP,
+ HdmiControlManager.TV_SEND_STANDBY_ON_SLEEP_ENABLED);
+ mHdmiCecLocalDevicePlayback.onStandby(true, HdmiControlService.STANDBY_SCREEN_OFF);
+ mTestLooper.dispatchAll();
+
+ HdmiCecMessage standbyMessageToTv = HdmiCecMessageBuilder.buildStandby(
+ mHdmiCecLocalDevicePlayback.mAddress, ADDR_TV);
+ HdmiCecMessage standbyMessageBroadcast = HdmiCecMessageBuilder.buildStandby(
+ mHdmiCecLocalDevicePlayback.mAddress, ADDR_BROADCAST);
+ HdmiCecMessage inactiveSource = HdmiCecMessageBuilder.buildInactiveSource(
+ mPlaybackLogicalAddress, mPlaybackPhysicalAddress);
+
+ assertThat(mNativeWrapper.getResultMessages()).doesNotContain(standbyMessageToTv);
+ assertThat(mNativeWrapper.getResultMessages()).doesNotContain(standbyMessageBroadcast);
+ assertThat(mNativeWrapper.getResultMessages()).contains(inactiveSource);
}
@Test
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTvTest.java b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTvTest.java
index 8ee983f..59711a6 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTvTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTvTest.java
@@ -86,8 +86,6 @@
Context context = InstrumentationRegistry.getTargetContext();
mMyLooper = mTestLooper.getLooper();
- PowerManager powerManager = new PowerManager(context, mIPowerManagerMock,
- mIThermalServiceMock, new Handler(mMyLooper));
mHdmiControlService =
new HdmiControlService(InstrumentationRegistry.getTargetContext()) {
@@ -118,7 +116,8 @@
@Override
protected PowerManager getPowerManager() {
- return powerManager;
+ return new PowerManager(context, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mMyLooper));
}
@Override
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecPowerStatusControllerTest.java b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecPowerStatusControllerTest.java
index 1c7ff42..572ffd9 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecPowerStatusControllerTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecPowerStatusControllerTest.java
@@ -75,10 +75,12 @@
Context contextSpy = spy(new ContextWrapper(InstrumentationRegistry.getTargetContext()));
Looper myLooper = mTestLooper.getLooper();
- PowerManager powerManager = new PowerManager(contextSpy, mIPowerManagerMock,
- mIThermalServiceMock, new Handler(myLooper));
- when(contextSpy.getSystemService(Context.POWER_SERVICE)).thenReturn(powerManager);
- when(contextSpy.getSystemService(PowerManager.class)).thenReturn(powerManager);
+ when(contextSpy.getSystemService(Context.POWER_SERVICE)).thenAnswer(i ->
+ new PowerManager(contextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(myLooper)));
+ when(contextSpy.getSystemService(PowerManager.class)).thenAnswer(i ->
+ new PowerManager(contextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(myLooper)));
when(mIPowerManagerMock.isInteractive()).thenReturn(true);
mHdmiControlService = new HdmiControlService(contextSpy) {
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/HdmiControlServiceTest.java b/services/tests/servicestests/src/com/android/server/hdmi/HdmiControlServiceTest.java
index 68aa96a..bcf30a2 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/HdmiControlServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/HdmiControlServiceTest.java
@@ -47,7 +47,6 @@
import android.os.RemoteException;
import android.os.test.TestLooper;
import android.platform.test.annotations.Presubmit;
-import android.provider.Settings;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
@@ -193,10 +192,12 @@
mContextSpy = spy(new ContextWrapper(InstrumentationRegistry.getTargetContext()));
- PowerManager powerManager = new PowerManager(mContextSpy, mIPowerManagerMock,
- mIThermalServiceMock, null);
- when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenReturn(powerManager);
- when(mContextSpy.getSystemService(PowerManager.class)).thenReturn(powerManager);
+ when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, null));
+ when(mContextSpy.getSystemService(PowerManager.class)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, null));
when(mIPowerManagerMock.isInteractive()).thenReturn(true);
HdmiCecConfig hdmiCecConfig = new FakeHdmiCecConfig(mContextSpy);
@@ -237,9 +238,6 @@
mHdmiPortInfo[3] =
new HdmiPortInfo(4, HdmiPortInfo.PORT_INPUT, 0x3000, true, false, false);
mNativeWrapper.setPortInfo(mHdmiPortInfo);
- mHdmiControlServiceSpy.getHdmiCecConfig().setIntValue(
- HdmiControlManager.CEC_SETTING_NAME_HDMI_CEC_ENABLED,
- HdmiControlManager.HDMI_CEC_CONTROL_ENABLED);
mHdmiControlServiceSpy.initService();
mHdmiControlServiceSpy.allocateLogicalAddress(mLocalDevices, INITIATED_BY_ENABLE_CEC);
@@ -362,23 +360,6 @@
}
@Test
- public void setAndGetCecVolumeControlEnabled_changesSetting() {
- mHdmiControlServiceSpy.getHdmiCecConfig().setIntValue(
- HdmiControlManager.CEC_SETTING_NAME_VOLUME_CONTROL_MODE,
- HdmiControlManager.VOLUME_CONTROL_DISABLED);
- assertThat(mHdmiControlServiceSpy.readIntSetting(
- Settings.Global.HDMI_CONTROL_VOLUME_CONTROL_ENABLED, -1)).isEqualTo(
- HdmiControlManager.VOLUME_CONTROL_DISABLED);
-
- mHdmiControlServiceSpy.getHdmiCecConfig().setIntValue(
- HdmiControlManager.CEC_SETTING_NAME_VOLUME_CONTROL_MODE,
- HdmiControlManager.VOLUME_CONTROL_ENABLED);
- assertThat(mHdmiControlServiceSpy.readIntSetting(
- Settings.Global.HDMI_CONTROL_VOLUME_CONTROL_ENABLED, -1)).isEqualTo(
- HdmiControlManager.VOLUME_CONTROL_ENABLED);
- }
-
- @Test
public void setAndGetCecVolumeControlEnabledInternal_doesNotChangeSetting() {
mHdmiControlServiceSpy.getHdmiCecConfig().setIntValue(
HdmiControlManager.CEC_SETTING_NAME_VOLUME_CONTROL_MODE,
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/OneTouchPlayActionTest.java b/services/tests/servicestests/src/com/android/server/hdmi/OneTouchPlayActionTest.java
index 826438f..4cd17e8 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/OneTouchPlayActionTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/OneTouchPlayActionTest.java
@@ -91,10 +91,12 @@
setHdmiControlEnabled(hdmiControlEnabled);
- PowerManager powerManager = new PowerManager(mContextSpy, mIPowerManagerMock,
- mIThermalServiceMock, new Handler(mTestLooper.getLooper()));
- when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenReturn(powerManager);
- when(mContextSpy.getSystemService(PowerManager.class)).thenReturn(powerManager);
+ when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper())));
+ when(mContextSpy.getSystemService(PowerManager.class)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper())));
when(mIPowerManagerMock.isInteractive()).thenReturn(true);
mHdmiControlService = new HdmiControlService(mContextSpy) {
@@ -120,7 +122,8 @@
@Override
protected PowerManager getPowerManager() {
- return powerManager;
+ return new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper()));
}
@Override
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/PowerStatusMonitorActionTest.java b/services/tests/servicestests/src/com/android/server/hdmi/PowerStatusMonitorActionTest.java
index 53b4b49..a9880c0 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/PowerStatusMonitorActionTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/PowerStatusMonitorActionTest.java
@@ -78,10 +78,12 @@
mContextSpy = spy(new ContextWrapper(InstrumentationRegistry.getTargetContext()));
- PowerManager powerManager = new PowerManager(mContextSpy, mIPowerManagerMock,
- mIThermalServiceMock, new Handler(mTestLooper.getLooper()));
- when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenReturn(powerManager);
- when(mContextSpy.getSystemService(PowerManager.class)).thenReturn(powerManager);
+ when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper())));
+ when(mContextSpy.getSystemService(PowerManager.class)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper())));
when(mIPowerManagerMock.isInteractive()).thenReturn(true);
mHdmiControlService = new HdmiControlService(mContextSpy,
@@ -108,7 +110,8 @@
@Override
protected PowerManager getPowerManager() {
- return powerManager;
+ return new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(mTestLooper.getLooper()));
}
@Override
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/SystemAudioAutoInitiationActionTest.java b/services/tests/servicestests/src/com/android/server/hdmi/SystemAudioAutoInitiationActionTest.java
index 865eb7a..2cf4ef1 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/SystemAudioAutoInitiationActionTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/SystemAudioAutoInitiationActionTest.java
@@ -78,10 +78,12 @@
mContextSpy = spy(new ContextWrapper(InstrumentationRegistry.getTargetContext()));
Looper myLooper = mTestLooper.getLooper();
- PowerManager powerManager = new PowerManager(mContextSpy, mIPowerManagerMock,
- mIThermalServiceMock, new Handler(myLooper));
- when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenReturn(powerManager);
- when(mContextSpy.getSystemService(PowerManager.class)).thenReturn(powerManager);
+ when(mContextSpy.getSystemService(Context.POWER_SERVICE)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(myLooper)));
+ when(mContextSpy.getSystemService(PowerManager.class)).thenAnswer(i ->
+ new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(myLooper)));
when(mIPowerManagerMock.isInteractive()).thenReturn(true);
mHdmiControlService = new HdmiControlService(mContextSpy) {
@@ -107,7 +109,8 @@
@Override
protected PowerManager getPowerManager() {
- return powerManager;
+ return new PowerManager(mContextSpy, mIPowerManagerMock,
+ mIThermalServiceMock, new Handler(myLooper));
}
@Override
diff --git a/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java b/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
index 3581206..4a09cf8 100644
--- a/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
@@ -50,12 +50,14 @@
import android.app.appsearch.AppSearchManager;
import android.app.appsearch.AppSearchResult;
import android.app.appsearch.GenericDocument;
-import android.app.appsearch.IAppSearchBatchResultCallback;
-import android.app.appsearch.IAppSearchManager;
-import android.app.appsearch.IAppSearchResultCallback;
import android.app.appsearch.PackageIdentifier;
import android.app.appsearch.SearchResultPage;
import android.app.appsearch.SetSchemaResponse;
+import android.app.appsearch.aidl.AppSearchBatchResultParcel;
+import android.app.appsearch.aidl.AppSearchResultParcel;
+import android.app.appsearch.aidl.IAppSearchBatchResultCallback;
+import android.app.appsearch.aidl.IAppSearchManager;
+import android.app.appsearch.aidl.IAppSearchResultCallback;
import android.app.role.OnRoleHoldersChangedListener;
import android.app.usage.UsageStatsManagerInternal;
import android.content.ActivityNotFoundException;
@@ -675,7 +677,9 @@
}
}
final SetSchemaResponse response = new SetSchemaResponse.Builder().build();
- callback.onResult(AppSearchResult.newSuccessfulResult(response.getBundle()));
+ callback.onResult(
+ new AppSearchResultParcel(
+ AppSearchResult.newSuccessfulResult(response.getBundle())));
}
@Override
@@ -711,7 +715,7 @@
}
docMap.put(doc.getId(), doc);
}
- callback.onResult(builder.build());
+ callback.onResult(new AppSearchBatchResultParcel<>(builder.build()));
}
@Override
@@ -737,7 +741,7 @@
}
}
}
- callback.onResult(builder.build());
+ callback.onResult(new AppSearchBatchResultParcel<>(builder.build()));
}
@Override
@@ -749,7 +753,8 @@
final Bundle page = new Bundle();
page.putLong(SearchResultPage.NEXT_PAGE_TOKEN_FIELD, 1);
page.putParcelableArrayList(SearchResultPage.RESULTS_FIELD, new ArrayList<>());
- callback.onResult(AppSearchResult.newSuccessfulResult(page));
+ callback.onResult(
+ new AppSearchResultParcel<>(AppSearchResult.newSuccessfulResult(page)));
return;
}
final List<GenericDocument> documents = new ArrayList<>(mDocumentMap.get(key).values());
@@ -765,7 +770,8 @@
resultBundles.add(resultBundle);
}
page.putParcelableArrayList(SearchResultPage.RESULTS_FIELD, resultBundles);
- callback.onResult(AppSearchResult.newSuccessfulResult(page));
+ callback.onResult(
+ new AppSearchResultParcel<>(AppSearchResult.newSuccessfulResult(page)));
}
@Override
@@ -780,7 +786,8 @@
final Bundle page = new Bundle();
page.putLong(SearchResultPage.NEXT_PAGE_TOKEN_FIELD, 1);
page.putParcelableArrayList(SearchResultPage.RESULTS_FIELD, new ArrayList<>());
- callback.onResult(AppSearchResult.newSuccessfulResult(page));
+ callback.onResult(
+ new AppSearchResultParcel<>(AppSearchResult.newSuccessfulResult(page)));
}
@Override
@@ -835,7 +842,7 @@
}
}
}
- callback.onResult(builder.build());
+ callback.onResult(new AppSearchBatchResultParcel<>(builder.build()));
}
@Override
@@ -844,11 +851,13 @@
throws RemoteException {
final String key = getKey(userId, databaseName);
if (!mDocumentMap.containsKey(key)) {
- callback.onResult(AppSearchResult.newSuccessfulResult(null));
+ callback.onResult(
+ new AppSearchResultParcel<>(AppSearchResult.newSuccessfulResult(null)));
return;
}
mDocumentMap.get(key).clear();
- callback.onResult(AppSearchResult.newSuccessfulResult(null));
+ callback.onResult(
+ new AppSearchResultParcel<>(AppSearchResult.newSuccessfulResult(null)));
}
@Override
@@ -878,7 +887,8 @@
}
private void ignore(IAppSearchResultCallback callback) throws RemoteException {
- callback.onResult(AppSearchResult.newSuccessfulResult(null));
+ callback.onResult(
+ new AppSearchResultParcel<>(AppSearchResult.newSuccessfulResult(null)));
}
}
diff --git a/services/tests/servicestests/src/com/android/server/pm/KeySetManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/pm/KeySetManagerServiceTest.java
index 709b009..1b6bddc 100644
--- a/services/tests/servicestests/src/com/android/server/pm/KeySetManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/KeySetManagerServiceTest.java
@@ -25,6 +25,7 @@
import android.util.LongSparseArray;
import com.android.internal.util.ArrayUtils;
+import com.android.server.utils.WatchedArrayMap;
import java.io.File;
import java.io.IOException;
@@ -33,7 +34,7 @@
public class KeySetManagerServiceTest extends AndroidTestCase {
- private ArrayMap<String, PackageSetting> mPackagesMap;
+ private WatchedArrayMap<String, PackageSetting> mPackagesMap;
private KeySetManagerService mKsms;
public PackageSetting generateFakePackageSetting(String name) {
@@ -46,7 +47,7 @@
@Override
public void setUp() throws Exception {
super.setUp();
- mPackagesMap = new ArrayMap<String, PackageSetting>();
+ mPackagesMap = new WatchedArrayMap<String, PackageSetting>();
mKsms = new KeySetManagerService(mPackagesMap);
}
@@ -94,7 +95,8 @@
}
public void testEncodePublicKey() throws IOException {
- ArrayMap<String, PackageSetting> packagesMap = new ArrayMap<String, PackageSetting>();
+ WatchedArrayMap<String, PackageSetting> packagesMap =
+ new WatchedArrayMap<String, PackageSetting>();
KeySetManagerService ksms = new KeySetManagerService(packagesMap);
PublicKey keyA = PackageParser.parsePublicKey(KeySetStrings.ctsKeySetPublicKeyA);
diff --git a/services/tests/servicestests/src/com/android/server/pm/PackageManagerSettingsTests.java b/services/tests/servicestests/src/com/android/server/pm/PackageManagerSettingsTests.java
index a231169..29f4aa9 100644
--- a/services/tests/servicestests/src/com/android/server/pm/PackageManagerSettingsTests.java
+++ b/services/tests/servicestests/src/com/android/server/pm/PackageManagerSettingsTests.java
@@ -47,7 +47,6 @@
import android.os.PersistableBundle;
import android.os.Process;
import android.os.UserHandle;
-import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.AtomicFile;
import android.util.Log;
@@ -64,6 +63,7 @@
import com.android.server.pm.permission.LegacyPermissionDataProvider;
import com.android.server.pm.verify.domain.DomainVerificationManagerInternal;
import com.android.server.utils.WatchableTester;
+import com.android.server.utils.WatchedArrayMap;
import com.google.common.truth.Truth;
@@ -1202,9 +1202,8 @@
private void verifyKeySetMetaData(Settings settings)
throws ReflectiveOperationException, IllegalAccessException {
- ArrayMap<String, PackageSetting> packages =
- settings.mPackages.untrackedStorage();
- KeySetManagerService ksms = settings.mKeySetManagerService;
+ WatchedArrayMap<String, PackageSetting> packages = settings.mPackages;
+ KeySetManagerService ksms = settings.getKeySetManagerService();
/* verify keyset and public key ref counts */
assertThat(KeySetUtils.getKeySetRefCount(ksms, 1), is(2));
diff --git a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest12.java b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest12.java
index 478aa41..9598a00 100644
--- a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest12.java
+++ b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest12.java
@@ -15,20 +15,11 @@
*/
package com.android.server.pm;
-import static android.provider.DeviceConfig.NAMESPACE_SYSTEMUI;
-
import static com.android.server.pm.shortcutmanagertest.ShortcutManagerTestUtils.list;
import android.app.PendingIntent;
-import android.app.appsearch.PackageIdentifier;
-import android.content.pm.AppSearchShortcutInfo;
import android.os.RemoteException;
import android.os.UserHandle;
-import android.provider.DeviceConfig;
-
-import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
-
-import java.util.Random;
/**
* Tests for {@link android.app.appsearch.AppSearchManager} and relevant APIs in ShortcutManager.
@@ -37,26 +28,6 @@
*/
public class ShortcutManagerTest12 extends BaseShortcutManagerTest {
- public void testUpdateShortcutVisibility_updatesShortcutSchema() {
- if (!DeviceConfig.getBoolean(NAMESPACE_SYSTEMUI,
- SystemUiDeviceConfigFlags.DARK_LAUNCH_REMOTE_PREDICTION_SERVICE_ENABLED,
- false)) {
- // no-op if app-search integration is disabled.
- return;
- }
- final byte[] cert = new byte[20];
- new Random().nextBytes(cert);
-
- runWithCaller(CALLING_PACKAGE_1, USER_0, () -> {
- mManager.updateShortcutVisibility(CALLING_PACKAGE_2, cert, true);
- assertTrue(mMockAppSearchManager.mSchemasPackageAccessible.containsKey(
- AppSearchShortcutInfo.SCHEMA_TYPE));
- assertTrue(mMockAppSearchManager.mSchemasPackageAccessible.get(
- AppSearchShortcutInfo.SCHEMA_TYPE).get(0).equals(
- new PackageIdentifier(CALLING_PACKAGE_2, cert)));
- });
- }
-
public void testGetShortcutIntents_ReturnsMutablePendingIntents() throws RemoteException {
setDefaultLauncher(USER_0, LAUNCHER_1);
diff --git a/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySaverPolicyTest.java b/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySaverPolicyTest.java
index 9001b3d..443476c 100644
--- a/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySaverPolicyTest.java
+++ b/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySaverPolicyTest.java
@@ -48,7 +48,7 @@
private static final float PRECISION = 0.001f;
private static final int GPS_MODE = 0; // LOCATION_MODE_NO_CHANGE
private static final int DEFAULT_GPS_MODE =
- PowerManager.LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF;
+ PowerManager.LOCATION_MODE_FOREGROUND_ONLY;
private static final int SOUND_TRIGGER_MODE = 0; // SOUND_TRIGGER_MODE_ALL_ENABLED
private static final int DEFAULT_SOUND_TRIGGER_MODE =
PowerManager.SOUND_TRIGGER_MODE_CRITICAL_ONLY;
diff --git a/services/tests/servicestests/src/com/android/server/power/batterysaver/OWNERS b/services/tests/servicestests/src/com/android/server/power/batterysaver/OWNERS
new file mode 100644
index 0000000..08276f5
--- /dev/null
+++ b/services/tests/servicestests/src/com/android/server/power/batterysaver/OWNERS
@@ -0,0 +1 @@
+include /services/core/java/com/android/server/power/batterysaver/OWNERS
\ No newline at end of file
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java
index c502ed5..825e53e 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java
@@ -100,6 +100,7 @@
private String mVersionString;
private final Set<ComponentName> mDefaults = new ArraySet();
private ManagedServices mService;
+ private String mUserSetString;
private static final String SETTING = "setting";
private static final String SECONDARY_SETTING = "secondary_setting";
@@ -138,7 +139,7 @@
profileIds.add(13);
when(mUserProfiles.getCurrentProfileIds()).thenReturn(profileIds);
- mVersionString = "2";
+ mVersionString = "4";
mExpectedPrimary = new ArrayMap<>();
mExpectedSecondary = new ArrayMap<>();
mExpectedPrimaryPackages = new ArrayMap<>();
@@ -1363,6 +1364,7 @@
public void loadDefaults_noVersionWithDefaults() throws Exception {
resetComponentsAndPackages();
mDefaults.add(new ComponentName("default", "class"));
+ mVersionString = null;
loadXml(mService);
assertEquals(mService.getDefaultComponents(), mDefaults);
}
@@ -1421,12 +1423,34 @@
resetComponentsAndPackages();
mDefaults.add(new ComponentName("default", "class"));
mDefaultsString = "xml/class";
- mVersionString = String.valueOf(mService.DB_VERSION);
loadXml(mService);
assertEquals(mService.getDefaultComponents(),
new ArraySet(Arrays.asList(new ComponentName("xml", "class"))));
}
+ @Test
+ public void upgradeUserSet_versionThree() throws Exception {
+ resetComponentsAndPackages();
+
+ List<UserInfo> users = new ArrayList<>();
+ users.add(new UserInfo(98, "98", 0));
+ users.add(new UserInfo(99, "99", 0));
+ for (UserInfo user : users) {
+ when(mUm.getUserInfo(eq(user.id))).thenReturn(user);
+ }
+
+ mDefaultsString = "xml/class";
+ mVersionString = "3";
+ mUserSetString = "xml/class";
+ loadXml(mService);
+
+ //Test services without overriding upgradeUserSet() remain unchanged
+ assertEquals(new ArraySet(Arrays.asList(mUserSetString)),
+ mService.mUserSetServices.get(98));
+ assertEquals(new ArraySet(Arrays.asList(mUserSetString)),
+ mService.mUserSetServices.get(99));
+ assertEquals(new ArrayMap(), mService.mIsUserChanged);
+ }
private void resetComponentsAndPackages() {
ArrayMap<Integer, ArrayMap<Integer, String>> empty = new ArrayMap(1);
@@ -1468,11 +1492,17 @@
xml.append("<" + ManagedServices.TAG_MANAGED_SERVICES + " "
+ ManagedServices.ATT_USER_ID + "=\"99\" "
+ ManagedServices.ATT_IS_PRIMARY + "=\"true\" "
- + ManagedServices.ATT_APPROVED_LIST + "=\"990\" />\n");
+ + ManagedServices.ATT_APPROVED_LIST + "=\"990\" "
+ + (mUserSetString != null ? ManagedServices.ATT_USER_SET + "=\""
+ + mUserSetString + "\" " : "")
+ + "/>\n");
xml.append("<" + ManagedServices.TAG_MANAGED_SERVICES + " "
+ ManagedServices.ATT_USER_ID + "=\"98\" "
+ ManagedServices.ATT_IS_PRIMARY + "=\"false\" "
- + ManagedServices.ATT_APPROVED_LIST + "=\"981\" />\n");
+ + ManagedServices.ATT_APPROVED_LIST + "=\"981\" "
+ + (mUserSetString != null ? ManagedServices.ATT_USER_SET + "=\""
+ + mUserSetString + "\" " : "")
+ + " />\n");
xml.append("</" + xmlTag + ">");
return xml.toString();
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java
index 6722fff..054a401 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java
@@ -16,6 +16,7 @@
package com.android.server.notification;
import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertNull;
@@ -41,11 +42,13 @@
import android.os.UserHandle;
import android.os.UserManager;
import android.testing.TestableContext;
+import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.IntArray;
import android.util.TypedXmlPullParser;
import android.util.Xml;
+import com.android.internal.util.function.TriPredicate;
import com.android.server.UiServiceTestCase;
import com.android.server.notification.NotificationManagerService.NotificationAssistants;
@@ -132,6 +135,68 @@
}
@Test
+ public void testReadXml_userDisabled() throws Exception {
+ String xml = "<enabled_assistants version=\"4\" defaults=\"b/b\">"
+ + "<service_listing approved=\"\" user=\"0\" primary=\"true\""
+ + "user_changed=\"true\"/>"
+ + "</enabled_assistants>";
+
+ final TypedXmlPullParser parser = Xml.newFastPullParser();
+ parser.setInput(new BufferedInputStream(
+ new ByteArrayInputStream(xml.toString().getBytes())), null);
+ TriPredicate<String, Integer, String> allowedManagedServicePackages =
+ mNm::canUseManagedServices;
+
+ parser.nextTag();
+ mAssistants.readXml(parser, allowedManagedServicePackages, false, UserHandle.USER_ALL);
+
+ ArrayMap<Boolean, ArraySet<String>> approved = mAssistants.mApproved.get(0);
+
+ // approved should not be null
+ assertNotNull(approved);
+ assertEquals(new ArraySet<>(), approved.get(true));
+ }
+
+ @Test
+ public void testReadXml_upgradeUserSet() throws Exception {
+ String xml = "<enabled_assistants version=\"3\" defaults=\"b/b\">"
+ + "<service_listing approved=\"\" user=\"0\" primary=\"true\""
+ + "user_set_services=\"b/b\"/>"
+ + "</enabled_assistants>";
+
+ final TypedXmlPullParser parser = Xml.newFastPullParser();
+ parser.setInput(new BufferedInputStream(
+ new ByteArrayInputStream(xml.toString().getBytes())), null);
+ TriPredicate<String, Integer, String> allowedManagedServicePackages =
+ mNm::canUseManagedServices;
+
+ parser.nextTag();
+ mAssistants.readXml(parser, allowedManagedServicePackages, false, UserHandle.USER_ALL);
+
+ verify(mAssistants, times(1)).upgradeUserSet();
+ assertTrue(mAssistants.mIsUserChanged.get(0));
+ }
+
+ @Test
+ public void testReadXml_multiApproved() throws Exception {
+ String xml = "<enabled_assistants version=\"4\" defaults=\"b/b\">"
+ + "<service_listing approved=\"a/a:b/b\" user=\"0\" primary=\"true\""
+ + "user_changed=\"true\"/>"
+ + "</enabled_assistants>";
+
+ final TypedXmlPullParser parser = Xml.newFastPullParser();
+ parser.setInput(new BufferedInputStream(
+ new ByteArrayInputStream(xml.toString().getBytes())), null);
+
+ parser.nextTag();
+ mAssistants.readXml(parser, null, false, UserHandle.USER_ALL);
+
+ assertEquals(1, mAssistants.getAllowedComponents(0).size());
+ assertEquals(new ArrayList(Arrays.asList(new ComponentName("a", "a"))),
+ mAssistants.getAllowedComponents(0));
+ }
+
+ @Test
public void testXmlUpgradeExistingApprovedComponents() throws Exception {
String xml = "<enabled_assistants version=\"2\" defaults=\"b\\b\">"
+ "<service_listing approved=\"b/b\" user=\"10\" primary=\"true\" />"
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 4bbea94..ddaf3ab 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -1351,25 +1351,39 @@
* must ensure the visibilities of activities being updated.
*/
@Test
- public void testCompleteFinishing_ensureActivitiesVisible() {
+ public void testCompleteFinishing_ensureActivitiesVisible_withConditions() {
+ testCompleteFinishing_ensureActivitiesVisible(false, PAUSED);
+ testCompleteFinishing_ensureActivitiesVisible(false, STARTED);
+ testCompleteFinishing_ensureActivitiesVisible(true, PAUSED);
+ testCompleteFinishing_ensureActivitiesVisible(true, STARTED);
+ }
+
+ private void testCompleteFinishing_ensureActivitiesVisible(boolean diffTask,
+ ActivityState secondActivityState) {
final ActivityRecord activity = createActivityWithTask();
final Task task = activity.getTask();
final ActivityRecord firstActivity = new ActivityBuilder(mAtm).setTask(task).build();
firstActivity.mVisibleRequested = false;
firstActivity.nowVisible = false;
- firstActivity.setState(STOPPED, "true");
+ firstActivity.setState(STOPPED, "test");
final ActivityRecord secondActivity = new ActivityBuilder(mAtm).setTask(task).build();
secondActivity.mVisibleRequested = true;
secondActivity.nowVisible = true;
- secondActivity.setState(PAUSED, "true");
+ secondActivity.setState(secondActivityState, "test");
- final ActivityRecord translucentActivity = new ActivityBuilder(mAtm).setTask(task).build();
+ ActivityRecord translucentActivity;
+ if (diffTask) {
+ translucentActivity = new ActivityBuilder(mAtm).setCreateTask(true).build();
+ } else {
+ translucentActivity = new ActivityBuilder(mAtm).setTask(task).build();
+ }
translucentActivity.mVisibleRequested = true;
translucentActivity.nowVisible = true;
- translucentActivity.setState(RESUMED, "true");
+ translucentActivity.setState(RESUMED, "test");
- doReturn(false).when(translucentActivity).occludesParent();
+ doReturn(true).when(firstActivity).occludesParent(true);
+ doReturn(true).when(secondActivity).occludesParent(true);
// Finish the second activity
secondActivity.finishing = true;
@@ -1385,6 +1399,10 @@
verify(firstActivity.mDisplayContent, times(2)).ensureActivitiesVisible(null /* starting */,
0 /* configChanges */ , false /* preserveWindows */,
true /* notifyClients */);
+
+ // Remove the translucent activity and clear invocations for next test
+ translucentActivity.getTask().removeImmediately("test");
+ clearInvocations(mDefaultDisplay);
}
/**
diff --git a/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java b/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java
index 748622b..e280a36 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java
@@ -38,6 +38,7 @@
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.server.wm.ActivityTaskManagerService.RELAUNCH_REASON_FREE_RESIZE;
import static com.android.server.wm.ActivityTaskManagerService.RELAUNCH_REASON_WINDOWING_MODE_RESIZE;
+import static com.android.server.wm.Task.ActivityState.DESTROYED;
import static com.android.server.wm.Task.ActivityState.DESTROYING;
import static com.android.server.wm.Task.ActivityState.FINISHING;
import static com.android.server.wm.Task.ActivityState.PAUSING;
@@ -1204,6 +1205,9 @@
// See {@link ActivityStack#destroyActivityLocked}.
activity.app = null;
overlayActivity.app = null;
+ // Simulate the process is dead
+ activity.mVisibleRequested = false;
+ activity.setState(DESTROYED, "Test");
assertEquals(2, task.getChildCount());
diff --git a/services/usage/java/com/android/server/usage/StorageStatsManagerInternal.java b/services/usage/java/com/android/server/usage/StorageStatsManagerInternal.java
deleted file mode 100644
index 47760ef..0000000
--- a/services/usage/java/com/android/server/usage/StorageStatsManagerInternal.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2020 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.usage;
-
-import android.annotation.NonNull;
-import android.annotation.UserIdInt;
-import android.content.pm.PackageStats;
-
-/**
- * StorageStatsManager local system service interface.
- *
- * Only for use within the system server.
- */
-public abstract class StorageStatsManagerInternal {
- /**
- * Class used to augment {@link PackageStats} with the data stored by the system on
- * behalf of apps in system specific directories
- * ({@link android.os.Environment#getDataSystemDirectory},
- * {@link android.os.Environment#getDataSystemCeDirectory}, etc).
- */
- public interface StorageStatsAugmenter {
- void augmentStatsForPackage(@NonNull PackageStats stats,
- @NonNull String packageName, @UserIdInt int userId,
- boolean callerHasStatsPermission);
- void augmentStatsForUid(@NonNull PackageStats stats, int uid,
- boolean callerHasStatsPermission);
- }
-
- /**
- * Register a {@link StorageStatsAugmenter}.
- *
- * @param augmenter the {@link StorageStatsAugmenter} object to be registered.
- * @param tag the identifier to be used for debugging in logs/trace.
- */
- public abstract void registerStorageStatsAugmenter(@NonNull StorageStatsAugmenter augmenter,
- @NonNull String tag);
-}
diff --git a/services/usage/java/com/android/server/usage/StorageStatsManagerLocal.java b/services/usage/java/com/android/server/usage/StorageStatsManagerLocal.java
new file mode 100644
index 0000000..7cac820
--- /dev/null
+++ b/services/usage/java/com/android/server/usage/StorageStatsManagerLocal.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2021 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.usage;
+
+import android.annotation.NonNull;
+import android.annotation.SystemApi;
+import android.content.pm.PackageStats;
+import android.os.UserHandle;
+
+/**
+ * StorageStatsManager local system service interface.
+ *
+ * @hide Only for use within the system server.
+ */
+@SystemApi(client = SystemApi.Client.SYSTEM_SERVER)
+public interface StorageStatsManagerLocal {
+ /**
+ * Class used to augment {@link PackageStats} with the data stored by the system on
+ * behalf of apps in system specific directories
+ * ({@link android.os.Environment#getDataSystemDirectory},
+ * {@link android.os.Environment#getDataSystemCeDirectory}, etc).
+ */
+ interface StorageStatsAugmenter {
+ /**
+ * Augments {@link PackageStats} with data stored by the system for the given package.
+ *
+ * @param stats Structure to modify with usage data
+ * @param packageName Package name of the app whose data is stored by the
+ * system and needs to be added to {@code stats}.
+ * @param userHandle Device user for which usage stats are being requested.
+ * @param canCallerAccessAllStats Whether the caller who is requesting the storage stats
+ * can query stats for packages other than itself. For
+ * example, holding the PACKAGE_USAGE_STATS permission is one
+ * way to accomplish this.
+ */
+ void augmentStatsForPackageForUser(
+ @NonNull PackageStats stats,
+ @NonNull String packageName,
+ @NonNull UserHandle userHandle,
+ boolean canCallerAccessAllStats);
+
+ /**
+ * Augments {@link PackageStats} with data stored by the system for the given uid.
+ *
+ * @param stats Structure to modify with usage data
+ * @param uid Unique app ID for the app instance whose stats are being
+ * requested.
+ * @param canCallerAccessAllStats Whether the caller who is requesting the storage stats
+ * can query stats for packages other than itself. For
+ * example, holding the PACKAGE_USAGE_STATS permission is one
+ * way to accomplish this.
+ */
+ void augmentStatsForUid(
+ @NonNull PackageStats stats, int uid, boolean canCallerAccessAllStats);
+
+ /**
+ * Augments {@link PackageStats} with data stored by the system for the given device user.
+ *
+ * @param stats Structure to modify with usage data
+ * @param userHandle Device user whose data is stored by the system and needs to be added to
+ * {@code stats}.
+ */
+ void augmentStatsForUser(@NonNull PackageStats stats, @NonNull UserHandle userHandle);
+ }
+
+ /**
+ * Register a {@link StorageStatsAugmenter}.
+ *
+ * @param augmenter the {@link StorageStatsAugmenter} object to be registered.
+ * @param tag the identifier to be used for debugging in logs/trace.
+ */
+ void registerStorageStatsAugmenter(
+ @NonNull StorageStatsAugmenter augmenter, @NonNull String tag);
+}
diff --git a/services/usage/java/com/android/server/usage/StorageStatsService.java b/services/usage/java/com/android/server/usage/StorageStatsService.java
index a0a3909..b056de0 100644
--- a/services/usage/java/com/android/server/usage/StorageStatsService.java
+++ b/services/usage/java/com/android/server/usage/StorageStatsService.java
@@ -20,7 +20,7 @@
import static com.android.internal.util.ArrayUtils.defeatNullable;
import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;
-import static com.android.server.usage.StorageStatsManagerInternal.StorageStatsAugmenter;
+import static com.android.server.usage.StorageStatsManagerLocal.StorageStatsAugmenter;
import android.Manifest;
import android.annotation.NonNull;
@@ -71,6 +71,7 @@
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.Preconditions;
import com.android.server.IoThread;
+import com.android.server.LocalManagerRegistry;
import com.android.server.LocalServices;
import com.android.server.SystemService;
import com.android.server.pm.Installer;
@@ -152,7 +153,7 @@
}
});
- LocalServices.addService(StorageStatsManagerInternal.class, new LocalService());
+ LocalManagerRegistry.addManager(StorageStatsManagerLocal.class, new LocalService());
}
private void invalidateMounts() {
@@ -335,9 +336,10 @@
throw new ParcelableException(new IOException(e.getMessage()));
}
if (volumeUuid == StorageManager.UUID_PRIVATE_INTERNAL) {
+ UserHandle userHandle = UserHandle.of(userId);
forEachStorageStatsAugmenter((storageStatsAugmenter) -> {
- storageStatsAugmenter.augmentStatsForPackage(stats,
- packageName, userId, callerHasStatsPermission);
+ storageStatsAugmenter.augmentStatsForPackageForUser(stats,
+ packageName, userHandle, callerHasStatsPermission);
}, "queryStatsForPackage");
}
return translate(stats);
@@ -430,6 +432,12 @@
} catch (InstallerException e) {
throw new ParcelableException(new IOException(e.getMessage()));
}
+ if (volumeUuid == StorageManager.UUID_PRIVATE_INTERNAL) {
+ UserHandle userHandle = UserHandle.of(userId);
+ forEachStorageStatsAugmenter((storageStatsAugmenter) -> {
+ storageStatsAugmenter.augmentStatsForUser(stats, userHandle);
+ }, "queryStatsForUser");
+ }
return translate(stats);
}
@@ -784,7 +792,7 @@
}
}
- private class LocalService extends StorageStatsManagerInternal {
+ private class LocalService implements StorageStatsManagerLocal {
@Override
public void registerStorageStatsAugmenter(
@NonNull StorageStatsAugmenter storageStatsAugmenter,
diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl b/services/usage/java/com/android/server/usage/package-info.java
similarity index 72%
copy from apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl
copy to services/usage/java/com/android/server/usage/package-info.java
index 37ce990..0719df4 100644
--- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.aidl
+++ b/services/usage/java/com/android/server/usage/package-info.java
@@ -1,11 +1,11 @@
-/**
- * Copyright 2020, The Android Open Source Project
+/*
+ * Copyright (C) 2021 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
+ * 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,
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.app.appsearch;
-/** {@hide} */
-parcelable AppSearchResult<ValueType>;
\ No newline at end of file
+/** @hide */
+package com.android.server.usage;
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java
index d1bd159..5df3d9c 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java
@@ -612,7 +612,7 @@
options,
new IDspHotwordDetectionCallback.Stub() {
@Override
- public void onRejected(@Nullable HotwordRejectedResult result)
+ public void onRejected(HotwordRejectedResult result)
throws RemoteException {
bestEffortClose(serviceAudioSink);
bestEffortClose(serviceAudioSource);
@@ -622,7 +622,7 @@
}
@Override
- public void onDetected(@Nullable HotwordDetectedResult triggerResult)
+ public void onDetected(HotwordDetectedResult triggerResult)
throws RemoteException {
bestEffortClose(serviceAudioSink);
bestEffortClose(serviceAudioSource);
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java
index 73f1783..30403f4 100644
--- a/telecomm/java/android/telecom/Connection.java
+++ b/telecomm/java/android/telecom/Connection.java
@@ -806,6 +806,15 @@
*/
public static final String EXTRA_AUDIO_CODEC_BANDWIDTH_KHZ =
"android.telecom.extra.AUDIO_CODEC_BANDWIDTH_KHZ";
+
+ /**
+ * Boolean connection extra key used to indicate whether device to device communication is
+ * available for the current call.
+ * @hide
+ */
+ public static final String EXTRA_IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE =
+ "android.telecom.extra.IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE";
+
/**
* Connection event used to inform Telecom that it should play the on hold tone. This is used
* to play a tone when the peer puts the current call on hold. Sent to Telecom via
diff --git a/telephony/common/com/android/internal/telephony/PackageChangeReceiver.java b/telephony/common/com/android/internal/telephony/PackageChangeReceiver.java
index 0b47547..e9b7d95 100644
--- a/telephony/common/com/android/internal/telephony/PackageChangeReceiver.java
+++ b/telephony/common/com/android/internal/telephony/PackageChangeReceiver.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.telephony;
+package com.android.internal.telephony;
import android.annotation.NonNull;
import android.annotation.Nullable;
diff --git a/telephony/common/com/android/internal/telephony/SmsApplication.java b/telephony/common/com/android/internal/telephony/SmsApplication.java
index 0d6cd5a..98db291 100644
--- a/telephony/common/com/android/internal/telephony/SmsApplication.java
+++ b/telephony/common/com/android/internal/telephony/SmsApplication.java
@@ -43,7 +43,6 @@
import android.os.UserManager;
import android.provider.Telephony;
import android.provider.Telephony.Sms.Intents;
-import android.telephony.PackageChangeReceiver;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.util.SparseArray;
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 84ea42f..33a9a96 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -3473,6 +3473,21 @@
"additional_nr_advanced_bands_int_array";
/**
+ * This configuration allows the framework to control the NR advanced capable by protocol
+ * configuration options(PCO).
+ *
+ * If this config is 0, then the nr advanced capable is enabled.
+ * If this config is not 0 and PCO container with this config's address is 1, then the nr
+ * advanced capable is enabled.
+ * If this config is not 0 and PCO container with this config's address is 0, then the nr
+ * advanced capable is disabled.
+ *
+ * @hide
+ */
+ public static final String KEY_NR_ADVANCED_CAPABLE_PCO_ID_INT =
+ "nr_advanced_capable_pco_id_int";
+
+ /**
* Controls time in milliseconds until DcTracker reevaluates 5G connection state.
* @hide
*/
@@ -5436,6 +5451,7 @@
/* Default value is 1 hour. */
sDefaults.putLong(KEY_5G_WATCHDOG_TIME_MS_LONG, 3600000);
sDefaults.putIntArray(KEY_ADDITIONAL_NR_ADVANCED_BANDS_INT_ARRAY, new int[0]);
+ sDefaults.putInt(KEY_NR_ADVANCED_CAPABLE_PCO_ID_INT, 0);
sDefaults.putBoolean(KEY_UNMETERED_NR_NSA_BOOL, false);
sDefaults.putBoolean(KEY_UNMETERED_NR_NSA_MMWAVE_BOOL, false);
sDefaults.putBoolean(KEY_UNMETERED_NR_NSA_SUB6_BOOL, false);
diff --git a/test-base/Android.bp b/test-base/Android.bp
index 9bd639b..b58aa11 100644
--- a/test-base/Android.bp
+++ b/test-base/Android.bp
@@ -32,7 +32,7 @@
java_sdk_library {
name: "android.test.base",
- srcs: ["src/**/*.java"],
+ srcs: [":android-test-base-sources"],
errorprone: {
javacflags: ["-Xep:DepAnn:ERROR"],
@@ -66,7 +66,7 @@
name: "android.test.base_static",
installable: false,
- srcs: ["src/**/*.java"],
+ srcs: [":android-test-base-sources"],
errorprone: {
javacflags: ["-Xep:DepAnn:ERROR"],
@@ -114,6 +114,12 @@
],
}
+filegroup {
+ name: "android-test-base-sources",
+ srcs: ["src/**/*.java"],
+ path: "src",
+}
+
// Make the current.txt available for use by the cts/tests/signature tests.
// ========================================================================
filegroup {
diff --git a/test-mock/Android.bp b/test-mock/Android.bp
index b83bce6..107292c 100644
--- a/test-mock/Android.bp
+++ b/test-mock/Android.bp
@@ -29,7 +29,7 @@
name: "android.test.mock",
srcs: [
- "src/**/*.java",
+ ":android-test-mock-sources",
// Note: Below are NOT APIs of this library. We only take APIs under
// the android.test.mock package. They however provide private APIs that
// android.test.mock APIs references to.
@@ -61,3 +61,9 @@
"api/current.txt",
],
}
+
+filegroup {
+ name: "android-test-mock-sources",
+ srcs: ["src/**/*.java"],
+ path: "src",
+}
diff --git a/test-runner/Android.bp b/test-runner/Android.bp
index fe007e39..c380ae3 100644
--- a/test-runner/Android.bp
+++ b/test-runner/Android.bp
@@ -29,7 +29,7 @@
java_sdk_library {
name: "android.test.runner",
- srcs: ["src/**/*.java"],
+ srcs: [":android-test-runner-sources"],
errorprone: {
javacflags: ["-Xep:DepAnn:ERROR"],
@@ -76,7 +76,7 @@
java_library_static {
name: "repackaged.android.test.runner",
- srcs: ["src/**/*.java"],
+ srcs: [":android-test-runner-sources"],
exclude_srcs: [
"src/android/test/ActivityUnitTestCase.java",
"src/android/test/ApplicationTestCase.java",
@@ -108,3 +108,9 @@
"api/current.txt",
],
}
+
+filegroup {
+ name: "android-test-runner-sources",
+ srcs: ["src/**/*.java"],
+ path: "src",
+}
diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java
index f277e94..6702869 100644
--- a/tests/net/java/com/android/server/ConnectivityServiceTest.java
+++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java
@@ -2777,8 +2777,9 @@
private void grantUsingBackgroundNetworksPermissionForUid(
final int uid, final String packageName) throws Exception {
- when(mPackageManager.getPackageInfo(eq(packageName), eq(GET_PERMISSIONS)))
- .thenReturn(buildPackageInfo(true, uid));
+ when(mPackageManager.getPackageInfo(
+ eq(packageName), eq(GET_PERMISSIONS | MATCH_ANY_USER)))
+ .thenReturn(buildPackageInfo(true /* hasSystemPermission */, uid));
mService.mPermissionMonitor.onPackageAdded(packageName, uid);
}
diff --git a/tests/net/java/com/android/server/connectivity/PermissionMonitorTest.java b/tests/net/java/com/android/server/connectivity/PermissionMonitorTest.java
index d7535a9..02a5808 100644
--- a/tests/net/java/com/android/server/connectivity/PermissionMonitorTest.java
+++ b/tests/net/java/com/android/server/connectivity/PermissionMonitorTest.java
@@ -479,13 +479,14 @@
public void testUidFilteringDuringVpnConnectDisconnectAndUidUpdates() throws Exception {
when(mPackageManager.getInstalledPackages(eq(GET_PERMISSIONS | MATCH_ANY_USER))).thenReturn(
Arrays.asList(new PackageInfo[] {
- buildPackageInfo(/* SYSTEM */ true, SYSTEM_UID1, MOCK_USER1),
- buildPackageInfo(/* SYSTEM */ false, MOCK_UID1, MOCK_USER1),
- buildPackageInfo(/* SYSTEM */ false, MOCK_UID2, MOCK_USER1),
- buildPackageInfo(/* SYSTEM */ false, VPN_UID, MOCK_USER1)
+ buildPackageInfo(true /* hasSystemPermission */, SYSTEM_UID1, MOCK_USER1),
+ buildPackageInfo(false /* hasSystemPermission */, MOCK_UID1, MOCK_USER1),
+ buildPackageInfo(false /* hasSystemPermission */, MOCK_UID2, MOCK_USER1),
+ buildPackageInfo(false /* hasSystemPermission */, VPN_UID, MOCK_USER1)
}));
- when(mPackageManager.getPackageInfo(eq(MOCK_PACKAGE1), eq(GET_PERMISSIONS))).thenReturn(
- buildPackageInfo(false, MOCK_UID1, MOCK_USER1));
+ when(mPackageManager.getPackageInfo(eq(MOCK_PACKAGE1),
+ eq(GET_PERMISSIONS | MATCH_ANY_USER))).thenReturn(
+ buildPackageInfo(false /* hasSystemPermission */, MOCK_UID1, MOCK_USER1));
mPermissionMonitor.startMonitoring();
// Every app on user 0 except MOCK_UID2 are under VPN.
final Set<UidRange> vpnRange1 = new HashSet<>(Arrays.asList(new UidRange[] {
@@ -530,11 +531,12 @@
public void testUidFilteringDuringPackageInstallAndUninstall() throws Exception {
when(mPackageManager.getInstalledPackages(eq(GET_PERMISSIONS | MATCH_ANY_USER))).thenReturn(
Arrays.asList(new PackageInfo[] {
- buildPackageInfo(true, SYSTEM_UID1, MOCK_USER1),
- buildPackageInfo(false, VPN_UID, MOCK_USER1)
+ buildPackageInfo(true /* hasSystemPermission */, SYSTEM_UID1, MOCK_USER1),
+ buildPackageInfo(false /* hasSystemPermission */, VPN_UID, MOCK_USER1)
}));
- when(mPackageManager.getPackageInfo(eq(MOCK_PACKAGE1), eq(GET_PERMISSIONS))).thenReturn(
- buildPackageInfo(false, MOCK_UID1, MOCK_USER1));
+ when(mPackageManager.getPackageInfo(eq(MOCK_PACKAGE1),
+ eq(GET_PERMISSIONS | MATCH_ANY_USER))).thenReturn(
+ buildPackageInfo(false /* hasSystemPermission */, MOCK_UID1, MOCK_USER1));
mPermissionMonitor.startMonitoring();
final Set<UidRange> vpnRange = Collections.singleton(UidRange.createForUser(MOCK_USER1));
diff --git a/tests/vcn/java/android/net/vcn/VcnGatewayConnectionConfigTest.java b/tests/vcn/java/android/net/vcn/VcnGatewayConnectionConfigTest.java
index 9410886..c59dcf8 100644
--- a/tests/vcn/java/android/net/vcn/VcnGatewayConnectionConfigTest.java
+++ b/tests/vcn/java/android/net/vcn/VcnGatewayConnectionConfigTest.java
@@ -16,13 +16,17 @@
package android.net.vcn;
+import static android.net.ipsec.ike.IkeSessionParams.IKE_OPTION_MOBIKE;
+
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import android.net.NetworkCapabilities;
+import android.net.ipsec.ike.IkeSessionParams;
import android.net.ipsec.ike.IkeTunnelConnectionParams;
+import android.net.vcn.persistablebundleutils.IkeSessionParamsUtilsTest;
import android.net.vcn.persistablebundleutils.TunnelConnectionParamsUtilsTest;
import androidx.test.filters.SmallTest;
@@ -120,6 +124,21 @@
}
@Test
+ public void testBuilderRequiresMobikeEnabled() {
+ try {
+ final IkeSessionParams ikeParams =
+ IkeSessionParamsUtilsTest.createBuilderMinimum()
+ .removeIkeOption(IKE_OPTION_MOBIKE)
+ .build();
+ final IkeTunnelConnectionParams tunnelParams =
+ TunnelConnectionParamsUtilsTest.buildTestParams(ikeParams);
+ new VcnGatewayConnectionConfig.Builder(GATEWAY_CONNECTION_NAME_PREFIX, tunnelParams);
+ fail("Expected exception due to MOBIKE not enabled");
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ @Test
public void testBuilderRequiresNonEmptyExposedCaps() {
try {
newBuilder()
diff --git a/tests/vcn/java/android/net/vcn/persistablebundleutils/IkeSessionParamsUtilsTest.java b/tests/vcn/java/android/net/vcn/persistablebundleutils/IkeSessionParamsUtilsTest.java
index 393787f..f385113 100644
--- a/tests/vcn/java/android/net/vcn/persistablebundleutils/IkeSessionParamsUtilsTest.java
+++ b/tests/vcn/java/android/net/vcn/persistablebundleutils/IkeSessionParamsUtilsTest.java
@@ -52,8 +52,8 @@
@RunWith(AndroidJUnit4.class)
@SmallTest
public class IkeSessionParamsUtilsTest {
- // Package private for use in EncryptedTunnelParamsUtilsTest
- static IkeSessionParams.Builder createBuilderMinimum() {
+ // Public for use in VcnGatewayConnectionConfigTest, EncryptedTunnelParamsUtilsTest
+ public static IkeSessionParams.Builder createBuilderMinimum() {
final InetAddress serverAddress = InetAddresses.parseNumericAddress("192.0.2.100");
// TODO: b/185941731 Make sure all valid IKE_OPTIONS are added and validated.
@@ -63,6 +63,7 @@
.setLocalIdentification(new IkeFqdnIdentification("client.test.android.net"))
.setRemoteIdentification(new IkeFqdnIdentification("server.test.android.net"))
.addIkeOption(IkeSessionParams.IKE_OPTION_FORCE_PORT_4500)
+ .addIkeOption(IkeSessionParams.IKE_OPTION_MOBIKE)
.setAuthPsk("psk".getBytes());
}
diff --git a/tests/vcn/java/android/net/vcn/persistablebundleutils/TunnelConnectionParamsUtilsTest.java b/tests/vcn/java/android/net/vcn/persistablebundleutils/TunnelConnectionParamsUtilsTest.java
index 0c8ad32..f9dc9eb 100644
--- a/tests/vcn/java/android/net/vcn/persistablebundleutils/TunnelConnectionParamsUtilsTest.java
+++ b/tests/vcn/java/android/net/vcn/persistablebundleutils/TunnelConnectionParamsUtilsTest.java
@@ -18,6 +18,7 @@
import static org.junit.Assert.assertEquals;
+import android.net.ipsec.ike.IkeSessionParams;
import android.net.ipsec.ike.IkeTunnelConnectionParams;
import androidx.test.filters.SmallTest;
@@ -31,9 +32,13 @@
public class TunnelConnectionParamsUtilsTest {
// Public for use in VcnGatewayConnectionConfigTest
public static IkeTunnelConnectionParams buildTestParams() {
+ return buildTestParams(IkeSessionParamsUtilsTest.createBuilderMinimum().build());
+ }
+
+ // Public for use in VcnGatewayConnectionConfigTest
+ public static IkeTunnelConnectionParams buildTestParams(IkeSessionParams params) {
return new IkeTunnelConnectionParams(
- IkeSessionParamsUtilsTest.createBuilderMinimum().build(),
- TunnelModeChildSessionParamsUtilsTest.createBuilderMinimum().build());
+ params, TunnelModeChildSessionParamsUtilsTest.createBuilderMinimum().build());
}
@Test
diff --git a/tests/vcn/java/com/android/server/VcnManagementServiceTest.java b/tests/vcn/java/com/android/server/VcnManagementServiceTest.java
index 9ecd82f..3360d40 100644
--- a/tests/vcn/java/com/android/server/VcnManagementServiceTest.java
+++ b/tests/vcn/java/com/android/server/VcnManagementServiceTest.java
@@ -37,6 +37,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
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 static org.mockito.Mockito.CALLS_REAL_METHODS;
@@ -66,6 +67,7 @@
import android.net.vcn.IVcnUnderlyingNetworkPolicyListener;
import android.net.vcn.VcnConfig;
import android.net.vcn.VcnConfigTest;
+import android.net.vcn.VcnGatewayConnectionConfigTest;
import android.net.vcn.VcnManager;
import android.net.vcn.VcnUnderlyingNetworkPolicy;
import android.os.IBinder;
@@ -197,7 +199,8 @@
.newVcnContext(
eq(mMockContext),
eq(mTestLooper.getLooper()),
- any(VcnNetworkProvider.class));
+ any(VcnNetworkProvider.class),
+ anyBoolean());
doReturn(mSubscriptionTracker)
.when(mMockDeps)
.newTelephonySubscriptionTracker(
@@ -371,6 +374,12 @@
TelephonySubscriptionSnapshot snapshot =
triggerSubscriptionTrackerCbAndGetSnapshot(Collections.singleton(TEST_UUID_1));
verify(mMockDeps)
+ .newVcnContext(
+ eq(mMockContext),
+ eq(mTestLooper.getLooper()),
+ any(VcnNetworkProvider.class),
+ anyBoolean());
+ verify(mMockDeps)
.newVcn(eq(mVcnContext), eq(TEST_UUID_1), eq(TEST_VCN_CONFIG), eq(snapshot), any());
}
@@ -528,6 +537,28 @@
}
@Test
+ public void testSetVcnConfigTestModeRequiresPermission() throws Exception {
+ doThrow(new SecurityException("Requires MANAGE_TEST_NETWORKS"))
+ .when(mMockContext)
+ .enforceCallingPermission(
+ eq(android.Manifest.permission.MANAGE_TEST_NETWORKS), any());
+
+ final VcnConfig vcnConfig =
+ new VcnConfig.Builder(mMockContext)
+ .addGatewayConnectionConfig(
+ VcnGatewayConnectionConfigTest.buildTestConfig())
+ .setIsTestModeProfile()
+ .build();
+
+ try {
+ mVcnMgmtSvc.setVcnConfig(TEST_UUID_2, vcnConfig, TEST_PACKAGE_NAME);
+ fail("Expected exception due to using test-mode without permission");
+ } catch (SecurityException e) {
+ verify(mMockPolicyListener, never()).onPolicyChanged();
+ }
+ }
+
+ @Test
public void testSetVcnConfigNotifiesStatusCallback() throws Exception {
triggerSubscriptionTrackerCbAndGetSnapshot(Collections.singleton(TEST_UUID_2));
diff --git a/tests/vcn/java/com/android/server/vcn/UnderlyingNetworkTrackerTest.java b/tests/vcn/java/com/android/server/vcn/UnderlyingNetworkTrackerTest.java
index 8289e85..6f63c4b 100644
--- a/tests/vcn/java/com/android/server/vcn/UnderlyingNetworkTrackerTest.java
+++ b/tests/vcn/java/com/android/server/vcn/UnderlyingNetworkTrackerTest.java
@@ -26,6 +26,7 @@
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -112,8 +113,14 @@
MockitoAnnotations.initMocks(this);
mTestLooper = new TestLooper();
- mVcnContext = spy(new VcnContext(mContext, mTestLooper.getLooper(), mVcnNetworkProvider));
- doNothing().when(mVcnContext).ensureRunningOnLooperThread();
+ mVcnContext =
+ spy(
+ new VcnContext(
+ mContext,
+ mTestLooper.getLooper(),
+ mVcnNetworkProvider,
+ false /* isInTestMode */));
+ resetVcnContext();
setupSystemService(
mContext,
@@ -132,6 +139,11 @@
mNetworkTrackerCb);
}
+ private void resetVcnContext() {
+ reset(mVcnContext);
+ doNothing().when(mVcnContext).ensureRunningOnLooperThread();
+ }
+
private static LinkProperties getLinkPropertiesWithName(String iface) {
LinkProperties linkProperties = new LinkProperties();
linkProperties.setInterfaceName(iface);
@@ -149,7 +161,29 @@
verifyNetworkRequestsRegistered(INITIAL_SUB_IDS);
}
+ @Test
+ public void testNetworkCallbacksRegisteredOnStartupForTestMode() {
+ resetVcnContext();
+ when(mVcnContext.isInTestMode()).thenReturn(true);
+ reset(mConnectivityManager);
+
+ mUnderlyingNetworkTracker =
+ new UnderlyingNetworkTracker(
+ mVcnContext,
+ SUB_GROUP,
+ mSubscriptionSnapshot,
+ Collections.singleton(NetworkCapabilities.NET_CAPABILITY_INTERNET),
+ mNetworkTrackerCb);
+
+ verifyNetworkRequestsRegistered(INITIAL_SUB_IDS, true /* expectTestMode */);
+ }
+
private void verifyNetworkRequestsRegistered(Set<Integer> expectedSubIds) {
+ verifyNetworkRequestsRegistered(expectedSubIds, false /* expectTestMode */);
+ }
+
+ private void verifyNetworkRequestsRegistered(
+ Set<Integer> expectedSubIds, boolean expectTestMode) {
verify(mConnectivityManager)
.requestBackgroundNetwork(
eq(getWifiRequest(expectedSubIds)),
@@ -162,10 +196,16 @@
any(NetworkBringupCallback.class), any());
}
+ final NetworkRequest expectedRouteSelectionRequest =
+ expectTestMode
+ ? getTestNetworkRequest(expectedSubIds)
+ : getRouteSelectionRequest(expectedSubIds);
+
verify(mConnectivityManager)
.requestBackgroundNetwork(
- eq(getRouteSelectionRequest(expectedSubIds)),
- any(RouteSelectionCallback.class), any());
+ eq(expectedRouteSelectionRequest),
+ any(RouteSelectionCallback.class),
+ any());
}
@Test
@@ -204,6 +244,15 @@
return getExpectedRequestBase().setSubscriptionIds(netCapsSubIds).build();
}
+ private NetworkRequest getTestNetworkRequest(Set<Integer> netCapsSubIds) {
+ return getExpectedRequestBase()
+ .addTransportType(NetworkCapabilities.TRANSPORT_TEST)
+ .removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
+ .removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
+ .setSubscriptionIds(netCapsSubIds)
+ .build();
+ }
+
private NetworkRequest.Builder getExpectedRequestBase() {
final NetworkRequest.Builder builder =
new NetworkRequest.Builder()
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index f2c3b86..812e208 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -1121,8 +1121,8 @@
// Skip all "uses-sdk" tags besides the very last tag. The android runtime only uses
// the attribute values from the last defined tag.
- for (size_t i = 0; i < usesSdkTagPositions.size() - 1; i++) {
- tagsToSkip.emplace_back(usesSdkTagPositions[i]);
+ for (size_t i = 1; i < usesSdkTagPositions.size(); i++) {
+ tagsToSkip.emplace_back(usesSdkTagPositions[i - 1]);
}
// Reset the position before parsing.
diff --git a/tools/aapt2/Debug.cpp b/tools/aapt2/Debug.cpp
index 77c0872..ef3a62f 100644
--- a/tools/aapt2/Debug.cpp
+++ b/tools/aapt2/Debug.cpp
@@ -278,17 +278,19 @@
printer->Println(StringPrintf(" entryCount=%zd", type.entries.size()));
printer->Indent();
- for (const ResourceEntry* entry : type.entries) {
+ for (const ResourceTableEntryView& entry : type.entries) {
printer->Print("resource ");
- printer->Print(entry->id.value_or_default(0).to_string());
+ printer->Print(ResourceId(package.id.value_or_default(0), type.id.value_or_default(0),
+ entry.id.value_or_default(0))
+ .to_string());
printer->Print(" ");
// Write the name without the package (this is obvious and too verbose).
printer->Print(to_string(type.type));
printer->Print("/");
- printer->Print(entry->name);
+ printer->Print(entry.name);
- switch (entry->visibility.level) {
+ switch (entry.visibility.level) {
case Visibility::Level::kPublic:
printer->Print(" PUBLIC");
break;
@@ -300,19 +302,24 @@
break;
}
- if (entry->visibility.staged_api) {
+ if (entry.visibility.staged_api) {
printer->Print(" STAGED");
}
- if (entry->overlayable_item) {
+ if (entry.overlayable_item) {
printer->Print(" OVERLAYABLE");
}
+ if (entry.staged_id) {
+ printer->Print(" STAGED_ID=");
+ printer->Print(entry.staged_id.value().id.to_string());
+ }
+
printer->Println();
if (options.show_values) {
printer->Indent();
- for (const auto& value : entry->values) {
+ for (const auto& value : entry.values) {
printer->Print("(");
printer->Print(value->config.to_string());
printer->Print(") ");
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp
index 1efabbb..f1e2da9 100644
--- a/tools/aapt2/ResourceParser.cpp
+++ b/tools/aapt2/ResourceParser.cpp
@@ -45,6 +45,7 @@
namespace {
constexpr const char* kPublicGroupTag = "public-group";
constexpr const char* kStagingPublicGroupTag = "staging-public-group";
+constexpr const char* kStagingPublicGroupFinalTag = "staging-public-group-final";
} // namespace
constexpr const char* sXliffNamespaceUri = "urn:oasis:names:tc:xliff:document:1.2";
@@ -109,6 +110,7 @@
bool staged_api = false;
bool allow_new = false;
Maybe<OverlayableItem> overlayable_item;
+ Maybe<StagedId> staged_alias;
std::string comment;
std::unique_ptr<Value> value;
@@ -155,6 +157,10 @@
res_builder.SetValue(std::move(res->value), res->config, res->product);
}
+ if (res->staged_alias) {
+ res_builder.SetStagedId(res->staged_alias.value());
+ }
+
bool error = false;
if (!res->name.entry.empty()) {
if (!table->AddResource(res_builder.Build(), diag)) {
@@ -532,6 +538,7 @@
{"public", std::mem_fn(&ResourceParser::ParsePublic)},
{"public-group", std::mem_fn(&ResourceParser::ParsePublicGroup)},
{"staging-public-group", std::mem_fn(&ResourceParser::ParseStagingPublicGroup)},
+ {"staging-public-group-final", std::mem_fn(&ResourceParser::ParseStagingPublicGroupFinal)},
{"string-array", std::mem_fn(&ResourceParser::ParseStringArray)},
{"style", std::bind(&ResourceParser::ParseStyle, std::placeholders::_1, ResourceType::kStyle,
std::placeholders::_2, std::placeholders::_3)},
@@ -671,7 +678,7 @@
if (bag_iter != elToBagMap.end()) {
// Ensure we have a name (unless this is a <public-group> or <overlayable>).
if (resource_type != kPublicGroupTag && resource_type != kStagingPublicGroupTag &&
- resource_type != "overlayable") {
+ resource_type != kStagingPublicGroupFinalTag && resource_type != "overlayable") {
if (!maybe_name) {
diag_->Error(DiagMessage(out_resource->source)
<< "<" << parser->element_name() << "> missing 'name' attribute");
@@ -1034,7 +1041,6 @@
ParsedResource& entry_res = out_resource->child_resources.emplace_back(ParsedResource{
.name = ResourceName{{}, *parsed_type, maybe_name.value().to_string()},
.source = item_source,
- .id = next_id,
.comment = std::move(comment),
});
@@ -1060,6 +1066,14 @@
});
}
+bool ResourceParser::ParseStagingPublicGroupFinal(xml::XmlPullParser* parser,
+ ParsedResource* out_resource) {
+ return ParseGroupImpl(parser, out_resource, kStagingPublicGroupFinalTag, diag_,
+ [](ParsedResource& parsed_entry, ResourceId id) {
+ parsed_entry.staged_alias = StagedId{id, parsed_entry.source};
+ });
+}
+
bool ResourceParser::ParsePublicGroup(xml::XmlPullParser* parser, ParsedResource* out_resource) {
if (options_.visibility) {
diag_->Error(DiagMessage(out_resource->source)
diff --git a/tools/aapt2/ResourceParser.h b/tools/aapt2/ResourceParser.h
index 5c92def..2614997 100644
--- a/tools/aapt2/ResourceParser.h
+++ b/tools/aapt2/ResourceParser.h
@@ -115,6 +115,7 @@
bool ParsePublic(xml::XmlPullParser* parser, ParsedResource* out_resource);
bool ParsePublicGroup(xml::XmlPullParser* parser, ParsedResource* out_resource);
bool ParseStagingPublicGroup(xml::XmlPullParser* parser, ParsedResource* out_resource);
+ bool ParseStagingPublicGroupFinal(xml::XmlPullParser* parser, ParsedResource* out_resource);
bool ParseSymbolImpl(xml::XmlPullParser* parser, ParsedResource* out_resource);
bool ParseSymbol(xml::XmlPullParser* parser, ParsedResource* out_resource);
bool ParseOverlayable(xml::XmlPullParser* parser, ParsedResource* out_resource);
diff --git a/tools/aapt2/ResourceTable.cpp b/tools/aapt2/ResourceTable.cpp
index 45ea654..8ab1493 100644
--- a/tools/aapt2/ResourceTable.cpp
+++ b/tools/aapt2/ResourceTable.cpp
@@ -83,6 +83,20 @@
return action(found, iter);
}
+struct ConfigKey {
+ const ConfigDescription* config;
+ const StringPiece& product;
+};
+
+template <typename T>
+bool lt_config_key_ref(const T& lhs, const ConfigKey& rhs) {
+ int cmp = lhs->config.compare(*rhs.config);
+ if (cmp == 0) {
+ cmp = StringPiece(lhs->product).compare(rhs.product);
+ }
+ return cmp < 0;
+}
+
} // namespace
ResourceTable::ResourceTable(ResourceTable::Validation validation) : validation_(validation) {
@@ -134,23 +148,10 @@
});
}
-struct ConfigKey {
- const ConfigDescription* config;
- const StringPiece& product;
-};
-
-bool lt_config_key_ref(const std::unique_ptr<ResourceConfigValue>& lhs, const ConfigKey& rhs) {
- int cmp = lhs->config.compare(*rhs.config);
- if (cmp == 0) {
- cmp = StringPiece(lhs->product).compare(rhs.product);
- }
- return cmp < 0;
-}
-
ResourceConfigValue* ResourceEntry::FindValue(const ConfigDescription& config,
android::StringPiece product) {
auto iter = std::lower_bound(values.begin(), values.end(), ConfigKey{&config, product},
- lt_config_key_ref);
+ lt_config_key_ref<std::unique_ptr<ResourceConfigValue>>);
if (iter != values.end()) {
ResourceConfigValue* value = iter->get();
if (value->config == config && StringPiece(value->product) == product) {
@@ -163,7 +164,7 @@
const ResourceConfigValue* ResourceEntry::FindValue(const android::ConfigDescription& config,
android::StringPiece product) const {
auto iter = std::lower_bound(values.begin(), values.end(), ConfigKey{&config, product},
- lt_config_key_ref);
+ lt_config_key_ref<std::unique_ptr<ResourceConfigValue>>);
if (iter != values.end()) {
ResourceConfigValue* value = iter->get();
if (value->config == config && StringPiece(value->product) == product) {
@@ -176,7 +177,7 @@
ResourceConfigValue* ResourceEntry::FindOrCreateValue(const ConfigDescription& config,
const StringPiece& product) {
auto iter = std::lower_bound(values.begin(), values.end(), ConfigKey{&config, product},
- lt_config_key_ref);
+ lt_config_key_ref<std::unique_ptr<ResourceConfigValue>>);
if (iter != values.end()) {
ResourceConfigValue* value = iter->get();
if (value->config == config && StringPiece(value->product) == product) {
@@ -296,6 +297,7 @@
return CollisionResult::kConflict;
}
+namespace {
template <typename T, typename Comparer>
struct SortedVectorInserter : public Comparer {
std::pair<bool, typename std::vector<T>::iterator> LowerBound(std::vector<T>& el,
@@ -313,7 +315,7 @@
if (found) {
return &*it;
}
- return &*el.insert(it, std::move(value));
+ return &*el.insert(it, std::forward<T>(value));
}
};
@@ -331,35 +333,77 @@
};
struct EntryViewComparer {
- bool operator()(const ResourceEntry* lhs, const ResourceEntry* rhs) {
- return less_than_struct_with_name_and_id<ResourceEntry, ResourceId>(
- *lhs, std::make_pair(rhs->name, rhs->id));
+ bool operator()(const ResourceTableEntryView& lhs, const ResourceTableEntryView& rhs) {
+ return less_than_struct_with_name_and_id<ResourceTableEntryView, uint16_t>(
+ lhs, std::make_pair(rhs.name, rhs.id));
}
};
-ResourceTableView ResourceTable::GetPartitionedView() const {
- ResourceTableView view;
+void InsertEntryIntoTableView(ResourceTableView& table, const ResourceTablePackage* package,
+ const ResourceTableType* type, const std::string& entry_name,
+ const Maybe<ResourceId>& id, const Visibility& visibility,
+ const Maybe<AllowNew>& allow_new,
+ const Maybe<OverlayableItem>& overlayable_item,
+ const Maybe<StagedId>& staged_id,
+ const std::vector<std::unique_ptr<ResourceConfigValue>>& values) {
SortedVectorInserter<ResourceTablePackageView, PackageViewComparer> package_inserter;
SortedVectorInserter<ResourceTableTypeView, TypeViewComparer> type_inserter;
- SortedVectorInserter<const ResourceEntry*, EntryViewComparer> entry_inserter;
+ SortedVectorInserter<ResourceTableEntryView, EntryViewComparer> entry_inserter;
+ ResourceTablePackageView new_package{package->name,
+ id ? id.value().package_id() : Maybe<uint8_t>{}};
+ auto view_package = package_inserter.Insert(table.packages, std::move(new_package));
+
+ ResourceTableTypeView new_type{type->type, id ? id.value().type_id() : Maybe<uint8_t>{}};
+ auto view_type = type_inserter.Insert(view_package->types, std::move(new_type));
+
+ if (visibility.level == Visibility::Level::kPublic) {
+ // Only mark the type visibility level as public, it doesn't care about being private.
+ view_type->visibility_level = Visibility::Level::kPublic;
+ }
+
+ ResourceTableEntryView new_entry{.name = entry_name,
+ .id = id ? id.value().entry_id() : Maybe<uint16_t>{},
+ .visibility = visibility,
+ .allow_new = allow_new,
+ .overlayable_item = overlayable_item,
+ .staged_id = staged_id};
+ for (auto& value : values) {
+ new_entry.values.emplace_back(value.get());
+ }
+
+ entry_inserter.Insert(view_type->entries, std::move(new_entry));
+}
+} // namespace
+
+const ResourceConfigValue* ResourceTableEntryView::FindValue(const ConfigDescription& config,
+ android::StringPiece product) const {
+ auto iter = std::lower_bound(values.begin(), values.end(), ConfigKey{&config, product},
+ lt_config_key_ref<const ResourceConfigValue*>);
+ if (iter != values.end()) {
+ const ResourceConfigValue* value = *iter;
+ if (value->config == config && StringPiece(value->product) == product) {
+ return value;
+ }
+ }
+ return nullptr;
+}
+
+ResourceTableView ResourceTable::GetPartitionedView(const ResourceTableViewOptions& options) const {
+ ResourceTableView view;
for (const auto& package : packages) {
for (const auto& type : package->types) {
for (const auto& entry : type->entries) {
- ResourceTablePackageView new_package{
- package->name, entry->id ? entry->id.value().package_id() : Maybe<uint8_t>{}};
- auto view_package = package_inserter.Insert(view.packages, std::move(new_package));
+ InsertEntryIntoTableView(view, package.get(), type.get(), entry->name, entry->id,
+ entry->visibility, entry->allow_new, entry->overlayable_item,
+ entry->staged_id, entry->values);
- ResourceTableTypeView new_type{type->type,
- entry->id ? entry->id.value().type_id() : Maybe<uint8_t>{}};
- auto view_type = type_inserter.Insert(view_package->types, std::move(new_type));
-
- if (entry->visibility.level == Visibility::Level::kPublic) {
- // Only mark the type visibility level as public, it doesn't care about being private.
- view_type->visibility_level = Visibility::Level::kPublic;
+ if (options.create_alias_entries && entry->staged_id) {
+ auto alias_id = entry->staged_id.value().id;
+ InsertEntryIntoTableView(view, package.get(), type.get(), entry->name, alias_id,
+ entry->visibility, entry->allow_new, entry->overlayable_item, {},
+ entry->values);
}
-
- entry_inserter.Insert(view_type->entries, entry.get());
}
}
}
@@ -368,6 +412,8 @@
// for the same resource type within the same package. For this reason, if there are types with
// multiple type ids, each type needs to exist in its own package in order to be queried by name.
std::vector<ResourceTablePackageView> new_packages;
+ SortedVectorInserter<ResourceTablePackageView, PackageViewComparer> package_inserter;
+ SortedVectorInserter<ResourceTableTypeView, TypeViewComparer> type_inserter;
for (auto& package : view.packages) {
// If a new package was already created for a different type within this package, then
// we can reuse those packages for other types that need to be extracted from this package.
@@ -498,6 +544,10 @@
entry->allow_new = res.allow_new.value();
}
+ if (res.staged_id.has_value()) {
+ entry->staged_id = res.staged_id.value();
+ }
+
if (res.value != nullptr) {
auto config_value = entry->FindOrCreateValue(res.config, res.product);
if (!config_value->value) {
@@ -575,6 +625,28 @@
return {};
}
+bool ResourceTable::RemoveResource(const ResourceNameRef& name, ResourceId id) const {
+ ResourceTablePackage* package = FindPackage(name.package);
+ if (package == nullptr) {
+ return {};
+ }
+
+ ResourceTableType* type = package->FindType(name.type);
+ if (type == nullptr) {
+ return {};
+ }
+
+ auto entry_it = std::equal_range(type->entries.begin(), type->entries.end(), name.entry,
+ NameEqualRange<ResourceEntry>{});
+ for (auto it = entry_it.first; it != entry_it.second; ++it) {
+ if ((*it)->id == id) {
+ type->entries.erase(it);
+ return true;
+ }
+ }
+ return false;
+}
+
std::unique_ptr<ResourceTable> ResourceTable::Clone() const {
std::unique_ptr<ResourceTable> new_table = util::make_unique<ResourceTable>();
CloningValueTransformer cloner(&new_table->string_pool);
@@ -640,6 +712,11 @@
return *this;
}
+NewResourceBuilder& NewResourceBuilder::SetStagedId(StagedId staged_alias) {
+ res_.staged_id = std::move(staged_alias);
+ return *this;
+}
+
NewResourceBuilder& NewResourceBuilder::SetAllowMangled(bool allow_mangled) {
res_.allow_mangled = allow_mangled;
return *this;
diff --git a/tools/aapt2/ResourceTable.h b/tools/aapt2/ResourceTable.h
index 080ecc2..bae1d82 100644
--- a/tools/aapt2/ResourceTable.h
+++ b/tools/aapt2/ResourceTable.h
@@ -64,6 +64,12 @@
std::string comment;
};
+// Represents the staged resource id of a finalized resource.
+struct StagedId {
+ ResourceId id;
+ Source source;
+};
+
struct Overlayable {
Overlayable() = default;
Overlayable(const android::StringPiece& name, const android::StringPiece& actor)
@@ -124,6 +130,9 @@
// The declarations of this resource as overlayable for RROs
Maybe<OverlayableItem> overlayable_item;
+ // The staged resource id for a finalized resource.
+ Maybe<StagedId> staged_id;
+
// The resource's values for each configuration.
std::vector<std::unique_ptr<ResourceConfigValue>> values;
@@ -194,14 +203,27 @@
DISALLOW_COPY_AND_ASSIGN(ResourceTablePackage);
};
+struct ResourceTableEntryView {
+ std::string name;
+ Maybe<uint16_t> id;
+ Visibility visibility;
+ Maybe<AllowNew> allow_new;
+ Maybe<OverlayableItem> overlayable_item;
+ Maybe<StagedId> staged_id;
+ std::vector<const ResourceConfigValue*> values;
+
+ const ResourceConfigValue* FindValue(const android::ConfigDescription& config,
+ android::StringPiece product = {}) const;
+};
+
struct ResourceTableTypeView {
ResourceType type;
Maybe<uint8_t> id;
Visibility::Level visibility_level = Visibility::Level::kUndefined;
// Entries sorted in ascending entry id order. If ids have not been assigned, the entries are
- // // sorted lexicographically.
- std::vector<const ResourceEntry*> entries;
+ // sorted lexicographically.
+ std::vector<ResourceTableEntryView> entries;
};
struct ResourceTablePackageView {
@@ -212,6 +234,10 @@
std::vector<ResourceTableTypeView> types;
};
+struct ResourceTableViewOptions {
+ bool create_alias_entries = false;
+};
+
struct ResourceTableView {
// Packages sorted in ascending package id order. If ids have not been assigned, the packages are
// sorted lexicographically.
@@ -237,6 +263,7 @@
std::optional<Visibility> visibility;
std::optional<OverlayableItem> overlayable;
std::optional<AllowNew> allow_new;
+ std::optional<StagedId> staged_id;
bool allow_mangled = false;
};
@@ -249,6 +276,7 @@
NewResourceBuilder& SetVisibility(Visibility id);
NewResourceBuilder& SetOverlayable(OverlayableItem overlayable);
NewResourceBuilder& SetAllowNew(AllowNew allow_new);
+ NewResourceBuilder& SetStagedId(StagedId id);
NewResourceBuilder& SetAllowMangled(bool allow_mangled);
NewResource Build();
@@ -273,7 +301,7 @@
// Retrieves a sorted a view of the packages, types, and entries sorted in ascending resource id
// order.
- ResourceTableView GetPartitionedView() const;
+ ResourceTableView GetPartitionedView(const ResourceTableViewOptions& options = {}) const;
struct SearchResult {
ResourceTablePackage* package;
@@ -283,6 +311,7 @@
Maybe<SearchResult> FindResource(const ResourceNameRef& name) const;
Maybe<SearchResult> FindResource(const ResourceNameRef& name, ResourceId id) const;
+ bool RemoveResource(const ResourceNameRef& name, ResourceId id) const;
// Returns the package struct with the given name, or nullptr if such a package does not
// exist. The empty string is a valid package and typically is used to represent the
diff --git a/tools/aapt2/Resources.proto b/tools/aapt2/Resources.proto
index b45c040..95b7949 100644
--- a/tools/aapt2/Resources.proto
+++ b/tools/aapt2/Resources.proto
@@ -190,6 +190,12 @@
uint32 overlayable_idx = 4;
}
+// The staged resource ID definition of a finalized resource.
+message StagedId {
+ Source source = 1;
+ uint32 staged_id = 2;
+}
+
// An entry ID in the range [0x0000, 0xffff].
message EntryId {
uint32 id = 1;
@@ -222,6 +228,9 @@
// The set of values defined for this entry, each corresponding to a different
// configuration/variant.
repeated ConfigValue config_value = 6;
+
+ // The staged resource ID of this finalized resource.
+ StagedId staged_id = 7;
}
// A Configuration/Value pair.
diff --git a/tools/aapt2/cmd/Diff.cpp b/tools/aapt2/cmd/Diff.cpp
index df31087..3950f33 100644
--- a/tools/aapt2/cmd/Diff.cpp
+++ b/tools/aapt2/cmd/Diff.cpp
@@ -97,15 +97,15 @@
static bool EmitResourceConfigValueDiff(
IAaptContext* context, LoadedApk* apk_a, const ResourceTablePackageView& pkg_a,
- const ResourceTableTypeView& type_a, const ResourceEntry* entry_a,
+ const ResourceTableTypeView& type_a, const ResourceTableEntryView& entry_a,
const ResourceConfigValue* config_value_a, LoadedApk* apk_b,
const ResourceTablePackageView& pkg_b, const ResourceTableTypeView& type_b,
- const ResourceEntry* entry_b, const ResourceConfigValue* config_value_b) {
+ const ResourceTableEntryView& entry_b, const ResourceConfigValue* config_value_b) {
Value* value_a = config_value_a->value.get();
Value* value_b = config_value_b->value.get();
if (!value_a->Equals(value_b)) {
std::stringstream str_stream;
- str_stream << "value " << pkg_a.name << ":" << type_a.type << "/" << entry_a->name
+ str_stream << "value " << pkg_a.name << ":" << type_a.type << "/" << entry_a.name
<< " config=" << config_value_a->config << " does not match:\n";
value_a->Print(&str_stream);
str_stream << "\n vs \n";
@@ -118,32 +118,32 @@
static bool EmitResourceEntryDiff(IAaptContext* context, LoadedApk* apk_a,
const ResourceTablePackageView& pkg_a,
- const ResourceTableTypeView& type_a, const ResourceEntry* entry_a,
- LoadedApk* apk_b, const ResourceTablePackageView& pkg_b,
+ const ResourceTableTypeView& type_a,
+ const ResourceTableEntryView& entry_a, LoadedApk* apk_b,
+ const ResourceTablePackageView& pkg_b,
const ResourceTableTypeView& type_b,
- const ResourceEntry* entry_b) {
+ const ResourceTableEntryView& entry_b) {
bool diff = false;
- for (const std::unique_ptr<ResourceConfigValue>& config_value_a : entry_a->values) {
- auto config_value_b = entry_b->FindValue(config_value_a->config);
+ for (const ResourceConfigValue* config_value_a : entry_a.values) {
+ auto config_value_b = entry_b.FindValue(config_value_a->config);
if (!config_value_b) {
std::stringstream str_stream;
- str_stream << "missing " << pkg_a.name << ":" << type_a.type << "/" << entry_a->name
+ str_stream << "missing " << pkg_a.name << ":" << type_a.type << "/" << entry_a.name
<< " config=" << config_value_a->config;
EmitDiffLine(apk_b->GetSource(), str_stream.str());
diff = true;
} else {
- diff |=
- EmitResourceConfigValueDiff(context, apk_a, pkg_a, type_a, entry_a, config_value_a.get(),
- apk_b, pkg_b, type_b, entry_b, config_value_b);
+ diff |= EmitResourceConfigValueDiff(context, apk_a, pkg_a, type_a, entry_a, config_value_a,
+ apk_b, pkg_b, type_b, entry_b, config_value_b);
}
}
// Check for any newly added config values.
- for (const std::unique_ptr<ResourceConfigValue>& config_value_b : entry_b->values) {
- auto config_value_a = entry_a->FindValue(config_value_b->config);
+ for (const ResourceConfigValue* config_value_b : entry_b.values) {
+ auto config_value_a = entry_a.FindValue(config_value_b->config);
if (!config_value_a) {
std::stringstream str_stream;
- str_stream << "new config " << pkg_b.name << ":" << type_b.type << "/" << entry_b->name
+ str_stream << "new config " << pkg_b.name << ":" << type_b.type << "/" << entry_b.name
<< " config=" << config_value_b->config;
EmitDiffLine(apk_b->GetSource(), str_stream.str());
diff = true;
@@ -164,36 +164,35 @@
if (entry_b_iter == type_b.entries.end()) {
// Type A contains a type that type B does not have.
std::stringstream str_stream;
- str_stream << "missing " << pkg_a.name << ":" << type_a.type << "/" << (*entry_a_iter)->name;
+ str_stream << "missing " << pkg_a.name << ":" << type_a.type << "/" << entry_a_iter->name;
EmitDiffLine(apk_a->GetSource(), str_stream.str());
diff = true;
} else if (entry_a_iter == type_a.entries.end()) {
// Type B contains a type that type A does not have.
std::stringstream str_stream;
- str_stream << "new entry " << pkg_b.name << ":" << type_b.type << "/"
- << (*entry_b_iter)->name;
+ str_stream << "new entry " << pkg_b.name << ":" << type_b.type << "/" << entry_b_iter->name;
EmitDiffLine(apk_b->GetSource(), str_stream.str());
diff = true;
} else {
const auto& entry_a = *entry_a_iter;
const auto& entry_b = *entry_b_iter;
- if (IsSymbolVisibilityDifferent(entry_a->visibility, entry_b->visibility)) {
+ if (IsSymbolVisibilityDifferent(entry_a.visibility, entry_b.visibility)) {
std::stringstream str_stream;
- str_stream << pkg_a.name << ":" << type_a.type << "/" << entry_a->name
+ str_stream << pkg_a.name << ":" << type_a.type << "/" << entry_a.name
<< " has different visibility (";
- if (entry_b->visibility.staged_api) {
+ if (entry_b.visibility.staged_api) {
str_stream << "STAGED ";
}
- if (entry_b->visibility.level == Visibility::Level::kPublic) {
+ if (entry_b.visibility.level == Visibility::Level::kPublic) {
str_stream << "PUBLIC";
} else {
str_stream << "PRIVATE";
}
str_stream << " vs ";
- if (entry_a->visibility.staged_api) {
+ if (entry_a.visibility.staged_api) {
str_stream << "STAGED ";
}
- if (entry_a->visibility.level == Visibility::Level::kPublic) {
+ if (entry_a.visibility.level == Visibility::Level::kPublic) {
str_stream << "PUBLIC";
} else {
str_stream << "PRIVATE";
@@ -201,19 +200,19 @@
str_stream << ")";
EmitDiffLine(apk_b->GetSource(), str_stream.str());
diff = true;
- } else if (IsIdDiff(entry_a->visibility.level, entry_a->id, entry_b->visibility.level,
- entry_b->id)) {
+ } else if (IsIdDiff(entry_a.visibility.level, entry_a.id, entry_b.visibility.level,
+ entry_b.id)) {
std::stringstream str_stream;
- str_stream << pkg_a.name << ":" << type_a.type << "/" << entry_a->name
+ str_stream << pkg_a.name << ":" << type_a.type << "/" << entry_a.name
<< " has different public ID (";
- if (entry_b->id) {
- str_stream << "0x" << std::hex << entry_b->id.value();
+ if (entry_b.id) {
+ str_stream << "0x" << std::hex << entry_b.id.value();
} else {
str_stream << "none";
}
str_stream << " vs ";
- if (entry_a->id) {
- str_stream << "0x " << std::hex << entry_a->id.value();
+ if (entry_a.id) {
+ str_stream << "0x " << std::hex << entry_a.id.value();
} else {
str_stream << "none";
}
diff --git a/tools/aapt2/cmd/Link_test.cpp b/tools/aapt2/cmd/Link_test.cpp
index 3118eb8..430c184 100644
--- a/tools/aapt2/cmd/Link_test.cpp
+++ b/tools/aapt2/cmd/Link_test.cpp
@@ -402,8 +402,39 @@
EXPECT_THAT(client_r_contents, HasSubstr(" com.example.lib.R.attr.foo, 0x7f010000"));
}
-TEST_F(LinkTest, StagedAndroidApi) {
- StdErrDiagnostics diag;
+struct SourceXML {
+ std::string res_file_path;
+ std::string file_contents;
+};
+
+static void BuildApk(const std::vector<SourceXML>& source_files, const std::string& apk_path,
+ LinkCommandBuilder&& link_args, CommandTestFixture* fixture,
+ IDiagnostics* diag) {
+ TemporaryDir res_dir;
+ TemporaryDir compiled_res_dir;
+ for (auto& source_file : source_files) {
+ ASSERT_TRUE(fixture->CompileFile(res_dir.path + source_file.res_file_path,
+ source_file.file_contents, compiled_res_dir.path, diag));
+ }
+ ASSERT_TRUE(fixture->Link(
+ link_args.AddCompiledResDir(compiled_res_dir.path, diag).Build(apk_path), diag));
+}
+
+static void BuildSDK(const std::vector<SourceXML>& source_files, const std::string& apk_path,
+ const std::string& java_root_path, CommandTestFixture* fixture,
+ IDiagnostics* diag) {
+ auto android_manifest = ManifestBuilder(fixture).SetPackageName("android").Build();
+
+ auto android_link_args = LinkCommandBuilder(fixture)
+ .SetManifestFile(android_manifest)
+ .AddParameter("--private-symbols", "com.android.internal")
+ .AddParameter("--java", java_root_path);
+
+ BuildApk(source_files, apk_path, std::move(android_link_args), fixture, diag);
+}
+
+static void BuildNonFinalizedSDK(const std::string& apk_path, const std::string& java_path,
+ CommandTestFixture* fixture, IDiagnostics* diag) {
const std::string android_values =
R"(<resources>
<public type="attr" name="finalized_res" id="0x01010001"/>
@@ -413,6 +444,10 @@
<public name="staged_s_res" />
</staging-public-group>
+ <staging-public-group type="string" first-id="0x01fd0080">
+ <public name="staged_s_string" />
+ </staging-public-group>
+
<!-- SV2 staged attributes (support staged resources in a separate type id) -->
<staging-public-group type="attr" first-id="0x01ff0049">
<public name="staged_s2_res" />
@@ -423,46 +458,90 @@
<public name="staged_t_res" />
</staging-public-group>
- <staging-public-group type="string" first-id="0x01fd0072">
- <public name="staged_t_string" />
+ <attr name="finalized_res" />
+ <attr name="staged_s_res" />
+ <attr name="staged_s2_res" />
+ <attr name="staged_t_res" />
+ <string name="staged_s_string">Hello</string>
+ </resources>)";
+
+ SourceXML source_xml{.res_file_path = "/res/values/values.xml", .file_contents = android_values};
+ BuildSDK({source_xml}, apk_path, java_path, fixture, diag);
+}
+
+static void BuildFinalizedSDK(const std::string& apk_path, const std::string& java_path,
+ CommandTestFixture* fixture, IDiagnostics* diag) {
+ const std::string android_values =
+ R"(<resources>
+ <public type="attr" name="finalized_res" id="0x01010001"/>
+ <public type="attr" name="staged_s_res" id="0x01010002"/>
+ <public type="attr" name="staged_s2_res" id="0x01010003"/>
+ <public type="string" name="staged_s_string" id="0x01020000"/>
+
+ <!-- S staged attributes (support staged resources in the same type id) -->
+ <staging-public-group-final type="attr" first-id="0x01010050">
+ <public name="staged_s_res" />
+ </staging-public-group-final>
+
+ <staging-public-group-final type="string" first-id="0x01fd0080">
+ <public name="staged_s_string" />
+ </staging-public-group-final>
+
+ <!-- SV2 staged attributes (support staged resources in a separate type id) -->
+ <staging-public-group-final type="attr" first-id="0x01ff0049">
+ <public name="staged_s2_res" />
+ </staging-public-group-final>
+
+ <!-- T staged attributes (support staged resources in multiple separate type ids) -->
+ <staging-public-group type="attr" first-id="0x01fe0063">
+ <public name="staged_t_res" />
</staging-public-group>
<attr name="finalized_res" />
<attr name="staged_s_res" />
<attr name="staged_s2_res" />
<attr name="staged_t_res" />
- <string name="staged_t_string">Hello</string>
+ <string name="staged_s_string">Hello</string>
</resources>)";
+ SourceXML source_xml{.res_file_path = "/res/values/values.xml", .file_contents = android_values};
+ BuildSDK({source_xml}, apk_path, java_path, fixture, diag);
+}
+
+static void BuildAppAgainstSDK(const std::string& apk_path, const std::string& java_path,
+ const std::string& sdk_path, CommandTestFixture* fixture,
+ IDiagnostics* diag) {
const std::string app_values =
R"(<resources xmlns:android="http://schemas.android.com/apk/res/android">
<attr name="bar" />
+ <style name="MyStyle">
+ <item name="android:staged_s_res">@android:string/staged_s_string</item>
+ </style>
<declare-styleable name="ClientStyleable">
<attr name="android:finalized_res" />
<attr name="android:staged_s_res" />
<attr name="bar" />
</declare-styleable>
+ <public name="MyStyle" type="style" id="0x7f020000" />
</resources>)";
- const std::string android_res = GetTestPath("android-res");
- ASSERT_TRUE(
- CompileFile(GetTestPath("res/values/values.xml"), android_values, android_res, &diag));
+ SourceXML source_xml{.res_file_path = "/res/values/values.xml", .file_contents = app_values};
+ auto app_manifest = ManifestBuilder(fixture).SetPackageName("com.example.app").Build();
+
+ auto app_link_args = LinkCommandBuilder(fixture)
+ .SetManifestFile(app_manifest)
+ .AddParameter("--java", java_path)
+ .AddParameter("-I", sdk_path);
+
+ BuildApk({source_xml}, apk_path, std::move(app_link_args), fixture, diag);
+}
+
+TEST_F(LinkTest, StagedAndroidApi) {
+ StdErrDiagnostics diag;
const std::string android_apk = GetTestPath("android.apk");
- const std::string android_java = GetTestPath("android_java");
- // clang-format off
- auto android_manifest = ManifestBuilder(this)
- .SetPackageName("android")
- .Build();
-
- auto android_link_args = LinkCommandBuilder(this)
- .SetManifestFile(android_manifest)
- .AddParameter("--private-symbols", "com.android.internal")
- .AddParameter("--java", android_java)
- .AddCompiledResDir(android_res, &diag)
- .Build(android_apk);
- // clang-format on
- ASSERT_TRUE(Link(android_link_args, &diag));
+ const std::string android_java = GetTestPath("android-java");
+ BuildNonFinalizedSDK(android_apk, android_java, this, &diag);
const std::string android_r_java = android_java + "/android/R.java";
std::string android_r_contents;
@@ -473,33 +552,17 @@
HasSubstr("public static final int staged_s_res; static { staged_s_res=0x01010050; }"));
EXPECT_THAT(
android_r_contents,
+ HasSubstr("public static final int staged_s_string; static { staged_s_string=0x01fd0080; }"));
+ EXPECT_THAT(
+ android_r_contents,
HasSubstr("public static final int staged_s2_res; static { staged_s2_res=0x01ff0049; }"));
EXPECT_THAT(
android_r_contents,
HasSubstr("public static final int staged_t_res; static { staged_t_res=0x01fe0063; }"));
- EXPECT_THAT(
- android_r_contents,
- HasSubstr("public static final int staged_t_string; static { staged_t_string=0x01fd0072; }"));
-
- // Build an app that uses the framework attribute in a declare-styleable
- const std::string client_res = GetTestPath("app-res");
- ASSERT_TRUE(CompileFile(GetTestPath("res/values/values.xml"), app_values, client_res, &diag));
const std::string app_apk = GetTestPath("app.apk");
- const std::string app_java = GetTestPath("app_java");
- // clang-format off
- auto app_manifest = ManifestBuilder(this)
- .SetPackageName("com.example.app")
- .Build();
-
- auto app_link_args = LinkCommandBuilder(this)
- .SetManifestFile(app_manifest)
- .AddParameter("--java", app_java)
- .AddParameter("-I", android_apk)
- .AddCompiledResDir(client_res, &diag)
- .Build(app_apk);
- // clang-format on
- ASSERT_TRUE(Link(app_link_args, &diag));
+ const std::string app_java = GetTestPath("app-java");
+ BuildAppAgainstSDK(app_apk, app_java, android_apk, this, &diag);
const std::string client_r_java = app_java + "/com/example/app/R.java";
std::string client_r_contents;
@@ -520,6 +583,10 @@
ASSERT_TRUE(result.has_value());
EXPECT_THAT(*result, Eq(0x01010050));
+ result = am.GetResourceId("android:string/staged_s_string");
+ ASSERT_TRUE(result.has_value());
+ EXPECT_THAT(*result, Eq(0x01fd0080));
+
result = am.GetResourceId("android:attr/staged_s2_res");
ASSERT_TRUE(result.has_value());
EXPECT_THAT(*result, Eq(0x01ff0049));
@@ -527,10 +594,88 @@
result = am.GetResourceId("android:attr/staged_t_res");
ASSERT_TRUE(result.has_value());
EXPECT_THAT(*result, Eq(0x01fe0063));
+}
- result = am.GetResourceId("android:string/staged_t_string");
+TEST_F(LinkTest, FinalizedAndroidApi) {
+ StdErrDiagnostics diag;
+ const std::string android_apk = GetTestPath("android.apk");
+ const std::string android_java = GetTestPath("android-java");
+ BuildFinalizedSDK(android_apk, android_java, this, &diag);
+
+ const std::string android_r_java = android_java + "/android/R.java";
+ std::string android_r_contents;
+ ASSERT_TRUE(android::base::ReadFileToString(android_r_java, &android_r_contents));
+ EXPECT_THAT(android_r_contents, HasSubstr("public static final int finalized_res=0x01010001;"));
+ EXPECT_THAT(android_r_contents, HasSubstr("public static final int staged_s_res=0x01010002;"));
+ EXPECT_THAT(android_r_contents, HasSubstr("public static final int staged_s_string=0x01020000;"));
+ EXPECT_THAT(android_r_contents, HasSubstr("public static final int staged_s2_res=0x01010003;"));
+ EXPECT_THAT(
+ android_r_contents,
+ HasSubstr("public static final int staged_t_res; static { staged_t_res=0x01fe0063; }"));
+ ;
+
+ // Build an application against the non-finalized SDK and then load it into an AssetManager with
+ // the finalized SDK.
+ const std::string non_finalized_android_apk = GetTestPath("non-finalized-android.apk");
+ const std::string non_finalized_android_java = GetTestPath("non-finalized-android-java");
+ BuildNonFinalizedSDK(non_finalized_android_apk, non_finalized_android_java, this, &diag);
+
+ const std::string app_apk = GetTestPath("app.apk");
+ const std::string app_java = GetTestPath("app-java");
+ BuildAppAgainstSDK(app_apk, app_java, non_finalized_android_apk, this, &diag);
+
+ android::AssetManager2 am;
+ auto android_asset = android::ApkAssets::Load(android_apk);
+ auto app_against_non_final = android::ApkAssets::Load(app_apk);
+ ASSERT_THAT(android_asset, NotNull());
+ ASSERT_THAT(app_against_non_final, NotNull());
+ ASSERT_TRUE(am.SetApkAssets({android_asset.get(), app_against_non_final.get()}));
+
+ auto result = am.GetResourceId("android:attr/finalized_res");
ASSERT_TRUE(result.has_value());
- EXPECT_THAT(*result, Eq(0x01fd0072));
+ EXPECT_THAT(*result, Eq(0x01010001));
+
+ result = am.GetResourceId("android:attr/staged_s_res");
+ ASSERT_TRUE(result.has_value());
+ EXPECT_THAT(*result, Eq(0x01010002));
+
+ result = am.GetResourceId("android:string/staged_s_string");
+ ASSERT_TRUE(result.has_value());
+ EXPECT_THAT(*result, Eq(0x01020000));
+
+ result = am.GetResourceId("android:attr/staged_s2_res");
+ ASSERT_TRUE(result.has_value());
+ EXPECT_THAT(*result, Eq(0x01010003));
+
+ {
+ auto style = am.GetBag(0x7f020000);
+ ASSERT_TRUE(style.has_value());
+
+ auto& entry = (*style)->entries[0];
+ EXPECT_THAT(entry.key, Eq(0x01010002));
+ EXPECT_THAT(entry.value.dataType, Eq(android::Res_value::TYPE_REFERENCE));
+ EXPECT_THAT(entry.value.data, Eq(0x01020000));
+ }
+
+ // Re-compile the application against the finalized SDK and then load it into an AssetManager with
+ // the finalized SDK.
+ const std::string app_apk_respin = GetTestPath("app-respin.apk");
+ const std::string app_java_respin = GetTestPath("app-respin-java");
+ BuildAppAgainstSDK(app_apk_respin, app_java_respin, android_apk, this, &diag);
+
+ auto app_against_final = android::ApkAssets::Load(app_apk_respin);
+ ASSERT_THAT(app_against_final, NotNull());
+ ASSERT_TRUE(am.SetApkAssets({android_asset.get(), app_against_final.get()}));
+
+ {
+ auto style = am.GetBag(0x7f020000);
+ ASSERT_TRUE(style.has_value());
+
+ auto& entry = (*style)->entries[0];
+ EXPECT_THAT(entry.key, Eq(0x01010002));
+ EXPECT_THAT(entry.value.dataType, Eq(android::Res_value::TYPE_REFERENCE));
+ EXPECT_THAT(entry.value.data, Eq(0x01020000));
+ }
}
TEST_F(LinkTest, MacroSubstitution) {
diff --git a/tools/aapt2/compile/IdAssigner.cpp b/tools/aapt2/compile/IdAssigner.cpp
index 9a50b26..339b8af 100644
--- a/tools/aapt2/compile/IdAssigner.cpp
+++ b/tools/aapt2/compile/IdAssigner.cpp
@@ -129,11 +129,16 @@
for (auto& type : package->types) {
for (auto& entry : type->entries) {
const ResourceName name(package->name, type->type, entry->name);
- if (entry->id) {
- if (!assigned_ids.ReserveId(name, entry->id.value(), entry->visibility,
- context->GetDiagnostics())) {
- return false;
- }
+ if (entry->id && !assigned_ids.ReserveId(name, entry->id.value(), entry->visibility,
+ context->GetDiagnostics())) {
+ return false;
+ }
+
+ auto v = entry->visibility;
+ v.staged_api = true;
+ if (entry->staged_id && !assigned_ids.ReserveId(name, entry->staged_id.value().id, v,
+ context->GetDiagnostics())) {
+ return false;
}
if (assigned_id_map_) {
@@ -237,7 +242,7 @@
if (type_id_ != id.type_id()) {
// Currently there cannot be multiple type ids for a single type.
std::stringstream error;
- error << "type '" << name.type << "' already has ID " << std::hex << (int)id.type_id();
+ error << "type '" << name.type << "' already has ID " << std::hex << (int)type_id_;
return unexpected(error.str());
}
diff --git a/tools/aapt2/dump/DumpManifest.cpp b/tools/aapt2/dump/DumpManifest.cpp
index 61ba09b..f2c6b15 100644
--- a/tools/aapt2/dump/DumpManifest.cpp
+++ b/tools/aapt2/dump/DumpManifest.cpp
@@ -135,7 +135,8 @@
template <typename Predicate>
void Filter(Predicate&& func) {
children_.erase(std::remove_if(children_.begin(), children_.end(),
- [&](const auto& e) { return func(e.get()); }));
+ [&](const auto& e) { return func(e.get()); }),
+ children_.end());
}
/** Retrieves the list of children of the element. */
diff --git a/tools/aapt2/format/binary/BinaryResourceParser.cpp b/tools/aapt2/format/binary/BinaryResourceParser.cpp
index f1b350f..72eaa35 100644
--- a/tools/aapt2/format/binary/BinaryResourceParser.cpp
+++ b/tools/aapt2/format/binary/BinaryResourceParser.cpp
@@ -254,6 +254,12 @@
}
break;
+ case android::RES_TABLE_STAGED_ALIAS_TYPE:
+ if (!ParseStagedAliases(parser.chunk())) {
+ return false;
+ }
+ break;
+
default:
diag_->Warn(DiagMessage(source_)
<< "unexpected chunk type "
@@ -489,6 +495,52 @@
return true;
}
+bool BinaryResourceParser::ParseStagedAliases(const ResChunk_header* chunk) {
+ auto header = ConvertTo<ResTable_staged_alias_header>(chunk);
+ if (!header) {
+ diag_->Error(DiagMessage(source_) << "corrupt ResTable_staged_alias_header chunk");
+ return false;
+ }
+
+ const auto ref_begin = reinterpret_cast<const ResTable_staged_alias_entry*>(
+ ((uint8_t*)header) + util::DeviceToHost32(header->header.headerSize));
+ const auto ref_end = ref_begin + util::DeviceToHost32(header->count);
+ for (auto ref_iter = ref_begin; ref_iter != ref_end; ++ref_iter) {
+ const auto staged_id = ResourceId(util::DeviceToHost32(ref_iter->stagedResId));
+ const auto finalized_id = ResourceId(util::DeviceToHost32(ref_iter->finalizedResId));
+
+ // If the staged alias chunk comes before the type chunks, the resource ids and resource name
+ // pairing will not exist at this point.
+ const auto iter = id_index_.find(finalized_id);
+ if (iter == id_index_.cend()) {
+ diag_->Error(DiagMessage(source_) << "failed to find resource name for finalized"
+ << " resource ID " << finalized_id);
+ return false;
+ }
+
+ // Set the staged id of the finalized resource.
+ const auto& resource_name = iter->second;
+ const StagedId staged_id_def{.id = staged_id};
+ if (!table_->AddResource(NewResourceBuilder(resource_name)
+ .SetId(finalized_id, OnIdConflict::CREATE_ENTRY)
+ .SetStagedId(staged_id_def)
+ .SetAllowMangled(true)
+ .Build(),
+ diag_)) {
+ return false;
+ }
+
+ // Since a the finalized resource entry is cloned and added to the resource table under the
+ // staged resource id, remove the cloned resource entry from the table.
+ if (!table_->RemoveResource(resource_name, staged_id)) {
+ diag_->Error(DiagMessage(source_) << "failed to find resource entry for staged "
+ << " resource ID " << staged_id);
+ return false;
+ }
+ }
+ return true;
+}
+
std::unique_ptr<Item> BinaryResourceParser::ParseValue(const ResourceNameRef& name,
const ConfigDescription& config,
const android::Res_value& value) {
diff --git a/tools/aapt2/format/binary/BinaryResourceParser.h b/tools/aapt2/format/binary/BinaryResourceParser.h
index 13dd982..cd71d16 100644
--- a/tools/aapt2/format/binary/BinaryResourceParser.h
+++ b/tools/aapt2/format/binary/BinaryResourceParser.h
@@ -57,6 +57,7 @@
uint8_t package_id);
bool ParseLibrary(const android::ResChunk_header* chunk);
bool ParseOverlayable(const android::ResChunk_header* chunk);
+ bool ParseStagedAliases(const android::ResChunk_header* chunk);
std::unique_ptr<Item> ParseValue(const ResourceNameRef& name,
const android::ConfigDescription& config,
diff --git a/tools/aapt2/format/binary/TableFlattener.cpp b/tools/aapt2/format/binary/TableFlattener.cpp
index 74ecf47..a9192e8 100644
--- a/tools/aapt2/format/binary/TableFlattener.cpp
+++ b/tools/aapt2/format/binary/TableFlattener.cpp
@@ -72,7 +72,7 @@
}
struct FlatEntry {
- const ResourceEntry* entry;
+ const ResourceTableEntryView* entry;
const Value* value;
// The entry string pool index to the entry's name.
@@ -286,6 +286,10 @@
return false;
}
+ if (!FlattenAliases(buffer)) {
+ return false;
+ }
+
pkg_writer.Finish();
return true;
}
@@ -351,8 +355,8 @@
BigBuffer values_buffer(512);
for (FlatEntry& flat_entry : *entries) {
- CHECK(static_cast<size_t>(flat_entry.entry->id.value().entry_id()) < num_total_entries);
- offsets[flat_entry.entry->id.value().entry_id()] = values_buffer.size();
+ CHECK(static_cast<size_t>(flat_entry.entry->id.value()) < num_total_entries);
+ offsets[flat_entry.entry->id.value()] = values_buffer.size();
if (!FlattenValue(&flat_entry, &values_buffer)) {
diag_->Error(DiagMessage()
<< "failed to flatten resource '"
@@ -404,6 +408,26 @@
return true;
}
+ bool FlattenAliases(BigBuffer* buffer) {
+ if (aliases_.empty()) {
+ return true;
+ }
+
+ ChunkWriter alias_writer(buffer);
+ auto header =
+ alias_writer.StartChunk<ResTable_staged_alias_header>(RES_TABLE_STAGED_ALIAS_TYPE);
+ header->count = util::HostToDevice32(aliases_.size());
+
+ auto mapping = alias_writer.NextBlock<ResTable_staged_alias_entry>(aliases_.size());
+ for (auto& p : aliases_) {
+ mapping->stagedResId = util::HostToDevice32(p.first);
+ mapping->finalizedResId = util::HostToDevice32(p.second);
+ ++mapping;
+ }
+ alias_writer.Finish();
+ return true;
+ }
+
bool FlattenOverlayable(BigBuffer* buffer) {
std::set<ResourceId> seen_ids;
std::map<std::string, OverlayableChunk> overlayable_chunks;
@@ -413,18 +437,17 @@
CHECK(bool(type.id)) << "type must have an ID set when flattening <overlayable>";
for (auto& entry : type.entries) {
CHECK(bool(type.id)) << "entry must have an ID set when flattening <overlayable>";
- if (!entry->overlayable_item) {
+ if (!entry.overlayable_item) {
continue;
}
- const OverlayableItem& item = entry->overlayable_item.value();
+ const OverlayableItem& item = entry.overlayable_item.value();
// Resource ids should only appear once in the resource table
- ResourceId id =
- android::make_resid(package_.id.value(), type.id.value(), entry->id.value().entry_id());
+ ResourceId id = android::make_resid(package_.id.value(), type.id.value(), entry.id.value());
CHECK(seen_ids.find(id) == seen_ids.end())
<< "multiple overlayable definitions found for resource "
- << ResourceName(package_.name, type.type, entry->name).to_string();
+ << ResourceName(package_.name, type.type, entry.name).to_string();
seen_ids.insert(id);
// Find the overlayable chunk with the specified name
@@ -452,9 +475,8 @@
if (item.policies == 0) {
context_->GetDiagnostics()->Error(DiagMessage(item.overlayable->source)
- << "overlayable "
- << entry->name
- << " does not specify policy");
+ << "overlayable " << entry.name
+ << " does not specify policy");
return false;
}
@@ -520,7 +542,8 @@
}
bool FlattenTypeSpec(const ResourceTableTypeView& type,
- const std::vector<const ResourceEntry*>& sorted_entries, BigBuffer* buffer) {
+ const std::vector<ResourceTableEntryView>& sorted_entries,
+ BigBuffer* buffer) {
ChunkWriter type_spec_writer(buffer);
ResTable_typeSpec* spec_header =
type_spec_writer.StartChunk<ResTable_typeSpec>(RES_TABLE_TYPE_SPEC_TYPE);
@@ -534,7 +557,7 @@
// We can't just take the size of the vector. There may be holes in the
// entry ID space.
// Since the entries are sorted by ID, the last one will be the biggest.
- const size_t num_entries = sorted_entries.back()->id.value().entry_id() + 1;
+ const size_t num_entries = sorted_entries.back().id.value() + 1;
spec_header->entryCount = util::HostToDevice32(num_entries);
@@ -542,23 +565,23 @@
// show for which configuration axis the resource changes.
uint32_t* config_masks = type_spec_writer.NextBlock<uint32_t>(num_entries);
- for (const ResourceEntry* entry : sorted_entries) {
- const uint16_t entry_id = entry->id.value().entry_id();
+ for (const ResourceTableEntryView& entry : sorted_entries) {
+ const uint16_t entry_id = entry.id.value();
// Populate the config masks for this entry.
uint32_t& entry_config_masks = config_masks[entry_id];
- if (entry->visibility.level == Visibility::Level::kPublic) {
+ if (entry.visibility.level == Visibility::Level::kPublic) {
entry_config_masks |= util::HostToDevice32(ResTable_typeSpec::SPEC_PUBLIC);
}
- if (entry->visibility.staged_api) {
+ if (entry.visibility.staged_api) {
entry_config_masks |= util::HostToDevice32(ResTable_typeSpec::SPEC_STAGED_API);
}
- const size_t config_count = entry->values.size();
+ const size_t config_count = entry.values.size();
for (size_t i = 0; i < config_count; i++) {
- const ConfigDescription& config = entry->values[i]->config;
+ const ConfigDescription& config = entry.values[i]->config;
for (size_t j = i + 1; j < config_count; j++) {
- config_masks[entry_id] |= util::HostToDevice32(config.diff(entry->values[j]->config));
+ config_masks[entry_id] |= util::HostToDevice32(config.diff(entry.values[j]->config));
}
}
}
@@ -590,7 +613,7 @@
}
// Since the entries are sorted by ID, the last ID will be the largest.
- const size_t num_entries = type.entries.back()->id.value().entry_id() + 1;
+ const size_t num_entries = type.entries.back().id.value() + 1;
// The binary resource table lists resource entries for each
// configuration.
@@ -603,20 +626,26 @@
// hardcoded string uses characters which make it an invalid resource name
const std::string obfuscated_resource_name = "0_resource_name_obfuscated";
- for (const ResourceEntry* entry : type.entries) {
+ for (const ResourceTableEntryView& entry : type.entries) {
+ if (entry.staged_id) {
+ aliases_.insert(std::make_pair(
+ entry.staged_id.value().id.id,
+ ResourceId(package_.id.value(), type.id.value(), entry.id.value()).id));
+ }
+
uint32_t local_key_index;
- ResourceName resource_name({}, type.type, entry->name);
+ ResourceName resource_name({}, type.type, entry.name);
if (!collapse_key_stringpool_ ||
name_collapse_exemptions_.find(resource_name) != name_collapse_exemptions_.end()) {
- local_key_index = (uint32_t)key_pool_.MakeRef(entry->name).index();
+ local_key_index = (uint32_t)key_pool_.MakeRef(entry.name).index();
} else {
// resource isn't exempt from collapse, add it as obfuscated value
local_key_index = (uint32_t)key_pool_.MakeRef(obfuscated_resource_name).index();
}
// Group values by configuration.
- for (auto& config_value : entry->values) {
+ for (auto& config_value : entry.values) {
config_to_entry_list_map[config_value->config].push_back(
- FlatEntry{entry, config_value->value.get(), local_key_index});
+ FlatEntry{&entry, config_value->value.get(), local_key_index});
}
}
@@ -667,6 +696,7 @@
StringPool key_pool_;
bool collapse_key_stringpool_;
const std::set<ResourceName>& name_collapse_exemptions_;
+ std::map<uint32_t, uint32_t> aliases_;
};
} // namespace
@@ -684,7 +714,8 @@
});
// Write the ResTable header.
- const auto& table_view = table->GetPartitionedView();
+ const auto& table_view =
+ table->GetPartitionedView(ResourceTableViewOptions{.create_alias_entries = true});
ChunkWriter table_writer(buffer_);
ResTable_header* table_header = table_writer.StartChunk<ResTable_header>(RES_TABLE_TYPE);
table_header->packageCount = util::HostToDevice32(table_view.packages.size());
diff --git a/tools/aapt2/format/proto/ProtoDeserialize.cpp b/tools/aapt2/format/proto/ProtoDeserialize.cpp
index ec331df..236c381 100644
--- a/tools/aapt2/format/proto/ProtoDeserialize.cpp
+++ b/tools/aapt2/format/proto/ProtoDeserialize.cpp
@@ -498,10 +498,20 @@
out_error)) {
return false;
}
-
entry->overlayable_item = std::move(overlayable_item);
}
+ if (pb_entry.has_staged_id()) {
+ const pb::StagedId& pb_staged_id = pb_entry.staged_id();
+
+ StagedId staged_id;
+ if (pb_staged_id.has_source()) {
+ DeserializeSourceFromPb(pb_staged_id.source(), src_pool, &staged_id.source);
+ }
+ staged_id.id = pb_staged_id.staged_id();
+ entry->staged_id = std::move(staged_id);
+ }
+
ResourceId resid(pb_package.package_id().id(), pb_type.type_id().id(),
pb_entry.entry_id().id());
if (resid.is_valid()) {
diff --git a/tools/aapt2/format/proto/ProtoSerialize.cpp b/tools/aapt2/format/proto/ProtoSerialize.cpp
index d2f0336..6042ba8 100644
--- a/tools/aapt2/format/proto/ProtoSerialize.cpp
+++ b/tools/aapt2/format/proto/ProtoSerialize.cpp
@@ -364,43 +364,52 @@
static const char* obfuscated_resource_name = "0_resource_name_obfuscated";
for (const auto& entry : type.entries) {
pb::Entry* pb_entry = pb_type->add_entry();
- if (entry->id) {
- pb_entry->mutable_entry_id()->set_id(entry->id.value().entry_id());
+ if (entry.id) {
+ pb_entry->mutable_entry_id()->set_id(entry.id.value());
}
- ResourceName resource_name({}, type.type, entry->name);
+ ResourceName resource_name({}, type.type, entry.name);
if (options.collapse_key_stringpool &&
options.name_collapse_exemptions.find(resource_name) ==
options.name_collapse_exemptions.end()) {
pb_entry->set_name(obfuscated_resource_name);
} else {
- pb_entry->set_name(entry->name);
+ pb_entry->set_name(entry.name);
}
// Write the Visibility struct.
pb::Visibility* pb_visibility = pb_entry->mutable_visibility();
- pb_visibility->set_staged_api(entry->visibility.staged_api);
- pb_visibility->set_level(SerializeVisibilityToPb(entry->visibility.level));
+ pb_visibility->set_staged_api(entry.visibility.staged_api);
+ pb_visibility->set_level(SerializeVisibilityToPb(entry.visibility.level));
if (source_pool != nullptr) {
- SerializeSourceToPb(entry->visibility.source, source_pool.get(),
+ SerializeSourceToPb(entry.visibility.source, source_pool.get(),
pb_visibility->mutable_source());
}
- pb_visibility->set_comment(entry->visibility.comment);
+ pb_visibility->set_comment(entry.visibility.comment);
- if (entry->allow_new) {
+ if (entry.allow_new) {
pb::AllowNew* pb_allow_new = pb_entry->mutable_allow_new();
if (source_pool != nullptr) {
- SerializeSourceToPb(entry->allow_new.value().source, source_pool.get(),
+ SerializeSourceToPb(entry.allow_new.value().source, source_pool.get(),
pb_allow_new->mutable_source());
}
- pb_allow_new->set_comment(entry->allow_new.value().comment);
+ pb_allow_new->set_comment(entry.allow_new.value().comment);
}
- if (entry->overlayable_item) {
- SerializeOverlayableItemToPb(entry->overlayable_item.value(), overlayables,
+ if (entry.overlayable_item) {
+ SerializeOverlayableItemToPb(entry.overlayable_item.value(), overlayables,
source_pool.get(), pb_entry, out_table);
}
- for (const std::unique_ptr<ResourceConfigValue>& config_value : entry->values) {
+ if (entry.staged_id) {
+ pb::StagedId* pb_staged_id = pb_entry->mutable_staged_id();
+ if (source_pool != nullptr) {
+ SerializeSourceToPb(entry.staged_id.value().source, source_pool.get(),
+ pb_staged_id->mutable_source());
+ }
+ pb_staged_id->set_staged_id(entry.staged_id.value().id.id);
+ }
+
+ for (const ResourceConfigValue* config_value : entry.values) {
pb::ConfigValue* pb_config_value = pb_entry->add_config_value();
SerializeConfig(config_value->config, pb_config_value->mutable_config());
pb_config_value->mutable_config()->set_product(config_value->product);
diff --git a/tools/aapt2/format/proto/ProtoSerialize_test.cpp b/tools/aapt2/format/proto/ProtoSerialize_test.cpp
index e563eda..38c811f 100644
--- a/tools/aapt2/format/proto/ProtoSerialize_test.cpp
+++ b/tools/aapt2/format/proto/ProtoSerialize_test.cpp
@@ -928,4 +928,27 @@
EXPECT_THAT(deserialized->alias_namespaces, Eq(original->alias_namespaces));
}
+TEST(ProtoSerializeTest, StagedId) {
+ CloningValueTransformer cloner(nullptr);
+ std::unique_ptr<IAaptContext> context = test::ContextBuilder().Build();
+ std::unique_ptr<ResourceTable> table = test::ResourceTableBuilder()
+ .Add(NewResourceBuilder("com.app.a:string/foo")
+ .SetStagedId(StagedId{.id = 0x01ff0001})
+ .Build())
+ .Build();
+
+ ResourceTable new_table;
+ pb::ResourceTable pb_table;
+ MockFileCollection files;
+ std::string error;
+ SerializeTableToPb(*table, &pb_table, context->GetDiagnostics());
+ ASSERT_TRUE(DeserializeTableFromPb(pb_table, &files, &new_table, &error));
+ EXPECT_THAT(error, IsEmpty());
+
+ auto result = new_table.FindResource(test::ParseNameOrDie("com.app.a:string/foo"));
+ ASSERT_TRUE(result);
+ ASSERT_TRUE(result.value().entry->staged_id);
+ EXPECT_THAT(result.value().entry->staged_id.value().id, Eq(ResourceId(0x01ff0001)));
+}
+
} // namespace aapt
diff --git a/tools/aapt2/link/TableMerger.cpp b/tools/aapt2/link/TableMerger.cpp
index bc93ec6..22f4d18 100644
--- a/tools/aapt2/link/TableMerger.cpp
+++ b/tools/aapt2/link/TableMerger.cpp
@@ -151,6 +151,18 @@
dst_entry->overlayable_item = std::move(src_entry->overlayable_item);
}
+ if (src_entry->staged_id) {
+ if (dst_entry->staged_id &&
+ dst_entry->staged_id.value().id != src_entry->staged_id.value().id) {
+ context->GetDiagnostics()->Error(DiagMessage(src_entry->staged_id.value().source)
+ << "conflicting staged id declaration for resource '"
+ << src_entry->name << "'");
+ context->GetDiagnostics()->Error(DiagMessage(dst_entry->staged_id.value().source)
+ << "previous declaration here");
+ }
+ dst_entry->staged_id = std::move(src_entry->staged_id);
+ }
+
return true;
}
diff --git a/tools/aapt2/test/Fixture.cpp b/tools/aapt2/test/Fixture.cpp
index f94f0fe..285e5a1 100644
--- a/tools/aapt2/test/Fixture.cpp
+++ b/tools/aapt2/test/Fixture.cpp
@@ -80,9 +80,6 @@
}
void TestDirectoryFixture::WriteFile(const std::string& path, const std::string& contents) {
- CHECK(util::StartsWith(path, temp_dir_))
- << "Attempting to create a file outside of test temporary directory.";
-
// Create any intermediate directories specified in the path
auto pos = std::find(path.rbegin(), path.rend(), file::sDirSep);
if (pos != path.rend()) {
diff --git a/tools/codegen/src/com/android/codegen/Utils.kt b/tools/codegen/src/com/android/codegen/Utils.kt
index 7cfa784..9ceb204 100644
--- a/tools/codegen/src/com/android/codegen/Utils.kt
+++ b/tools/codegen/src/com/android/codegen/Utils.kt
@@ -43,8 +43,8 @@
* cccc dd
*/
fun Iterable<Pair<String, String>>.columnize(separator: String = " | "): String {
- val col1w = map { (a, _) -> a.length }.max()!!
- val col2w = map { (_, b) -> b.length }.max()!!
+ val col1w = map { (a, _) -> a.length }.maxOrNull()!!
+ val col2w = map { (_, b) -> b.length }.maxOrNull()!!
return map { it.first.padEnd(col1w) + separator + it.second.padEnd(col2w) }.joinToString("\n")
}