Merge "[PM] Use callingUid instead of binder#getCallingUid for uninstall" into main
diff --git a/AconfigFlags.bp b/AconfigFlags.bp
index 6b8baf8..3620a11 100644
--- a/AconfigFlags.bp
+++ b/AconfigFlags.bp
@@ -478,6 +478,13 @@
defaults: ["framework-minus-apex-aconfig-java-defaults"],
}
+cc_aconfig_library {
+ name: "android.os.vibrator.flags-aconfig-cc",
+ aconfig_declarations: "android.os.vibrator.flags-aconfig",
+ host_supported: true,
+ vendor_available: true,
+}
+
// View
aconfig_declarations {
name: "android.view.flags-aconfig",
diff --git a/Ravenwood.bp b/Ravenwood.bp
index 87f1124..7faa33f 100644
--- a/Ravenwood.bp
+++ b/Ravenwood.bp
@@ -26,24 +26,13 @@
}
// Generate the stub/impl from framework-all, with hidden APIs.
-java_genrule {
- name: "framework-minus-apex.ravenwood-base",
+// This step takes several tens of seconds, so we manually shard it to multiple modules.
+// All the copies have to be kept in sync.
+// TODO: Do the sharding better.
+
+genrule_defaults {
+ name: "framework-minus-apex.ravenwood-base_defaults",
tools: ["hoststubgen"],
- cmd: "$(location hoststubgen) " +
- "@$(location :ravenwood-standard-options) " +
-
- "--debug-log $(location hoststubgen_framework-minus-apex.log) " +
- "--stats-file $(location hoststubgen_framework-minus-apex_stats.csv) " +
- "--supported-api-list-file $(location hoststubgen_framework-minus-apex_apis.csv) " +
-
- "--out-impl-jar $(location ravenwood.jar) " +
-
- "--gen-keep-all-file $(location hoststubgen_framework-minus-apex_keep_all.txt) " +
- "--gen-input-dump-file $(location hoststubgen_framework-minus-apex_dump.txt) " +
-
- "--in-jar $(location :framework-minus-apex-for-hoststubgen) " +
- "--policy-override-file $(location :ravenwood-framework-policies) " +
- "--annotation-allowed-classes-file $(location :ravenwood-annotation-allowed-classes) ",
srcs: [
":framework-minus-apex-for-hoststubgen",
":ravenwood-framework-policies",
@@ -61,24 +50,221 @@
"hoststubgen_framework-minus-apex_stats.csv",
"hoststubgen_framework-minus-apex_apis.csv",
],
- defaults: ["ravenwood-internal-only-visibility-genrule"],
+ visibility: ["//visibility:private"],
}
-// Extract the impl jar from "framework-minus-apex.ravenwood-base" for subsequent build rules.
-// Note this emits a "device side" output, so that ravenwood tests can (implicitly)
-// depend on it.
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X0",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: "$(location hoststubgen) " +
+ "--num-shards 6 --shard-index 0 " + // Only this line differs
+
+ "@$(location :ravenwood-standard-options) " +
+
+ "--debug-log $(location hoststubgen_framework-minus-apex.log) " +
+ "--stats-file $(location hoststubgen_framework-minus-apex_stats.csv) " +
+ "--supported-api-list-file $(location hoststubgen_framework-minus-apex_apis.csv) " +
+
+ "--out-impl-jar $(location ravenwood.jar) " +
+
+ "--gen-keep-all-file $(location hoststubgen_framework-minus-apex_keep_all.txt) " +
+ "--gen-input-dump-file $(location hoststubgen_framework-minus-apex_dump.txt) " +
+
+ "--in-jar $(location :framework-minus-apex-for-hoststubgen) " +
+ "--policy-override-file $(location :ravenwood-framework-policies) " +
+ "--annotation-allowed-classes-file $(location :ravenwood-annotation-allowed-classes) ",
+}
+
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X1",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: "$(location hoststubgen) " +
+ "--num-shards 6 --shard-index 1 " + // Only this line differs
+
+ "@$(location :ravenwood-standard-options) " +
+
+ "--debug-log $(location hoststubgen_framework-minus-apex.log) " +
+ "--stats-file $(location hoststubgen_framework-minus-apex_stats.csv) " +
+ "--supported-api-list-file $(location hoststubgen_framework-minus-apex_apis.csv) " +
+
+ "--out-impl-jar $(location ravenwood.jar) " +
+
+ "--gen-keep-all-file $(location hoststubgen_framework-minus-apex_keep_all.txt) " +
+ "--gen-input-dump-file $(location hoststubgen_framework-minus-apex_dump.txt) " +
+
+ "--in-jar $(location :framework-minus-apex-for-hoststubgen) " +
+ "--policy-override-file $(location :ravenwood-framework-policies) " +
+ "--annotation-allowed-classes-file $(location :ravenwood-annotation-allowed-classes) ",
+}
+
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X2",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: "$(location hoststubgen) " +
+ "--num-shards 6 --shard-index 2 " + // Only this line differs
+
+ "@$(location :ravenwood-standard-options) " +
+
+ "--debug-log $(location hoststubgen_framework-minus-apex.log) " +
+ "--stats-file $(location hoststubgen_framework-minus-apex_stats.csv) " +
+ "--supported-api-list-file $(location hoststubgen_framework-minus-apex_apis.csv) " +
+
+ "--out-impl-jar $(location ravenwood.jar) " +
+
+ "--gen-keep-all-file $(location hoststubgen_framework-minus-apex_keep_all.txt) " +
+ "--gen-input-dump-file $(location hoststubgen_framework-minus-apex_dump.txt) " +
+
+ "--in-jar $(location :framework-minus-apex-for-hoststubgen) " +
+ "--policy-override-file $(location :ravenwood-framework-policies) " +
+ "--annotation-allowed-classes-file $(location :ravenwood-annotation-allowed-classes) ",
+}
+
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X3",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: "$(location hoststubgen) " +
+ "--num-shards 6 --shard-index 3 " + // Only this line differs
+
+ "@$(location :ravenwood-standard-options) " +
+
+ "--debug-log $(location hoststubgen_framework-minus-apex.log) " +
+ "--stats-file $(location hoststubgen_framework-minus-apex_stats.csv) " +
+ "--supported-api-list-file $(location hoststubgen_framework-minus-apex_apis.csv) " +
+
+ "--out-impl-jar $(location ravenwood.jar) " +
+
+ "--gen-keep-all-file $(location hoststubgen_framework-minus-apex_keep_all.txt) " +
+ "--gen-input-dump-file $(location hoststubgen_framework-minus-apex_dump.txt) " +
+
+ "--in-jar $(location :framework-minus-apex-for-hoststubgen) " +
+ "--policy-override-file $(location :ravenwood-framework-policies) " +
+ "--annotation-allowed-classes-file $(location :ravenwood-annotation-allowed-classes) ",
+}
+
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X4",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: "$(location hoststubgen) " +
+ "--num-shards 6 --shard-index 4 " + // Only this line differs
+
+ "@$(location :ravenwood-standard-options) " +
+
+ "--debug-log $(location hoststubgen_framework-minus-apex.log) " +
+ "--stats-file $(location hoststubgen_framework-minus-apex_stats.csv) " +
+ "--supported-api-list-file $(location hoststubgen_framework-minus-apex_apis.csv) " +
+
+ "--out-impl-jar $(location ravenwood.jar) " +
+
+ "--gen-keep-all-file $(location hoststubgen_framework-minus-apex_keep_all.txt) " +
+ "--gen-input-dump-file $(location hoststubgen_framework-minus-apex_dump.txt) " +
+
+ "--in-jar $(location :framework-minus-apex-for-hoststubgen) " +
+ "--policy-override-file $(location :ravenwood-framework-policies) " +
+ "--annotation-allowed-classes-file $(location :ravenwood-annotation-allowed-classes) ",
+}
+
+java_genrule {
+ name: "framework-minus-apex.ravenwood-base_X5",
+ defaults: ["framework-minus-apex.ravenwood-base_defaults"],
+ cmd: "$(location hoststubgen) " +
+ "--num-shards 6 --shard-index 5 " + // Only this line differs
+
+ "@$(location :ravenwood-standard-options) " +
+
+ "--debug-log $(location hoststubgen_framework-minus-apex.log) " +
+ "--stats-file $(location hoststubgen_framework-minus-apex_stats.csv) " +
+ "--supported-api-list-file $(location hoststubgen_framework-minus-apex_apis.csv) " +
+
+ "--out-impl-jar $(location ravenwood.jar) " +
+
+ "--gen-keep-all-file $(location hoststubgen_framework-minus-apex_keep_all.txt) " +
+ "--gen-input-dump-file $(location hoststubgen_framework-minus-apex_dump.txt) " +
+
+ "--in-jar $(location :framework-minus-apex-for-hoststubgen) " +
+ "--policy-override-file $(location :ravenwood-framework-policies) " +
+ "--annotation-allowed-classes-file $(location :ravenwood-annotation-allowed-classes) ",
+}
+
+// Marge all the sharded jars
java_genrule {
name: "framework-minus-apex.ravenwood",
- defaults: ["ravenwood-internal-only-visibility-genrule"],
- cmd: "cp $(in) $(out)",
+ defaults: ["ravenwood-internal-only-visibility-java"],
+ cmd: "$(location merge_zips) $(out) $(in)",
+ tools: ["merge_zips"],
srcs: [
- ":framework-minus-apex.ravenwood-base{ravenwood.jar}",
+ ":framework-minus-apex.ravenwood-base_X0{ravenwood.jar}",
+ ":framework-minus-apex.ravenwood-base_X1{ravenwood.jar}",
+ ":framework-minus-apex.ravenwood-base_X2{ravenwood.jar}",
+ ":framework-minus-apex.ravenwood-base_X3{ravenwood.jar}",
+ ":framework-minus-apex.ravenwood-base_X4{ravenwood.jar}",
+ ":framework-minus-apex.ravenwood-base_X5{ravenwood.jar}",
],
out: [
"framework-minus-apex.ravenwood.jar",
],
}
+// Merge the sharded text files
+genrule {
+ name: "hoststubgen_framework-minus-apex_stats.csv",
+ defaults: ["ravenwood-internal-only-visibility-genrule"],
+ cmd: "cat $(in) > $(out)",
+ srcs: [
+ ":framework-minus-apex.ravenwood-base_X0{hoststubgen_framework-minus-apex_stats.csv}",
+ ":framework-minus-apex.ravenwood-base_X1{hoststubgen_framework-minus-apex_stats.csv}",
+ ":framework-minus-apex.ravenwood-base_X2{hoststubgen_framework-minus-apex_stats.csv}",
+ ":framework-minus-apex.ravenwood-base_X3{hoststubgen_framework-minus-apex_stats.csv}",
+ ":framework-minus-apex.ravenwood-base_X4{hoststubgen_framework-minus-apex_stats.csv}",
+ ":framework-minus-apex.ravenwood-base_X5{hoststubgen_framework-minus-apex_stats.csv}",
+ ],
+ out: ["hoststubgen_framework-minus-apex_stats.csv"],
+}
+
+genrule {
+ name: "hoststubgen_framework-minus-apex_apis.csv",
+ defaults: ["ravenwood-internal-only-visibility-genrule"],
+ cmd: "cat $(in) > $(out)",
+ srcs: [
+ ":framework-minus-apex.ravenwood-base_X0{hoststubgen_framework-minus-apex_apis.csv}",
+ ":framework-minus-apex.ravenwood-base_X1{hoststubgen_framework-minus-apex_apis.csv}",
+ ":framework-minus-apex.ravenwood-base_X2{hoststubgen_framework-minus-apex_apis.csv}",
+ ":framework-minus-apex.ravenwood-base_X3{hoststubgen_framework-minus-apex_apis.csv}",
+ ":framework-minus-apex.ravenwood-base_X4{hoststubgen_framework-minus-apex_apis.csv}",
+ ":framework-minus-apex.ravenwood-base_X5{hoststubgen_framework-minus-apex_apis.csv}",
+ ],
+ out: ["hoststubgen_framework-minus-apex_apis.csv"],
+}
+
+genrule {
+ name: "hoststubgen_framework-minus-apex_keep_all.txt",
+ defaults: ["ravenwood-internal-only-visibility-genrule"],
+ cmd: "cat $(in) > $(out)",
+ srcs: [
+ ":framework-minus-apex.ravenwood-base_X0{hoststubgen_framework-minus-apex_keep_all.txt}",
+ ":framework-minus-apex.ravenwood-base_X1{hoststubgen_framework-minus-apex_keep_all.txt}",
+ ":framework-minus-apex.ravenwood-base_X2{hoststubgen_framework-minus-apex_keep_all.txt}",
+ ":framework-minus-apex.ravenwood-base_X3{hoststubgen_framework-minus-apex_keep_all.txt}",
+ ":framework-minus-apex.ravenwood-base_X4{hoststubgen_framework-minus-apex_keep_all.txt}",
+ ":framework-minus-apex.ravenwood-base_X5{hoststubgen_framework-minus-apex_keep_all.txt}",
+ ],
+ out: ["hoststubgen_framework-minus-apex_keep_all.txt"],
+}
+
+genrule {
+ name: "hoststubgen_framework-minus-apex_dump.txt",
+ defaults: ["ravenwood-internal-only-visibility-genrule"],
+ cmd: "cat $(in) > $(out)",
+ srcs: [
+ ":framework-minus-apex.ravenwood-base_X0{hoststubgen_framework-minus-apex_dump.txt}",
+ ":framework-minus-apex.ravenwood-base_X1{hoststubgen_framework-minus-apex_dump.txt}",
+ ":framework-minus-apex.ravenwood-base_X2{hoststubgen_framework-minus-apex_dump.txt}",
+ ":framework-minus-apex.ravenwood-base_X3{hoststubgen_framework-minus-apex_dump.txt}",
+ ":framework-minus-apex.ravenwood-base_X4{hoststubgen_framework-minus-apex_dump.txt}",
+ ":framework-minus-apex.ravenwood-base_X5{hoststubgen_framework-minus-apex_dump.txt}",
+ ],
+ out: ["hoststubgen_framework-minus-apex_dump.txt"],
+}
+
java_library {
name: "services.core-for-hoststubgen",
installable: false, // host only jar.
@@ -159,7 +345,8 @@
"framework-minus-apex.ravenwood",
],
sdk_version: "core_platform",
- jarjar_rules: ":ravenwood-framework-jarjar-rules",
+ // See b/313930116. Jarjar is too slow on this jar. We use HostStubGen to do the rename.
+ // jarjar_rules: ":ravenwood-framework-jarjar-rules",
}
java_genrule {
diff --git a/cmds/idmap2/idmap2d/Idmap2Service.cpp b/cmds/idmap2/idmap2d/Idmap2Service.cpp
index f264125..6902d6d 100644
--- a/cmds/idmap2/idmap2d/Idmap2Service.cpp
+++ b/cmds/idmap2/idmap2d/Idmap2Service.cpp
@@ -78,6 +78,11 @@
namespace android::os {
+template <typename T>
+const T* Idmap2Service::GetPointer(const OwningPtr<T>& ptr) {
+ return std::visit([](auto&& ptr) { return ptr.get(); }, ptr);
+}
+
Status Idmap2Service::getIdmapPath(const std::string& overlay_path,
int32_t user_id ATTRIBUTE_UNUSED, std::string* _aidl_return) {
assert(_aidl_return);
@@ -224,7 +229,7 @@
if (is_framework ||
(item.dev == st.st_dev && item.inode == st.st_ino && item.size == st.st_size
&& item.mtime.tv_sec == st.st_mtim.tv_sec && item.mtime.tv_nsec == st.st_mtim.tv_nsec)) {
- return {item.apk.get()};
+ return {item.apk};
}
container_cache_.erase(cache_it);
}
@@ -238,14 +243,14 @@
return {std::move(*target)};
}
- const auto res = target->get();
+ auto res = std::shared_ptr(std::move(*target));
std::lock_guard lock(container_cache_mutex_);
container_cache_.emplace(target_path, CachedContainer {
.dev = dev_t(st.st_dev),
.inode = ino_t(st.st_ino),
.size = st.st_size,
.mtime = st.st_mtim,
- .apk = std::move(*target)
+ .apk = res
});
return {res};
}
diff --git a/cmds/idmap2/idmap2d/Idmap2Service.h b/cmds/idmap2/idmap2d/Idmap2Service.h
index a69fa61..272ec6b 100644
--- a/cmds/idmap2/idmap2d/Idmap2Service.h
+++ b/cmds/idmap2/idmap2d/Idmap2Service.h
@@ -85,7 +85,7 @@
ino_t inode;
int64_t size;
struct timespec mtime;
- std::unique_ptr<idmap2::TargetResourceContainer> apk;
+ std::shared_ptr<idmap2::TargetResourceContainer> apk;
};
std::unordered_map<std::string, CachedContainer> container_cache_;
std::mutex container_cache_mutex_;
@@ -95,24 +95,15 @@
std::mutex frro_iter_mutex_;
template <typename T>
- using MaybeUniquePtr = std::variant<std::unique_ptr<T>, T*>;
+ using OwningPtr = std::variant<std::unique_ptr<T>, std::shared_ptr<T>>;
- using TargetResourceContainerPtr = MaybeUniquePtr<idmap2::TargetResourceContainer>;
+ using TargetResourceContainerPtr = OwningPtr<idmap2::TargetResourceContainer>;
idmap2::Result<TargetResourceContainerPtr> GetTargetContainer(const std::string& target_path);
template <typename T>
- WARN_UNUSED static const T* GetPointer(const MaybeUniquePtr<T>& ptr);
+ WARN_UNUSED static const T* GetPointer(const OwningPtr<T>& ptr);
};
-template <typename T>
-const T* Idmap2Service::GetPointer(const MaybeUniquePtr<T>& ptr) {
- auto u = std::get_if<T*>(&ptr);
- if (u != nullptr) {
- return *u;
- }
- return std::get<std::unique_ptr<T>>(ptr).get();
-}
-
} // namespace android::os
#endif // IDMAP2_IDMAP2D_IDMAP2SERVICE_H_
diff --git a/config/preloaded-classes-denylist b/config/preloaded-classes-denylist
index a413bbd..dd2569a 100644
--- a/config/preloaded-classes-denylist
+++ b/config/preloaded-classes-denylist
@@ -1,13 +1,23 @@
android.content.AsyncTaskLoader$LoadTask
+android.media.MediaCodecInfo$CodecCapabilities$FeatureList
+android.media.MediaCodecInfo$LazyHolder
android.net.ConnectivityThread$Singleton
-android.os.FileObserver
-android.os.NullVibrator
-android.speech.tts.TextToSpeech$Connection$SetupConnectionAsyncTask
-android.widget.Magnifier
-gov.nist.core.net.DefaultNetworkLayer
android.net.rtp.AudioGroup
android.net.rtp.AudioStream
android.net.rtp.RtpStream
-java.util.concurrent.ThreadLocalRandom
-java.util.ImmutableCollections
+android.os.FileObserver
+android.os.NullVibrator
+android.permission.PermissionManager
+android.provider.MediaStore
+android.speech.tts.TextToSpeech$Connection$SetupConnectionAsyncTask
+android.view.HdrRenderState
+android.text.TextFlags
+android.widget.Magnifier
com.android.internal.jank.InteractionJankMonitor$InstanceHolder
+com.android.internal.os.BinderCallsStats$SettingsObserver
+com.android.internal.util.LatencyTracker$SLatencyTrackerHolder
+com.android.server.BootReceiver$2
+gov.nist.core.net.DefaultNetworkLayer
+java.util.ImmutableCollections
+java.util.concurrent.ThreadLocalRandom
+sun.nio.fs.UnixChannelFactory
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index bed1b43..15e5706 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -3448,7 +3448,7 @@
}
public static interface VirtualDeviceManager.ActivityListener {
- method @FlaggedApi("android.companion.virtualdevice.flags.activity_control_api") public default void onActivityLaunchBlocked(int, @NonNull android.content.ComponentName, int);
+ method @FlaggedApi("android.companion.virtualdevice.flags.activity_control_api") public default void onActivityLaunchBlocked(int, @NonNull android.content.ComponentName, int, @Nullable android.content.IntentSender);
method public void onDisplayEmpty(int);
method @Deprecated public void onTopActivityChanged(int, @NonNull android.content.ComponentName);
method public default void onTopActivityChanged(int, @NonNull android.content.ComponentName, int);
diff --git a/core/java/android/app/AppCompatTaskInfo.java b/core/java/android/app/AppCompatTaskInfo.java
index a6d3f9d..81e9df6 100644
--- a/core/java/android/app/AppCompatTaskInfo.java
+++ b/core/java/android/app/AppCompatTaskInfo.java
@@ -18,63 +18,21 @@
import static android.app.TaskInfo.PROPERTY_VALUE_UNSET;
+import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
/**
* Stores App Compat information about a particular Task.
* @hide
*/
public class AppCompatTaskInfo implements Parcelable {
/**
- * Whether the direct top activity is eligible for letterbox education.
- */
- public boolean topActivityEligibleForLetterboxEducation;
-
- /**
- * Whether the letterbox education is enabled.
- */
- public boolean isLetterboxEducationEnabled;
-
- /**
- * Whether the direct top activity is in size compat mode on foreground.
- */
- public boolean topActivityInSizeCompat;
-
- /**
- * Whether the double tap is enabled.
- */
- public boolean isLetterboxDoubleTapEnabled;
-
- /**
- * Whether the user aspect ratio settings button is enabled.
- */
- public boolean topActivityEligibleForUserAspectRatioButton;
-
- /**
- * Whether the user has forced the activity to be fullscreen through the user aspect ratio
- * settings.
- */
- public boolean isUserFullscreenOverrideEnabled;
-
- /**
- * Whether the system has forced the activity to be fullscreen
- */
- public boolean isSystemFullscreenOverrideEnabled;
-
- /**
- * Hint about the letterbox state of the top activity.
- */
- public boolean topActivityBoundsLetterboxed;
-
- /**
- * Whether the update comes from a letterbox double-tap action from the user or not.
- */
- public boolean isFromLetterboxDoubleTap;
-
- /**
* If {@link #isLetterboxDoubleTapEnabled} it contains the current letterbox vertical position
* or {@link TaskInfo#PROPERTY_VALUE_UNSET} otherwise.
*/
@@ -115,6 +73,57 @@
*/
public CameraCompatTaskInfo cameraCompatTaskInfo = CameraCompatTaskInfo.create();
+ /** Constant indicating no top activity flag has been set. */
+ private static final int FLAG_UNDEFINED = 0x0;
+ /** Constant base value for top activity flag. */
+ private static final int FLAG_BASE = 0x1;
+ /** Top activity flag for whether letterbox education is enabled. */
+ private static final int FLAG_LETTERBOX_EDU_ENABLED = FLAG_BASE;
+ /** Top activity flag for whether activity is eligible for letterbox education. */
+ private static final int FLAG_ELIGIBLE_FOR_LETTERBOX_EDU = FLAG_BASE << 1;
+ /** Top activity flag for whether activity bounds are letterboxed. */
+ private static final int FLAG_LETTERBOXED = FLAG_BASE << 2;
+ /** Top activity flag for whether activity is in size compat mode. */
+ private static final int FLAG_IN_SIZE_COMPAT = FLAG_BASE << 3;
+ /** Top activity flag for whether letterbox double tap is enabled. */
+ private static final int FLAG_LETTERBOX_DOUBLE_TAP_ENABLED = FLAG_BASE << 4;
+ /** Top activity flag for whether the update comes from a letterbox double tap action. */
+ private static final int FLAG_IS_FROM_LETTERBOX_DOUBLE_TAP = FLAG_BASE << 5;
+ /** Top activity flag for whether activity is eligible for user aspect ratio button. */
+ private static final int FLAG_ELIGIBLE_FOR_USER_ASPECT_RATIO_BUTTON = FLAG_BASE << 6;
+ /** Top activity flag for whether has activity has been overridden to fullscreen by system. */
+ private static final int FLAG_FULLSCREEN_OVERRIDE_SYSTEM = FLAG_BASE << 7;
+ /** Top activity flag for whether has activity has been overridden to fullscreen by user. */
+ private static final int FLAG_FULLSCREEN_OVERRIDE_USER = FLAG_BASE << 8;
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(flag = true, value = {
+ FLAG_UNDEFINED,
+ FLAG_BASE,
+ FLAG_LETTERBOX_EDU_ENABLED,
+ FLAG_ELIGIBLE_FOR_LETTERBOX_EDU,
+ FLAG_LETTERBOXED,
+ FLAG_IN_SIZE_COMPAT,
+ FLAG_LETTERBOX_DOUBLE_TAP_ENABLED,
+ FLAG_IS_FROM_LETTERBOX_DOUBLE_TAP,
+ FLAG_ELIGIBLE_FOR_USER_ASPECT_RATIO_BUTTON,
+ FLAG_FULLSCREEN_OVERRIDE_SYSTEM,
+ FLAG_FULLSCREEN_OVERRIDE_USER
+ })
+ public @interface TopActivityFlag {}
+
+ @TopActivityFlag
+ private int mTopActivityFlags;
+
+ @TopActivityFlag
+ private static final int FLAGS_ORGANIZER_INTERESTED = FLAG_IS_FROM_LETTERBOX_DOUBLE_TAP
+ | FLAG_ELIGIBLE_FOR_USER_ASPECT_RATIO_BUTTON | FLAG_FULLSCREEN_OVERRIDE_SYSTEM
+ | FLAG_FULLSCREEN_OVERRIDE_USER;
+
+ @TopActivityFlag
+ private static final int FLAGS_COMPAT_UI_INTERESTED = FLAGS_ORGANIZER_INTERESTED
+ | FLAG_IN_SIZE_COMPAT | FLAG_ELIGIBLE_FOR_LETTERBOX_EDU | FLAG_LETTERBOX_EDU_ENABLED;
+
private AppCompatTaskInfo() {
// Do nothing
}
@@ -150,9 +159,8 @@
* @return {@code true} if the task has some compat ui.
*/
public boolean hasCompatUI() {
- return topActivityInSizeCompat || topActivityEligibleForLetterboxEducation
- || isLetterboxDoubleTapEnabled
- || topActivityEligibleForUserAspectRatioButton;
+ return isTopActivityInSizeCompat() || eligibleForLetterboxEducation()
+ || isLetterboxDoubleTapEnabled() || eligibleForUserAspectRatioButton();
}
/**
@@ -163,6 +171,142 @@
}
/**
+ * @return {@code true} if the letterbox education is enabled.
+ */
+ public boolean isLetterboxEducationEnabled() {
+ return isTopActivityFlagEnabled(FLAG_LETTERBOX_EDU_ENABLED);
+ }
+
+ /**
+ * Sets the top activity flag for whether letterbox education is enabled.
+ */
+ public void setLetterboxEducationEnabled(boolean enable) {
+ setTopActivityFlag(FLAG_LETTERBOX_EDU_ENABLED, enable);
+ }
+
+ /**
+ * @return {@code true} if the direct top activity is eligible for letterbox education.
+ */
+ public boolean eligibleForLetterboxEducation() {
+ return isTopActivityFlagEnabled(FLAG_ELIGIBLE_FOR_LETTERBOX_EDU);
+ }
+
+ /**
+ * Sets the top activity flag to be eligible for letterbox education.
+ */
+ public void setEligibleForLetterboxEducation(boolean enable) {
+ setTopActivityFlag(FLAG_ELIGIBLE_FOR_LETTERBOX_EDU, enable);
+ }
+
+ /**
+ * @return {@code true} if the direct top activity is eligible for the user aspect ratio
+ * settings button.
+ */
+ public boolean eligibleForUserAspectRatioButton() {
+ return isTopActivityFlagEnabled(FLAG_ELIGIBLE_FOR_USER_ASPECT_RATIO_BUTTON);
+ }
+
+ /**
+ * Sets the top activity flag to be eligible for the user aspect ratio settings button.
+ */
+ public void setEligibleForUserAspectRatioButton(boolean enable) {
+ setTopActivityFlag(FLAG_ELIGIBLE_FOR_USER_ASPECT_RATIO_BUTTON, enable);
+ }
+
+ /**
+ * @return {@code true} if double tap to reposition letterboxed app is enabled.
+ */
+ public boolean isLetterboxDoubleTapEnabled() {
+ return isTopActivityFlagEnabled(FLAG_LETTERBOX_DOUBLE_TAP_ENABLED);
+ }
+
+ /**
+ * Sets the top activity flag to enable double tap to reposition letterboxed app.
+ */
+ public void setLetterboxDoubleTapEnabled(boolean enable) {
+ setTopActivityFlag(FLAG_LETTERBOX_DOUBLE_TAP_ENABLED, enable);
+ }
+
+ /**
+ * @return {@code true} if the update comes from a letterbox double-tap action from the user.
+ */
+ public boolean isFromLetterboxDoubleTap() {
+ return isTopActivityFlagEnabled(FLAG_IS_FROM_LETTERBOX_DOUBLE_TAP);
+ }
+
+ /**
+ * Sets the top activity flag for whether the update comes from a letterbox double-tap action
+ * from the user.
+ */
+ public void setIsFromLetterboxDoubleTap(boolean enable) {
+ setTopActivityFlag(FLAG_IS_FROM_LETTERBOX_DOUBLE_TAP, enable);
+ }
+
+ /**
+ * @return {@code true} if the user has forced the activity to be fullscreen through the
+ * user aspect ratio settings.
+ */
+ public boolean isUserFullscreenOverrideEnabled() {
+ return isTopActivityFlagEnabled(FLAG_FULLSCREEN_OVERRIDE_USER);
+ }
+
+ /**
+ * Sets the top activity flag for whether the user has forced the activity to be fullscreen
+ * through the user aspect ratio settings.
+ */
+ public void setUserFullscreenOverrideEnabled(boolean enable) {
+ setTopActivityFlag(FLAG_FULLSCREEN_OVERRIDE_USER, enable);
+ }
+
+ /**
+ * @return {@code true} if the system has forced the activity to be fullscreen.
+ */
+ public boolean isSystemFullscreenOverrideEnabled() {
+ return isTopActivityFlagEnabled(FLAG_FULLSCREEN_OVERRIDE_SYSTEM);
+ }
+
+ /**
+ * Sets the top activity flag for whether the system has forced the activity to be fullscreen.
+ */
+ public void setSystemFullscreenOverrideEnabled(boolean enable) {
+ setTopActivityFlag(FLAG_FULLSCREEN_OVERRIDE_SYSTEM, enable);
+ }
+
+ /**
+ * @return {@code true} if the direct top activity is in size compat mode on foreground.
+ */
+ public boolean isTopActivityInSizeCompat() {
+ return isTopActivityFlagEnabled(FLAG_IN_SIZE_COMPAT);
+ }
+
+ /**
+ * Sets the top activity flag for whether the direct top activity is in size compat mode
+ * on foreground.
+ */
+ public void setTopActivityInSizeCompat(boolean enable) {
+ setTopActivityFlag(FLAG_IN_SIZE_COMPAT, enable);
+ }
+
+ /**
+ * @return {@code true} if the top activity bounds are letterboxed.
+ */
+ public boolean isTopActivityLetterboxed() {
+ return isTopActivityFlagEnabled(FLAG_LETTERBOXED);
+ }
+
+ /**
+ * Sets the top activity flag for whether the top activity bounds are letterboxed.
+ */
+ public void setTopActivityLetterboxed(boolean enable) {
+ setTopActivityFlag(FLAG_LETTERBOXED, enable);
+ }
+
+ /** Clear all top activity flags and set to false. */
+ public void clearTopActivityFlags() {
+ mTopActivityFlags = FLAG_UNDEFINED;
+ }
+
+ /**
* @return {@code true} if the app compat parameters that are important for task organizers
* are equal.
*/
@@ -170,9 +314,8 @@
if (that == null) {
return false;
}
- return isFromLetterboxDoubleTap == that.isFromLetterboxDoubleTap
- && topActivityEligibleForUserAspectRatioButton
- == that.topActivityEligibleForUserAspectRatioButton
+ return (mTopActivityFlags & FLAGS_ORGANIZER_INTERESTED)
+ == (that.mTopActivityFlags & FLAGS_ORGANIZER_INTERESTED)
&& topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition
&& topActivityLetterboxWidth == that.topActivityLetterboxWidth
&& topActivityLetterboxHeight == that.topActivityLetterboxHeight
@@ -180,8 +323,6 @@
&& topActivityLetterboxAppHeight == that.topActivityLetterboxAppHeight
&& topActivityLetterboxHorizontalPosition
== that.topActivityLetterboxHorizontalPosition
- && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled
- && isSystemFullscreenOverrideEnabled == that.isSystemFullscreenOverrideEnabled
&& cameraCompatTaskInfo.equalsForTaskOrganizer(that.cameraCompatTaskInfo);
}
@@ -192,13 +333,8 @@
if (that == null) {
return false;
}
- return topActivityInSizeCompat == that.topActivityInSizeCompat
- && isFromLetterboxDoubleTap == that.isFromLetterboxDoubleTap
- && topActivityEligibleForUserAspectRatioButton
- == that.topActivityEligibleForUserAspectRatioButton
- && topActivityEligibleForLetterboxEducation
- == that.topActivityEligibleForLetterboxEducation
- && isLetterboxEducationEnabled == that.isLetterboxEducationEnabled
+ return (mTopActivityFlags & FLAGS_COMPAT_UI_INTERESTED)
+ == (that.mTopActivityFlags & FLAGS_COMPAT_UI_INTERESTED)
&& topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition
&& topActivityLetterboxHorizontalPosition
== that.topActivityLetterboxHorizontalPosition
@@ -206,8 +342,6 @@
&& topActivityLetterboxHeight == that.topActivityLetterboxHeight
&& topActivityLetterboxAppWidth == that.topActivityLetterboxAppWidth
&& topActivityLetterboxAppHeight == that.topActivityLetterboxAppHeight
- && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled
- && isSystemFullscreenOverrideEnabled == that.isSystemFullscreenOverrideEnabled
&& cameraCompatTaskInfo.equalsForCompatUi(that.cameraCompatTaskInfo);
}
@@ -215,21 +349,13 @@
* Reads the AppCompatTaskInfo from a parcel.
*/
void readFromParcel(Parcel source) {
- isLetterboxEducationEnabled = source.readBoolean();
- topActivityInSizeCompat = source.readBoolean();
- topActivityEligibleForLetterboxEducation = source.readBoolean();
- isLetterboxDoubleTapEnabled = source.readBoolean();
- topActivityEligibleForUserAspectRatioButton = source.readBoolean();
- topActivityBoundsLetterboxed = source.readBoolean();
- isFromLetterboxDoubleTap = source.readBoolean();
+ mTopActivityFlags = source.readInt();
topActivityLetterboxVerticalPosition = source.readInt();
topActivityLetterboxHorizontalPosition = source.readInt();
topActivityLetterboxWidth = source.readInt();
topActivityLetterboxHeight = source.readInt();
topActivityLetterboxAppWidth = source.readInt();
topActivityLetterboxAppHeight = source.readInt();
- isUserFullscreenOverrideEnabled = source.readBoolean();
- isSystemFullscreenOverrideEnabled = source.readBoolean();
cameraCompatTaskInfo = source.readTypedObject(CameraCompatTaskInfo.CREATOR);
}
@@ -238,35 +364,25 @@
*/
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeBoolean(isLetterboxEducationEnabled);
- dest.writeBoolean(topActivityInSizeCompat);
- dest.writeBoolean(topActivityEligibleForLetterboxEducation);
- dest.writeBoolean(isLetterboxDoubleTapEnabled);
- dest.writeBoolean(topActivityEligibleForUserAspectRatioButton);
- dest.writeBoolean(topActivityBoundsLetterboxed);
- dest.writeBoolean(isFromLetterboxDoubleTap);
+ dest.writeInt(mTopActivityFlags);
dest.writeInt(topActivityLetterboxVerticalPosition);
dest.writeInt(topActivityLetterboxHorizontalPosition);
dest.writeInt(topActivityLetterboxWidth);
dest.writeInt(topActivityLetterboxHeight);
dest.writeInt(topActivityLetterboxAppWidth);
dest.writeInt(topActivityLetterboxAppHeight);
- dest.writeBoolean(isUserFullscreenOverrideEnabled);
- dest.writeBoolean(isSystemFullscreenOverrideEnabled);
dest.writeTypedObject(cameraCompatTaskInfo, flags);
}
@Override
public String toString() {
- return "AppCompatTaskInfo { topActivityInSizeCompat=" + topActivityInSizeCompat
- + " topActivityEligibleForLetterboxEducation= "
- + topActivityEligibleForLetterboxEducation
- + "isLetterboxEducationEnabled= " + isLetterboxEducationEnabled
- + " isLetterboxDoubleTapEnabled= " + isLetterboxDoubleTapEnabled
- + " topActivityEligibleForUserAspectRatioButton= "
- + topActivityEligibleForUserAspectRatioButton
- + " topActivityBoundsLetterboxed= " + topActivityBoundsLetterboxed
- + " isFromLetterboxDoubleTap= " + isFromLetterboxDoubleTap
+ return "AppCompatTaskInfo { topActivityInSizeCompat=" + isTopActivityInSizeCompat()
+ + " eligibleForLetterboxEducation= " + eligibleForLetterboxEducation()
+ + " isLetterboxEducationEnabled= " + isLetterboxEducationEnabled()
+ + " isLetterboxDoubleTapEnabled= " + isLetterboxDoubleTapEnabled()
+ + " eligibleForUserAspectRatioButton= " + eligibleForUserAspectRatioButton()
+ + " topActivityBoundsLetterboxed= " + isTopActivityLetterboxed()
+ + " isFromLetterboxDoubleTap= " + isFromLetterboxDoubleTap()
+ " topActivityLetterboxVerticalPosition= " + topActivityLetterboxVerticalPosition
+ " topActivityLetterboxHorizontalPosition= "
+ topActivityLetterboxHorizontalPosition
@@ -274,9 +390,17 @@
+ " topActivityLetterboxHeight=" + topActivityLetterboxHeight
+ " topActivityLetterboxAppWidth=" + topActivityLetterboxAppWidth
+ " topActivityLetterboxAppHeight=" + topActivityLetterboxAppHeight
- + " isUserFullscreenOverrideEnabled=" + isUserFullscreenOverrideEnabled
- + " isSystemFullscreenOverrideEnabled=" + isSystemFullscreenOverrideEnabled
+ + " isUserFullscreenOverrideEnabled=" + isUserFullscreenOverrideEnabled()
+ + " isSystemFullscreenOverrideEnabled=" + isSystemFullscreenOverrideEnabled()
+ " cameraCompatTaskInfo=" + cameraCompatTaskInfo.toString()
+ "}";
}
+
+ private void setTopActivityFlag(@TopActivityFlag int flag, boolean enable) {
+ mTopActivityFlags = enable ? (mTopActivityFlags | flag) : (mTopActivityFlags & ~flag);
+ }
+
+ private boolean isTopActivityFlagEnabled(@TopActivityFlag int flag) {
+ return (mTopActivityFlags & flag) == flag;
+ }
}
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index 5214d2c..9d63be7 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -11013,7 +11013,8 @@
if (access != null) {
NoteOpEvent existingAccess = accessEvents.get(key);
- if (existingAccess == null || existingAccess.getDuration() == -1) {
+ if (existingAccess == null || existingAccess.getDuration() == -1
+ || existingAccess.getDuration() < access.getDuration()) {
accessEvents.append(key, access);
} else if (existingAccess.mProxy == null && access.mProxy != null ) {
existingAccess.mProxy = access.mProxy;
diff --git a/core/java/android/app/ComponentOptions.java b/core/java/android/app/ComponentOptions.java
index b3fc058..0819833 100644
--- a/core/java/android/app/ComponentOptions.java
+++ b/core/java/android/app/ComponentOptions.java
@@ -105,17 +105,10 @@
public @NonNull ComponentOptions setPendingIntentBackgroundActivityStartMode(
@BackgroundActivityStartMode int state) {
switch (state) {
- case MODE_BACKGROUND_ACTIVITY_START_ALLOWED:
- if (mPendingIntentBalAllowed != MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS) {
- // do not overwrite ALWAYS with ALLOWED for backwards compatibility,
- // if setPendingIntentBackgroundActivityLaunchAllowedByPermission is used
- // before this method.
- mPendingIntentBalAllowed = state;
- }
- break;
case MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED:
case MODE_BACKGROUND_ACTIVITY_START_DENIED:
case MODE_BACKGROUND_ACTIVITY_START_COMPAT:
+ case MODE_BACKGROUND_ACTIVITY_START_ALLOWED:
case MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS:
case MODE_BACKGROUND_ACTIVITY_START_ALLOW_IF_VISIBLE:
mPendingIntentBalAllowed = state;
@@ -139,35 +132,6 @@
return mPendingIntentBalAllowed;
}
- /**
- * Get PendingIntent activity is allowed to be started in the background if the caller
- * has BAL permission.
- * @hide
- * @deprecated check for #MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS
- */
- @Deprecated
- public boolean isPendingIntentBackgroundActivityLaunchAllowedByPermission() {
- return mPendingIntentBalAllowed == MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS;
- }
-
- /**
- * Set PendingIntent activity can be launched from background if caller has BAL permission.
- * @hide
- * @deprecated use #MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS
- */
- @Deprecated
- public void setPendingIntentBackgroundActivityLaunchAllowedByPermission(boolean allowed) {
- if (allowed) {
- setPendingIntentBackgroundActivityStartMode(
- MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS);
- } else {
- if (getPendingIntentBackgroundActivityStartMode()
- == MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS) {
- setPendingIntentBackgroundActivityStartMode(MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
- }
- }
- }
-
/** @hide */
public Bundle toBundle() {
Bundle b = new Bundle();
diff --git a/core/java/android/companion/virtual/IVirtualDeviceActivityListener.aidl b/core/java/android/companion/virtual/IVirtualDeviceActivityListener.aidl
index 39371a3..564fb02 100644
--- a/core/java/android/companion/virtual/IVirtualDeviceActivityListener.aidl
+++ b/core/java/android/companion/virtual/IVirtualDeviceActivityListener.aidl
@@ -17,6 +17,7 @@
package android.companion.virtual;
import android.content.ComponentName;
+import android.content.IntentSender;
/**
* Interface to listen for activity changes in a virtual device.
@@ -48,6 +49,8 @@
* @param displayId The display ID on which the activity tried to launch.
* @param componentName The component name of the blocked activity.
* @param userId The user ID associated with the blocked activity.
+ * @param intentSender The original sender of the intent.
*/
- void onActivityLaunchBlocked(int displayId, in ComponentName componentName, int userId);
+ void onActivityLaunchBlocked(int displayId, in ComponentName componentName, int userId,
+ in IntentSender intentSender);
}
diff --git a/core/java/android/companion/virtual/VirtualDeviceInternal.java b/core/java/android/companion/virtual/VirtualDeviceInternal.java
index d8899b2..19eb497 100644
--- a/core/java/android/companion/virtual/VirtualDeviceInternal.java
+++ b/core/java/android/companion/virtual/VirtualDeviceInternal.java
@@ -38,6 +38,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.IntentSender;
import android.hardware.display.DisplayManagerGlobal;
import android.hardware.display.IVirtualDisplayCallback;
import android.hardware.display.VirtualDisplay;
@@ -135,13 +136,14 @@
@Override
public void onActivityLaunchBlocked(int displayId, ComponentName componentName,
- @UserIdInt int userId) {
+ @UserIdInt int userId, IntentSender intentSender) {
final long token = Binder.clearCallingIdentity();
try {
synchronized (mActivityListenersLock) {
for (int i = 0; i < mActivityListeners.size(); i++) {
mActivityListeners.valueAt(i)
- .onActivityLaunchBlocked(displayId, componentName, userId);
+ .onActivityLaunchBlocked(
+ displayId, componentName, userId, intentSender);
}
}
} finally {
@@ -593,9 +595,10 @@
}
public void onActivityLaunchBlocked(int displayId, ComponentName componentName,
- @UserIdInt int userId) {
+ @UserIdInt int userId, IntentSender intentSender) {
mExecutor.execute(() ->
- mActivityListener.onActivityLaunchBlocked(displayId, componentName, userId));
+ mActivityListener.onActivityLaunchBlocked(
+ displayId, componentName, userId, intentSender));
}
}
diff --git a/core/java/android/companion/virtual/VirtualDeviceManager.java b/core/java/android/companion/virtual/VirtualDeviceManager.java
index d89ffc9..8b60580 100644
--- a/core/java/android/companion/virtual/VirtualDeviceManager.java
+++ b/core/java/android/companion/virtual/VirtualDeviceManager.java
@@ -43,6 +43,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.IntentSender;
import android.graphics.Point;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.VirtualDisplayFlag;
@@ -1264,13 +1265,18 @@
* @param displayId The display ID on which the activity tried to launch.
* @param componentName The component name of the blocked activity.
* @param userId The user ID associated with the blocked activity.
+ * @param intentSender The original sender of the intent. May be {@code null} if the sender
+ * expects an activity result to be reported. In that case
+ * {@link android.app.Activity#RESULT_CANCELED} was already reported back because the
+ * launch was blocked. This {@link IntentSender} can be used to relaunch the blocked
+ * activity to a different display.
*
* @see VirtualDeviceParams#POLICY_TYPE_ACTIVITY
* @see VirtualDevice#addActivityPolicyExemption(ComponentName)
*/
@FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_ACTIVITY_CONTROL_API)
default void onActivityLaunchBlocked(int displayId, @NonNull ComponentName componentName,
- @UserIdInt int userId) {}
+ @UserIdInt int userId, @Nullable IntentSender intentSender) {}
}
/**
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 00ce949..e79b8f3 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -2796,6 +2796,9 @@
* <p>This dismisses the {@link #getStylusHandwritingWindow ink window} and stops intercepting
* stylus {@code MotionEvent}s.
*
+ * <p>Connectionless handwriting sessions should be finished using {@link
+ * #finishConnectionlessStylusHandwriting(CharSequence)}.
+ *
* <p>Note for IME developers: Call this method at any time to finish the current handwriting
* session. Generally, this should be invoked after a short timeout, giving the user enough time
* to start the next stylus stroke, if any. By default, system will time-out after few seconds.
@@ -2803,9 +2806,6 @@
*
* <p>Handwriting session will be finished by framework on next {@link #onFinishInput()}.
*/
- // TODO(b/300979854): Once connectionless APIs are finalised, update documentation to add:
- // <p>Connectionless handwriting sessions should be finished using {@link
- // #finishConnectionlessStylusHandwriting(CharSequence)}.
public final void finishStylusHandwriting() {
if (DEBUG) Log.v(TAG, "finishStylusHandwriting()");
if (mInkWindow == null) {
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 392b6eb..06c516a 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -2391,10 +2391,15 @@
*/
public static final int USER_OPERATION_ERROR_DISABLED_USER = 8;
/**
- * Indicates user operation failed because user is disabled on the device.
+ * Indicates user operation failed because private space is disabled on the device.
* @hide
*/
public static final int USER_OPERATION_ERROR_PRIVATE_PROFILE = 9;
+ /**
+ * Indicates user operation failed because user is restricted on the device.
+ * @hide
+ */
+ public static final int USER_OPERATION_ERROR_USER_RESTRICTED = 10;
/**
* Result returned from various user operations.
@@ -2413,6 +2418,7 @@
USER_OPERATION_ERROR_USER_ACCOUNT_ALREADY_EXISTS,
USER_OPERATION_ERROR_DISABLED_USER,
USER_OPERATION_ERROR_PRIVATE_PROFILE,
+ USER_OPERATION_ERROR_USER_RESTRICTED,
})
public @interface UserOperationResult {}
diff --git a/core/java/android/os/vibrator/flags.aconfig b/core/java/android/os/vibrator/flags.aconfig
index 67c3464..40dd91f 100644
--- a/core/java/android/os/vibrator/flags.aconfig
+++ b/core/java/android/os/vibrator/flags.aconfig
@@ -85,3 +85,13 @@
purpose: PURPOSE_FEATURE
}
}
+
+flag {
+ namespace: "haptics"
+ name: "fix_audio_coupled_haptics_scaling"
+ description: "Fix the audio-coupled haptics scaling to use same function as VibrationEffect"
+ bug: "356144312"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
diff --git a/core/java/android/view/HapticScrollFeedbackProvider.java b/core/java/android/view/HapticScrollFeedbackProvider.java
index 6b354a0..f370256 100644
--- a/core/java/android/view/HapticScrollFeedbackProvider.java
+++ b/core/java/android/view/HapticScrollFeedbackProvider.java
@@ -135,15 +135,16 @@
private void maybeUpdateCurrentConfig(int deviceId, int source, int axis) {
if (mAxis != axis || mSource != source || mDeviceId != deviceId) {
+ mSource = source;
+ mAxis = axis;
+ mDeviceId = deviceId;
+
if (mDisabledIfViewPlaysScrollHaptics
&& (source == InputDevice.SOURCE_ROTARY_ENCODER)
&& mViewConfig.isViewBasedRotaryEncoderHapticScrollFeedbackEnabled()) {
mHapticScrollFeedbackEnabled = false;
return;
}
- mSource = source;
- mAxis = axis;
- mDeviceId = deviceId;
mHapticScrollFeedbackEnabled =
mViewConfig.isHapticScrollFeedbackEnabled(deviceId, axis, source);
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 4ab6758..b281015 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -2887,6 +2887,11 @@
* initiation delegation was previously requested using
* {@link #prepareStylusHandwritingDelegation(View)} from the delegator.
*
+ * <p>Otherwise, if the delegator view previously started delegation using {@link
+ * #startConnectionlessStylusHandwritingForDelegation(View, CursorAnchorInfo, Executor,
+ * ConnectionlessHandwritingCallback)}, requests the IME to commit the recognised handwritten
+ * text from the connectionless session to the delegate view.
+ *
* <p>Note: If delegator and delegate are in different application packages, use
* {@link #acceptStylusHandwritingDelegation(View, String)} instead.</p>
*
@@ -2895,14 +2900,9 @@
* {@link #prepareStylusHandwritingDelegation(View)} and delegation is accepted
* @see #prepareStylusHandwritingDelegation(View)
* @see #acceptStylusHandwritingDelegation(View, String)
+ * @see #startConnectionlessStylusHandwritingForDelegation(View, CursorAnchorInfo, Executor,
+ * ConnectionlessHandwritingCallback)
*/
- // TODO(b/300979854): Once connectionless APIs are finalised, update documentation to add:
- // <p>Otherwise, if the delegator view previously started delegation using {@link
- // #startConnectionlessStylusHandwritingForDelegation(View, ResultReceiver, CursorAnchorInfo)},
- // requests the IME to commit the recognised handwritten text from the connectionless session to
- // the delegate view.
- // @see #startConnectionlessStylusHandwritingForDelegation(View, ResultReceiver,
- // CursorAnchorInfo)
public boolean acceptStylusHandwritingDelegation(@NonNull View delegateView) {
return startStylusHandwritingInternal(
delegateView, delegateView.getContext().getOpPackageName(),
@@ -2915,6 +2915,11 @@
* {@link #prepareStylusHandwritingDelegation(View, String)} from the delegator and the view
* belongs to a specified delegate package.
*
+ * <p>Otherwise, if the delegator view previously started delegation using {@link
+ * #startConnectionlessStylusHandwritingForDelegation(View, CursorAnchorInfo, String, Executor,
+ * ConnectionlessHandwritingCallback)}, requests the IME to commit the recognised handwritten
+ * text from the connectionless session to the delegate view.
+ *
* <p>Note: If delegator and delegate are in the same application package, use
* {@link #acceptStylusHandwritingDelegation(View)} instead.</p>
*
@@ -2924,15 +2929,10 @@
* #prepareStylusHandwritingDelegation(View, String)} and delegation is accepted
* @see #prepareStylusHandwritingDelegation(View, String)
* @see #acceptStylusHandwritingDelegation(View)
+ * @see #startConnectionlessStylusHandwritingForDelegation(View, CursorAnchorInfo, String,
+ * Executor, ConnectionlessHandwritingCallback)
* TODO (b/293640003): deprecate this method once flag is enabled.
*/
- // TODO(b/300979854): Once connectionless APIs are finalised, update documentation to add:
- // <p>Otherwise, if the delegator view previously started delegation using {@link
- // #startConnectionlessStylusHandwritingForDelegation(View, ResultReceiver, CursorAnchorInfo,
- // String)}, requests the IME to commit the recognised handwritten text from the connectionless
- // session to the delegate view.
- // @see #startConnectionlessStylusHandwritingForDelegation(View, ResultReceiver,
- // CursorAnchorInfo, String)
public boolean acceptStylusHandwritingDelegation(
@NonNull View delegateView, @NonNull String delegatorPackageName) {
Objects.requireNonNull(delegatorPackageName);
@@ -2946,6 +2946,11 @@
* {@link #prepareStylusHandwritingDelegation(View, String)} from the delegator and the view
* belongs to a specified delegate package.
*
+ * <p>Otherwise, if the delegator view previously started delegation using {@link
+ * #startConnectionlessStylusHandwritingForDelegation(View, CursorAnchorInfo, String, Executor,
+ * ConnectionlessHandwritingCallback)}, requests the IME to commit the recognised handwritten
+ * text from the connectionless session to the delegate view.
+ *
* @param delegateView delegate view capable of receiving input via {@link InputConnection}
* on which {@link #startStylusHandwriting(View)} will be called.
* @param delegatorPackageName package name of the delegator that handled initial stylus stroke.
@@ -2957,6 +2962,8 @@
* The framework only holds a weak reference.
* @see #prepareStylusHandwritingDelegation(View, String)
* @see #acceptStylusHandwritingDelegation(View)
+ * @see #startConnectionlessStylusHandwritingForDelegation(View, CursorAnchorInfo, String,
+ * Executor, ConnectionlessHandwritingCallback)
*/
@FlaggedApi(Flags.FLAG_USE_ZERO_JANK_PROXY)
public void acceptStylusHandwritingDelegation(
@@ -2977,6 +2984,11 @@
* #prepareStylusHandwritingDelegation(View, String)} from the delegator and the view belongs to
* a specified delegate package.
*
+ * <p>Otherwise, if the delegator view previously started delegation using {@link
+ * #startConnectionlessStylusHandwritingForDelegation(View, CursorAnchorInfo, String, Executor,
+ * ConnectionlessHandwritingCallback)}, requests the IME to commit the recognised handwritten
+ * text from the connectionless session to the delegate view.
+ *
* <p>Note: If delegator and delegate are in the same application package, use {@link
* #acceptStylusHandwritingDelegation(View)} instead.
*
@@ -2988,15 +3000,9 @@
* hold a reference to the callback. The framework only holds a weak reference.
* @see #prepareStylusHandwritingDelegation(View, String)
* @see #acceptStylusHandwritingDelegation(View)
+ * @see #startConnectionlessStylusHandwritingForDelegation(View, CursorAnchorInfo, String,
+ * Executor, ConnectionlessHandwritingCallback)
*/
- // TODO(b/300979854): Once connectionless APIs are finalised, update documentation to add:
- // <p>Otherwise, if the delegator view previously started delegation using {@link
- // #startConnectionlessStylusHandwritingForDelegation(View, ResultReceiver, CursorAnchorInfo,
- // String)}, requests the IME to commit the recognised handwritten text from the connectionless
- // session to the delegate view.
- // @see #startConnectionlessStylusHandwritingForDelegation(View, ResultReceiver,
- // CursorAnchorInfo, String)
- //
@FlaggedApi(FLAG_HOME_SCREEN_HANDWRITING_DELEGATOR)
public void acceptStylusHandwritingDelegation(
@NonNull View delegateView, @NonNull String delegatorPackageName,
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 8b6ead7..d28c953 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -3285,9 +3285,11 @@
.setEnabled(mTextView.canShare())
.setIcon(a.getDrawable(6))
.setOnMenuItemClickListener(mOnContextMenuItemClickListener);
+ final String selected = mTextView.getSelectedText();
menu.add(CONTEXT_MENU_GROUP_MISC, TextView.ID_AUTOFILL, menuItemOrderAutofill,
android.R.string.autofill)
- .setEnabled(mTextView.canRequestAutofill())
+ .setEnabled(mTextView.canRequestAutofill()
+ && (selected == null || selected.isEmpty()))
.setOnMenuItemClickListener(mOnContextMenuItemClickListener);
mPreserveSelection = true;
diff --git a/core/java/android/window/DisplayWindowPolicyController.java b/core/java/android/window/DisplayWindowPolicyController.java
index 62a7283..a16d537 100644
--- a/core/java/android/window/DisplayWindowPolicyController.java
+++ b/core/java/android/window/DisplayWindowPolicyController.java
@@ -25,12 +25,14 @@
import android.app.WindowConfiguration;
import android.content.ComponentName;
import android.content.Intent;
+import android.content.IntentSender;
import android.content.pm.ActivityInfo;
import android.util.ArraySet;
import java.io.PrintWriter;
import java.util.List;
import java.util.Set;
+import java.util.function.Supplier;
/**
* Abstract class to control the policies of the windows that can be displayed on the virtual
@@ -136,10 +138,14 @@
* Returns {@code true} if the given activity can be launched on this virtual display in the
* configuration defined by the rest of the arguments. If the given intent would be intercepted
* by the display owner then this means that the activity cannot be launched.
+ *
+ * The intentSender argument can provide an IntentSender for the original intent to be passed
+ * to any activity listeners, in case the activity cannot be launched.
*/
public abstract boolean canActivityBeLaunched(@NonNull ActivityInfo activityInfo,
@Nullable Intent intent, @WindowConfiguration.WindowingMode int windowingMode,
- int launchingFromDisplayId, boolean isNewTask);
+ int launchingFromDisplayId, boolean isNewTask, boolean isResultExpected,
+ @Nullable Supplier<IntentSender> intentSender);
/**
* Returns {@code true} if the given activity can be launched on this virtual display in the
diff --git a/core/java/com/android/internal/widget/MessagingMessage.java b/core/java/com/android/internal/widget/MessagingMessage.java
index ad90a63..a59ee77 100644
--- a/core/java/com/android/internal/widget/MessagingMessage.java
+++ b/core/java/com/android/internal/widget/MessagingMessage.java
@@ -105,7 +105,10 @@
}
default void removeMessage(ArrayList<MessagingLinearLayout.MessagingChild> toRecycle) {
- getGroup().removeMessage(this, toRecycle);
+ final MessagingGroup group = getGroup();
+ if (group != null) {
+ group.removeMessage(this, toRecycle);
+ }
}
default void setMessagingGroup(MessagingGroup group) {
@@ -132,7 +135,12 @@
@Override
default void hideAnimated() {
setIsHidingAnimated(true);
- getGroup().performRemoveAnimation(getView(), () -> setIsHidingAnimated(false));
+ final MessagingGroup group = getGroup();
+ if (group != null) {
+ group.performRemoveAnimation(getView(), () -> setIsHidingAnimated(false));
+ } else {
+ setIsHidingAnimated(false);
+ }
}
default boolean hasOverlappingRendering() {
diff --git a/core/tests/coretests/src/android/view/HapticScrollFeedbackProviderTest.java b/core/tests/coretests/src/android/view/HapticScrollFeedbackProviderTest.java
index 3dfeb7f..b9a9557 100644
--- a/core/tests/coretests/src/android/view/HapticScrollFeedbackProviderTest.java
+++ b/core/tests/coretests/src/android/view/HapticScrollFeedbackProviderTest.java
@@ -428,6 +428,35 @@
assertFeedbackCount(mView, HapticFeedbackConstants.SCROLL_LIMIT, 1);
}
+ @Test
+ public void testNonRotaryInputFeedbackNotBlockedByRotaryUnavailability() {
+ when(mMockViewConfig.isViewBasedRotaryEncoderHapticScrollFeedbackEnabled())
+ .thenReturn(true);
+ setHapticScrollFeedbackEnabled(true);
+ setHapticScrollTickInterval(5);
+ mProvider = new HapticScrollFeedbackProvider(mView, mMockViewConfig,
+ /* disabledIfViewPlaysScrollHaptics= */ true);
+
+ // Expect one feedback here. Touch input should provide feedback since scroll feedback has
+ // been enabled via `setHapticScrollFeedbackEnabled(true)`.
+ mProvider.onScrollProgress(
+ INPUT_DEVICE_1, InputDevice.SOURCE_TOUCHSCREEN, MotionEvent.AXIS_Y,
+ /* deltaInPixels= */ 10);
+ // Because `isViewBasedRotaryEncoderHapticScrollFeedbackEnabled()` is false and
+ // `disabledIfViewPlaysScrollHaptics` is true, the scroll progress from rotary encoders will
+ // produce no feedback.
+ mProvider.onScrollProgress(
+ INPUT_DEVICE_2, InputDevice.SOURCE_ROTARY_ENCODER, MotionEvent.AXIS_SCROLL,
+ /* deltaInPixels= */ 20);
+ // This event from the touch screen should produce feedback. The rotary encoder event's
+ // inability to not play scroll feedback should not impact this touch input.
+ mProvider.onScrollProgress(
+ INPUT_DEVICE_1, InputDevice.SOURCE_TOUCHSCREEN, MotionEvent.AXIS_Y,
+ /* deltaInPixels= */ 30);
+
+ assertFeedbackCount(mView, HapticFeedbackConstants.SCROLL_TICK, 2);
+ }
+
private void assertNoFeedback(TestView view) {
for (int feedback : new int[] {SCROLL_ITEM_FOCUS, SCROLL_LIMIT, SCROLL_TICK}) {
diff --git a/core/tests/coretests/src/android/widget/TextViewContextMenuTest.java b/core/tests/coretests/src/android/widget/TextViewContextMenuTest.java
index 12f8c9c..f9da832 100644
--- a/core/tests/coretests/src/android/widget/TextViewContextMenuTest.java
+++ b/core/tests/coretests/src/android/widget/TextViewContextMenuTest.java
@@ -240,4 +240,45 @@
verify(mockNoIconMenu, times(0)).setIcon(any());
verify(mockNoIconMenu2, times(0)).setIcon(any());
}
+
+ @UiThreadTest
+ @Test
+ public void testAutofillMenuItemEnabledWhenNoTextSelected() {
+ ContextMenu menu = mock(ContextMenu.class);
+ MenuItem mockMenuItem = newMockMenuItem();
+ when(menu.add(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(mockMenuItem);
+ MenuItem mockAutofillMenuItem = newMockMenuItem();
+ when(menu.add(anyInt(), eq(TextView.ID_AUTOFILL), anyInt(), anyInt()))
+ .thenReturn(mockAutofillMenuItem);
+
+ EditText et = mActivity.findViewById(R.id.editText);
+ et.setText("Test");
+
+ Editor editor = et.getEditorForTesting();
+ editor.onCreateContextMenu(menu);
+
+ verify(menu).add(anyInt(), eq(TextView.ID_AUTOFILL), anyInt(), anyInt());
+ verify(mockAutofillMenuItem).setEnabled(true);
+ }
+
+ @UiThreadTest
+ @Test
+ public void testAutofillMenuItemNotEnabledWhenTextSelected() {
+ ContextMenu menu = mock(ContextMenu.class);
+ MenuItem mockMenuItem = newMockMenuItem();
+ when(menu.add(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(mockMenuItem);
+ MenuItem mockAutofillMenuItem = newMockMenuItem();
+ when(menu.add(anyInt(), eq(TextView.ID_AUTOFILL), anyInt(), anyInt()))
+ .thenReturn(mockAutofillMenuItem);
+
+ EditText et = mActivity.findViewById(R.id.editText);
+ et.setText("Test");
+ et.selectAll();
+ Editor editor = et.getEditorForTesting();
+ editor.onCreateContextMenu(menu);
+
+ verify(menu).add(anyInt(), eq(TextView.ID_AUTOFILL), anyInt(), anyInt());
+ verify(mockAutofillMenuItem).setEnabled(false);
+ }
+
}
diff --git a/data/keyboards/Vendor_054c_Product_05c4.idc b/data/keyboards/Vendor_054c_Product_05c4.idc
index 2da6227..45b5207 100644
--- a/data/keyboards/Vendor_054c_Product_05c4.idc
+++ b/data/keyboards/Vendor_054c_Product_05c4.idc
@@ -51,7 +51,7 @@
# fingers, it prevents tapping to click because it thinks the finger's moving
# too fast.
#
-# Since this touchpad doesn't seem to have to drumroll issues, we can safely
+# Since this touchpad doesn't seem to have drumroll issues, we can safely
# disable drumroll detection.
gestureProp.Drumroll_Suppression_Enable = 0
@@ -60,3 +60,11 @@
# from the palm classifier to increase the usable area of the pad.
gestureProp.Palm_Edge_Zone_Width = 0
gestureProp.Tap_Exclusion_Border_Width = 0
+
+# Touchpad is small, scale up the pointer movements to make it more practical
+# to use.
+gestureProp.Point_X_Out_Scale = 2.5
+gestureProp.Point_Y_Out_Scale = 2.5
+
+# TODO(b/351326684): Ideally "Scroll X Out Scale" and "Scroll Y Out Scale"
+# should be adjusted as well. Currently not supported in IDC files.
diff --git a/data/keyboards/Vendor_054c_Product_09cc.idc b/data/keyboards/Vendor_054c_Product_09cc.idc
index 2a1a4fc..45b5207 100644
--- a/data/keyboards/Vendor_054c_Product_09cc.idc
+++ b/data/keyboards/Vendor_054c_Product_09cc.idc
@@ -60,3 +60,11 @@
# from the palm classifier to increase the usable area of the pad.
gestureProp.Palm_Edge_Zone_Width = 0
gestureProp.Tap_Exclusion_Border_Width = 0
+
+# Touchpad is small, scale up the pointer movements to make it more practical
+# to use.
+gestureProp.Point_X_Out_Scale = 2.5
+gestureProp.Point_Y_Out_Scale = 2.5
+
+# TODO(b/351326684): Ideally "Scroll X Out Scale" and "Scroll Y Out Scale"
+# should be adjusted as well. Currently not supported in IDC files.
diff --git a/data/keyboards/Vendor_054c_Product_0ce6.idc b/data/keyboards/Vendor_054c_Product_0ce6.idc
new file mode 100644
index 0000000..48027e7
--- /dev/null
+++ b/data/keyboards/Vendor_054c_Product_0ce6.idc
@@ -0,0 +1,31 @@
+# Copyright 2024 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.
+
+#
+# Sony Playstation(R) DualSense 5 Controller
+#
+
+## Touchpad ##
+
+# Because of the way this touchpad is positioned, touches around the edges are
+# no more likely to be palms than ones in the middle, so remove the edge zones
+# from the palm classifier to increase the usable area of the pad.
+gestureProp.Palm_Edge_Zone_Width = 0
+gestureProp.Tap_Exclusion_Border_Width = 0
+
+gestureProp.Point_X_Out_Scale = 2.0
+gestureProp.Point_Y_Out_Scale = 2.0
+
+# TODO(b/351326684): Ideally "Scroll X Out Scale" and "Scroll Y Out Scale"
+# should be adjusted as well. Currently not supported in IDC files.
diff --git a/data/keyboards/Vendor_054c_Product_0df2.idc b/data/keyboards/Vendor_054c_Product_0df2.idc
new file mode 100644
index 0000000..4bcf0be
--- /dev/null
+++ b/data/keyboards/Vendor_054c_Product_0df2.idc
@@ -0,0 +1,31 @@
+# Copyright 2024 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.
+
+#
+# Sony Playstation(R) DualSense Edge 5 Controller
+#
+
+## Touchpad ##
+
+# Because of the way this touchpad is positioned, touches around the edges are
+# no more likely to be palms than ones in the middle, so remove the edge zones
+# from the palm classifier to increase the usable area of the pad.
+gestureProp.Palm_Edge_Zone_Width = 0
+gestureProp.Tap_Exclusion_Border_Width = 0
+
+gestureProp.Point_X_Out_Scale = 2.0
+gestureProp.Point_Y_Out_Scale = 2.0
+
+# TODO(b/351326684): Ideally "Scroll X Out Scale" and "Scroll Y Out Scale"
+# should be adjusted as well. Currently not supported in IDC files.
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.kt
index 4e0c82b..c7e8df9 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.kt
@@ -170,7 +170,7 @@
initialTouchPos.set(backMotionEvent.touchX, backMotionEvent.touchY)
transaction.setAnimationTransaction()
- isLetterboxed = closingTarget!!.taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed
+ isLetterboxed = closingTarget!!.taskInfo.appCompatTaskInfo.isTopActivityLetterboxed
enteringHasSameLetterbox =
isLetterboxed && closingTarget!!.localBounds.equals(enteringTarget!!.localBounds)
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java
index 434b512..b6da761 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java
@@ -174,6 +174,7 @@
BubbleBarUpdate getInitialState() {
BubbleBarUpdate bubbleBarUpdate = BubbleBarUpdate.createInitialState();
bubbleBarUpdate.shouldShowEducation = shouldShowEducation;
+ bubbleBarUpdate.showOverflow = !overflowBubbles.isEmpty();
for (int i = 0; i < bubbles.size(); i++) {
bubbleBarUpdate.currentBubbleList.add(bubbles.get(i).asBubbleBarBubble());
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java
index 8f8b77b..efa1031 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java
@@ -2004,6 +2004,7 @@
// and then remove our views (removing the icon view triggers the removal of the
// bubble window so do that at the end of the animation so we see the scrim animate).
BadgedImageView iconView = bubble.getIconView();
+ final BubbleViewProvider expandedBubbleBeforeScrim = mExpandedBubble;
showScrim(false, () -> {
mRemovingLastBubbleWhileExpanded = false;
bubble.cleanupExpandedView();
@@ -2012,7 +2013,17 @@
}
bubble.cleanupViews(); // cleans up the icon view
updateExpandedView(); // resets state for no expanded bubble
- mExpandedBubble = null;
+ // Bubble keys may not have changed if we receive an update to the same bubble.
+ // Compare bubble object instances to see if the expanded bubble has changed.
+ if (expandedBubbleBeforeScrim == mExpandedBubble) {
+ // Only clear expanded bubble if it has not changed since the scrim animation
+ // started.
+ // Scrim animation can take some time run and it is possible for a new bubble
+ // to be added while the animation is running. This causes the expanded
+ // bubble to change. Make sure we only clear the expanded bubble if it did
+ // not change between when the scrim animation started and completed.
+ mExpandedBubble = null;
+ }
});
logBubbleEvent(bubble, FrameworkStatsLog.BUBBLE_UICHANGED__ACTION__DISMISSED);
return;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java
index d7d19f7..3fa51a9 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java
@@ -468,6 +468,12 @@
if (mImeSourceControl == null || mImeSourceControl.getLeash() == null) {
if (DEBUG) Slog.d(TAG, "No leash available, not starting the animation.");
return;
+ } else if (!mImeRequestedVisible && show) {
+ // we have a control with leash, but the IME was not requested visible before,
+ // therefore aborting the show animation.
+ Slog.e(TAG, "IME was not requested visible, not starting the show animation.");
+ // TODO(b/353463205) fail statsToken here
+ return;
}
}
final InsetsSource imeSource = mInsetsState.peekSource(InsetsSource.ID_IME);
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java
index c02c9cf..7c0455e 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java
@@ -238,7 +238,7 @@
public void onCompatInfoChanged(@NonNull CompatUIInfo compatUIInfo) {
final TaskInfo taskInfo = compatUIInfo.getTaskInfo();
final ShellTaskOrganizer.TaskListener taskListener = compatUIInfo.getListener();
- if (taskInfo != null && !taskInfo.appCompatTaskInfo.topActivityInSizeCompat) {
+ if (taskInfo != null && !taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat()) {
mSetOfTaskIdsShowingRestartDialog.remove(taskInfo.taskId);
}
@@ -256,16 +256,16 @@
// basically cancel all the onboarding flow. We don't have to ignore events in case
// the app is in size compat mode.
if (mIsFirstReachabilityEducationRunning) {
- if (!taskInfo.appCompatTaskInfo.isFromLetterboxDoubleTap
- && !taskInfo.appCompatTaskInfo.topActivityInSizeCompat) {
+ if (!taskInfo.appCompatTaskInfo.isFromLetterboxDoubleTap()
+ && !taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat()) {
return;
}
mIsFirstReachabilityEducationRunning = false;
}
- if (taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed) {
- if (taskInfo.appCompatTaskInfo.isLetterboxEducationEnabled) {
+ if (taskInfo.appCompatTaskInfo.isTopActivityLetterboxed()) {
+ if (taskInfo.appCompatTaskInfo.isLetterboxEducationEnabled()) {
createOrUpdateLetterboxEduLayout(taskInfo, taskListener);
- } else if (!taskInfo.appCompatTaskInfo.isFromLetterboxDoubleTap) {
+ } else if (!taskInfo.appCompatTaskInfo.isFromLetterboxDoubleTap()) {
// In this case the app is letterboxed and the letterbox education
// is disabled. In this case we need to understand if it's the first
// time we show the reachability education. When this is happening
@@ -282,7 +282,7 @@
// We activate the first reachability education if the double-tap is enabled.
// If the double tap is not enabled (e.g. thin letterbox) we just set the value
// of the education being seen.
- if (taskInfo.appCompatTaskInfo.isLetterboxDoubleTapEnabled) {
+ if (taskInfo.appCompatTaskInfo.isLetterboxDoubleTapEnabled()) {
mIsFirstReachabilityEducationRunning = true;
createOrUpdateReachabilityEduLayout(taskInfo, taskListener);
return;
@@ -293,7 +293,7 @@
createOrUpdateCompatLayout(taskInfo, taskListener);
createOrUpdateRestartDialogLayout(taskInfo, taskListener);
if (mCompatUIConfiguration.getHasSeenLetterboxEducation(taskInfo.userId)) {
- if (taskInfo.appCompatTaskInfo.isLetterboxDoubleTapEnabled) {
+ if (taskInfo.appCompatTaskInfo.isLetterboxDoubleTapEnabled()) {
createOrUpdateReachabilityEduLayout(taskInfo, taskListener);
}
// The user aspect ratio button should not be handled when a new TaskInfo is
@@ -305,7 +305,7 @@
}
return;
}
- if (!taskInfo.appCompatTaskInfo.isFromLetterboxDoubleTap) {
+ if (!taskInfo.appCompatTaskInfo.isFromLetterboxDoubleTap()) {
createOrUpdateUserAspectRatioSettingsLayout(taskInfo, taskListener);
}
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java
index 271c07d..8ce7837 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIWindowManager.java
@@ -82,7 +82,7 @@
onRestartButtonClicked) {
super(context, taskInfo, syncQueue, taskListener, displayLayout);
mCallback = callback;
- mHasSizeCompat = taskInfo.appCompatTaskInfo.topActivityInSizeCompat;
+ mHasSizeCompat = taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat();
if (DESKTOP_WINDOWING_MODE.isEnabled(mContext)
&& DesktopModeFlags.DYNAMIC_INITIAL_BOUNDS.isEnabled(context)) {
// Don't show the SCM button for freeform tasks
@@ -138,7 +138,7 @@
public boolean updateCompatInfo(TaskInfo taskInfo, ShellTaskOrganizer.TaskListener taskListener,
boolean canShow) {
final boolean prevHasSizeCompat = mHasSizeCompat;
- mHasSizeCompat = taskInfo.appCompatTaskInfo.topActivityInSizeCompat;
+ mHasSizeCompat = taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat();
if (DESKTOP_WINDOWING_MODE.isEnabled(mContext)
&& DesktopModeFlags.DYNAMIC_INITIAL_BOUNDS.isEnabled(mContext)) {
// Don't show the SCM button for freeform tasks
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/LetterboxEduWindowManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/LetterboxEduWindowManager.java
index 623fead..2347032 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/LetterboxEduWindowManager.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/LetterboxEduWindowManager.java
@@ -104,7 +104,7 @@
mDockStateReader = dockStateReader;
mCompatUIConfiguration = compatUIConfiguration;
mEligibleForLetterboxEducation =
- taskInfo.appCompatTaskInfo.topActivityEligibleForLetterboxEducation;
+ taskInfo.appCompatTaskInfo.eligibleForLetterboxEducation();
}
@Override
@@ -205,8 +205,7 @@
@Override
public boolean updateCompatInfo(TaskInfo taskInfo, ShellTaskOrganizer.TaskListener taskListener,
boolean canShow) {
- mEligibleForLetterboxEducation =
- taskInfo.appCompatTaskInfo.topActivityEligibleForLetterboxEducation;
+ mEligibleForLetterboxEducation = taskInfo.appCompatTaskInfo.eligibleForLetterboxEducation();
return super.updateCompatInfo(taskInfo, taskListener, canShow);
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/ReachabilityEduWindowManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/ReachabilityEduWindowManager.java
index 07082a5..06f2dd1 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/ReachabilityEduWindowManager.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/ReachabilityEduWindowManager.java
@@ -91,7 +91,7 @@
Function<Integer, Integer> disappearTimeSupplier) {
super(context, taskInfo, syncQueue, taskListener, displayLayout);
final AppCompatTaskInfo appCompatTaskInfo = taskInfo.appCompatTaskInfo;
- mIsLetterboxDoubleTapEnabled = appCompatTaskInfo.isLetterboxDoubleTapEnabled;
+ mIsLetterboxDoubleTapEnabled = appCompatTaskInfo.isLetterboxDoubleTapEnabled();
mLetterboxVerticalPosition = appCompatTaskInfo.topActivityLetterboxVerticalPosition;
mLetterboxHorizontalPosition = appCompatTaskInfo.topActivityLetterboxHorizontalPosition;
mTopActivityLetterboxWidth = appCompatTaskInfo.topActivityLetterboxWidth;
@@ -148,12 +148,12 @@
final int prevTopActivityLetterboxWidth = mTopActivityLetterboxWidth;
final int prevTopActivityLetterboxHeight = mTopActivityLetterboxHeight;
final AppCompatTaskInfo appCompatTaskInfo = taskInfo.appCompatTaskInfo;
- mIsLetterboxDoubleTapEnabled = appCompatTaskInfo.isLetterboxDoubleTapEnabled;
+ mIsLetterboxDoubleTapEnabled = appCompatTaskInfo.isLetterboxDoubleTapEnabled();
mLetterboxVerticalPosition = appCompatTaskInfo.topActivityLetterboxVerticalPosition;
mLetterboxHorizontalPosition = appCompatTaskInfo.topActivityLetterboxHorizontalPosition;
mTopActivityLetterboxWidth = appCompatTaskInfo.topActivityLetterboxWidth;
mTopActivityLetterboxHeight = appCompatTaskInfo.topActivityLetterboxHeight;
- mHasUserDoubleTapped = appCompatTaskInfo.isFromLetterboxDoubleTap;
+ mHasUserDoubleTapped = appCompatTaskInfo.isFromLetterboxDoubleTap();
if (!super.updateCompatInfo(taskInfo, taskListener, canShow)) {
return false;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManager.java
index 8fb4bdb..3f67172 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManager.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManager.java
@@ -238,14 +238,14 @@
// App is not visibly letterboxed if it covers status bar/bottom insets or matches the
// stable bounds, so don't show the button
if (stableBounds.height() <= letterboxHeight && stableBounds.width() <= letterboxWidth
- && !taskInfo.isUserFullscreenOverrideEnabled) {
+ && !taskInfo.isUserFullscreenOverrideEnabled()) {
return false;
}
- return taskInfo.topActivityEligibleForUserAspectRatioButton
- && (taskInfo.topActivityBoundsLetterboxed
- || taskInfo.isUserFullscreenOverrideEnabled)
- && !taskInfo.isSystemFullscreenOverrideEnabled
+ return taskInfo.eligibleForUserAspectRatioButton()
+ && (taskInfo.isTopActivityLetterboxed()
+ || taskInfo.isUserFullscreenOverrideEnabled())
+ && !taskInfo.isSystemFullscreenOverrideEnabled()
&& Intent.ACTION_MAIN.equals(intent.getAction())
&& intent.hasCategory(Intent.CATEGORY_LAUNCHER)
&& (!mUserAspectRatioButtonShownChecker.get() || isShowingButton());
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt
index 026094c..3e7b4fe 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt
@@ -146,7 +146,7 @@
fun calculateAspectRatio(taskInfo: RunningTaskInfo): Float {
val appLetterboxWidth = taskInfo.appCompatTaskInfo.topActivityLetterboxAppWidth
val appLetterboxHeight = taskInfo.appCompatTaskInfo.topActivityLetterboxAppHeight
- if (taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed) {
+ if (taskInfo.appCompatTaskInfo.isTopActivityLetterboxed) {
return maxOf(appLetterboxWidth, appLetterboxHeight) /
minOf(appLetterboxWidth, appLetterboxHeight).toFloat()
}
@@ -200,7 +200,7 @@
}
// Then check if the activity is portrait when letterboxed
- appCompatTaskInfo.topActivityBoundsLetterboxed -> appCompatTaskInfo.isTopActivityPillarboxed
+ appCompatTaskInfo.isTopActivityLetterboxed -> appCompatTaskInfo.isTopActivityPillarboxed
// Then check if the activity is portrait
appBounds != null -> appBounds.height() > appBounds.width()
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java
index 333c75f..abec3b9 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/keyguard/KeyguardTransitionHandler.java
@@ -170,7 +170,7 @@
@NonNull SurfaceControl.Transaction startTransaction,
@NonNull SurfaceControl.Transaction finishTransaction,
@NonNull TransitionFinishCallback finishCallback) {
- if (!handles(info) || mIsLaunchingActivityOverLockscreen) {
+ if (!handles(info)) {
return false;
}
@@ -185,6 +185,9 @@
transition, info, startTransaction, finishTransaction, finishCallback);
}
+ if (mIsLaunchingActivityOverLockscreen) {
+ return false;
+ }
// Occlude/unocclude animations are only played if the keyguard is locked.
if ((info.getFlags() & TRANSIT_FLAG_KEYGUARD_LOCKED) != 0) {
diff --git a/libs/WindowManager/Shell/tests/OWNERS b/libs/WindowManager/Shell/tests/OWNERS
index a77fd51..9f735c4 100644
--- a/libs/WindowManager/Shell/tests/OWNERS
+++ b/libs/WindowManager/Shell/tests/OWNERS
@@ -1,4 +1,4 @@
-# Bug component: 1157642
+# Bug component: 928594
# includes OWNERS from parent directories
natanieljr@google.com
pablogamito@google.com
diff --git a/libs/WindowManager/Shell/tests/flicker/OWNERS b/libs/WindowManager/Shell/tests/flicker/OWNERS
new file mode 100644
index 0000000..4db0bab
--- /dev/null
+++ b/libs/WindowManager/Shell/tests/flicker/OWNERS
@@ -0,0 +1,3 @@
+# Bug component: 1157642
+# includes OWNERS from parent directories
+include platform/development:/tools/winscope/OWNERS
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java
index 716a148..413e495 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/ShellTaskOrganizerTests.java
@@ -365,7 +365,7 @@
final RunningTaskInfo taskInfo1 = createTaskInfo(/* taskId= */ 12,
WINDOWING_MODE_FULLSCREEN);
taskInfo1.displayId = DEFAULT_DISPLAY;
- taskInfo1.appCompatTaskInfo.topActivityInSizeCompat = false;
+ taskInfo1.appCompatTaskInfo.setTopActivityInSizeCompat(false);
final TrackingTaskListener taskListener = new TrackingTaskListener();
mOrganizer.addListenerForType(taskListener, TASK_LISTENER_TYPE_FULLSCREEN);
mOrganizer.onTaskAppeared(taskInfo1, /* leash= */ null);
@@ -378,7 +378,7 @@
final RunningTaskInfo taskInfo2 =
createTaskInfo(taskInfo1.taskId, taskInfo1.getWindowingMode());
taskInfo2.displayId = taskInfo1.displayId;
- taskInfo2.appCompatTaskInfo.topActivityInSizeCompat = true;
+ taskInfo2.appCompatTaskInfo.setTopActivityInSizeCompat(true);
taskInfo2.isVisible = true;
mOrganizer.onTaskInfoChanged(taskInfo2);
verifyOnCompatInfoChangedInvokedWith(taskInfo2, taskListener);
@@ -388,7 +388,7 @@
final RunningTaskInfo taskInfo3 =
createTaskInfo(taskInfo1.taskId, taskInfo1.getWindowingMode());
taskInfo3.displayId = taskInfo1.displayId;
- taskInfo3.appCompatTaskInfo.topActivityInSizeCompat = true;
+ taskInfo3.appCompatTaskInfo.setTopActivityInSizeCompat(true);
taskInfo3.isVisible = false;
mOrganizer.onTaskInfoChanged(taskInfo3);
verifyOnCompatInfoChangedInvokedWith(taskInfo3, null /* taskListener */);
@@ -403,7 +403,7 @@
final RunningTaskInfo taskInfo1 = createTaskInfo(/* taskId= */ 12,
WINDOWING_MODE_FULLSCREEN);
taskInfo1.displayId = DEFAULT_DISPLAY;
- taskInfo1.appCompatTaskInfo.topActivityEligibleForLetterboxEducation = false;
+ taskInfo1.appCompatTaskInfo.setEligibleForLetterboxEducation(false);
final TrackingTaskListener taskListener = new TrackingTaskListener();
mOrganizer.addListenerForType(taskListener, TASK_LISTENER_TYPE_FULLSCREEN);
mOrganizer.onTaskAppeared(taskInfo1, /* leash= */ null);
@@ -418,7 +418,7 @@
final RunningTaskInfo taskInfo2 =
createTaskInfo(taskInfo1.taskId, WINDOWING_MODE_FULLSCREEN);
taskInfo2.displayId = taskInfo1.displayId;
- taskInfo2.appCompatTaskInfo.topActivityEligibleForLetterboxEducation = true;
+ taskInfo2.appCompatTaskInfo.setEligibleForLetterboxEducation(true);
taskInfo2.isVisible = true;
mOrganizer.onTaskInfoChanged(taskInfo2);
verifyOnCompatInfoChangedInvokedWith(taskInfo2, taskListener);
@@ -428,7 +428,7 @@
final RunningTaskInfo taskInfo3 =
createTaskInfo(taskInfo1.taskId, WINDOWING_MODE_FULLSCREEN);
taskInfo3.displayId = taskInfo1.displayId;
- taskInfo3.appCompatTaskInfo.topActivityEligibleForLetterboxEducation = true;
+ taskInfo3.appCompatTaskInfo.setEligibleForLetterboxEducation(true);
taskInfo3.isVisible = false;
mOrganizer.onTaskInfoChanged(taskInfo3);
verifyOnCompatInfoChangedInvokedWith(taskInfo3, null /* taskListener */);
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayImeControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayImeControllerTest.java
index 764d5a9..654d7a8e 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayImeControllerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/DisplayImeControllerTest.java
@@ -119,7 +119,7 @@
@Test
public void reappliesVisibilityToChangedLeash() {
verifyZeroInteractions(mT);
- mPerDisplay.mImeShowing = true;
+ mPerDisplay.mImeShowing = false;
mPerDisplay.insetsControlChanged(insetsStateWithIme(false), insetsSourceControl());
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java
index 77e22cd..de1659b 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java
@@ -681,7 +681,7 @@
@Test
public void testLetterboxEduLayout_notCreatedWhenLetterboxEducationIsDisabled() {
TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true);
- taskInfo.appCompatTaskInfo.isLetterboxEducationEnabled = false;
+ taskInfo.appCompatTaskInfo.setLetterboxEducationEnabled(false);
mController.onCompatInfoChanged(new CompatUIInfo(taskInfo, mMockTaskListener));
@@ -705,12 +705,12 @@
RunningTaskInfo taskInfo = new RunningTaskInfo();
taskInfo.taskId = taskId;
taskInfo.displayId = displayId;
- taskInfo.appCompatTaskInfo.topActivityInSizeCompat = hasSizeCompat;
+ taskInfo.appCompatTaskInfo.setTopActivityInSizeCompat(hasSizeCompat);
taskInfo.isVisible = isVisible;
taskInfo.isFocused = isFocused;
taskInfo.isTopActivityTransparent = isTopActivityTransparent;
- taskInfo.appCompatTaskInfo.isLetterboxEducationEnabled = true;
- taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed = true;
+ taskInfo.appCompatTaskInfo.setLetterboxEducationEnabled(true);
+ taskInfo.appCompatTaskInfo.setTopActivityLetterboxed(true);
return taskInfo;
}
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java
index 3b93861..e5d1919 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUILayoutTest.java
@@ -146,7 +146,7 @@
private static TaskInfo createTaskInfo(boolean hasSizeCompat) {
ActivityManager.RunningTaskInfo taskInfo = new ActivityManager.RunningTaskInfo();
taskInfo.taskId = TASK_ID;
- taskInfo.appCompatTaskInfo.topActivityInSizeCompat = hasSizeCompat;
+ taskInfo.appCompatTaskInfo.setTopActivityInSizeCompat(hasSizeCompat);
taskInfo.appCompatTaskInfo.topActivityLetterboxHeight = 1000;
taskInfo.appCompatTaskInfo.topActivityLetterboxWidth = 1000;
taskInfo.configuration.windowConfiguration.setBounds(new Rect(0, 0, 2000, 2000));
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java
index c5033f3..1c01756 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIWindowManagerTest.java
@@ -446,7 +446,7 @@
private static TaskInfo createTaskInfo(boolean hasSizeCompat) {
ActivityManager.RunningTaskInfo taskInfo = new ActivityManager.RunningTaskInfo();
taskInfo.taskId = TASK_ID;
- taskInfo.appCompatTaskInfo.topActivityInSizeCompat = hasSizeCompat;
+ taskInfo.appCompatTaskInfo.setTopActivityInSizeCompat(hasSizeCompat);
taskInfo.configuration.uiMode &= ~Configuration.UI_MODE_TYPE_DESK;
// Letterboxed activity that takes half the screen should show size compat restart button
taskInfo.appCompatTaskInfo.topActivityLetterboxHeight = 1000;
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java
index b5664ac..7617269 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java
@@ -499,7 +499,7 @@
ActivityManager.RunningTaskInfo taskInfo = new ActivityManager.RunningTaskInfo();
taskInfo.userId = userId;
taskInfo.taskId = TASK_ID;
- taskInfo.appCompatTaskInfo.topActivityEligibleForLetterboxEducation = eligible;
+ taskInfo.appCompatTaskInfo.setEligibleForLetterboxEducation(eligible);
taskInfo.configuration.windowConfiguration.setBounds(bounds);
return taskInfo;
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsLayoutTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsLayoutTest.java
index 7a64196..e8e68bd 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsLayoutTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsLayoutTest.java
@@ -155,7 +155,7 @@
private static TaskInfo createTaskInfo(boolean hasSizeCompat) {
ActivityManager.RunningTaskInfo taskInfo = new ActivityManager.RunningTaskInfo();
taskInfo.taskId = TASK_ID;
- taskInfo.appCompatTaskInfo.topActivityInSizeCompat = hasSizeCompat;
+ taskInfo.appCompatTaskInfo.setTopActivityInSizeCompat(hasSizeCompat);
taskInfo.realActivity = new ComponentName("com.mypackage.test", "TestActivity");
return taskInfo;
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManagerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManagerTest.java
index 9f288cc..9f86d49 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManagerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/UserAspectRatioSettingsWindowManagerTest.java
@@ -317,7 +317,7 @@
// layout should be inflated
taskInfo.appCompatTaskInfo.topActivityLetterboxHeight = stableBounds.height();
taskInfo.appCompatTaskInfo.topActivityLetterboxWidth = stableBounds.width();
- taskInfo.appCompatTaskInfo.isUserFullscreenOverrideEnabled = true;
+ taskInfo.appCompatTaskInfo.setUserFullscreenOverrideEnabled(true);
mWindowManager.updateCompatInfo(taskInfo, mTaskListener, /* canShow= */ true);
@@ -482,9 +482,9 @@
boolean topActivityBoundsLetterboxed, String action, String category) {
ActivityManager.RunningTaskInfo taskInfo = new ActivityManager.RunningTaskInfo();
taskInfo.taskId = TASK_ID;
- taskInfo.appCompatTaskInfo.topActivityEligibleForUserAspectRatioButton =
- eligibleForUserAspectRatioButton;
- taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed = topActivityBoundsLetterboxed;
+ taskInfo.appCompatTaskInfo.setEligibleForUserAspectRatioButton(
+ eligibleForUserAspectRatioButton);
+ taskInfo.appCompatTaskInfo.setTopActivityLetterboxed(topActivityBoundsLetterboxed);
taskInfo.configuration.uiMode &= ~Configuration.UI_MODE_TYPE_DESK;
taskInfo.realActivity = new ComponentName("com.mypackage.test", "TestActivity");
taskInfo.baseIntent = new Intent(action).addCategory(category);
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
index 76939f6..92f7050 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
@@ -2734,18 +2734,16 @@
if (deviceOrientation == ORIENTATION_LANDSCAPE &&
screenOrientation == SCREEN_ORIENTATION_PORTRAIT) {
// Letterbox to portrait size
- appCompatTaskInfo.topActivityBoundsLetterboxed = true
+ appCompatTaskInfo.setTopActivityLetterboxed(true)
appCompatTaskInfo.topActivityLetterboxAppWidth = 1200
appCompatTaskInfo.topActivityLetterboxAppHeight = 1600
} else if (deviceOrientation == ORIENTATION_PORTRAIT &&
screenOrientation == SCREEN_ORIENTATION_LANDSCAPE) {
// Letterbox to landscape size
- appCompatTaskInfo.topActivityBoundsLetterboxed = true
+ appCompatTaskInfo.setTopActivityLetterboxed(true)
appCompatTaskInfo.topActivityLetterboxAppWidth = 1600
appCompatTaskInfo.topActivityLetterboxAppHeight = 1200
}
- } else {
- appCompatTaskInfo.topActivityBoundsLetterboxed = false
}
if (deviceOrientation == ORIENTATION_LANDSCAPE) {
diff --git a/libs/androidfw/Idmap.cpp b/libs/androidfw/Idmap.cpp
index 9824190..f066e46 100644
--- a/libs/androidfw/Idmap.cpp
+++ b/libs/androidfw/Idmap.cpp
@@ -121,7 +121,7 @@
uint8_t target_assigned_package_id)
: data_header_(data_header),
entries_(entries),
- target_assigned_package_id_(target_assigned_package_id) { };
+ target_assigned_package_id_(target_assigned_package_id) {}
status_t OverlayDynamicRefTable::lookupResourceId(uint32_t* resId) const {
const Idmap_overlay_entry* first_entry = entries_;
diff --git a/libs/androidfw/include/androidfw/Idmap.h b/libs/androidfw/include/androidfw/Idmap.h
index c32a38e..64b1f0c 100644
--- a/libs/androidfw/include/androidfw/Idmap.h
+++ b/libs/androidfw/include/androidfw/Idmap.h
@@ -171,14 +171,14 @@
}
// Returns a mapping from target resource ids to overlay values.
- const IdmapResMap GetTargetResourcesMap(uint8_t target_assigned_package_id,
- const OverlayDynamicRefTable* overlay_ref_table) const {
+ IdmapResMap GetTargetResourcesMap(uint8_t target_assigned_package_id,
+ const OverlayDynamicRefTable* overlay_ref_table) const {
return IdmapResMap(data_header_, target_entries_, target_inline_entries_, inline_entry_values_,
configurations_, target_assigned_package_id, overlay_ref_table);
}
// Returns a dynamic reference table for a loaded overlay package.
- const OverlayDynamicRefTable GetOverlayDynamicRefTable(uint8_t target_assigned_package_id) const {
+ OverlayDynamicRefTable GetOverlayDynamicRefTable(uint8_t target_assigned_package_id) const {
return OverlayDynamicRefTable(data_header_, overlay_entries_, target_assigned_package_id);
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManagerCallbackExt.kt b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManagerCallbackExt.kt
new file mode 100644
index 0000000..b7338fc
--- /dev/null
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManagerCallbackExt.kt
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2024 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.bluetooth
+
+import kotlinx.coroutines.channels.Channel
+import kotlinx.coroutines.channels.awaitClose
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.buffer
+import kotlinx.coroutines.flow.callbackFlow
+import kotlinx.coroutines.launch
+
+/** [Flow] for [LocalBluetoothProfileManager.ServiceListener] service state changes */
+val LocalBluetoothProfileManager.onServiceStateChanged: Flow<Unit>
+ get() =
+ callbackFlow {
+ val listener =
+ object : LocalBluetoothProfileManager.ServiceListener {
+ override fun onServiceConnected() {
+ launch { trySend(Unit) }
+ }
+
+ override fun onServiceDisconnected() {
+ launch { trySend(Unit) }
+ }
+ }
+ addServiceListener(listener)
+ awaitClose { removeServiceListener(listener) }
+ }
+ .buffer(capacity = Channel.CONFLATED)
\ No newline at end of file
diff --git a/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioSharingRepository.kt b/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioSharingRepository.kt
index 99d5891..7a66335 100644
--- a/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioSharingRepository.kt
+++ b/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioSharingRepository.kt
@@ -30,6 +30,7 @@
import com.android.settingslib.bluetooth.LocalBluetoothManager
import com.android.settingslib.bluetooth.onBroadcastStartedOrStopped
import com.android.settingslib.bluetooth.onProfileConnectionStateChanged
+import com.android.settingslib.bluetooth.onServiceStateChanged
import com.android.settingslib.bluetooth.onSourceConnectedOrRemoved
import com.android.settingslib.volume.data.repository.AudioSharingRepository.Companion.AUDIO_SHARING_VOLUME_MAX
import com.android.settingslib.volume.data.repository.AudioSharingRepository.Companion.AUDIO_SHARING_VOLUME_MIN
@@ -90,13 +91,24 @@
private val coroutineScope: CoroutineScope,
private val backgroundCoroutineContext: CoroutineContext,
) : AudioSharingRepository {
+ private val isAudioSharingProfilesReady: StateFlow<Boolean> =
+ btManager.profileManager.onServiceStateChanged
+ .map { isAudioSharingProfilesReady() }
+ .onStart { emit(isAudioSharingProfilesReady()) }
+ .flowOn(backgroundCoroutineContext)
+ .stateIn(coroutineScope, SharingStarted.WhileSubscribed(), false)
+
override val inAudioSharing: Flow<Boolean> =
- btManager.profileManager.leAudioBroadcastProfile?.let { broadcast ->
- broadcast.onBroadcastStartedOrStopped
- .map { isBroadcasting() }
- .onStart { emit(isBroadcasting()) }
- .flowOn(backgroundCoroutineContext)
- } ?: flowOf(false)
+ isAudioSharingProfilesReady.flatMapLatest { ready ->
+ if (ready) {
+ btManager.profileManager.leAudioBroadcastProfile.onBroadcastStartedOrStopped
+ .map { isBroadcasting() }
+ .onStart { emit(isBroadcasting()) }
+ .flowOn(backgroundCoroutineContext)
+ } else {
+ flowOf(false)
+ }
+ }
private val primaryChange: Flow<Unit> = callbackFlow {
val callback =
@@ -108,7 +120,8 @@
contentResolver.registerContentObserver(
Settings.Secure.getUriFor(BluetoothUtils.getPrimaryGroupIdUriForBroadcast()),
false,
- callback)
+ callback
+ )
awaitClose { contentResolver.unregisterContentObserver(callback) }
}
@@ -120,64 +133,80 @@
.stateIn(
coroutineScope,
SharingStarted.WhileSubscribed(),
- BluetoothUtils.getPrimaryGroupIdForBroadcast(contentResolver))
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID
+ )
override val secondaryGroupId: StateFlow<Int> =
merge(
- btManager.profileManager.leAudioBroadcastAssistantProfile
- ?.onSourceConnectedOrRemoved
- ?.map { getSecondaryGroupId() } ?: emptyFlow(),
- btManager.eventManager.onProfileConnectionStateChanged
- .filter { profileConnection ->
- profileConnection.state == BluetoothAdapter.STATE_DISCONNECTED &&
+ isAudioSharingProfilesReady.flatMapLatest { ready ->
+ if (ready) {
+ btManager.profileManager.leAudioBroadcastAssistantProfile
+ .onSourceConnectedOrRemoved
+ .map { getSecondaryGroupId() }
+ } else {
+ emptyFlow()
+ }
+ },
+ btManager.eventManager.onProfileConnectionStateChanged
+ .filter { profileConnection ->
+ profileConnection.state == BluetoothAdapter.STATE_DISCONNECTED &&
profileConnection.bluetoothProfile ==
- BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT
- }
- .map { getSecondaryGroupId() },
- primaryGroupId.map { getSecondaryGroupId() })
+ BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT
+ }
+ .map { getSecondaryGroupId() },
+ primaryGroupId.map { getSecondaryGroupId() })
.onStart { emit(getSecondaryGroupId()) }
.flowOn(backgroundCoroutineContext)
- .stateIn(coroutineScope, SharingStarted.WhileSubscribed(), getSecondaryGroupId())
+ .stateIn(
+ coroutineScope,
+ SharingStarted.WhileSubscribed(),
+ BluetoothCsipSetCoordinator.GROUP_ID_INVALID
+ )
override val volumeMap: StateFlow<GroupIdToVolumes> =
- (btManager.profileManager.volumeControlProfile?.let { volumeControl ->
- inAudioSharing.flatMapLatest { isSharing ->
- if (isSharing) {
- callbackFlow {
- val callback =
- object : BluetoothVolumeControl.Callback {
- override fun onDeviceVolumeChanged(
- device: BluetoothDevice,
- @IntRange(
- from = AUDIO_SHARING_VOLUME_MIN.toLong(),
- to = AUDIO_SHARING_VOLUME_MAX.toLong())
- volume: Int
- ) {
- launch { send(Pair(device, volume)) }
- }
- }
- // Once registered, we will receive the initial volume of all
- // connected BT devices on VolumeControlProfile via callbacks
- volumeControl.registerCallback(
- ConcurrentUtils.DIRECT_EXECUTOR, callback)
- awaitClose { volumeControl.unregisterCallback(callback) }
+ inAudioSharing.flatMapLatest { isSharing ->
+ if (isSharing) {
+ callbackFlow {
+ val callback =
+ object : BluetoothVolumeControl.Callback {
+ override fun onDeviceVolumeChanged(
+ device: BluetoothDevice,
+ @IntRange(
+ from = AUDIO_SHARING_VOLUME_MIN.toLong(),
+ to = AUDIO_SHARING_VOLUME_MAX.toLong()
+ )
+ volume: Int
+ ) {
+ launch { send(Pair(device, volume)) }
}
- .runningFold(emptyMap<Int, Int>()) { acc, value ->
- val groupId =
- BluetoothUtils.getGroupId(
- btManager.cachedDeviceManager.findDevice(value.first))
- if (groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) {
- acc + Pair(groupId, value.second)
- } else {
- acc
- }
- }
- .flowOn(backgroundCoroutineContext)
- } else {
- emptyFlow()
+ }
+ // Once registered, we will receive the initial volume of all
+ // connected BT devices on VolumeControlProfile via callbacks
+ btManager.profileManager.volumeControlProfile.registerCallback(
+ ConcurrentUtils.DIRECT_EXECUTOR, callback
+ )
+ awaitClose {
+ btManager.profileManager.volumeControlProfile.unregisterCallback(
+ callback
+ )
}
}
- } ?: emptyFlow())
+ .runningFold(emptyMap<Int, Int>()) { acc, value ->
+ val groupId =
+ BluetoothUtils.getGroupId(
+ btManager.cachedDeviceManager.findDevice(value.first)
+ )
+ if (groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) {
+ acc + Pair(groupId, value.second)
+ } else {
+ acc
+ }
+ }
+ .flowOn(backgroundCoroutineContext)
+ } else {
+ emptyFlow()
+ }
+ }
.stateIn(coroutineScope, SharingStarted.WhileSubscribed(), emptyMap())
override suspend fun setSecondaryVolume(
@@ -196,12 +225,25 @@
}
}
+ private fun isBroadcastProfileReady(): Boolean =
+ btManager.profileManager.leAudioBroadcastProfile?.isProfileReady ?: false
+
+ private fun isAssistantProfileReady(): Boolean =
+ btManager.profileManager.leAudioBroadcastAssistantProfile?.isProfileReady ?: false
+
+ private fun isVolumeControlProfileReady(): Boolean =
+ btManager.profileManager.volumeControlProfile?.isProfileReady ?: false
+
+ private fun isAudioSharingProfilesReady(): Boolean =
+ isBroadcastProfileReady() && isAssistantProfileReady() && isVolumeControlProfileReady()
+
private fun isBroadcasting(): Boolean =
btManager.profileManager.leAudioBroadcastProfile?.isEnabled(null) ?: false
private fun getSecondaryGroupId(): Int =
BluetoothUtils.getGroupId(
- BluetoothUtils.getSecondaryDeviceForBroadcast(contentResolver, btManager))
+ BluetoothUtils.getSecondaryDeviceForBroadcast(contentResolver, btManager)
+ )
}
class AudioSharingRepositoryEmptyImpl : AudioSharingRepository {
@@ -215,5 +257,6 @@
override suspend fun setSecondaryVolume(
@IntRange(from = AUDIO_SHARING_VOLUME_MIN.toLong(), to = AUDIO_SHARING_VOLUME_MAX.toLong())
volume: Int
- ) {}
+ ) {
+ }
}
diff --git a/packages/SettingsLib/tests/integ/src/com/android/settingslib/volume/data/repository/AudioSharingRepositoryTest.kt b/packages/SettingsLib/tests/integ/src/com/android/settingslib/volume/data/repository/AudioSharingRepositoryTest.kt
index c54a2e4..078f0c8 100644
--- a/packages/SettingsLib/tests/integ/src/com/android/settingslib/volume/data/repository/AudioSharingRepositoryTest.kt
+++ b/packages/SettingsLib/tests/integ/src/com/android/settingslib/volume/data/repository/AudioSharingRepositoryTest.kt
@@ -57,6 +57,7 @@
import org.mockito.ArgumentMatchers.eq
import org.mockito.Captor
import org.mockito.Mock
+import org.mockito.Mockito.never
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.Spy
@@ -145,8 +146,11 @@
}
@Test
- fun audioSharingStateChange_emitValues() {
+ fun audioSharingStateChange_profileReady_emitValues() {
testScope.runTest {
+ `when`(broadcast.isProfileReady).thenReturn(true)
+ `when`(assistant.isProfileReady).thenReturn(true)
+ `when`(volumeControl.isProfileReady).thenReturn(true)
val states = mutableListOf<Boolean?>()
underTest.inAudioSharing.onEach { states.add(it) }.launchIn(backgroundScope)
runCurrent()
@@ -155,7 +159,19 @@
triggerAudioSharingStateChange(TriggerType.BROADCAST_START, broadcastStarted)
runCurrent()
- Truth.assertThat(states).containsExactly(true, false, true)
+ Truth.assertThat(states).containsExactly(false, true, false, true)
+ }
+ }
+
+ @Test
+ fun audioSharingStateChange_profileNotReady_broadcastCallbackNotRegistered() {
+ testScope.runTest {
+ val states = mutableListOf<Boolean?>()
+ underTest.inAudioSharing.onEach { states.add(it) }.launchIn(backgroundScope)
+ runCurrent()
+ verify(broadcast, never()).registerServiceCallBack(any(), any())
+
+ Truth.assertThat(states).containsExactly(false)
}
}
@@ -176,11 +192,24 @@
}
@Test
- fun secondaryGroupIdChange_emitValues() {
+ fun secondaryGroupIdChange_profileNotReady_assistantCallbackNotRegistered() {
testScope.runTest {
val groupIds = mutableListOf<Int?>()
underTest.secondaryGroupId.onEach { groupIds.add(it) }.launchIn(backgroundScope)
runCurrent()
+ verify(assistant, never()).registerServiceCallBack(any(), any())
+ }
+ }
+
+ @Test
+ fun secondaryGroupIdChange_profileReady_emitValues() {
+ testScope.runTest {
+ `when`(broadcast.isProfileReady).thenReturn(true)
+ `when`(assistant.isProfileReady).thenReturn(true)
+ `when`(volumeControl.isProfileReady).thenReturn(true)
+ val groupIds = mutableListOf<Int?>()
+ underTest.secondaryGroupId.onEach { groupIds.add(it) }.launchIn(backgroundScope)
+ runCurrent()
triggerSourceAdded()
runCurrent()
triggerContentObserverChange()
@@ -211,8 +240,11 @@
}
@Test
- fun volumeMapChange_emitValues() {
+ fun volumeMapChange_profileReady_emitValues() {
testScope.runTest {
+ `when`(broadcast.isProfileReady).thenReturn(true)
+ `when`(assistant.isProfileReady).thenReturn(true)
+ `when`(volumeControl.isProfileReady).thenReturn(true)
val volumeMaps = mutableListOf<GroupIdToVolumes?>()
underTest.volumeMap.onEach { volumeMaps.add(it) }.launchIn(backgroundScope)
runCurrent()
@@ -234,6 +266,16 @@
}
@Test
+ fun volumeMapChange_profileNotReady_volumeControlCallbackNotRegistered() {
+ testScope.runTest {
+ val volumeMaps = mutableListOf<GroupIdToVolumes?>()
+ underTest.volumeMap.onEach { volumeMaps.add(it) }.launchIn(backgroundScope)
+ runCurrent()
+ verify(volumeControl, never()).registerCallback(any(), any())
+ }
+ }
+
+ @Test
fun setSecondaryVolume_setValue() {
testScope.runTest {
Settings.Secure.putInt(
@@ -258,6 +300,7 @@
`when`(broadcast.isEnabled(null)).thenReturn(true)
broadcastCallbackCaptor.value.broadcastAction()
}
+
TriggerType.BROADCAST_STOP -> {
`when`(broadcast.isEnabled(null)).thenReturn(false)
broadcastCallbackCaptor.value.broadcastAction()
diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp
index c2e8c37..6d78705 100644
--- a/packages/SystemUI/Android.bp
+++ b/packages/SystemUI/Android.bp
@@ -645,6 +645,15 @@
}
filegroup {
+ name: "SystemUI-robotest-utils",
+ srcs: [
+ "tests/robolectric/src/com/android/systemui/testutils/**/*.kt",
+ "tests/robolectric/src/com/android/systemui/testutils/**/*.java",
+ ],
+ path: "tests/robolectric/src/com/android/systemui/testutils",
+}
+
+filegroup {
name: "SystemUI-tests-multivalent",
srcs: [
"multivalentTests/src/**/*.kt",
@@ -944,35 +953,36 @@
strict_mode: false,
}
-android_ravenwood_test {
- name: "SystemUiRavenTests",
- srcs: [
- ":SystemUI-tests-utils",
- ":SystemUI-tests-multivalent",
- // TODO(b/294256649): pivot to using {.aapt.jar} and re-enable
- // use_resource_processor: true when better supported by soong
- ":SystemUIRobo-stub{.aapt.srcjar}",
- ],
- static_libs: [
- "SystemUI-core",
- "SystemUI-res",
- "SystemUI-tests-base",
- "androidx.test.uiautomator_uiautomator",
- "androidx.core_core-animation-testing",
- "androidx.test.ext.junit",
- "kosmos",
- "mockito-kotlin-nodeps",
- ],
- libs: [
- "android.test.runner",
- "android.test.base",
- "android.test.mock",
- ],
- auto_gen_config: true,
- plugins: [
- "dagger2-compiler",
- ],
-}
+// Disable for now. TODO(b/356666754) Re-enable it
+// android_ravenwood_test {
+// name: "SystemUiRavenTests",
+// srcs: [
+// ":SystemUI-tests-utils",
+// ":SystemUI-tests-multivalent",
+// // TODO(b/294256649): pivot to using {.aapt.jar} and re-enable
+// // use_resource_processor: true when better supported by soong
+// ":SystemUIRobo-stub{.aapt.srcjar}",
+// ],
+// static_libs: [
+// "SystemUI-core",
+// "SystemUI-res",
+// "SystemUI-tests-base",
+// "androidx.test.uiautomator_uiautomator",
+// "androidx.core_core-animation-testing",
+// "androidx.test.ext.junit",
+// "kosmos",
+// "mockito-kotlin-nodeps",
+// ],
+// libs: [
+// "android.test.runner",
+// "android.test.base",
+// "android.test.mock",
+// ],
+// auto_gen_config: true,
+// plugins: [
+// "dagger2-compiler",
+// ],
+// }
// Opt-out config for optimizing the SystemUI target using R8.
// Disabled via `export SYSTEMUI_OPTIMIZE_JAVA=false`, or explicitly in Make via
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index 1435172..3767a27 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -352,17 +352,6 @@
}
flag {
- name: "truncated_status_bar_icons_fix"
- namespace: "systemui"
- description: "Fixes the status bar icons being trunacted due to the status bar window height "
- "not being updated after certain rotations"
- bug: "323299264"
- metadata {
- purpose: PURPOSE_BUGFIX
- }
-}
-
-flag {
name: "status_bar_monochrome_icons_fix"
namespace: "systemui"
description: "Fixes the status bar icon size when drawing InsetDrawables (ie. monochrome icons)"
@@ -1059,16 +1048,6 @@
}
flag {
- namespace: "systemui"
- name: "privacy_dot_unfold_wrong_corner_fix"
- description: "Fixes an issue where the privacy dot is at the wrong corner after unfolding/folding."
- bug: "339335643"
- metadata {
- purpose: PURPOSE_BUGFIX
- }
-}
-
-flag {
name: "validate_keyboard_shortcut_helper_icon_uri"
namespace: "systemui"
description: "Adds a check that the caller can access the content URI of an icon in the shortcut helper."
diff --git a/packages/SystemUI/compose/facade/enabled/src/com/android/systemui/scene/LockscreenSceneModule.kt b/packages/SystemUI/compose/facade/enabled/src/com/android/systemui/scene/LockscreenSceneModule.kt
index bd5b795a..72965fb 100644
--- a/packages/SystemUI/compose/facade/enabled/src/com/android/systemui/scene/LockscreenSceneModule.kt
+++ b/packages/SystemUI/compose/facade/enabled/src/com/android/systemui/scene/LockscreenSceneModule.kt
@@ -66,11 +66,11 @@
@Provides
fun providesLockscreenContent(
- viewModel: LockscreenContentViewModel,
+ viewModelFactory: LockscreenContentViewModel.Factory,
blueprints: Set<@JvmSuppressWildcards ComposableLockscreenSceneBlueprint>,
clockInteractor: KeyguardClockInteractor,
): LockscreenContent {
- return LockscreenContent(viewModel, blueprints, clockInteractor)
+ return LockscreenContent(viewModelFactory, blueprints, clockInteractor)
}
}
}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt
index d4bad23..872bef2 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt
@@ -27,7 +27,7 @@
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.semantics.clearAndSetSemantics
-import androidx.compose.ui.semantics.contentDescription
+import androidx.compose.ui.semantics.disabled
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -243,7 +243,7 @@
if (isFocusable) {
Modifier.focusable()
} else {
- Modifier.semantics { contentDescription = "" }.clearAndSetSemantics {}
+ Modifier.semantics { disabled() }.clearAndSetSemantics {}
}
)
) {
@@ -259,7 +259,7 @@
modifier =
modifier.focusable(isFocusable).semantics {
if (!isFocusable) {
- contentDescription = ""
+ disabled()
}
}
)
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenContent.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenContent.kt
index 25e91be..672b8a7 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenContent.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenContent.kt
@@ -29,6 +29,7 @@
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.ui.composable.blueprint.ComposableLockscreenSceneBlueprint
import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel
+import com.android.systemui.lifecycle.rememberViewModel
/**
* Renders the content of the lockscreen.
@@ -37,7 +38,7 @@
* outside the scene container framework.
*/
class LockscreenContent(
- private val viewModel: LockscreenContentViewModel,
+ private val viewModelFactory: LockscreenContentViewModel.Factory,
private val blueprints: Set<@JvmSuppressWildcards ComposableLockscreenSceneBlueprint>,
private val clockInteractor: KeyguardClockInteractor,
) {
@@ -49,6 +50,7 @@
fun SceneScope.Content(
modifier: Modifier = Modifier,
) {
+ val viewModel = rememberViewModel { viewModelFactory.create() }
val isContentVisible: Boolean by viewModel.isContentVisible.collectAsStateWithLifecycle()
if (!isContentVisible) {
// If the content isn't supposed to be visible, show a large empty box as it's needed
@@ -69,6 +71,6 @@
}
val blueprint = blueprintByBlueprintId[blueprintId] ?: return
- with(blueprint) { Content(modifier.sysuiResTag("keyguard_root_view")) }
+ with(blueprint) { Content(viewModel, modifier.sysuiResTag("keyguard_root_view")) }
}
}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt
index b077e18..7fe1b3e 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt
@@ -24,7 +24,7 @@
import com.android.compose.animation.scene.UserActionResult
import com.android.compose.animation.scene.animateSceneFloatAsState
import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.keyguard.ui.viewmodel.LockscreenSceneViewModel
+import com.android.systemui.keyguard.ui.viewmodel.LockscreenSceneActionsViewModel
import com.android.systemui.qs.ui.composable.QuickSettings
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.ui.composable.ComposableScene
@@ -37,13 +37,21 @@
class LockscreenScene
@Inject
constructor(
- viewModel: LockscreenSceneViewModel,
+ actionsViewModelFactory: LockscreenSceneActionsViewModel.Factory,
private val lockscreenContent: Lazy<LockscreenContent>,
) : ComposableScene {
override val key = Scenes.Lockscreen
+ private val actionsViewModel: LockscreenSceneActionsViewModel by lazy {
+ actionsViewModelFactory.create()
+ }
+
override val destinationScenes: Flow<Map<UserAction, UserActionResult>> =
- viewModel.destinationScenes
+ actionsViewModel.actions
+
+ override suspend fun activate() {
+ actionsViewModel.activate()
+ }
@Composable
override fun SceneScope.Content(
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/CommunalBlueprint.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/CommunalBlueprint.kt
index 210ca69..adad446 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/CommunalBlueprint.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/CommunalBlueprint.kt
@@ -32,16 +32,15 @@
import javax.inject.Inject
/** Renders the lockscreen scene when showing the communal glanceable hub. */
-class CommunalBlueprint
-@Inject
-constructor(
- private val viewModel: LockscreenContentViewModel,
-) : ComposableLockscreenSceneBlueprint {
+class CommunalBlueprint @Inject constructor() : ComposableLockscreenSceneBlueprint {
override val id: String = "communal"
@Composable
- override fun SceneScope.Content(modifier: Modifier) {
+ override fun SceneScope.Content(
+ viewModel: LockscreenContentViewModel,
+ modifier: Modifier,
+ ) {
LockscreenLongPress(
viewModel = viewModel.touchHandling,
modifier = modifier,
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/ComposableLockscreenSceneBlueprint.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/ComposableLockscreenSceneBlueprint.kt
index cb73983..df36d07 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/ComposableLockscreenSceneBlueprint.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/ComposableLockscreenSceneBlueprint.kt
@@ -20,9 +20,14 @@
import androidx.compose.ui.Modifier
import com.android.compose.animation.scene.SceneScope
import com.android.systemui.keyguard.shared.model.LockscreenSceneBlueprint
+import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel
/** Defines interface for classes that can render the content for a specific blueprint/layout. */
interface ComposableLockscreenSceneBlueprint : LockscreenSceneBlueprint {
/** Renders the content of this blueprint. */
- @Composable fun SceneScope.Content(modifier: Modifier)
+ @Composable
+ fun SceneScope.Content(
+ viewModel: LockscreenContentViewModel,
+ modifier: Modifier,
+ )
}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/DefaultBlueprint.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/DefaultBlueprint.kt
index a9e63c6..a3e0701 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/DefaultBlueprint.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/DefaultBlueprint.kt
@@ -53,7 +53,6 @@
class DefaultBlueprint
@Inject
constructor(
- private val viewModel: LockscreenContentViewModel,
private val statusBarSection: StatusBarSection,
private val lockSection: LockSection,
private val ambientIndicationSectionOptional: Optional<AmbientIndicationSection>,
@@ -66,10 +65,17 @@
override val id: String = "default"
@Composable
- override fun SceneScope.Content(modifier: Modifier) {
+ override fun SceneScope.Content(
+ viewModel: LockscreenContentViewModel,
+ modifier: Modifier,
+ ) {
val isUdfpsVisible = viewModel.isUdfpsVisible
val isShadeLayoutWide by viewModel.isShadeLayoutWide.collectAsStateWithLifecycle()
val unfoldTranslations by viewModel.unfoldTranslations.collectAsStateWithLifecycle()
+ val areNotificationsVisible by
+ viewModel
+ .areNotificationsVisible(contentKey)
+ .collectAsStateWithLifecycle(initialValue = false)
LockscreenLongPress(
viewModel = viewModel.touchHandling,
@@ -94,6 +100,7 @@
Box {
with(topAreaSection) {
DefaultClockLayout(
+ smartSpacePaddingTop = viewModel::getSmartSpacePaddingTop,
modifier =
Modifier.thenIf(isShadeLayoutWide) {
Modifier.fillMaxWidth(0.5f)
@@ -106,6 +113,8 @@
if (isShadeLayoutWide) {
with(notificationSection) {
Notifications(
+ areNotificationsVisible = areNotificationsVisible,
+ isShadeLayoutWide = isShadeLayoutWide,
burnInParams = null,
modifier =
Modifier.fillMaxWidth(0.5f)
@@ -118,6 +127,8 @@
if (!isShadeLayoutWide) {
with(notificationSection) {
Notifications(
+ areNotificationsVisible = areNotificationsVisible,
+ isShadeLayoutWide = isShadeLayoutWide,
burnInParams = null,
modifier = Modifier.weight(weight = 1f)
)
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/ShortcutsBesideUdfpsBlueprint.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/ShortcutsBesideUdfpsBlueprint.kt
index 72cf832..a5e120c 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/ShortcutsBesideUdfpsBlueprint.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/blueprint/ShortcutsBesideUdfpsBlueprint.kt
@@ -54,7 +54,6 @@
class ShortcutsBesideUdfpsBlueprint
@Inject
constructor(
- private val viewModel: LockscreenContentViewModel,
private val statusBarSection: StatusBarSection,
private val lockSection: LockSection,
private val ambientIndicationSectionOptional: Optional<AmbientIndicationSection>,
@@ -67,10 +66,17 @@
override val id: String = "shortcuts-besides-udfps"
@Composable
- override fun SceneScope.Content(modifier: Modifier) {
+ override fun SceneScope.Content(
+ viewModel: LockscreenContentViewModel,
+ modifier: Modifier,
+ ) {
val isUdfpsVisible = viewModel.isUdfpsVisible
val isShadeLayoutWide by viewModel.isShadeLayoutWide.collectAsStateWithLifecycle()
val unfoldTranslations by viewModel.unfoldTranslations.collectAsStateWithLifecycle()
+ val areNotificationsVisible by
+ viewModel
+ .areNotificationsVisible(contentKey)
+ .collectAsStateWithLifecycle(initialValue = false)
LockscreenLongPress(
viewModel = viewModel.touchHandling,
@@ -95,6 +101,7 @@
Box {
with(topAreaSection) {
DefaultClockLayout(
+ smartSpacePaddingTop = viewModel::getSmartSpacePaddingTop,
modifier =
Modifier.graphicsLayer {
translationX = unfoldTranslations.start
@@ -104,6 +111,8 @@
if (isShadeLayoutWide) {
with(notificationSection) {
Notifications(
+ areNotificationsVisible = areNotificationsVisible,
+ isShadeLayoutWide = isShadeLayoutWide,
burnInParams = null,
modifier =
Modifier.fillMaxWidth(0.5f)
@@ -116,6 +125,8 @@
if (!isShadeLayoutWide) {
with(notificationSection) {
Notifications(
+ areNotificationsVisible = areNotificationsVisible,
+ isShadeLayoutWide = isShadeLayoutWide,
burnInParams = null,
modifier = Modifier.weight(weight = 1f)
)
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt
index df068c4..f0f407a 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt
@@ -26,7 +26,6 @@
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
-import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.compose.animation.scene.SceneScope
import com.android.compose.modifiers.thenIf
import com.android.systemui.Flags
@@ -35,7 +34,6 @@
import com.android.systemui.keyguard.ui.composable.modifier.burnInAware
import com.android.systemui.keyguard.ui.viewmodel.AodBurnInViewModel
import com.android.systemui.keyguard.ui.viewmodel.BurnInParameters
-import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel
import com.android.systemui.notifications.ui.composable.ConstrainedNotificationStack
import com.android.systemui.res.R
import com.android.systemui.shade.LargeScreenHeaderHelper
@@ -59,7 +57,6 @@
sharedNotificationContainerViewModel: SharedNotificationContainerViewModel,
stackScrollLayout: NotificationStackScrollLayout,
sharedNotificationContainerBinder: SharedNotificationContainerBinder,
- private val lockscreenContentViewModel: LockscreenContentViewModel,
) {
init {
@@ -89,17 +86,16 @@
* adjustment
*/
@Composable
- fun SceneScope.Notifications(burnInParams: BurnInParameters?, modifier: Modifier = Modifier) {
- val areNotificationsVisible by
- lockscreenContentViewModel
- .areNotificationsVisible(contentKey)
- .collectAsStateWithLifecycle(initialValue = false)
+ fun SceneScope.Notifications(
+ areNotificationsVisible: Boolean,
+ isShadeLayoutWide: Boolean,
+ burnInParams: BurnInParameters?,
+ modifier: Modifier = Modifier
+ ) {
if (!areNotificationsVisible) {
return
}
- val isShadeLayoutWide by
- lockscreenContentViewModel.isShadeLayoutWide.collectAsStateWithLifecycle()
val splitShadeTopMargin: Dp =
if (Flags.centralizedStatusBarHeightFix()) {
LargeScreenHeaderHelper.getLargeScreenHeaderHeight(LocalContext.current).dp
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/SmartSpaceSection.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/SmartSpaceSection.kt
index 33ed14b..da78eed 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/SmartSpaceSection.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/SmartSpaceSection.kt
@@ -16,6 +16,7 @@
package com.android.systemui.keyguard.ui.composable.section
+import android.content.res.Resources
import android.widget.FrameLayout
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
@@ -43,7 +44,6 @@
import com.android.systemui.keyguard.ui.viewmodel.AodBurnInViewModel
import com.android.systemui.keyguard.ui.viewmodel.BurnInParameters
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
-import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel
import com.android.systemui.res.R
import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController
import javax.inject.Inject
@@ -55,12 +55,12 @@
private val keyguardUnlockAnimationController: KeyguardUnlockAnimationController,
private val keyguardSmartspaceViewModel: KeyguardSmartspaceViewModel,
private val aodBurnInViewModel: AodBurnInViewModel,
- private val lockscreenContentViewModel: LockscreenContentViewModel,
) {
@Composable
fun SceneScope.SmartSpace(
burnInParams: BurnInParameters,
onTopChanged: (top: Float?) -> Unit,
+ smartSpacePaddingTop: (Resources) -> Int,
modifier: Modifier = Modifier,
) {
val resources = LocalContext.current.resources
@@ -72,9 +72,7 @@
modifier
.onTopPlacementChanged(onTopChanged)
.padding(
- top = {
- lockscreenContentViewModel.getSmartSpacePaddingTop(resources)
- },
+ top = { smartSpacePaddingTop(resources) },
bottom = {
resources.getDimensionPixelSize(
R.dimen.keyguard_status_view_bottom_margin
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/TopAreaSection.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/TopAreaSection.kt
index c0832d9..0eeb79b 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/TopAreaSection.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/TopAreaSection.kt
@@ -17,6 +17,7 @@
package com.android.systemui.keyguard.ui.composable.section
import android.content.Context
+import android.content.res.Resources
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
@@ -61,6 +62,7 @@
) {
@Composable
fun SceneScope.DefaultClockLayout(
+ smartSpacePaddingTop: (Resources) -> Int,
modifier: Modifier = Modifier,
) {
val currentClockLayout by clockViewModel.currentClockLayout.collectAsStateWithLifecycle()
@@ -99,22 +101,41 @@
SceneTransitionLayout(state) {
scene(splitShadeLargeClockScene) {
LargeClockWithSmartSpace(
+ smartSpacePaddingTop = smartSpacePaddingTop,
shouldOffSetClockToOneHalf = !hasCustomPositionUpdatedAnimation
)
}
scene(splitShadeSmallClockScene) {
- SmallClockWithSmartSpace(modifier = Modifier.fillMaxWidth(0.5f))
+ SmallClockWithSmartSpace(
+ smartSpacePaddingTop = smartSpacePaddingTop,
+ modifier = Modifier.fillMaxWidth(0.5f),
+ )
}
- scene(smallClockScene) { SmallClockWithSmartSpace() }
+ scene(smallClockScene) {
+ SmallClockWithSmartSpace(
+ smartSpacePaddingTop = smartSpacePaddingTop,
+ )
+ }
- scene(largeClockScene) { LargeClockWithSmartSpace() }
+ scene(largeClockScene) {
+ LargeClockWithSmartSpace(
+ smartSpacePaddingTop = smartSpacePaddingTop,
+ )
+ }
- scene(WeatherClockScenes.largeClockScene) { WeatherLargeClockWithSmartSpace() }
+ scene(WeatherClockScenes.largeClockScene) {
+ WeatherLargeClockWithSmartSpace(
+ smartSpacePaddingTop = smartSpacePaddingTop,
+ )
+ }
scene(WeatherClockScenes.splitShadeLargeClockScene) {
- WeatherLargeClockWithSmartSpace(modifier = Modifier.fillMaxWidth(0.5f))
+ WeatherLargeClockWithSmartSpace(
+ smartSpacePaddingTop = smartSpacePaddingTop,
+ modifier = Modifier.fillMaxWidth(0.5f),
+ )
}
}
with(mediaCarouselSection) { KeyguardMediaCarousel() }
@@ -122,7 +143,10 @@
}
@Composable
- private fun SceneScope.SmallClockWithSmartSpace(modifier: Modifier = Modifier) {
+ private fun SceneScope.SmallClockWithSmartSpace(
+ smartSpacePaddingTop: (Resources) -> Int,
+ modifier: Modifier = Modifier,
+ ) {
val burnIn = rememberBurnIn(clockInteractor)
Column(modifier = modifier) {
@@ -137,13 +161,17 @@
SmartSpace(
burnInParams = burnIn.parameters,
onTopChanged = burnIn.onSmartspaceTopChanged,
+ smartSpacePaddingTop = smartSpacePaddingTop,
)
}
}
}
@Composable
- private fun SceneScope.LargeClockWithSmartSpace(shouldOffSetClockToOneHalf: Boolean = false) {
+ private fun SceneScope.LargeClockWithSmartSpace(
+ smartSpacePaddingTop: (Resources) -> Int,
+ shouldOffSetClockToOneHalf: Boolean = false,
+ ) {
val burnIn = rememberBurnIn(clockInteractor)
val isLargeClockVisible by clockViewModel.isLargeClockVisible.collectAsStateWithLifecycle()
@@ -158,6 +186,7 @@
SmartSpace(
burnInParams = burnIn.parameters,
onTopChanged = burnIn.onSmartspaceTopChanged,
+ smartSpacePaddingTop = smartSpacePaddingTop,
)
}
with(clockSection) {
@@ -180,7 +209,10 @@
}
@Composable
- private fun SceneScope.WeatherLargeClockWithSmartSpace(modifier: Modifier = Modifier) {
+ private fun SceneScope.WeatherLargeClockWithSmartSpace(
+ smartSpacePaddingTop: (Resources) -> Int,
+ modifier: Modifier = Modifier,
+ ) {
val burnIn = rememberBurnIn(clockInteractor)
val isLargeClockVisible by clockViewModel.isLargeClockVisible.collectAsStateWithLifecycle()
val currentClockState = clockViewModel.currentClock.collectAsStateWithLifecycle()
@@ -206,6 +238,7 @@
SmartSpace(
burnInParams = burnIn.parameters,
onTopChanged = burnIn.onSmartspaceTopChanged,
+ smartSpacePaddingTop = smartSpacePaddingTop,
modifier =
Modifier.heightIn(
min = getDimen(context, "enhanced_smartspace_height", density)
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt
index a9ddf84..b0c3fb31 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt
@@ -31,7 +31,7 @@
import com.android.systemui.qs.ui.composable.QuickSettings.SharedValues.MediaLandscapeTopOffset
import com.android.systemui.qs.ui.composable.QuickSettings.SharedValues.MediaOffset.Default
import com.android.systemui.scene.shared.model.Scenes
-import com.android.systemui.scene.ui.viewmodel.GoneSceneViewModel
+import com.android.systemui.scene.ui.viewmodel.GoneSceneActionsViewModel
import com.android.systemui.statusbar.notification.stack.ui.view.NotificationScrollView
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel
import dagger.Lazy
@@ -48,12 +48,18 @@
constructor(
private val notificationStackScrolLView: Lazy<NotificationScrollView>,
private val notificationsPlaceholderViewModel: NotificationsPlaceholderViewModel,
- private val viewModel: GoneSceneViewModel,
+ private val viewModelFactory: GoneSceneActionsViewModel.Factory,
) : ComposableScene {
override val key = Scenes.Gone
+ private val actionsViewModel: GoneSceneActionsViewModel by lazy { viewModelFactory.create() }
+
override val destinationScenes: Flow<Map<UserAction, UserActionResult>> =
- viewModel.destinationScenes
+ actionsViewModel.actions
+
+ override suspend fun activate() {
+ actionsViewModel.activate()
+ }
@Composable
override fun SceneScope.Content(
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/bottombar/ui/BottomBarComponent.kt b/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/bottombar/ui/BottomBarComponent.kt
index c08eb94..981a0ff 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/bottombar/ui/BottomBarComponent.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/volume/panel/component/bottombar/ui/BottomBarComponent.kt
@@ -20,16 +20,14 @@
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
-import androidx.compose.material3.Button
-import androidx.compose.material3.ButtonDefaults
-import androidx.compose.material3.MaterialTheme
-import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
+import com.android.compose.PlatformButton
+import com.android.compose.PlatformOutlinedButton
import com.android.systemui.res.R
import com.android.systemui.volume.panel.component.bottombar.ui.viewmodel.BottomBarViewModel
import com.android.systemui.volume.panel.dagger.scope.VolumePanelScope
@@ -51,16 +49,10 @@
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
) {
- OutlinedButton(
- onClick = viewModel::onSettingsClicked,
- colors =
- ButtonDefaults.outlinedButtonColors(
- contentColor = MaterialTheme.colorScheme.onSurface,
- ),
- ) {
+ PlatformOutlinedButton(onClick = viewModel::onSettingsClicked) {
Text(text = stringResource(R.string.volume_panel_dialog_settings_button))
}
- Button(onClick = viewModel::onDoneClicked) {
+ PlatformButton(onClick = viewModel::onDoneClicked) {
Text(stringResource(R.string.inline_done_button))
}
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/PredictiveBackHandler.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/PredictiveBackHandler.kt
index fe16ef751..0105af3 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/PredictiveBackHandler.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/PredictiveBackHandler.kt
@@ -127,7 +127,16 @@
return coroutineScope
.launch(start = CoroutineStart.ATOMIC) {
try {
- animatable.animateTo(targetProgress)
+ if (currentScene == toScene) {
+ animatable.animateTo(targetProgress, transformationSpec.progressSpec)
+ } else {
+ // If the back gesture is cancelled, the progress is animated back to 0f by
+ // the system. But we need this animate call anyways because
+ // PredictiveBackHandler doesn't guarantee that it ends at 0f. Since the
+ // remaining change in progress is usually very small, the progressSpec is
+ // omitted and the default spring spec used instead.
+ animatable.animateTo(targetProgress)
+ }
} finally {
state.finishTransition(this@PredictiveBackTransition, scene)
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/PredictiveBackHandlerTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/PredictiveBackHandlerTest.kt
index 0eaecb0..c414fbe 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/PredictiveBackHandlerTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/PredictiveBackHandlerTest.kt
@@ -18,6 +18,8 @@
import androidx.activity.BackEventCompat
import androidx.activity.ComponentActivity
+import androidx.compose.animation.core.LinearEasing
+import androidx.compose.animation.core.tween
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.rememberCoroutineScope
@@ -59,7 +61,23 @@
@Test
fun testPredictiveBack() {
- val layoutState = rule.runOnUiThread { MutableSceneTransitionLayoutState(SceneA) }
+ val transitionFrames = 2
+ val layoutState =
+ rule.runOnUiThread {
+ MutableSceneTransitionLayoutState(
+ SceneA,
+ transitions =
+ transitions {
+ from(SceneA, to = SceneB) {
+ spec =
+ tween(
+ durationMillis = transitionFrames * 16,
+ easing = LinearEasing
+ )
+ }
+ }
+ )
+ }
rule.setContent {
SceneTransitionLayout(layoutState) {
scene(SceneA, mapOf(Back to SceneB)) { Box(Modifier.fillMaxSize()) }
@@ -88,12 +106,27 @@
assertThat(layoutState.transitionState).hasCurrentScene(SceneA)
assertThat(layoutState.transitionState).isIdle()
+ rule.mainClock.autoAdvance = false
+
// Start again and commit it.
rule.runOnUiThread {
dispatcher.dispatchOnBackStarted(backEvent())
dispatcher.dispatchOnBackProgressed(backEvent(progress = 0.4f))
dispatcher.onBackPressed()
}
+ rule.mainClock.advanceTimeByFrame()
+ rule.waitForIdle()
+ val transition2 = assertThat(layoutState.transitionState).isTransition()
+ // verify that transition picks up progress from preview
+ assertThat(transition2).hasProgress(0.4f, tolerance = 0.0001f)
+
+ rule.mainClock.advanceTimeByFrame()
+ rule.waitForIdle()
+ // verify that transition is half way between preview-end-state (0.4f) and target-state (1f)
+ // after one frame
+ assertThat(transition2).hasProgress(0.7f, tolerance = 0.0001f)
+
+ rule.mainClock.autoAdvance = true
rule.waitForIdle()
assertThat(layoutState.transitionState).hasCurrentScene(SceneB)
assertThat(layoutState.transitionState).isIdle()
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt
index 3075c54..8236eec 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelTest.kt
@@ -34,6 +34,7 @@
import com.android.systemui.keyguard.shared.model.ClockSize
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testScope
+import com.android.systemui.lifecycle.activateIn
import com.android.systemui.res.R
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.model.Scenes
@@ -79,6 +80,7 @@
fakeFeatureFlagsClassic.set(Flags.LOCK_SCREEN_LONG_PRESS_ENABLED, true)
shadeRepository.setShadeLayoutWide(false)
underTest = lockscreenContentViewModel
+ underTest.activateIn(testScope)
}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneActionsViewModelTest.kt
similarity index 95%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneActionsViewModelTest.kt
index bca83f0..b3ea03e 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneActionsViewModelTest.kt
@@ -37,6 +37,7 @@
import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.kosmos.testScope
+import com.android.systemui.lifecycle.activateIn
import com.android.systemui.power.data.repository.fakePowerRepository
import com.android.systemui.power.shared.model.WakefulnessState
import com.android.systemui.scene.domain.interactor.sceneInteractor
@@ -44,9 +45,7 @@
import com.android.systemui.scene.shared.model.TransitionKeys
import com.android.systemui.shade.data.repository.shadeRepository
import com.android.systemui.shade.domain.interactor.shadeInteractor
-import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationsPlaceholderViewModel
import com.android.systemui.testKosmos
-import com.android.systemui.util.mockito.mock
import com.google.common.truth.Truth.assertThat
import kotlin.math.pow
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -63,7 +62,7 @@
@RunWith(ParameterizedAndroidJunit4::class)
@RunWithLooper
@EnableSceneContainer
-class LockscreenSceneViewModelTest : SysuiTestCase() {
+class LockscreenSceneActionsViewModelTest : SysuiTestCase() {
companion object {
private const val parameterCount = 6
@@ -172,6 +171,7 @@
@EnableFlags(Flags.FLAG_COMMUNAL_HUB)
fun destinationScenes() =
testScope.runTest {
+ underTest.activateIn(this)
kosmos.fakeDeviceEntryRepository.setLockscreenEnabled(true)
kosmos.fakeAuthenticationRepository.setAuthenticationMethod(
if (canSwipeToEnter) {
@@ -192,7 +192,7 @@
},
)
- val destinationScenes by collectLastValue(underTest.destinationScenes)
+ val destinationScenes by collectLastValue(underTest.actions)
val downDestination =
destinationScenes?.get(
Swipe(
@@ -255,15 +255,10 @@
)
}
- private fun createLockscreenSceneViewModel(): LockscreenSceneViewModel {
- return LockscreenSceneViewModel(
+ private fun createLockscreenSceneViewModel(): LockscreenSceneActionsViewModel {
+ return LockscreenSceneActionsViewModel(
deviceEntryInteractor = kosmos.deviceEntryInteractor,
communalInteractor = kosmos.communalInteractor,
- touchHandling =
- KeyguardTouchHandlingViewModel(
- interactor = mock(),
- ),
- notifications = kosmos.notificationsPlaceholderViewModel,
shadeInteractor = kosmos.shadeInteractor,
)
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt
index 228d61a..72a5cd1 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt
@@ -48,9 +48,9 @@
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.flags.Flags
import com.android.systemui.flags.fakeFeatureFlagsClassic
-import com.android.systemui.keyguard.ui.viewmodel.KeyguardTouchHandlingViewModel
-import com.android.systemui.keyguard.ui.viewmodel.LockscreenSceneViewModel
+import com.android.systemui.keyguard.ui.viewmodel.LockscreenSceneActionsViewModel
import com.android.systemui.kosmos.testScope
+import com.android.systemui.lifecycle.activateIn
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest
import com.android.systemui.power.domain.interactor.powerInteractor
@@ -65,13 +65,11 @@
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.ui.viewmodel.ShadeSceneViewModel
import com.android.systemui.shade.ui.viewmodel.shadeSceneViewModel
-import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationsPlaceholderViewModel
import com.android.systemui.statusbar.pipeline.mobile.data.repository.FakeMobileConnectionsRepository
import com.android.systemui.statusbar.pipeline.mobile.data.repository.fakeMobileConnectionsRepository
import com.android.systemui.telephony.data.repository.fakeTelephonyRepository
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.any
-import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.android.telecom.telecomManager
import com.google.common.truth.Truth.assertThat
@@ -141,15 +139,10 @@
private lateinit var bouncerActionButtonInteractor: BouncerActionButtonInteractor
private lateinit var bouncerViewModel: BouncerViewModel
- private val lockscreenSceneViewModel by lazy {
- LockscreenSceneViewModel(
+ private val lockscreenSceneActionsViewModel by lazy {
+ LockscreenSceneActionsViewModel(
deviceEntryInteractor = deviceEntryInteractor,
communalInteractor = communalInteractor,
- touchHandling =
- KeyguardTouchHandlingViewModel(
- interactor = mock(),
- ),
- notifications = kosmos.notificationsPlaceholderViewModel,
shadeInteractor = kosmos.shadeInteractor,
)
}
@@ -198,6 +191,8 @@
val startable = kosmos.sceneContainerStartable
startable.start()
+ lockscreenSceneActionsViewModel.activateIn(testScope)
+
assertWithMessage("Initial scene key mismatch!")
.that(sceneContainerViewModel.currentScene.value)
.isEqualTo(sceneContainerConfig.initialSceneKey)
@@ -225,7 +220,7 @@
@Test
fun swipeUpOnLockscreen_enterCorrectPin_unlocksDevice() =
testScope.runTest {
- val destinationScenes by collectLastValue(lockscreenSceneViewModel.destinationScenes)
+ val destinationScenes by collectLastValue(lockscreenSceneActionsViewModel.actions)
val upDestinationSceneKey = destinationScenes?.get(Swipe.Up)?.toScene
assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer)
emulateUserDrivenTransition(
@@ -245,7 +240,7 @@
testScope.runTest {
setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true)
- val destinationScenes by collectLastValue(lockscreenSceneViewModel.destinationScenes)
+ val destinationScenes by collectLastValue(lockscreenSceneActionsViewModel.actions)
val upDestinationSceneKey = destinationScenes?.get(Swipe.Up)?.toScene
assertThat(upDestinationSceneKey).isEqualTo(Scenes.Gone)
emulateUserDrivenTransition(
@@ -351,7 +346,7 @@
fun swipeUpOnLockscreenWhileUnlocked_dismissesLockscreen() =
testScope.runTest {
unlockDevice()
- val destinationScenes by collectLastValue(lockscreenSceneViewModel.destinationScenes)
+ val destinationScenes by collectLastValue(lockscreenSceneActionsViewModel.actions)
val upDestinationSceneKey = destinationScenes?.get(Swipe.Up)?.toScene
assertThat(upDestinationSceneKey).isEqualTo(Scenes.Gone)
}
@@ -373,7 +368,7 @@
fun dismissingIme_whileOnPasswordBouncer_navigatesToLockscreen() =
testScope.runTest {
setAuthMethod(AuthenticationMethodModel.Password)
- val destinationScenes by collectLastValue(lockscreenSceneViewModel.destinationScenes)
+ val destinationScenes by collectLastValue(lockscreenSceneActionsViewModel.actions)
val upDestinationSceneKey = destinationScenes?.get(Swipe.Up)?.toScene
assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer)
emulateUserDrivenTransition(
@@ -391,7 +386,7 @@
fun bouncerActionButtonClick_opensEmergencyServicesDialer() =
testScope.runTest {
setAuthMethod(AuthenticationMethodModel.Password)
- val destinationScenes by collectLastValue(lockscreenSceneViewModel.destinationScenes)
+ val destinationScenes by collectLastValue(lockscreenSceneActionsViewModel.actions)
val upDestinationSceneKey = destinationScenes?.get(Swipe.Up)?.toScene
assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer)
emulateUserDrivenTransition(to = upDestinationSceneKey)
@@ -411,7 +406,7 @@
testScope.runTest {
setAuthMethod(AuthenticationMethodModel.Password)
startPhoneCall()
- val destinationScenes by collectLastValue(lockscreenSceneViewModel.destinationScenes)
+ val destinationScenes by collectLastValue(lockscreenSceneActionsViewModel.actions)
val upDestinationSceneKey = destinationScenes?.get(Swipe.Up)?.toScene
assertThat(upDestinationSceneKey).isEqualTo(Scenes.Bouncer)
emulateUserDrivenTransition(to = upDestinationSceneKey)
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/GoneSceneViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/GoneSceneActionsViewModelTest.kt
similarity index 91%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/GoneSceneViewModelTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/GoneSceneActionsViewModelTest.kt
index a4992e2..b526275 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/GoneSceneViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/GoneSceneActionsViewModelTest.kt
@@ -25,6 +25,7 @@
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.kosmos.testScope
+import com.android.systemui.lifecycle.activateIn
import com.android.systemui.scene.shared.model.TransitionKeys.ToSplitShade
import com.android.systemui.shade.data.repository.shadeRepository
import com.android.systemui.shade.domain.interactor.shadeInteractor
@@ -42,25 +43,26 @@
@RunWith(AndroidJUnit4::class)
@TestableLooper.RunWithLooper
@EnableSceneContainer
-class GoneSceneViewModelTest : SysuiTestCase() {
+class GoneSceneActionsViewModelTest : SysuiTestCase() {
private val kosmos = testKosmos()
private val testScope = kosmos.testScope
private val shadeRepository by lazy { kosmos.shadeRepository }
- private lateinit var underTest: GoneSceneViewModel
+ private lateinit var underTest: GoneSceneActionsViewModel
@Before
fun setUp() {
underTest =
- GoneSceneViewModel(
+ GoneSceneActionsViewModel(
shadeInteractor = kosmos.shadeInteractor,
)
+ underTest.activateIn(testScope)
}
@Test
fun downTransitionKey_splitShadeEnabled_isGoneToSplitShade() =
testScope.runTest {
- val destinationScenes by collectLastValue(underTest.destinationScenes)
+ val destinationScenes by collectLastValue(underTest.actions)
shadeRepository.setShadeLayoutWide(true)
runCurrent()
@@ -71,7 +73,7 @@
@Test
fun downTransitionKey_splitShadeDisabled_isNull() =
testScope.runTest {
- val destinationScenes by collectLastValue(underTest.destinationScenes)
+ val destinationScenes by collectLastValue(underTest.actions)
shadeRepository.setShadeLayoutWide(false)
runCurrent()
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneActionsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneActionsViewModelTest.kt
new file mode 100644
index 0000000..206d3ac
--- /dev/null
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneActionsViewModelTest.kt
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2024 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.
+ */
+
+@file:OptIn(ExperimentalCoroutinesApi::class)
+
+package com.android.systemui.scene.ui.viewmodel
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.compose.animation.scene.Back
+import com.android.compose.animation.scene.Swipe
+import com.android.compose.animation.scene.SwipeDirection
+import com.android.compose.animation.scene.UserAction
+import com.android.compose.animation.scene.UserActionResult
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.coroutines.collectLastValue
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.lifecycle.activateIn
+import com.android.systemui.scene.shared.model.Scenes
+import com.android.systemui.testKosmos
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.Job
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.collectLatest
+import kotlinx.coroutines.test.runCurrent
+import kotlinx.coroutines.test.runTest
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class SceneActionsViewModelTest : SysuiTestCase() {
+
+ private val kosmos = testKosmos()
+ private val testScope = kosmos.testScope
+
+ private val underTest = FakeSceneActionsViewModel()
+
+ @Test
+ fun actions_emptyBeforeActivation() =
+ testScope.runTest {
+ val actions by collectLastValue(underTest.actions)
+
+ assertThat(underTest.isActive).isFalse()
+ assertThat(actions).isEmpty()
+ }
+
+ @Test
+ fun actions_emptyBeforeFirstValue() =
+ testScope.runTest {
+ val actions by collectLastValue(underTest.actions)
+ underTest.activateIn(testScope)
+ runCurrent()
+
+ assertThat(underTest.isActive).isTrue()
+ assertThat(actions).isEmpty()
+ }
+
+ @Test
+ fun actions() =
+ testScope.runTest {
+ val actions by collectLastValue(underTest.actions)
+ underTest.activateIn(testScope)
+ runCurrent()
+ assertThat(underTest.isActive).isTrue()
+
+ val expected1 =
+ mapOf(
+ Back to UserActionResult(toScene = Scenes.Gone),
+ Swipe(SwipeDirection.Up) to UserActionResult(toScene = Scenes.Shade)
+ )
+ underTest.upstream.value = expected1
+ runCurrent()
+ assertThat(actions).isEqualTo(expected1)
+
+ val expected2 =
+ mapOf(
+ Back to UserActionResult(toScene = Scenes.Lockscreen),
+ Swipe(SwipeDirection.Down) to UserActionResult(toScene = Scenes.Shade)
+ )
+ underTest.upstream.value = expected2
+ runCurrent()
+ assertThat(actions).isEqualTo(expected2)
+ }
+
+ @Test
+ fun actions_emptyAfterCancellation() =
+ testScope.runTest {
+ val actions by collectLastValue(underTest.actions)
+ val job = Job()
+ underTest.activateIn(testScope, job)
+ runCurrent()
+
+ val expected =
+ mapOf(
+ Back to UserActionResult(toScene = Scenes.Lockscreen),
+ Swipe(SwipeDirection.Down) to UserActionResult(toScene = Scenes.Shade)
+ )
+ underTest.upstream.value = expected
+ runCurrent()
+ assertThat(actions).isEqualTo(expected)
+
+ job.cancel()
+ runCurrent()
+ assertThat(underTest.isActive).isFalse()
+ assertThat(actions).isEmpty()
+ }
+
+ private class FakeSceneActionsViewModel : SceneActionsViewModel() {
+
+ val upstream = MutableStateFlow<Map<UserAction, UserActionResult>>(emptyMap())
+
+ override suspend fun hydrateActions(
+ setActions: (Map<UserAction, UserActionResult>) -> Unit,
+ ) {
+ upstream.collectLatest { setActions(it) }
+ }
+ }
+}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/events/PrivacyDotViewControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/events/PrivacyDotViewControllerTest.kt
index f126432..663c341 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/events/PrivacyDotViewControllerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/events/PrivacyDotViewControllerTest.kt
@@ -18,8 +18,6 @@
import android.graphics.Point
import android.graphics.Rect
-import android.platform.test.annotations.DisableFlags
-import android.platform.test.annotations.EnableFlags
import android.testing.TestableLooper.RunWithLooper
import android.view.Display
import android.view.DisplayAdjustments
@@ -28,7 +26,6 @@
import android.widget.FrameLayout.LayoutParams.UNSPECIFIED_GRAVITY
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
-import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
import com.android.systemui.res.R
import com.android.systemui.statusbar.FakeStatusBarStateController
@@ -297,8 +294,7 @@
}
@Test
- @EnableFlags(Flags.FLAG_PRIVACY_DOT_UNFOLD_WRONG_CORNER_FIX)
- fun initialize_newViews_fixFlagEnabled_gravityIsUpdated() {
+ fun initialize_newViews_gravityIsUpdated() {
val newTopLeftView = initDotView()
val newTopRightView = initDotView()
val newBottomLeftView = initDotView()
@@ -318,28 +314,6 @@
.isNotEqualTo(UNSPECIFIED_GRAVITY)
}
- @Test
- @DisableFlags(Flags.FLAG_PRIVACY_DOT_UNFOLD_WRONG_CORNER_FIX)
- fun initialize_newViews_fixFlagDisabled_gravityIsNotUpdated() {
- val newTopLeftView = initDotView()
- val newTopRightView = initDotView()
- val newBottomLeftView = initDotView()
- val newBottomRightView = initDotView()
- setRotation(ROTATION_LANDSCAPE) // Bottom right used in landscape
-
- val controller = createAndInitializeController()
- // Re-init with different views, but same rotation
- controller.initialize(
- newTopLeftView,
- newTopRightView,
- newBottomLeftView,
- newBottomRightView
- )
-
- assertThat((newBottomRightView.layoutParams as FrameLayout.LayoutParams).gravity)
- .isEqualTo(UNSPECIFIED_GRAVITY)
- }
-
private fun setRotation(rotation: Int) {
whenever(mockDisplay.rotation).thenReturn(rotation)
}
@@ -347,7 +321,7 @@
private fun initDotView(): View {
val privacyDot = View(context).also { it.id = R.id.privacy_dot }
return FrameLayout(context).also {
- it.layoutParams = FrameLayout.LayoutParams(/* width = */ 0, /* height = */ 0)
+ it.layoutParams = FrameLayout.LayoutParams(/* width= */ 0, /* height= */ 0)
it.addView(privacyDot)
}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java
index 2114489..6441405 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java
@@ -88,7 +88,6 @@
@Mock private PowerManager mPowerManager;
@Mock private WakefulnessLifecycle mWakefullnessLifecycle;
@Mock private CentralSurfaces mCentralSurfaces;
- @Mock private NotificationIconAreaController mNotificationIconAreaController;
@Mock private NotificationShadeWindowViewController mNotificationShadeWindowViewController;
@Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
@Mock private ShadeLockscreenInteractor mShadeLockscreenInteractor;
@@ -106,7 +105,7 @@
mHeadsUpManager, mBatteryController, mScrimController,
() -> mBiometricUnlockController, () -> mAssistManager, mDozeScrimController,
mKeyguardUpdateMonitor, mPulseExpansionHandler, mNotificationShadeWindowController,
- mNotificationWakeUpCoordinator, mAuthController, mNotificationIconAreaController,
+ mNotificationWakeUpCoordinator, mAuthController,
mShadeLockscreenInteractor, mDozeInteractor);
mDozeServiceHost.initialize(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/sensors/ProximityCheckTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/util/sensors/ProximityCheckTest.java
similarity index 87%
rename from packages/SystemUI/tests/src/com/android/systemui/util/sensors/ProximityCheckTest.java
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/util/sensors/ProximityCheckTest.java
index 5dd008a..0eea120 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/util/sensors/ProximityCheckTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/util/sensors/ProximityCheckTest.java
@@ -74,6 +74,26 @@
}
@Test
+ public void testRecursiveCheck() {
+ mProximityCheck.check(100, event-> mProximityCheck.check(100, mTestableCallback));
+
+ assertThat(mTestableCallback.mNumCalls).isEqualTo(0);
+ assertThat(mTestableCallback.mLastResult).isNull();
+
+ mFakeExecutor.advanceClockToNext();
+ mFakeExecutor.runAllReady();
+
+ assertThat(mTestableCallback.mNumCalls).isEqualTo(0);
+ assertThat(mTestableCallback.mLastResult).isNull();
+
+ mFakeProximitySensor.setLastEvent(new ThresholdSensorEvent(true, 0));
+ mFakeProximitySensor.alertListeners();
+
+ assertThat(mTestableCallback.mNumCalls).isEqualTo(1);
+ assertThat(mTestableCallback.mLastResult).isTrue();
+ }
+
+ @Test
public void testTimeout() {
mProximityCheck.check(100, mTestableCallback);
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 159fb2e..4bc4692 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1389,7 +1389,7 @@
<!-- System casting media projection permission warning for capturing a single app when SysUI casting requests it. [CHAR LIMIT=350] -->
<string name="media_projection_entry_cast_permission_dialog_warning_single_app">When you’re casting an app, anything shown or played in that app is visible. So be careful with things like passwords, payment details, messages, photos, and audio and video.</string>
<!-- System casting media projection permission button to continue for SysUI casting. [CHAR LIMIT=60] -->
- <string name="media_projection_entry_cast_permission_dialog_continue">Start casting</string>
+ <string name="media_projection_entry_cast_permission_dialog_continue_entire_screen">Cast screen</string>
<!-- Other sharing (not recording nor casting) that launched by SysUI (currently not in use) -->
<!-- System sharing media projection permission dialog title. [CHAR LIMIT=100] -->
@@ -1400,6 +1400,8 @@
<string name="media_projection_entry_generic_permission_dialog_warning_single_app">When you’re sharing, recording, or casting an app, Android has access to anything shown or played on that app. So be careful with things like passwords, payment details, messages, photos, and audio and video.</string>
<!-- System sharing media projection permission button to continue. [CHAR LIMIT=60] -->
<string name="media_projection_entry_generic_permission_dialog_continue">Start</string>
+ <!-- System sharing media projection permission button to continue to the next step. [CHAR LIMIT=60] -->
+ <string name="media_projection_entry_generic_permission_dialog_continue_single_app">Next</string>
<!-- Task switcher notification -->
<!-- Task switcher notification text. [CHAR LIMIT=100] -->
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
index f688d4f..d468f2f 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
@@ -60,9 +60,7 @@
import com.android.systemui.statusbar.notification.AnimatableProperty;
import com.android.systemui.statusbar.notification.PropertyAnimator;
import com.android.systemui.statusbar.notification.icon.ui.viewbinder.NotificationIconContainerAlwaysOnDisplayViewBinder;
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
-import com.android.systemui.statusbar.phone.NotificationIconAreaController;
import com.android.systemui.statusbar.phone.NotificationIconContainer;
import com.android.systemui.util.ViewController;
import com.android.systemui.util.concurrency.DelayableExecutor;
@@ -87,7 +85,6 @@
private final StatusBarStateController mStatusBarStateController;
private final ClockRegistry mClockRegistry;
private final KeyguardSliceViewController mKeyguardSliceViewController;
- private final NotificationIconAreaController mNotificationIconAreaController;
private final LockscreenSmartspaceController mSmartspaceController;
private final SecureSettings mSecureSettings;
private final DumpManager mDumpManager;
@@ -165,7 +162,6 @@
StatusBarStateController statusBarStateController,
ClockRegistry clockRegistry,
KeyguardSliceViewController keyguardSliceViewController,
- NotificationIconAreaController notificationIconAreaController,
LockscreenSmartspaceController smartspaceController,
NotificationIconContainerAlwaysOnDisplayViewBinder nicViewBinder,
KeyguardUnlockAnimationController keyguardUnlockAnimationController,
@@ -183,7 +179,6 @@
mStatusBarStateController = statusBarStateController;
mClockRegistry = clockRegistry;
mKeyguardSliceViewController = keyguardSliceViewController;
- mNotificationIconAreaController = notificationIconAreaController;
mSmartspaceController = smartspaceController;
mNicViewBinder = nicViewBinder;
mSecureSettings = secureSettings;
@@ -351,10 +346,8 @@
int getNotificationIconAreaHeight() {
if (MigrateClocksToBlueprint.isEnabled()) {
return 0;
- } else if (NotificationIconContainerRefactor.isEnabled()) {
- return mAodIconContainer != null ? mAodIconContainer.getHeight() : 0;
} else {
- return mNotificationIconAreaController.getHeight();
+ return mAodIconContainer != null ? mAodIconContainer.getHeight() : 0;
}
}
@@ -603,16 +596,11 @@
NotificationIconContainer nic = (NotificationIconContainer)
mView.findViewById(
com.android.systemui.res.R.id.left_aligned_notification_icon_container);
- if (NotificationIconContainerRefactor.isEnabled()) {
- if (mAodIconsBindHandle != null) {
- mAodIconsBindHandle.dispose();
- }
- if (nic != null) {
- mAodIconsBindHandle = mNicViewBinder.bindWhileAttached(nic);
- mAodIconContainer = nic;
- }
- } else {
- mNotificationIconAreaController.setupAodIcons(nic);
+ if (mAodIconsBindHandle != null) {
+ mAodIconsBindHandle.dispose();
+ }
+ if (nic != null) {
+ mAodIconsBindHandle = mNicViewBinder.bindWhileAttached(nic);
mAodIconContainer = nic;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt
index 2d525aa..43ba097 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt
@@ -699,7 +699,12 @@
}
fun startTransitionToCredentialUI(isError: Boolean) {
- applicationScope.launch {
+ if (!constraintBp()) {
+ applicationScope.launch {
+ viewModel.onSwitchToCredential()
+ legacyCallback?.onUseDeviceCredential()
+ }
+ } else {
viewModel.onSwitchToCredential()
legacyCallback?.onUseDeviceCredential()
}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModel.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModel.kt
index fbc6470..214420d 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModel.kt
@@ -833,7 +833,7 @@
messageJob?.cancel()
messageJob = null
- if (helpMessage.isNotBlank()) {
+ if (helpMessage.isNotBlank() && needsUserConfirmation) {
showHelp(helpMessage)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
index 609aa39..25b6b14 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
@@ -132,7 +132,6 @@
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.ConfigurationControllerModule;
import com.android.systemui.statusbar.phone.LetterboxModule;
-import com.android.systemui.statusbar.phone.NotificationIconAreaControllerModule;
import com.android.systemui.statusbar.pipeline.dagger.StatusBarPipelineModule;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -230,7 +229,6 @@
MediaProjectionTaskSwitcherModule.class,
MediaRouterModule.class,
MotionToolModule.class,
- NotificationIconAreaControllerModule.class,
PeopleHubModule.class,
PeopleModule.class,
PluginModule.class,
diff --git a/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/OccludingAppDeviceEntryInteractor.kt b/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/OccludingAppDeviceEntryInteractor.kt
index 195aa5f..28db3b8 100644
--- a/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/OccludingAppDeviceEntryInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/OccludingAppDeviceEntryInteractor.kt
@@ -20,6 +20,7 @@
import android.content.Intent
import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor
+import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.shared.model.BiometricMessage
@@ -33,6 +34,7 @@
import com.android.systemui.keyguard.shared.model.SuccessFingerprintAuthenticationStatus
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.power.domain.interactor.PowerInteractor
+import com.android.systemui.util.kotlin.combine
import com.android.systemui.util.kotlin.sample
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
@@ -64,6 +66,7 @@
activityStarter: ActivityStarter,
powerInteractor: PowerInteractor,
keyguardTransitionInteractor: KeyguardTransitionInteractor,
+ communalSceneInteractor: CommunalSceneInteractor,
) {
private val keyguardOccludedByApp: Flow<Boolean> =
if (KeyguardWmStateRefactor.isEnabled) {
@@ -75,12 +78,20 @@
primaryBouncerInteractor.isShowing,
alternateBouncerInteractor.isVisible,
keyguardInteractor.isDozing,
- ) { occluded, showing, primaryBouncerShowing, alternateBouncerVisible, dozing ->
+ communalSceneInteractor.isIdleOnCommunal,
+ ) {
+ occluded,
+ showing,
+ primaryBouncerShowing,
+ alternateBouncerVisible,
+ dozing,
+ isIdleOnCommunal ->
occluded &&
showing &&
!primaryBouncerShowing &&
!alternateBouncerVisible &&
- !dozing
+ !dozing &&
+ !isIdleOnCommunal
}
.distinctUntilChanged()
}
diff --git a/packages/SystemUI/src/com/android/systemui/flags/FlagDependencies.kt b/packages/SystemUI/src/com/android/systemui/flags/FlagDependencies.kt
index 59de203..1d1ac5a 100644
--- a/packages/SystemUI/src/com/android/systemui/flags/FlagDependencies.kt
+++ b/packages/SystemUI/src/com/android/systemui/flags/FlagDependencies.kt
@@ -39,14 +39,11 @@
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.shade.shared.flag.DualShade
import com.android.systemui.statusbar.notification.collection.SortBySectionTimeFlag
-import com.android.systemui.statusbar.notification.footer.shared.FooterViewRefactor
import com.android.systemui.statusbar.notification.interruption.VisualInterruptionRefactor
import com.android.systemui.statusbar.notification.shared.NotificationAvalancheSuppression
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor
import com.android.systemui.statusbar.notification.shared.NotificationMinimalismPrototype
import com.android.systemui.statusbar.notification.shared.NotificationThrottleHun
import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor
-import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor
import com.android.systemui.statusbar.notification.shared.PriorityPeopleSection
import javax.inject.Inject
@@ -61,8 +58,6 @@
modesUi dependsOn modesApi
// Internal notification frontend dependencies
- NotificationsLiveDataStoreRefactor.token dependsOn NotificationIconContainerRefactor.token
- FooterViewRefactor.token dependsOn NotificationIconContainerRefactor.token
NotificationAvalancheSuppression.token dependsOn VisualInterruptionRefactor.token
PriorityPeopleSection.token dependsOn SortBySectionTimeFlag.token
NotificationMinimalismPrototype.token dependsOn NotificationsHeadsUpRefactor.token
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt
index 80cf4c5..ba533ce 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt
@@ -106,7 +106,7 @@
private val falsingManager: FalsingManager,
private val keyguardClockViewModel: KeyguardClockViewModel,
private val smartspaceViewModel: KeyguardSmartspaceViewModel,
- private val lockscreenContentViewModel: LockscreenContentViewModel,
+ private val lockscreenContentViewModelFactory: LockscreenContentViewModel.Factory,
private val lockscreenSceneBlueprintsLazy: Lazy<Set<LockscreenSceneBlueprint>>,
private val clockInteractor: KeyguardClockInteractor,
private val keyguardViewMediator: KeyguardViewMediator,
@@ -143,7 +143,7 @@
val composeView =
createLockscreen(
context = context,
- viewModel = lockscreenContentViewModel,
+ viewModelFactory = lockscreenContentViewModelFactory,
blueprints = lockscreenSceneBlueprintsLazy.get(),
)
composeView.id = View.generateViewId()
@@ -224,7 +224,7 @@
private fun createLockscreen(
context: Context,
- viewModel: LockscreenContentViewModel,
+ viewModelFactory: LockscreenContentViewModel.Factory,
blueprints: Set<@JvmSuppressWildcards LockscreenSceneBlueprint>,
): View {
val sceneBlueprints =
@@ -239,7 +239,7 @@
scene(currentScene) {
with(
LockscreenContent(
- viewModel = viewModel,
+ viewModelFactory = viewModelFactory,
blueprints = sceneBlueprints,
clockInteractor = clockInteractor
)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
index 91b66c3..aab5b9b 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
@@ -70,7 +70,6 @@
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.statusbar.CrossFadeHelper
import com.android.systemui.statusbar.VibratorHelper
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor
import com.android.systemui.statusbar.phone.ScreenOffAnimationController
import com.android.systemui.temporarydisplay.ViewPriority
import com.android.systemui.temporarydisplay.chipbar.ChipbarCoordinator
@@ -292,20 +291,18 @@
}
}
- if (NotificationIconContainerRefactor.isEnabled) {
- launch {
- val iconsAppearTranslationPx =
- configuration
- .getDimensionPixelSize(R.dimen.shelf_appear_translation)
- .stateIn(this)
- viewModel.isNotifIconContainerVisible.collect { isVisible ->
- childViews[aodNotificationIconContainerId]
- ?.setAodNotifIconContainerIsVisible(
- isVisible,
- iconsAppearTranslationPx.value,
- screenOffAnimationController,
- )
- }
+ launch {
+ val iconsAppearTranslationPx =
+ configuration
+ .getDimensionPixelSize(R.dimen.shelf_appear_translation)
+ .stateIn(this)
+ viewModel.isNotifIconContainerVisible.collect { isVisible ->
+ childViews[aodNotificationIconContainerId]
+ ?.setAodNotifIconContainerIsVisible(
+ isVisible,
+ iconsAppearTranslationPx.value,
+ screenOffAnimationController,
+ )
}
}
@@ -519,7 +516,6 @@
if (MigrateClocksToBlueprint.isEnabled) {
throw IllegalStateException("should only be called in legacy code paths")
}
- if (NotificationIconContainerRefactor.isUnexpectedlyInLegacyMode()) return
coroutineScope {
val iconAppearTranslationPx =
configuration.getDimensionPixelSize(R.dimen.shelf_appear_translation).stateIn(this)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodNotificationIconsSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodNotificationIconsSection.kt
index d77b548..36ef78e 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodNotificationIconsSection.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodNotificationIconsSection.kt
@@ -37,8 +37,6 @@
import com.android.systemui.statusbar.notification.icon.ui.viewbinder.NotificationIconContainerViewBinder
import com.android.systemui.statusbar.notification.icon.ui.viewbinder.StatusBarIconViewBindingFailureTracker
import com.android.systemui.statusbar.notification.icon.ui.viewmodel.NotificationIconContainerAlwaysOnDisplayViewModel
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor
-import com.android.systemui.statusbar.phone.NotificationIconAreaController
import com.android.systemui.statusbar.phone.NotificationIconContainer
import com.android.systemui.statusbar.ui.SystemBarUtilsState
import com.android.systemui.util.ui.value
@@ -53,7 +51,6 @@
private val iconBindingFailureTracker: StatusBarIconViewBindingFailureTracker,
private val nicAodViewModel: NotificationIconContainerAlwaysOnDisplayViewModel,
private val nicAodIconViewStore: AlwaysOnDisplayNotificationIconViewStore,
- private val notificationIconAreaController: NotificationIconAreaController,
private val systemBarUtilsState: SystemBarUtilsState,
private val rootViewModel: KeyguardRootViewModel,
) : KeyguardSection() {
@@ -86,20 +83,16 @@
return
}
- if (NotificationIconContainerRefactor.isEnabled) {
- nicBindingDisposable?.dispose()
- nicBindingDisposable =
- NotificationIconContainerViewBinder.bindWhileAttached(
- nic,
- nicAodViewModel,
- configurationState,
- systemBarUtilsState,
- iconBindingFailureTracker,
- nicAodIconViewStore,
- )
- } else {
- notificationIconAreaController.setupAodIcons(nic)
- }
+ nicBindingDisposable?.dispose()
+ nicBindingDisposable =
+ NotificationIconContainerViewBinder.bindWhileAttached(
+ nic,
+ nicAodViewModel,
+ configurationState,
+ systemBarUtilsState,
+ iconBindingFailureTracker,
+ nicAodIconViewStore,
+ )
}
override fun applyConstraints(constraintSet: ConstraintSet) {
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModel.kt
index 3fffeff..59cb6e5 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModel.kt
@@ -20,40 +20,43 @@
import com.android.compose.animation.scene.ContentKey
import com.android.internal.annotations.VisibleForTesting
import com.android.systemui.biometrics.AuthController
-import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.shared.model.ClockSize
+import com.android.systemui.lifecycle.SysUiViewModel
import com.android.systemui.res.R
import com.android.systemui.scene.domain.interactor.SceneContainerOcclusionInteractor
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.unfold.domain.interactor.UnfoldTransitionInteractor
-import javax.inject.Inject
+import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asStateFlow
+import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
+import kotlinx.coroutines.launch
-@SysUISingleton
class LockscreenContentViewModel
-@Inject
+@AssistedInject
constructor(
clockInteractor: KeyguardClockInteractor,
private val interactor: KeyguardBlueprintInteractor,
private val authController: AuthController,
val touchHandling: KeyguardTouchHandlingViewModel,
- val shadeInteractor: ShadeInteractor,
- @Application private val applicationScope: CoroutineScope,
- unfoldTransitionInteractor: UnfoldTransitionInteractor,
- occlusionInteractor: SceneContainerOcclusionInteractor,
-) {
+ private val shadeInteractor: ShadeInteractor,
+ private val unfoldTransitionInteractor: UnfoldTransitionInteractor,
+ private val occlusionInteractor: SceneContainerOcclusionInteractor,
+) : SysUiViewModel() {
@VisibleForTesting val clockSize = clockInteractor.clockSize
val isUdfpsVisible: Boolean
@@ -61,32 +64,36 @@
val isShadeLayoutWide: StateFlow<Boolean> = shadeInteractor.isShadeLayoutWide
+ private val _unfoldTranslations = MutableStateFlow(UnfoldTranslations())
/** Amount of horizontal translation that should be applied to elements in the scene. */
- val unfoldTranslations: StateFlow<UnfoldTranslations> =
- combine(
- unfoldTransitionInteractor.unfoldTranslationX(isOnStartSide = true),
- unfoldTransitionInteractor.unfoldTranslationX(isOnStartSide = false),
- ) { start, end ->
- UnfoldTranslations(
- start = start,
- end = end,
- )
- }
- .stateIn(
- scope = applicationScope,
- started = SharingStarted.WhileSubscribed(),
- initialValue = UnfoldTranslations(),
- )
+ val unfoldTranslations: StateFlow<UnfoldTranslations> = _unfoldTranslations.asStateFlow()
+ private val _isContentVisible = MutableStateFlow(true)
/** Whether the content of the scene UI should be shown. */
- val isContentVisible: StateFlow<Boolean> =
- occlusionInteractor.isOccludingActivityShown
- .map { !it }
- .stateIn(
- scope = applicationScope,
- started = SharingStarted.WhileSubscribed(),
- initialValue = true,
- )
+ val isContentVisible: StateFlow<Boolean> = _isContentVisible.asStateFlow()
+
+ override suspend fun onActivated() {
+ coroutineScope {
+ launch {
+ combine(
+ unfoldTransitionInteractor.unfoldTranslationX(isOnStartSide = true),
+ unfoldTransitionInteractor.unfoldTranslationX(isOnStartSide = false),
+ ) { start, end ->
+ UnfoldTranslations(
+ start = start,
+ end = end,
+ )
+ }
+ .collectLatest { _unfoldTranslations.value = it }
+ }
+
+ launch {
+ occlusionInteractor.isOccludingActivityShown
+ .map { !it }
+ .collectLatest { _isContentVisible.value = it }
+ }
+ }
+ }
/**
* Returns a flow that indicates whether lockscreen notifications should be rendered in the
@@ -142,4 +149,9 @@
*/
val end: Float = 0f,
)
+
+ @AssistedFactory
+ interface Factory {
+ fun create(): LockscreenContentViewModel
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneActionsViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneActionsViewModel.kt
new file mode 100644
index 0000000..7383f57
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneActionsViewModel.kt
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@file:OptIn(ExperimentalCoroutinesApi::class)
+
+package com.android.systemui.keyguard.ui.viewmodel
+
+import com.android.compose.animation.scene.Edge
+import com.android.compose.animation.scene.Swipe
+import com.android.compose.animation.scene.SwipeDirection
+import com.android.compose.animation.scene.UserAction
+import com.android.compose.animation.scene.UserActionResult
+import com.android.systemui.communal.domain.interactor.CommunalInteractor
+import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
+import com.android.systemui.scene.shared.model.SceneFamilies
+import com.android.systemui.scene.shared.model.Scenes
+import com.android.systemui.scene.shared.model.TransitionKeys.ToSplitShade
+import com.android.systemui.scene.ui.viewmodel.SceneActionsViewModel
+import com.android.systemui.shade.domain.interactor.ShadeInteractor
+import com.android.systemui.shade.shared.model.ShadeMode
+import com.android.systemui.util.kotlin.filterValuesNotNull
+import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.collectLatest
+import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.flow.flatMapLatest
+import kotlinx.coroutines.flow.flowOf
+
+/** Models UI state and handles user input for the lockscreen scene. */
+class LockscreenSceneActionsViewModel
+@AssistedInject
+constructor(
+ private val deviceEntryInteractor: DeviceEntryInteractor,
+ private val communalInteractor: CommunalInteractor,
+ private val shadeInteractor: ShadeInteractor,
+) : SceneActionsViewModel() {
+
+ override suspend fun hydrateActions(setActions: (Map<UserAction, UserActionResult>) -> Unit) {
+ shadeInteractor.isShadeTouchable
+ .flatMapLatest { isShadeTouchable ->
+ if (!isShadeTouchable) {
+ flowOf(emptyMap())
+ } else {
+ combine(
+ deviceEntryInteractor.isUnlocked,
+ communalInteractor.isCommunalAvailable,
+ shadeInteractor.shadeMode,
+ ) { isDeviceUnlocked, isCommunalAvailable, shadeMode ->
+ val notifShadeSceneKey =
+ UserActionResult(
+ toScene = SceneFamilies.NotifShade,
+ transitionKey =
+ ToSplitShade.takeIf { shadeMode is ShadeMode.Split },
+ )
+
+ mapOf(
+ Swipe.Left to
+ UserActionResult(Scenes.Communal).takeIf {
+ isCommunalAvailable
+ },
+ Swipe.Up to if (isDeviceUnlocked) Scenes.Gone else Scenes.Bouncer,
+
+ // Swiping down from the top edge goes to QS (or shade if in split
+ // shade mode).
+ swipeDownFromTop(pointerCount = 1) to
+ if (shadeMode is ShadeMode.Single) {
+ UserActionResult(Scenes.QuickSettings)
+ } else {
+ notifShadeSceneKey
+ },
+
+ // TODO(b/338577208): Remove once we add Dual Shade invocation zones
+ swipeDownFromTop(pointerCount = 2) to
+ UserActionResult(
+ toScene = SceneFamilies.QuickSettings,
+ transitionKey =
+ ToSplitShade.takeIf { shadeMode is ShadeMode.Split }
+ ),
+
+ // Swiping down, not from the edge, always navigates to the notif
+ // shade scene.
+ swipeDown(pointerCount = 1) to notifShadeSceneKey,
+ swipeDown(pointerCount = 2) to notifShadeSceneKey,
+ )
+ .filterValuesNotNull()
+ }
+ }
+ }
+ .collectLatest { setActions(it) }
+ }
+
+ private fun swipeDownFromTop(pointerCount: Int): Swipe {
+ return Swipe(
+ SwipeDirection.Down,
+ fromSource = Edge.Top,
+ pointerCount = pointerCount,
+ )
+ }
+
+ private fun swipeDown(pointerCount: Int): Swipe {
+ return Swipe(
+ SwipeDirection.Down,
+ pointerCount = pointerCount,
+ )
+ }
+
+ @AssistedFactory
+ interface Factory {
+ fun create(): LockscreenSceneActionsViewModel
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModel.kt
deleted file mode 100644
index 15892e9..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModel.kt
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@file:OptIn(ExperimentalCoroutinesApi::class)
-
-package com.android.systemui.keyguard.ui.viewmodel
-
-import com.android.compose.animation.scene.Edge
-import com.android.compose.animation.scene.Swipe
-import com.android.compose.animation.scene.SwipeDirection
-import com.android.compose.animation.scene.UserAction
-import com.android.compose.animation.scene.UserActionResult
-import com.android.systemui.communal.domain.interactor.CommunalInteractor
-import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
-import com.android.systemui.scene.shared.model.SceneFamilies
-import com.android.systemui.scene.shared.model.Scenes
-import com.android.systemui.scene.shared.model.TransitionKeys.ToSplitShade
-import com.android.systemui.shade.domain.interactor.ShadeInteractor
-import com.android.systemui.shade.shared.model.ShadeMode
-import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel
-import com.android.systemui.util.kotlin.filterValuesNotNull
-import javax.inject.Inject
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.combine
-import kotlinx.coroutines.flow.flatMapLatest
-import kotlinx.coroutines.flow.flowOf
-
-/** Models UI state and handles user input for the lockscreen scene. */
-@SysUISingleton
-class LockscreenSceneViewModel
-@Inject
-constructor(
- private val deviceEntryInteractor: DeviceEntryInteractor,
- private val communalInteractor: CommunalInteractor,
- private val shadeInteractor: ShadeInteractor,
- val touchHandling: KeyguardTouchHandlingViewModel,
- val notifications: NotificationsPlaceholderViewModel,
-) {
- val destinationScenes: Flow<Map<UserAction, UserActionResult>> =
- shadeInteractor.isShadeTouchable.flatMapLatest { isShadeTouchable ->
- if (!isShadeTouchable) {
- flowOf(emptyMap())
- } else {
- combine(
- deviceEntryInteractor.isUnlocked,
- communalInteractor.isCommunalAvailable,
- shadeInteractor.shadeMode,
- ) { isDeviceUnlocked, isCommunalAvailable, shadeMode ->
- val notifShadeSceneKey =
- UserActionResult(
- toScene = SceneFamilies.NotifShade,
- transitionKey = ToSplitShade.takeIf { shadeMode is ShadeMode.Split },
- )
-
- mapOf(
- Swipe.Left to
- UserActionResult(Scenes.Communal).takeIf { isCommunalAvailable },
- Swipe.Up to if (isDeviceUnlocked) Scenes.Gone else Scenes.Bouncer,
-
- // Swiping down from the top edge goes to QS (or shade if in split shade
- // mode).
- swipeDownFromTop(pointerCount = 1) to
- if (shadeMode is ShadeMode.Single) {
- UserActionResult(Scenes.QuickSettings)
- } else {
- notifShadeSceneKey
- },
-
- // TODO(b/338577208): Remove once we add Dual Shade invocation zones.
- swipeDownFromTop(pointerCount = 2) to
- UserActionResult(
- toScene = SceneFamilies.QuickSettings,
- transitionKey =
- ToSplitShade.takeIf { shadeMode is ShadeMode.Split }
- ),
-
- // Swiping down, not from the edge, always navigates to the notif shade
- // scene.
- swipeDown(pointerCount = 1) to notifShadeSceneKey,
- swipeDown(pointerCount = 2) to notifShadeSceneKey,
- )
- .filterValuesNotNull()
- }
- }
- }
-
- private fun swipeDownFromTop(pointerCount: Int): Swipe {
- return Swipe(
- SwipeDirection.Down,
- fromSource = Edge.Top,
- pointerCount = pointerCount,
- )
- }
-
- private fun swipeDown(pointerCount: Int): Swipe {
- return Swipe(
- SwipeDirection.Down,
- pointerCount = pointerCount,
- )
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/BaseMediaProjectionPermissionDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/BaseMediaProjectionPermissionDialogDelegate.kt
index 83f694b..cdf8f06 100644
--- a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/BaseMediaProjectionPermissionDialogDelegate.kt
+++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/BaseMediaProjectionPermissionDialogDelegate.kt
@@ -95,13 +95,16 @@
private fun initScreenShareOptions() {
selectedScreenShareOption = screenShareOptions.first { it.mode == defaultSelectedMode }
- warning.text = warningText
+ setOptionSpecificFields()
initScreenShareSpinner()
}
private val warningText: String
get() = dialog.context.getString(selectedScreenShareOption.warningText, appName)
+ private val startButtonText: String
+ get() = dialog.context.getString(selectedScreenShareOption.startButtonText)
+
private fun initScreenShareSpinner() {
val adapter = OptionsAdapter(dialog.context.applicationContext, screenShareOptions)
screenShareModeSpinner = dialog.requireViewById(R.id.screen_share_mode_options)
@@ -126,7 +129,13 @@
override fun onItemSelected(adapterView: AdapterView<*>?, view: View, pos: Int, id: Long) {
selectedScreenShareOption = screenShareOptions[pos]
+ setOptionSpecificFields()
+ }
+
+ /** Sets fields on the dialog that change based on which option is selected. */
+ private fun setOptionSpecificFields() {
warning.text = warningText
+ startButton.text = startButtonText
}
override fun onNothingSelected(parent: AdapterView<*>?) {}
@@ -137,10 +146,6 @@
dialogTitle.text = title
}
- protected fun setStartButtonText(@StringRes stringId: Int) {
- startButton.setText(stringId)
- }
-
protected fun setStartButtonOnClickListener(listener: View.OnClickListener?) {
startButton.setOnClickListener { view ->
shouldLogCancel = false
diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ScreenShareOption.kt b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ScreenShareOption.kt
index 9bd5783..ab92173 100644
--- a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ScreenShareOption.kt
+++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ScreenShareOption.kt
@@ -26,9 +26,10 @@
const val SINGLE_APP = 0
const val ENTIRE_SCREEN = 1
-class ScreenShareOption(
+data class ScreenShareOption(
@ScreenShareMode val mode: Int,
@StringRes val spinnerText: Int,
@StringRes val warningText: Int,
+ @StringRes val startButtonText: Int,
val spinnerDisabledText: String? = null,
)
diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ShareToAppPermissionDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ShareToAppPermissionDialogDelegate.kt
index 5a2d88c..8bf2202 100644
--- a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ShareToAppPermissionDialogDelegate.kt
+++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/ShareToAppPermissionDialogDelegate.kt
@@ -53,7 +53,6 @@
super.onCreate(dialog, savedInstanceState)
// TODO(b/270018943): Handle the case of System sharing (not recording nor casting)
setDialogTitle(R.string.media_projection_entry_app_permission_dialog_title)
- setStartButtonText(R.string.media_projection_entry_app_permission_dialog_continue)
setStartButtonOnClickListener {
// Note that it is important to run this callback before dismissing, so that the
// callback can disable the dialog exit animation if it wants to.
@@ -88,6 +87,8 @@
warningText =
R.string
.media_projection_entry_app_permission_dialog_warning_single_app,
+ startButtonText =
+ R.string.media_projection_entry_app_permission_dialog_continue,
spinnerDisabledText = singleAppDisabledText,
),
ScreenShareOption(
@@ -96,6 +97,8 @@
warningText =
R.string
.media_projection_entry_app_permission_dialog_warning_entire_screen,
+ startButtonText =
+ R.string.media_projection_entry_app_permission_dialog_continue,
)
)
return if (singleAppDisabledText != null) {
diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegate.kt
index 1ac3ccd..a19fb96 100644
--- a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegate.kt
+++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegate.kt
@@ -52,7 +52,6 @@
super.onCreate(dialog, savedInstanceState)
// TODO(b/270018943): Handle the case of System sharing (not recording nor casting)
setDialogTitle(R.string.media_projection_entry_cast_permission_dialog_title)
- setStartButtonText(R.string.media_projection_entry_cast_permission_dialog_continue)
setStartButtonOnClickListener {
// Note that it is important to run this callback before dismissing, so that the
// callback can disable the dialog exit animation if it wants to.
@@ -89,6 +88,9 @@
warningText =
R.string
.media_projection_entry_cast_permission_dialog_warning_single_app,
+ startButtonText =
+ R.string
+ .media_projection_entry_generic_permission_dialog_continue_single_app,
spinnerDisabledText = singleAppDisabledText,
),
ScreenShareOption(
@@ -99,6 +101,9 @@
warningText =
R.string
.media_projection_entry_cast_permission_dialog_warning_entire_screen,
+ startButtonText =
+ R.string
+ .media_projection_entry_cast_permission_dialog_continue_entire_screen,
)
)
return if (singleAppDisabledText != null) {
diff --git a/packages/SystemUI/src/com/android/systemui/power/InattentiveSleepWarningView.java b/packages/SystemUI/src/com/android/systemui/power/InattentiveSleepWarningView.java
index 1cd5d91..2ecca2d 100644
--- a/packages/SystemUI/src/com/android/systemui/power/InattentiveSleepWarningView.java
+++ b/packages/SystemUI/src/com/android/systemui/power/InattentiveSleepWarningView.java
@@ -16,6 +16,8 @@
package com.android.systemui.power;
+import static com.android.systemui.Flags.enableViewCaptureTracing;
+
import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.animation.AnimatorListenerAdapter;
@@ -29,21 +31,27 @@
import android.view.WindowManager;
import android.widget.FrameLayout;
+import com.android.app.viewcapture.ViewCapture;
+import com.android.app.viewcapture.ViewCaptureAwareWindowManager;
import com.android.systemui.res.R;
+import kotlin.Lazy;
+
/**
* View that shows a warning shortly before the device goes into sleep
* after prolonged user inactivity when bound to.
*/
public class InattentiveSleepWarningView extends FrameLayout {
private final IBinder mWindowToken = new Binder();
- private final WindowManager mWindowManager;
+ private final ViewCaptureAwareWindowManager mWindowManager;
private Animator mFadeOutAnimator;
private boolean mDismissing;
- InattentiveSleepWarningView(Context context) {
+ InattentiveSleepWarningView(Context context, Lazy<ViewCapture> lazyViewCapture) {
super(context);
- mWindowManager = mContext.getSystemService(WindowManager.class);
+ WindowManager wm = mContext.getSystemService(WindowManager.class);
+ mWindowManager = new ViewCaptureAwareWindowManager(wm, lazyViewCapture,
+ enableViewCaptureTracing());
final LayoutInflater layoutInflater = LayoutInflater.from(mContext);
layoutInflater.inflate(R.layout.inattentive_sleep_warning, this, true /* attachToRoot */);
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
index 958ace35..861a7ce 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java
@@ -16,6 +16,8 @@
package com.android.systemui.power;
+import static com.android.systemui.util.ConvenienceExtensionsKt.toKotlinLazy;
+
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
@@ -44,6 +46,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import com.android.app.viewcapture.ViewCapture;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settingslib.fuelgauge.Estimate;
import com.android.settingslib.utils.ThreadUtils;
@@ -56,6 +59,8 @@
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.policy.ConfigurationController;
+import kotlin.Lazy;
+
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.concurrent.Future;
@@ -117,6 +122,7 @@
private final Context mContext;
private final BroadcastDispatcher mBroadcastDispatcher;
private final CommandQueue mCommandQueue;
+ private final Lazy<ViewCapture> mLazyViewCapture;
@Nullable
private final IVrManager mVrManager;
private final WakefulnessLifecycle.Observer mWakefulnessObserver =
@@ -157,7 +163,8 @@
EnhancedEstimates enhancedEstimates,
WakefulnessLifecycle wakefulnessLifecycle,
PowerManager powerManager,
- UserTracker userTracker) {
+ UserTracker userTracker,
+ dagger.Lazy<ViewCapture> daggerLazyViewCapture) {
mContext = context;
mBroadcastDispatcher = broadcastDispatcher;
mCommandQueue = commandQueue;
@@ -167,6 +174,7 @@
mPowerManager = powerManager;
mWakefulnessLifecycle = wakefulnessLifecycle;
mUserTracker = userTracker;
+ mLazyViewCapture = toKotlinLazy(daggerLazyViewCapture);
}
public void start() {
@@ -641,7 +649,7 @@
@Override
public void showInattentiveSleepWarning() {
if (mOverlayView == null) {
- mOverlayView = new InattentiveSleepWarningView(mContext);
+ mOverlayView = new InattentiveSleepWarningView(mContext, mLazyViewCapture);
}
mOverlayView.show();
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 abc0453..6a8cc17 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
@@ -1082,7 +1082,12 @@
inner class StateChangeRunnable(private val state: QSTile.State) : Runnable {
override fun run() {
- traceSection("QSTileViewImpl#handleStateChanged") { handleStateChanged(state) }
+ var traceTag = "QSTileViewImpl#handleStateChanged"
+ if (!state.spec.isNullOrEmpty()) {
+ traceTag += ":"
+ traceTag += state.spec
+ }
+ traceSection(traceTag.take(Trace.MAX_SECTION_NAME_LEN)) { handleStateChanged(state) }
}
// We want all instances of this runnable to be equal to each other, so they can be used to
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt
index ddd0c76..9bcf927 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileViewModelAdapter.kt
@@ -34,7 +34,6 @@
import dagger.assisted.AssistedInject
import java.io.PrintWriter
import java.util.concurrent.CopyOnWriteArraySet
-import java.util.function.Supplier
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.collectIndexed
@@ -158,6 +157,8 @@
override fun isTileReady(): Boolean = qsTileViewModel.currentState != null
+ private var cachedState = QSTile.AdapterState()
+
override fun setListening(client: Any?, listening: Boolean) {
client ?: return
if (listening) {
@@ -168,7 +169,10 @@
.filterNotNull()
.map { mapState(context, it, qsTileViewModel.config) }
.onEach { legacyState ->
- callbacks.forEach { it.onStateChanged(legacyState) }
+ val changed = legacyState.copyTo(cachedState)
+ if (changed) {
+ callbacks.forEach { it.onStateChanged(legacyState) }
+ }
}
.launchIn(applicationScope)
}
@@ -235,7 +239,7 @@
handlesLongClick =
viewModelState.supportedActions.contains(QSTileState.UserAction.LONG_CLICK)
- iconSupplier = Supplier {
+ icon =
when (val stateIcon = viewModelState.icon()) {
is Icon.Loaded ->
if (viewModelState.iconRes == null) DrawableIcon(stateIcon.drawable)
@@ -243,7 +247,7 @@
is Icon.Resource -> ResourceIcon.get(stateIcon.res)
null -> null
}
- }
+
state = viewModelState.activationState.legacyState
contentDescription = viewModelState.contentDescription
diff --git a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/GoneSceneActionsViewModel.kt b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/GoneSceneActionsViewModel.kt
new file mode 100644
index 0000000..b707a5a
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/GoneSceneActionsViewModel.kt
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2024 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.scene.ui.viewmodel
+
+import androidx.compose.ui.Alignment
+import com.android.compose.animation.scene.Edge
+import com.android.compose.animation.scene.Swipe
+import com.android.compose.animation.scene.SwipeDirection
+import com.android.compose.animation.scene.UserAction
+import com.android.compose.animation.scene.UserActionResult
+import com.android.systemui.scene.shared.model.SceneFamilies
+import com.android.systemui.scene.shared.model.TransitionKeys.OpenBottomShade
+import com.android.systemui.scene.shared.model.TransitionKeys.ToSplitShade
+import com.android.systemui.shade.domain.interactor.ShadeInteractor
+import com.android.systemui.shade.shared.model.ShadeMode
+import dagger.assisted.AssistedFactory
+import dagger.assisted.AssistedInject
+import kotlinx.coroutines.flow.collectLatest
+import kotlinx.coroutines.flow.map
+
+class GoneSceneActionsViewModel
+@AssistedInject
+constructor(
+ private val shadeInteractor: ShadeInteractor,
+) : SceneActionsViewModel() {
+
+ override suspend fun hydrateActions(setActions: (Map<UserAction, UserActionResult>) -> Unit) {
+ shadeInteractor.shadeMode
+ .map { shadeMode ->
+ buildMap<UserAction, UserActionResult> {
+ if (
+ shadeMode is ShadeMode.Single ||
+ // TODO(b/338577208): Remove this once we add Dual Shade invocation
+ // zones.
+ shadeMode is ShadeMode.Dual
+ ) {
+ if (shadeInteractor.shadeAlignment == Alignment.BottomEnd) {
+ put(
+ Swipe(
+ pointerCount = 2,
+ fromSource = Edge.Bottom,
+ direction = SwipeDirection.Up,
+ ),
+ UserActionResult(SceneFamilies.QuickSettings, OpenBottomShade)
+ )
+ } else {
+ put(
+ Swipe(
+ pointerCount = 2,
+ fromSource = Edge.Top,
+ direction = SwipeDirection.Down,
+ ),
+ UserActionResult(SceneFamilies.QuickSettings)
+ )
+ }
+ }
+
+ if (shadeInteractor.shadeAlignment == Alignment.BottomEnd) {
+ put(Swipe.Up, UserActionResult(SceneFamilies.NotifShade, OpenBottomShade))
+ } else {
+ put(
+ Swipe.Down,
+ UserActionResult(
+ SceneFamilies.NotifShade,
+ ToSplitShade.takeIf { shadeMode is ShadeMode.Split }
+ )
+ )
+ }
+ }
+ }
+ .collectLatest { setActions(it) }
+ }
+
+ @AssistedFactory
+ interface Factory {
+ fun create(): GoneSceneActionsViewModel
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/GoneSceneViewModel.kt b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/GoneSceneViewModel.kt
deleted file mode 100644
index b739ffe..0000000
--- a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/GoneSceneViewModel.kt
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2024 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.scene.ui.viewmodel
-
-import androidx.compose.ui.Alignment
-import com.android.compose.animation.scene.Edge
-import com.android.compose.animation.scene.Swipe
-import com.android.compose.animation.scene.SwipeDirection
-import com.android.compose.animation.scene.UserAction
-import com.android.compose.animation.scene.UserActionResult
-import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.scene.shared.model.SceneFamilies
-import com.android.systemui.scene.shared.model.TransitionKeys.OpenBottomShade
-import com.android.systemui.scene.shared.model.TransitionKeys.ToSplitShade
-import com.android.systemui.shade.domain.interactor.ShadeInteractor
-import com.android.systemui.shade.shared.model.ShadeMode
-import javax.inject.Inject
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.map
-
-@SysUISingleton
-class GoneSceneViewModel
-@Inject
-constructor(
- private val shadeInteractor: ShadeInteractor,
-) {
- val destinationScenes: Flow<Map<UserAction, UserActionResult>> =
- shadeInteractor.shadeMode.map { shadeMode ->
- buildMap {
- if (
- shadeMode is ShadeMode.Single ||
- // TODO(b/338577208): Remove this once we add Dual Shade invocation zones.
- shadeMode is ShadeMode.Dual
- ) {
- if (shadeInteractor.shadeAlignment == Alignment.BottomEnd) {
- put(
- Swipe(
- pointerCount = 2,
- fromSource = Edge.Bottom,
- direction = SwipeDirection.Up,
- ),
- UserActionResult(SceneFamilies.QuickSettings, OpenBottomShade)
- )
- } else {
- put(
- Swipe(
- pointerCount = 2,
- fromSource = Edge.Top,
- direction = SwipeDirection.Down,
- ),
- UserActionResult(SceneFamilies.QuickSettings)
- )
- }
- }
-
- if (shadeInteractor.shadeAlignment == Alignment.BottomEnd) {
- put(Swipe.Up, UserActionResult(SceneFamilies.NotifShade, OpenBottomShade))
- } else {
- put(
- Swipe.Down,
- UserActionResult(
- SceneFamilies.NotifShade,
- ToSplitShade.takeIf { shadeMode is ShadeMode.Split }
- )
- )
- }
- }
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneActionsViewModel.kt b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneActionsViewModel.kt
new file mode 100644
index 0000000..c2fd65b
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneActionsViewModel.kt
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2024 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.scene.ui.viewmodel
+
+import com.android.compose.animation.scene.UserAction
+import com.android.compose.animation.scene.UserActionResult
+import com.android.systemui.lifecycle.SysUiViewModel
+import kotlinx.coroutines.awaitCancellation
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asStateFlow
+
+/**
+ * Base class for view-models that need to keep a map of scene actions (also known as "destination
+ * scenes") up-to-date.
+ *
+ * Subclasses need only to override [hydrateActions], suspending forever if they need; they don't
+ * need to worry about resetting the value of [actions] when the view-model is deactivated/canceled,
+ * this base class takes care of it.
+ */
+abstract class SceneActionsViewModel : SysUiViewModel() {
+
+ private val _actions = MutableStateFlow<Map<UserAction, UserActionResult>>(emptyMap())
+ /**
+ * [UserActionResult] by [UserAction] to be collected by the scene container to enable the right
+ * user input/gestures.
+ */
+ val actions: StateFlow<Map<UserAction, UserActionResult>> = _actions.asStateFlow()
+
+ final override suspend fun onActivated() {
+ try {
+ hydrateActions { state -> _actions.value = state }
+ awaitCancellation()
+ } finally {
+ _actions.value = emptyMap()
+ }
+ }
+
+ /**
+ * Keeps the user actions up-to-date (AKA "hydrated").
+ *
+ * Subclasses should implement this `suspend fun` by running coroutine work and calling
+ * [setActions] each time the actions should be published/updated. The work can safely suspend
+ * forever; the base class will take care of canceling it as needed. There's no need to handle
+ * cancellation in this method.
+ *
+ * The base class will also take care of resetting the [actions] flow back to the default value
+ * when this happens.
+ */
+ protected abstract suspend fun hydrateActions(
+ setActions: (Map<UserAction, UserActionResult>) -> Unit,
+ )
+}
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialogDelegate.kt
index ab6067c..b54bf6c 100644
--- a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialogDelegate.kt
+++ b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordPermissionDialogDelegate.kt
@@ -125,7 +125,6 @@
super<BaseMediaProjectionPermissionDialogDelegate>.onCreate(dialog, savedInstanceState)
setDialogTitle(R.string.screenrecord_permission_dialog_title)
dialog.setTitle(R.string.screenrecord_title)
- setStartButtonText(R.string.screenrecord_permission_dialog_continue)
setStartButtonOnClickListener { v: View? ->
onStartRecordingClicked?.run()
if (selectedScreenShareOption.mode == ENTIRE_SCREEN) {
@@ -272,12 +271,14 @@
ScreenShareOption(
SINGLE_APP,
R.string.screen_share_permission_dialog_option_single_app,
- R.string.screenrecord_permission_dialog_warning_single_app
+ R.string.screenrecord_permission_dialog_warning_single_app,
+ startButtonText = R.string.screenrecord_permission_dialog_continue,
),
ScreenShareOption(
ENTIRE_SCREEN,
R.string.screen_share_permission_dialog_option_entire_screen,
- R.string.screenrecord_permission_dialog_warning_entire_screen
+ R.string.screenrecord_permission_dialog_warning_entire_screen,
+ startButtonText = R.string.screenrecord_permission_dialog_continue,
)
)
}
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
index 257390f..104d4b5 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java
@@ -1097,14 +1097,6 @@
}
@Override
- public void onPulseExpansionAmountChanged(boolean expandingChanged) {
- if (mKeyguardBypassController.getBypassEnabled()) {
- // Position the notifications while dragging down while pulsing
- requestScrollerTopPaddingUpdate(false /* animate */);
- }
- }
-
- @Override
public void onDelayedDozeAmountAnimationRunning(boolean running) {
// On running OR finished, the animation is no longer waiting to play
setWillPlayDelayedDozeAmountAnimation(false);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java
index 49743bf..ccea254 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java
@@ -35,7 +35,6 @@
import com.android.systemui.statusbar.notification.collection.NotifCollection;
import com.android.systemui.statusbar.notification.collection.PipelineDumpable;
import com.android.systemui.statusbar.notification.collection.PipelineDumper;
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.NotificationListenerWithPlugins;
import com.android.systemui.util.time.SystemClock;
@@ -66,7 +65,6 @@
private final SystemClock mSystemClock;
private final Executor mMainExecutor;
private final List<NotificationHandler> mNotificationHandlers = new ArrayList<>();
- private final ArrayList<NotificationSettingsListener> mSettingsListeners = new ArrayList<>();
private final Deque<RankingMap> mRankingMapQueue = new ConcurrentLinkedDeque<>();
private final Runnable mDispatchRankingUpdateRunnable = this::dispatchRankingUpdate;
@@ -99,13 +97,6 @@
mNotificationHandlers.add(handler);
}
- /** Registers a listener that's notified when any notification-related settings change. */
- @Deprecated
- public void addNotificationSettingsListener(NotificationSettingsListener listener) {
- NotificationIconContainerRefactor.assertInLegacyMode();
- mSettingsListeners.add(listener);
- }
-
@Override
public void onListenerConnected() {
if (DEBUG) Log.d(TAG, "onListenerConnected");
@@ -237,13 +228,7 @@
@Override
public void onSilentStatusBarIconsVisibilityChanged(boolean hideSilentStatusIcons) {
- if (NotificationIconContainerRefactor.isEnabled()) {
- mStatusIconInteractor.setHideSilentStatusIcons(hideSilentStatusIcons);
- } else {
- for (NotificationSettingsListener listener : mSettingsListeners) {
- listener.onStatusBarIconsBehaviorChanged(hideSilentStatusIcons);
- }
- }
+ mStatusIconInteractor.setHideSilentStatusIcons(hideSilentStatusIcons);
}
public final void unsnoozeNotification(@NonNull String key) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
index 28e3a83..696e222 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
@@ -48,7 +48,6 @@
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableView;
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
import com.android.systemui.statusbar.notification.stack.AmbientState;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.notification.stack.ExpandableViewState;
@@ -153,11 +152,7 @@
R.dimen.notification_corner_animation_distance);
mEnableNotificationClipping = res.getBoolean(R.bool.notification_enable_clipping);
- if (NotificationIconContainerRefactor.isEnabled()) {
- mShelfIcons.setOverrideIconColor(true);
- } else {
- mShelfIcons.setInNotificationIconShelf(true);
- }
+ mShelfIcons.setOverrideIconColor(true);
if (!mShowNotificationShelf) {
setVisibility(GONE);
}
@@ -228,9 +223,6 @@
} else {
viewState.setAlpha(1f - ambientState.getHideAmount());
}
- if (!NotificationIconContainerRefactor.isEnabled()) {
- viewState.belowSpeedBump = getSpeedBumpIndex() == 0;
- }
viewState.hideSensitive = false;
viewState.setXTranslation(getTranslationX());
viewState.hasItemsInStableShelf = lastViewState.inShelf;
@@ -276,30 +268,7 @@
}
}
- private int getSpeedBumpIndex() {
- NotificationIconContainerRefactor.assertInLegacyMode();
- return mHostLayout.getSpeedBumpIndex();
- }
-
- /**
- * @param fractionToShade Fraction of lockscreen to shade transition
- * @param shortestWidth Shortest width to use for lockscreen shelf
- */
- @VisibleForTesting
- public void updateActualWidth(float fractionToShade, float shortestWidth) {
- NotificationIconContainerRefactor.assertInLegacyMode();
- final float actualWidth = mAmbientState.isOnKeyguard()
- ? MathUtils.lerp(shortestWidth, getWidth(), fractionToShade)
- : getWidth();
- setBackgroundWidth((int) actualWidth);
- if (mShelfIcons != null) {
- mShelfIcons.setActualLayoutWidth((int) actualWidth);
- }
- mActualWidth = actualWidth;
- }
-
private void setActualWidth(float actualWidth) {
- if (NotificationIconContainerRefactor.isUnexpectedlyInLegacyMode()) return;
setBackgroundWidth((int) actualWidth);
if (mShelfIcons != null) {
mShelfIcons.setActualLayoutWidth((int) actualWidth);
@@ -482,25 +451,17 @@
final float fractionToShade = Interpolators.STANDARD.getInterpolation(
mAmbientState.getFractionToShade());
- if (NotificationIconContainerRefactor.isEnabled()) {
- if (mAmbientState.isOnKeyguard()) {
- float numViews = MathUtils.min(numViewsInShelf, mMaxIconsOnLockscreen + 1);
- float shortestWidth = mShelfIcons.calculateWidthFor(numViews);
- float actualWidth = MathUtils.lerp(shortestWidth, getWidth(), fractionToShade);
- setActualWidth(actualWidth);
- } else {
- setActualWidth(getWidth());
- }
+ if (mAmbientState.isOnKeyguard()) {
+ float numViews = MathUtils.min(numViewsInShelf, mMaxIconsOnLockscreen + 1);
+ float shortestWidth = mShelfIcons.calculateWidthFor(numViews);
+ float actualWidth = MathUtils.lerp(shortestWidth, getWidth(), fractionToShade);
+ setActualWidth(actualWidth);
} else {
- final float shortestWidth = mShelfIcons.calculateWidthFor(numViewsInShelf);
- updateActualWidth(fractionToShade, shortestWidth);
+ setActualWidth(getWidth());
}
// TODO(b/172289889) transition last icon in shelf to notification icon and vice versa.
setVisibility(isHidden ? View.INVISIBLE : View.VISIBLE);
- if (!NotificationIconContainerRefactor.isEnabled()) {
- mShelfIcons.setSpeedBumpIndex(getSpeedBumpIndex());
- }
mShelfIcons.calculateIconXTranslations();
mShelfIcons.applyIconStates();
for (int i = 0; i < getHostLayoutChildCount(); i++) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
index bbf0ae1..3068460 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
@@ -64,7 +64,6 @@
import com.android.systemui.statusbar.notification.NotificationContentDescription;
import com.android.systemui.statusbar.notification.NotificationDozeHelper;
import com.android.systemui.statusbar.notification.NotificationUtils;
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
import com.android.systemui.util.drawable.DrawableSize;
import java.lang.annotation.Retention;
@@ -906,12 +905,7 @@
return mDotAppearAmount;
}
- public void setDozing(boolean dozing, boolean animate, long delay) {
- setDozing(dozing, animate, delay, /* onChildCompleted= */ null);
- }
-
public void setTintAlpha(float tintAlpha) {
- if (NotificationIconContainerRefactor.isUnexpectedlyInLegacyMode()) return;
setDozeAmount(tintAlpha);
}
@@ -921,15 +915,6 @@
updateIconColor();
}
- public void setDozing(boolean dozing, boolean animate, long delay,
- @Nullable Runnable endRunnable) {
- NotificationIconContainerRefactor.assertInLegacyMode();
- mDozer.setDozing(f -> {
- setDozeAmount(f);
- updateAllowAnimation();
- }, dozing, animate, delay, this, endRunnable);
- }
-
private void updateAllowAnimation() {
if (mDozeAmount == 0 || mDozeAmount == 1) {
setAllowAnimation(mDozeAmount == 0);
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 9eb9ed5..2930de2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/events/PrivacyDotViewController.kt
@@ -26,7 +26,6 @@
import androidx.core.animation.Animator
import com.android.app.animation.Interpolators
import com.android.internal.annotations.GuardedBy
-import com.android.systemui.Flags.privacyDotUnfoldWrongCornerFix
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Main
@@ -45,10 +44,10 @@
import com.android.systemui.util.leak.RotationUtils.ROTATION_SEASCAPE
import com.android.systemui.util.leak.RotationUtils.ROTATION_UPSIDE_DOWN
import com.android.systemui.util.leak.RotationUtils.Rotation
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.launch
import java.util.concurrent.Executor
import javax.inject.Inject
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.launch
/**
* Understands how to keep the persistent privacy dot in the corner of the screen in
@@ -61,12 +60,13 @@
* 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 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
+ * 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
*/
-
@SysUISingleton
-open class PrivacyDotViewController @Inject constructor(
+open class PrivacyDotViewController
+@Inject
+constructor(
@Main private val mainExecutor: Executor,
@Application scope: CoroutineScope,
private val stateController: StatusBarStateController,
@@ -90,6 +90,7 @@
field = value
scheduleUpdate()
}
+
private val lock = Object()
private var cancelRunnable: Runnable? = null
@@ -106,46 +107,48 @@
get() = field
init {
- contentInsetsProvider.addCallback(object : StatusBarContentInsetsChangedListener {
- override fun onStatusBarContentInsetsChanged() {
- dlog("onStatusBarContentInsetsChanged: ")
- setNewLayoutRects()
+ contentInsetsProvider.addCallback(
+ object : StatusBarContentInsetsChangedListener {
+ override fun onStatusBarContentInsetsChanged() {
+ dlog("onStatusBarContentInsetsChanged: ")
+ setNewLayoutRects()
+ }
}
- })
+ )
- configurationController.addCallback(object : ConfigurationController.ConfigurationListener {
- override fun onLayoutDirectionChanged(isRtl: Boolean) {
- uiExecutor?.execute {
- // If rtl changed, hide all dotes until the next state resolves
- setCornerVisibilities(View.INVISIBLE)
+ configurationController.addCallback(
+ object : ConfigurationController.ConfigurationListener {
+ override fun onLayoutDirectionChanged(isRtl: Boolean) {
+ uiExecutor?.execute {
+ // If rtl changed, hide all dotes until the next state resolves
+ setCornerVisibilities(View.INVISIBLE)
- synchronized(this) {
- val corner = selectDesignatedCorner(nextViewState.rotation, isRtl)
- nextViewState = nextViewState.copy(
- layoutRtl = isRtl,
- designatedCorner = corner
- )
+ synchronized(this) {
+ val corner = selectDesignatedCorner(nextViewState.rotation, isRtl)
+ nextViewState =
+ nextViewState.copy(layoutRtl = isRtl, designatedCorner = corner)
+ }
}
}
}
- })
+ )
- stateController.addCallback(object : StatusBarStateController.StateListener {
- override fun onExpandedChanged(isExpanded: Boolean) {
- updateStatusBarState()
- }
+ stateController.addCallback(
+ object : StatusBarStateController.StateListener {
+ override fun onExpandedChanged(isExpanded: Boolean) {
+ updateStatusBarState()
+ }
- override fun onStateChanged(newState: Int) {
- updateStatusBarState()
+ override fun onStateChanged(newState: Int) {
+ updateStatusBarState()
+ }
}
- })
+ )
scope.launch {
shadeInteractor?.isQsExpanded?.collect { isQsExpanded ->
dlog("setQsExpanded $isQsExpanded")
- synchronized(lock) {
- nextViewState = nextViewState.copy(qsExpanded = isQsExpanded)
- }
+ synchronized(lock) { nextViewState = nextViewState.copy(qsExpanded = isQsExpanded) }
}
}
}
@@ -179,11 +182,13 @@
val paddingTop = contentInsetsProvider.getStatusBarPaddingTop(rot)
synchronized(lock) {
- nextViewState = nextViewState.copy(
+ nextViewState =
+ nextViewState.copy(
rotation = rot,
paddingTop = paddingTop,
designatedCorner = newCorner,
- cornerIndex = index)
+ cornerIndex = index
+ )
}
}
@@ -192,14 +197,14 @@
dot.clearAnimation()
if (animate) {
dot.animate()
- .setDuration(DURATION)
- .setInterpolator(Interpolators.ALPHA_OUT)
- .alpha(0f)
- .withEndAction {
- dot.visibility = View.INVISIBLE
- showingListener?.onPrivacyDotHidden(dot)
- }
- .start()
+ .setDuration(DURATION)
+ .setInterpolator(Interpolators.ALPHA_OUT)
+ .alpha(0f)
+ .withEndAction {
+ dot.visibility = View.INVISIBLE
+ showingListener?.onPrivacyDotHidden(dot)
+ }
+ .start()
} else {
dot.visibility = View.INVISIBLE
showingListener?.onPrivacyDotHidden(dot)
@@ -213,10 +218,10 @@
dot.visibility = View.VISIBLE
dot.alpha = 0f
dot.animate()
- .alpha(1f)
- .setDuration(DURATION)
- .setInterpolator(Interpolators.ALPHA_IN)
- .start()
+ .alpha(1f)
+ .setDuration(DURATION)
+ .setInterpolator(Interpolators.ALPHA_IN)
+ .start()
} else {
dot.visibility = View.VISIBLE
dot.alpha = 1f
@@ -241,9 +246,9 @@
}
// Set the dot's view gravity to hug the status bar
- (corner.requireViewById<View>(R.id.privacy_dot)
- .layoutParams as FrameLayout.LayoutParams)
- .gravity = rotatedCorner.innerGravity()
+ (corner.requireViewById<View>(R.id.privacy_dot).layoutParams
+ as FrameLayout.LayoutParams)
+ .gravity = rotatedCorner.innerGravity()
}
}
@@ -353,10 +358,7 @@
clearAnimation()
visibility = View.VISIBLE
alpha = 0f
- animate()
- .alpha(1.0f)
- .setDuration(300)
- .start()
+ animate().alpha(1.0f).setDuration(300).start()
}
}
}
@@ -405,15 +407,21 @@
private fun widthForCorner(corner: Int, left: Int, right: Int): Int {
return when (corner) {
- TOP_LEFT, BOTTOM_LEFT -> left
- TOP_RIGHT, BOTTOM_RIGHT -> right
+ TOP_LEFT,
+ BOTTOM_LEFT -> left
+ TOP_RIGHT,
+ BOTTOM_RIGHT -> right
else -> throw IllegalArgumentException("Unknown corner")
}
}
fun initialize(topLeft: View, topRight: View, bottomLeft: View, bottomRight: View) {
- if (this::tl.isInitialized && this::tr.isInitialized &&
- this::bl.isInitialized && this::br.isInitialized) {
+ if (
+ this::tl.isInitialized &&
+ this::tr.isInitialized &&
+ this::bl.isInitialized &&
+ this::br.isInitialized
+ ) {
if (tl == topLeft && tr == topRight && bl == bottomLeft && br == bottomRight) {
return
}
@@ -430,19 +438,17 @@
val index = dc.cornerIndex()
- mainExecutor.execute {
- animationScheduler.addCallback(systemStatusAnimationCallback)
- }
+ mainExecutor.execute { animationScheduler.addCallback(systemStatusAnimationCallback) }
val left = contentInsetsProvider.getStatusBarContentAreaForRotation(ROTATION_SEASCAPE)
val top = contentInsetsProvider.getStatusBarContentAreaForRotation(ROTATION_NONE)
val right = contentInsetsProvider.getStatusBarContentAreaForRotation(ROTATION_LANDSCAPE)
- val bottom = contentInsetsProvider
- .getStatusBarContentAreaForRotation(ROTATION_UPSIDE_DOWN)
+ val bottom = contentInsetsProvider.getStatusBarContentAreaForRotation(ROTATION_UPSIDE_DOWN)
val paddingTop = contentInsetsProvider.getStatusBarPaddingTop()
synchronized(lock) {
- nextViewState = nextViewState.copy(
+ nextViewState =
+ nextViewState.copy(
viewInitialized = true,
designatedCorner = dc,
cornerIndex = index,
@@ -452,14 +458,12 @@
upsideDownRect = bottom,
paddingTop = paddingTop,
layoutRtl = rtl
- )
+ )
}
}
private fun updateStatusBarState() {
- synchronized(lock) {
- nextViewState = nextViewState.copy(shadeExpanded = isShadeInQs())
- }
+ synchronized(lock) { nextViewState = nextViewState.copy(shadeExpanded = isShadeInQs()) }
}
/**
@@ -469,16 +473,14 @@
@GuardedBy("lock")
private fun isShadeInQs(): Boolean {
return (stateController.isExpanded && stateController.state == SHADE) ||
- (stateController.state == SHADE_LOCKED)
+ (stateController.state == SHADE_LOCKED)
}
private fun scheduleUpdate() {
dlog("scheduleUpdate: ")
cancelRunnable?.run()
- cancelRunnable = uiExecutor?.executeDelayed({
- processNextViewState()
- }, 100)
+ cancelRunnable = uiExecutor?.executeDelayed({ processNextViewState() }, 100)
}
@UiThread
@@ -486,9 +488,7 @@
dlog("processNextViewState: ")
val newState: ViewState
- synchronized(lock) {
- newState = nextViewState.copy()
- }
+ synchronized(lock) { newState = nextViewState.copy() }
resolveState(newState)
}
@@ -508,7 +508,7 @@
val designatedCornerChanged = state.designatedCorner != currentViewState.designatedCorner
val rotationChanged = state.rotation != currentViewState.rotation
- if (rotationChanged || (designatedCornerChanged && privacyDotUnfoldWrongCornerFix())) {
+ if (rotationChanged || designatedCornerChanged) {
// A rotation has started, hide the views to avoid flicker
updateRotations(state.rotation, state.paddingTop)
}
@@ -545,27 +545,29 @@
}
private val systemStatusAnimationCallback: SystemStatusAnimationCallback =
- object : SystemStatusAnimationCallback {
- override fun onSystemStatusAnimationTransitionToPersistentDot(
- contentDescr: String?
- ): Animator? {
- synchronized(lock) {
- nextViewState = nextViewState.copy(
- systemPrivacyEventIsActive = true,
- contentDescription = contentDescr)
+ object : SystemStatusAnimationCallback {
+ override fun onSystemStatusAnimationTransitionToPersistentDot(
+ contentDescr: String?
+ ): Animator? {
+ synchronized(lock) {
+ nextViewState =
+ nextViewState.copy(
+ systemPrivacyEventIsActive = true,
+ contentDescription = contentDescr
+ )
+ }
+
+ return null
}
- return null
- }
+ override fun onHidePersistentDot(): Animator? {
+ synchronized(lock) {
+ nextViewState = nextViewState.copy(systemPrivacyEventIsActive = false)
+ }
- override fun onHidePersistentDot(): Animator? {
- synchronized(lock) {
- nextViewState = nextViewState.copy(systemPrivacyEventIsActive = false)
+ return null
}
-
- return null
}
- }
private fun View?.cornerIndex(): Int {
if (this != null) {
@@ -579,8 +581,7 @@
val left = contentInsetsProvider.getStatusBarContentAreaForRotation(ROTATION_SEASCAPE)
val top = contentInsetsProvider.getStatusBarContentAreaForRotation(ROTATION_NONE)
val right = contentInsetsProvider.getStatusBarContentAreaForRotation(ROTATION_LANDSCAPE)
- val bottom = contentInsetsProvider
- .getStatusBarContentAreaForRotation(ROTATION_UPSIDE_DOWN)
+ val bottom = contentInsetsProvider.getStatusBarContentAreaForRotation(ROTATION_UPSIDE_DOWN)
return listOf(left, top, right, bottom)
}
@@ -589,17 +590,19 @@
val rects = getLayoutRects()
synchronized(lock) {
- nextViewState = nextViewState.copy(
+ nextViewState =
+ nextViewState.copy(
seascapeRect = rects[0],
portraitRect = rects[1],
landscapeRect = rects[2],
upsideDownRect = rects[3]
- )
+ )
}
}
interface ShowingListener {
fun onPrivacyDotShown(v: View?)
+
fun onPrivacyDotHidden(v: View?)
}
}
@@ -647,22 +650,18 @@
data class ViewState(
val viewInitialized: Boolean = false,
-
val systemPrivacyEventIsActive: Boolean = false,
val shadeExpanded: Boolean = false,
val qsExpanded: Boolean = false,
-
val portraitRect: Rect? = null,
val landscapeRect: Rect? = null,
val upsideDownRect: Rect? = null,
val seascapeRect: Rect? = null,
val layoutRtl: Boolean = false,
-
val rotation: Int = 0,
val paddingTop: Int = 0,
val cornerIndex: Int = -1,
val designatedCorner: View? = null,
-
val contentDescription: String? = null
) {
fun shouldShowDot(): Boolean {
@@ -671,11 +670,11 @@
fun needsLayout(other: ViewState): Boolean {
return rotation != other.rotation ||
- layoutRtl != other.layoutRtl ||
- portraitRect != other.portraitRect ||
- landscapeRect != other.landscapeRect ||
- upsideDownRect != other.upsideDownRect ||
- seascapeRect != other.seascapeRect
+ layoutRtl != other.layoutRtl ||
+ portraitRect != other.portraitRect ||
+ landscapeRect != other.landscapeRect ||
+ upsideDownRect != other.upsideDownRect ||
+ seascapeRect != other.seascapeRect
}
fun contentRectForRotation(@Rotation rot: Int): Rect {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt
index 9240c1c..22c537c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt
@@ -34,7 +34,6 @@
import com.android.systemui.statusbar.StatusBarState
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.domain.interactor.NotificationsKeyguardInteractor
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.notification.stack.StackStateAnimator
import com.android.systemui.statusbar.phone.DozeParameters
@@ -223,11 +222,6 @@
val nowExpanding = isPulseExpanding()
val changed = nowExpanding != pulseExpanding
pulseExpanding = nowExpanding
- if (!NotificationIconContainerRefactor.isEnabled) {
- for (listener in wakeUpListeners) {
- listener.onPulseExpansionAmountChanged(changed)
- }
- }
if (changed) {
for (listener in wakeUpListeners) {
listener.onPulseExpandingChanged(pulseExpanding)
@@ -683,17 +677,6 @@
fun onFullyHiddenChanged(isFullyHidden: Boolean) {}
/**
- * Called whenever the pulseExpansion changes
- *
- * @param expandingChanged if the user has started or stopped expanding
- */
- @Deprecated(
- message = "Use onPulseExpandedChanged instead.",
- replaceWith = ReplaceWith("onPulseExpandedChanged"),
- )
- fun onPulseExpansionAmountChanged(expandingChanged: Boolean) {}
-
- /**
* Called when the animator started by [scheduleDelayedDozeAmountAnimation] begins running
* after the start delay, or after it ends/is cancelled.
*/
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/StackCoordinator.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/StackCoordinator.kt
index 1511abd..f74c9a6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/StackCoordinator.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/StackCoordinator.kt
@@ -28,9 +28,7 @@
import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor
import com.android.systemui.statusbar.notification.domain.interactor.RenderNotificationListInteractor
import com.android.systemui.statusbar.notification.footer.shared.FooterViewRefactor
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor
import com.android.systemui.statusbar.notification.stack.BUCKET_SILENT
-import com.android.systemui.statusbar.phone.NotificationIconAreaController
import com.android.systemui.statusbar.policy.SensitiveNotificationProtectionController
import javax.inject.Inject
@@ -43,7 +41,6 @@
@Inject
internal constructor(
private val groupExpansionManagerImpl: GroupExpansionManagerImpl,
- private val notificationIconAreaController: NotificationIconAreaController,
private val renderListInteractor: RenderNotificationListInteractor,
private val activeNotificationsInteractor: ActiveNotificationsInteractor,
private val sensitiveNotificationProtectionController:
@@ -63,12 +60,7 @@
} else {
controller.setNotifStats(notifStats)
}
- if (NotificationIconContainerRefactor.isEnabled || FooterViewRefactor.isEnabled) {
- renderListInteractor.setRenderedList(entries)
- }
- if (!NotificationIconContainerRefactor.isEnabled) {
- notificationIconAreaController.updateNotificationIcons(entries)
- }
+ renderListInteractor.setRenderedList(entries)
}
private fun calculateNotifStats(entries: List<ListEntry>): NotifStats {
@@ -76,9 +68,10 @@
var hasClearableAlertingNotifs = false
var hasNonClearableSilentNotifs = false
var hasClearableSilentNotifs = false
- val isSensitiveContentProtectionActive = screenshareNotificationHiding() &&
- screenshareNotificationHidingBugFix() &&
- sensitiveNotificationProtectionController.isSensitiveStateActive
+ val isSensitiveContentProtectionActive =
+ screenshareNotificationHiding() &&
+ screenshareNotificationHidingBugFix() &&
+ sensitiveNotificationProtectionController.isSensitiveStateActive
entries.forEach {
val section = checkNotNull(it.section) { "Null section for ${it.key}" }
val entry = checkNotNull(it.representativeEntry) { "Null notif entry for ${it.key}" }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconAreaControllerViewBinderWrapperImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconAreaControllerViewBinderWrapperImpl.kt
deleted file mode 100644
index 1bcab3f..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconAreaControllerViewBinderWrapperImpl.kt
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.systemui.statusbar.notification.icon.ui.viewbinder
-
-import android.content.Context
-import android.graphics.Rect
-import android.view.View
-import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.statusbar.StatusBarIconView
-import com.android.systemui.statusbar.notification.collection.ListEntry
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor
-import com.android.systemui.statusbar.phone.NotificationIconAreaController
-import com.android.systemui.statusbar.phone.NotificationIconContainer
-import javax.inject.Inject
-
-/**
- * Controller class for [NotificationIconContainer]. This implementation serves as a temporary
- * wrapper around [NotificationIconContainerViewBinder], so that external code can continue to
- * depend on the [NotificationIconAreaController] interface. Once
- * [LegacyNotificationIconAreaControllerImpl] is removed, this class can go away and the ViewBinder
- * can be used directly.
- */
-@SysUISingleton
-class NotificationIconAreaControllerViewBinderWrapperImpl @Inject constructor() :
- NotificationIconAreaController {
-
- /** Called by the Keyguard*ViewController whose view contains the aod icons. */
- override fun setupAodIcons(aodIcons: NotificationIconContainer?) = unsupported
-
- override fun setShelfIcons(icons: NotificationIconContainer) = unsupported
-
- override fun onDensityOrFontScaleChanged(context: Context) = unsupported
-
- /** Returns the view that represents the notification area. */
- override fun getNotificationInnerAreaView(): View? = unsupported
-
- /** Updates the notifications with the given list of notifications to display. */
- override fun updateNotificationIcons(entries: List<ListEntry>) = unsupported
-
- override fun updateAodNotificationIcons() = unsupported
-
- override fun showIconIsolated(icon: StatusBarIconView?, animated: Boolean) = unsupported
-
- override fun setIsolatedIconLocation(iconDrawingRect: Rect, requireStateUpdate: Boolean) =
- unsupported
-
- override fun setAnimationsEnabled(enabled: Boolean) = unsupported
-
- override fun onThemeChanged() = unsupported
-
- override fun getHeight(): Int = unsupported
-
- companion object {
- val unsupported: Nothing
- get() =
- error(
- "Code path not supported when ${NotificationIconContainerRefactor.FLAG_NAME}" +
- " is disabled"
- )
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/StatusBarIconViewBindingFailureTracker.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/StatusBarIconViewBindingFailureTracker.kt
index 0c114a2..931381f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/StatusBarIconViewBindingFailureTracker.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/StatusBarIconViewBindingFailureTracker.kt
@@ -17,7 +17,6 @@
import com.android.systemui.CoreStartable
import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor
import com.android.systemui.util.asIndenting
import com.android.systemui.util.printCollection
import dagger.Binds
@@ -40,7 +39,6 @@
}
override fun dump(pw: PrintWriter, args: Array<out String>) {
- if (!NotificationIconContainerRefactor.isEnabled) return
pw.asIndenting().run {
printCollection("AOD Icon binding failures:", aodFailures)
printCollection("Status Bar Icon binding failures:", statusBarFailures)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java
index d2d0aaa..560028c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java
@@ -46,7 +46,6 @@
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.notification.SourceType;
import com.android.systemui.statusbar.notification.shared.NotificationHeadsUpCycling;
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
import com.android.systemui.statusbar.notification.shared.NotificationsImprovedHunAnimation;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
@@ -236,16 +235,6 @@
setOutlineAlpha(alpha);
}
- @Override
- public void setBelowSpeedBump(boolean below) {
- NotificationIconContainerRefactor.assertInLegacyMode();
- super.setBelowSpeedBump(below);
- if (below != mIsBelowSpeedBump) {
- mIsBelowSpeedBump = below;
- updateBackgroundTint();
- }
- }
-
/**
* Sets the tint color of the background
*/
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java
index 6becbd2..afda426 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableView.java
@@ -40,7 +40,6 @@
import com.android.systemui.statusbar.StatusBarIconView;
import com.android.systemui.statusbar.notification.Roundable;
import com.android.systemui.statusbar.notification.RoundableState;
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
import com.android.systemui.statusbar.notification.stack.ExpandableViewState;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.util.Compile;
@@ -394,14 +393,6 @@
public abstract void performAddAnimation(long delay, long duration, boolean isHeadsUpAppear,
Runnable onEndRunnable);
- /**
- * Set the notification appearance to be below the speed bump.
- * @param below true if it is below.
- */
- public void setBelowSpeedBump(boolean below) {
- NotificationIconContainerRefactor.assertInLegacyMode();
- }
-
public int getPinnedHeadsUpHeight() {
return getIntrinsicHeight();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/shared/NotificationIconContainerRefactor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/shared/NotificationIconContainerRefactor.kt
deleted file mode 100644
index a08af75..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/shared/NotificationIconContainerRefactor.kt
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- *
- */
-
-package com.android.systemui.statusbar.notification.shared
-
-import com.android.systemui.Flags
-import com.android.systemui.flags.FlagToken
-import com.android.systemui.flags.RefactorFlagUtils
-
-/** Helper for reading or using the NotificationIconContainer refactor flag state. */
-@Suppress("NOTHING_TO_INLINE")
-object NotificationIconContainerRefactor {
- /** The aconfig flag name */
- const val FLAG_NAME = Flags.FLAG_NOTIFICATIONS_ICON_CONTAINER_REFACTOR
-
- /** A token used for dependency declaration */
- val token: FlagToken
- get() = FlagToken(FLAG_NAME, isEnabled)
-
- /** Is the refactor enabled? */
- @JvmStatic
- inline val isEnabled
- get() = Flags.notificationsIconContainerRefactor()
-
- /**
- * Called to ensure code is only run when the flag is enabled. This protects users from the
- * unintended behaviors caused by accidentally running new logic, while also crashing on an eng
- * build to ensure that the refactor author catches issues in testing.
- */
- @JvmStatic
- inline fun isUnexpectedlyInLegacyMode() =
- RefactorFlagUtils.isUnexpectedlyInLegacyMode(isEnabled, FLAG_NAME)
-
- /**
- * Called to ensure code is only run when the flag is disabled. This will throw an exception if
- * the flag is enabled to ensure that the refactor author catches issues in testing.
- */
- @JvmStatic
- inline fun assertInLegacyMode() = RefactorFlagUtils.assertInLegacyMode(isEnabled, FLAG_NAME)
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/ui/viewbinder/NotificationShelfViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/ui/viewbinder/NotificationShelfViewBinder.kt
index 819527e..15dc115 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/ui/viewbinder/NotificationShelfViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/shelf/ui/viewbinder/NotificationShelfViewBinder.kt
@@ -21,9 +21,7 @@
import com.android.systemui.statusbar.NotificationShelf
import com.android.systemui.statusbar.notification.icon.ui.viewbinder.NotificationIconContainerShelfViewBinder
import com.android.systemui.statusbar.notification.row.ui.viewbinder.ActivatableNotificationViewBinder
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor
import com.android.systemui.statusbar.notification.shelf.ui.viewmodel.NotificationShelfViewModel
-import com.android.systemui.statusbar.phone.NotificationIconAreaController
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
@@ -35,17 +33,10 @@
viewModel: NotificationShelfViewModel,
falsingManager: FalsingManager,
nicBinder: NotificationIconContainerShelfViewBinder,
- notificationIconAreaController: NotificationIconAreaController,
): Unit = coroutineScope {
ActivatableNotificationViewBinder.bind(viewModel, shelf, falsingManager)
shelf.apply {
- traceSection("NotifShelf#bindShelfIcons") {
- if (NotificationIconContainerRefactor.isEnabled) {
- launch { nicBinder.bind(shelfIcons) }
- } else {
- notificationIconAreaController.setShelfIcons(shelfIcons)
- }
- }
+ traceSection("NotifShelf#bindShelfIcons") { launch { nicBinder.bind(shelfIcons) } }
launch {
viewModel.canModifyColorOfNotifications.collect(::setCanModifyColorOfNotifications)
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ExpandableViewState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ExpandableViewState.java
index 83de226..69c9a4b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ExpandableViewState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ExpandableViewState.java
@@ -26,7 +26,6 @@
import com.android.systemui.res.R;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableView;
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
/**
* A state of an expandable view
@@ -157,11 +156,6 @@
expandableView.setHideSensitive(
this.hideSensitive, false /* animated */, 0 /* delay */, 0 /* duration */);
- // apply below shelf speed bump
- if (!NotificationIconContainerRefactor.isEnabled()) {
- expandableView.setBelowSpeedBump(this.belowSpeedBump);
- }
-
// apply clipping
final float oldClipTopAmount = expandableView.getClipTopAmount();
if (oldClipTopAmount != this.clipTopAmount) {
@@ -211,11 +205,6 @@
abortAnimation(child, TAG_ANIMATOR_BOTTOM_INSET);
}
- // apply below the speed bump
- if (!NotificationIconContainerRefactor.isEnabled()) {
- expandableView.setBelowSpeedBump(this.belowSpeedBump);
- }
-
// start hiding sensitive animation
expandableView.setHideSensitive(this.hideSensitive, animationFilter.animateHideSensitive,
properties.delay, properties.duration);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
index 608fe95..41195aa 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java
@@ -1426,6 +1426,7 @@
}
public void setHeadsUpBoundaries(int height, int bottomBarHeight) {
+ SceneContainerFlag.assertInLegacyMode();
mView.setHeadsUpBoundaries(height, bottomBarHeight);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationListViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationListViewBinder.kt
index 5544f93..5572f8e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationListViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationListViewBinder.kt
@@ -46,7 +46,6 @@
import com.android.systemui.statusbar.notification.stack.ui.viewbinder.HideNotificationsBinder.bindHideList
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationListViewModel
import com.android.systemui.statusbar.notification.ui.viewbinder.HeadsUpNotificationViewBinder
-import com.android.systemui.statusbar.phone.NotificationIconAreaController
import com.android.systemui.util.kotlin.awaitCancellationThenDispose
import com.android.systemui.util.kotlin.getOrNull
import com.android.systemui.util.ui.isAnimating
@@ -74,7 +73,6 @@
private val configuration: ConfigurationState,
private val falsingManager: FalsingManager,
private val hunBinder: HeadsUpNotificationViewBinder,
- private val iconAreaController: NotificationIconAreaController,
private val loggerOptional: Optional<NotificationStatsLogger>,
private val metricsLogger: MetricsLogger,
private val nicBinder: NotificationIconContainerShelfViewBinder,
@@ -128,7 +126,6 @@
viewModel.shelf,
falsingManager,
nicBinder,
- iconAreaController,
)
}
@@ -183,12 +180,12 @@
launchNotificationSettings = { view ->
notificationActivityStarter
.get()
- .startHistoryIntent(view, /* showHistory = */ false)
+ .startHistoryIntent(view, /* showHistory= */ false)
},
launchNotificationHistory = { view ->
notificationActivityStarter
.get()
- .startHistoryIntent(view, /* showHistory = */ true)
+ .startHistoryIntent(view, /* showHistory= */ true)
},
)
launch {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt
index e8a7840..db91eed 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt
@@ -74,7 +74,8 @@
}
/** Whether or not the notification scrim should be clickable. */
- val isClickable: StateFlow<Boolean> = shadeSceneViewModel.isClickable
+ val isClickable: StateFlow<Boolean>
+ get() = shadeSceneViewModel.isClickable
/** True when a HUN is pinned or animating away. */
val isHeadsUpOrAnimatingAway: Flow<Boolean> =
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
index 6d3cad5..2c7ce00 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java
@@ -30,7 +30,6 @@
import static com.android.systemui.Flags.keyboardShortcutHelperRewrite;
import static com.android.systemui.Flags.lightRevealMigration;
import static com.android.systemui.Flags.newAodTransition;
-import static com.android.systemui.Flags.truncatedStatusBarIconsFix;
import static com.android.systemui.charging.WirelessChargingAnimation.UNKNOWN_BATTERY_LEVEL;
import static com.android.systemui.flags.Flags.SHORTCUT_LIST_SEARCH_LAYOUT;
import static com.android.systemui.statusbar.NotificationLockscreenUserManager.PERMISSION_SELF;
@@ -210,7 +209,6 @@
import com.android.systemui.statusbar.notification.init.NotificationsController;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
@@ -238,10 +236,10 @@
import com.android.wm.shell.startingsurface.SplashscreenContentDrawer;
import com.android.wm.shell.startingsurface.StartingSurface;
-import dalvik.annotation.optimization.NeverCompile;
-
import dagger.Lazy;
+import dalvik.annotation.optimization.NeverCompile;
+
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Map;
@@ -547,7 +545,6 @@
protected final BatteryController mBatteryController;
private UiModeManager mUiModeManager;
private LogMaker mStatusBarStateLog;
- protected final NotificationIconAreaController mNotificationIconAreaController;
@Nullable private View mAmbientIndicationContainer;
private final SysuiColorExtractor mColorExtractor;
private final ScreenLifecycle mScreenLifecycle;
@@ -684,7 +681,6 @@
DemoModeController demoModeController,
Lazy<NotificationShadeDepthController> notificationShadeDepthControllerLazy,
StatusBarTouchableRegionManager statusBarTouchableRegionManager,
- NotificationIconAreaController notificationIconAreaController,
BrightnessSliderController.Factory brightnessSliderFactory,
ScreenOffAnimationController screenOffAnimationController,
WallpaperController wallpaperController,
@@ -788,7 +784,6 @@
mUserInfoControllerImpl = userInfoControllerImpl;
mIconPolicy = phoneStatusBarPolicy;
mDemoModeController = demoModeController;
- mNotificationIconAreaController = notificationIconAreaController;
mBrightnessSliderFactory = brightnessSliderFactory;
mWallpaperController = wallpaperController;
mStatusBarSignalPolicy = statusBarSignalPolicy;
@@ -1933,11 +1928,6 @@
mQSPanelController.updateResources();
}
- if (!truncatedStatusBarIconsFix()) {
- if (mStatusBarWindowController != null) {
- mStatusBarWindowController.refreshStatusBarHeight();
- }
- }
if (mShadeSurface != null) {
mShadeSurface.updateResources();
}
@@ -2658,9 +2648,6 @@
!mDozeServiceHost.isPulsing());
mShadeSurface.setTouchAndAnimationDisabled(disabled);
- if (!NotificationIconContainerRefactor.isEnabled()) {
- mNotificationIconAreaController.setAnimationsEnabled(!disabled);
- }
}
final ScreenLifecycle.Observer mScreenObserver = new ScreenLifecycle.Observer() {
@@ -3059,9 +3046,6 @@
}
// TODO: Bring these out of CentralSurfaces.
mUserInfoControllerImpl.onDensityOrFontScaleChanged();
- if (!NotificationIconContainerRefactor.isEnabled()) {
- mNotificationIconAreaController.onDensityOrFontScaleChanged(mContext);
- }
}
@Override
@@ -3079,9 +3063,6 @@
if (mAmbientIndicationContainer instanceof AutoReinflateContainer) {
((AutoReinflateContainer) mAmbientIndicationContainer).inflateLayout();
}
- if (!NotificationIconContainerRefactor.isEnabled()) {
- mNotificationIconAreaController.onThemeChanged();
- }
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java
index ca1fb78b..f13a593 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java
@@ -52,7 +52,6 @@
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.HeadsUpManager;
@@ -106,7 +105,6 @@
private final NotificationWakeUpCoordinator mNotificationWakeUpCoordinator;
private NotificationShadeWindowViewController mNotificationShadeWindowViewController;
private final AuthController mAuthController;
- private final NotificationIconAreaController mNotificationIconAreaController;
private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
private final ShadeLockscreenInteractor mShadeLockscreenInteractor;
private View mAmbientIndicationContainer;
@@ -129,7 +127,6 @@
NotificationShadeWindowController notificationShadeWindowController,
NotificationWakeUpCoordinator notificationWakeUpCoordinator,
AuthController authController,
- NotificationIconAreaController notificationIconAreaController,
ShadeLockscreenInteractor shadeLockscreenInteractor,
DozeInteractor dozeInteractor) {
super();
@@ -149,7 +146,6 @@
mNotificationShadeWindowController = notificationShadeWindowController;
mNotificationWakeUpCoordinator = notificationWakeUpCoordinator;
mAuthController = authController;
- mNotificationIconAreaController = notificationIconAreaController;
mShadeLockscreenInteractor = shadeLockscreenInteractor;
mHeadsUpManager.addListener(mOnHeadsUpChangedListener);
mDozeInteractor = dozeInteractor;
@@ -196,13 +192,8 @@
void fireNotificationPulse(NotificationEntry entry) {
Runnable pulseSuppressedListener = () -> {
- if (NotificationIconContainerRefactor.isEnabled()) {
- mHeadsUpManager.removeNotification(
- entry.getKey(), /* releaseImmediately= */ true, /* animate= */ false);
- } else {
- entry.setPulseSuppressed(true);
- mNotificationIconAreaController.updateAodNotificationIcons();
- }
+ mHeadsUpManager.removeNotification(
+ entry.getKey(), /* releaseImmediately= */ true, /* animate= */ false);
};
Assert.isMainThread();
for (Callback callback : mCallbacks) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java
index f99a81e..8f94c06 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java
@@ -42,7 +42,6 @@
import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNotificationIconInteractor;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation;
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
import com.android.systemui.statusbar.notification.stack.NotificationRoundnessManager;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentScope;
@@ -74,7 +73,6 @@
private static final SourceType HEADS_UP = SourceType.from("HeadsUp");
private static final SourceType PULSING = SourceType.from("Pulsing");
- private final NotificationIconAreaController mNotificationIconAreaController;
private final HeadsUpManager mHeadsUpManager;
private final NotificationStackScrollLayoutController mStackScrollerController;
@@ -114,7 +112,6 @@
@VisibleForTesting
@Inject
public HeadsUpAppearanceController(
- NotificationIconAreaController notificationIconAreaController,
HeadsUpManager headsUpManager,
StatusBarStateController stateController,
PhoneStatusBarTransitions phoneStatusBarTransitions,
@@ -132,7 +129,6 @@
HeadsUpNotificationIconInteractor headsUpNotificationIconInteractor,
@Named(OPERATOR_NAME_FRAME_VIEW) Optional<View> operatorNameViewOptional) {
super(headsUpStatusBarView);
- mNotificationIconAreaController = notificationIconAreaController;
mNotificationRoundnessManager = notificationRoundnessManager;
mHeadsUpManager = headsUpManager;
@@ -178,11 +174,8 @@
@Override
protected void onViewAttached() {
mHeadsUpManager.addListener(this);
- mView.setOnDrawingRectChangedListener(
- () -> updateIsolatedIconLocation(true /* requireUpdate */));
- if (NotificationIconContainerRefactor.isEnabled()) {
- updateIsolatedIconLocation(true);
- }
+ mView.setOnDrawingRectChangedListener(this::updateIsolatedIconLocation);
+ updateIsolatedIconLocation();
mWakeUpCoordinator.addListener(this);
getShadeHeadsUpTracker().addTrackingHeadsUpListener(mSetTrackingHeadsUp);
getShadeHeadsUpTracker().setHeadsUpAppearanceController(this);
@@ -198,9 +191,7 @@
protected void onViewDetached() {
mHeadsUpManager.removeListener(this);
mView.setOnDrawingRectChangedListener(null);
- if (NotificationIconContainerRefactor.isEnabled()) {
- mHeadsUpNotificationIconInteractor.setIsolatedIconLocation(null);
- }
+ mHeadsUpNotificationIconInteractor.setIsolatedIconLocation(null);
mWakeUpCoordinator.removeListener(this);
getShadeHeadsUpTracker().removeTrackingHeadsUpListener(mSetTrackingHeadsUp);
getShadeHeadsUpTracker().setHeadsUpAppearanceController(null);
@@ -208,14 +199,8 @@
mDarkIconDispatcher.removeDarkReceiver(this);
}
- private void updateIsolatedIconLocation(boolean requireStateUpdate) {
- if (NotificationIconContainerRefactor.isEnabled()) {
- mHeadsUpNotificationIconInteractor
- .setIsolatedIconLocation(mView.getIconDrawingRect());
- } else {
- mNotificationIconAreaController.setIsolatedIconLocation(
- mView.getIconDrawingRect(), requireStateUpdate);
- }
+ private void updateIsolatedIconLocation() {
+ mHeadsUpNotificationIconInteractor.setIsolatedIconLocation(mView.getIconDrawingRect());
}
@Override
@@ -251,14 +236,8 @@
setShown(true);
animateIsolation = !isExpanded();
}
- if (NotificationIconContainerRefactor.isEnabled()) {
- mHeadsUpNotificationIconInteractor.setIsolatedIconNotificationKey(
- newEntry == null ? null : newEntry.getRepresentativeEntry().getKey());
- } else {
- updateIsolatedIconLocation(false /* requireUpdate */);
- mNotificationIconAreaController.showIconIsolated(newEntry == null ? null
- : newEntry.getIcons().getStatusBarIcon(), animateIsolation);
- }
+ mHeadsUpNotificationIconInteractor.setIsolatedIconNotificationKey(
+ newEntry == null ? null : newEntry.getRepresentativeEntry().getKey());
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyNotificationIconAreaControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyNotificationIconAreaControllerImpl.java
deleted file mode 100644
index f84efbb..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyNotificationIconAreaControllerImpl.java
+++ /dev/null
@@ -1,700 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.systemui.statusbar.phone;
-
-import static com.android.systemui.Flags.newAodTransition;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Color;
-import android.graphics.Rect;
-import android.os.Bundle;
-import android.os.Trace;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.FrameLayout;
-
-import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
-import androidx.annotation.VisibleForTesting;
-import androidx.collection.ArrayMap;
-
-import com.android.app.animation.Interpolators;
-import com.android.internal.statusbar.StatusBarIcon;
-import com.android.internal.util.ContrastColorUtil;
-import com.android.settingslib.Utils;
-import com.android.systemui.dagger.SysUISingleton;
-import com.android.systemui.demomode.DemoMode;
-import com.android.systemui.demomode.DemoModeController;
-import com.android.systemui.flags.FeatureFlags;
-import com.android.systemui.keyguard.MigrateClocksToBlueprint;
-import com.android.systemui.plugins.DarkIconDispatcher;
-import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
-import com.android.systemui.plugins.statusbar.StatusBarStateController;
-import com.android.systemui.res.R;
-import com.android.systemui.statusbar.CrossFadeHelper;
-import com.android.systemui.statusbar.NotificationListener;
-import com.android.systemui.statusbar.NotificationMediaManager;
-import com.android.systemui.statusbar.StatusBarIconView;
-import com.android.systemui.statusbar.StatusBarState;
-import com.android.systemui.statusbar.notification.NotificationUtils;
-import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
-import com.android.systemui.statusbar.notification.collection.ListEntry;
-import com.android.systemui.statusbar.notification.collection.NotificationEntry;
-import com.android.systemui.statusbar.notification.collection.provider.SectionStyleProvider;
-import com.android.systemui.statusbar.window.StatusBarWindowController;
-import com.android.wm.shell.bubbles.Bubbles;
-
-import org.jetbrains.annotations.NotNull;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.function.Function;
-
-import javax.inject.Inject;
-
-/**
- * A controller for the space in the status bar to the left of the system icons. This area is
- * normally reserved for notifications.
- */
-@SysUISingleton
-public class LegacyNotificationIconAreaControllerImpl implements
- NotificationIconAreaController,
- DarkReceiver,
- StatusBarStateController.StateListener,
- NotificationWakeUpCoordinator.WakeUpListener,
- DemoMode {
-
- private static final long AOD_ICONS_APPEAR_DURATION = 200;
- @ColorInt
- private static final int DEFAULT_AOD_ICON_COLOR = 0xffffffff;
-
- private final ContrastColorUtil mContrastColorUtil;
- private final Runnable mUpdateStatusBarIcons = this::updateStatusBarIcons;
- private final StatusBarStateController mStatusBarStateController;
- private final NotificationMediaManager mMediaManager;
- private final NotificationWakeUpCoordinator mWakeUpCoordinator;
- private final KeyguardBypassController mBypassController;
- private final DozeParameters mDozeParameters;
- private final SectionStyleProvider mSectionStyleProvider;
- private final Optional<Bubbles> mBubblesOptional;
- private final StatusBarWindowController mStatusBarWindowController;
- private final ScreenOffAnimationController mScreenOffAnimationController;
-
- private int mIconSize;
- private int mIconHPadding;
- private int mIconTint = Color.WHITE;
-
- private List<ListEntry> mNotificationEntries = List.of();
- protected View mNotificationIconArea;
- private NotificationIconContainer mNotificationIcons;
- private NotificationIconContainer mShelfIcons;
- private NotificationIconContainer mAodIcons;
- private final ArrayList<Rect> mTintAreas = new ArrayList<>();
- private final Context mContext;
- private int mAodIconAppearTranslation;
-
- private boolean mAnimationsEnabled;
- private int mAodIconTint;
- private boolean mAodIconsVisible;
- private boolean mShowLowPriority = true;
-
- @VisibleForTesting
- final NotificationListener.NotificationSettingsListener mSettingsListener =
- new NotificationListener.NotificationSettingsListener() {
- @Override
- public void onStatusBarIconsBehaviorChanged(boolean hideSilentStatusIcons) {
- mShowLowPriority = !hideSilentStatusIcons;
- updateStatusBarIcons();
- }
- };
-
- @Inject
- public LegacyNotificationIconAreaControllerImpl(
- Context context,
- StatusBarStateController statusBarStateController,
- NotificationWakeUpCoordinator wakeUpCoordinator,
- KeyguardBypassController keyguardBypassController,
- NotificationMediaManager notificationMediaManager,
- NotificationListener notificationListener,
- DozeParameters dozeParameters,
- SectionStyleProvider sectionStyleProvider,
- Optional<Bubbles> bubblesOptional,
- DemoModeController demoModeController,
- DarkIconDispatcher darkIconDispatcher,
- FeatureFlags featureFlags,
- StatusBarWindowController statusBarWindowController,
- ScreenOffAnimationController screenOffAnimationController) {
- mContrastColorUtil = ContrastColorUtil.getInstance(context);
- mContext = context;
- mStatusBarStateController = statusBarStateController;
- mStatusBarStateController.addCallback(this);
- mMediaManager = notificationMediaManager;
- mDozeParameters = dozeParameters;
- mSectionStyleProvider = sectionStyleProvider;
- mWakeUpCoordinator = wakeUpCoordinator;
- wakeUpCoordinator.addListener(this);
- mBypassController = keyguardBypassController;
- mBubblesOptional = bubblesOptional;
- demoModeController.addCallback(this);
- mStatusBarWindowController = statusBarWindowController;
- mScreenOffAnimationController = screenOffAnimationController;
- notificationListener.addNotificationSettingsListener(mSettingsListener);
- initializeNotificationAreaViews(context);
- reloadAodColor();
- darkIconDispatcher.addDarkReceiver(this);
- }
-
- protected View inflateIconArea(LayoutInflater inflater) {
- return inflater.inflate(R.layout.notification_icon_area, null);
- }
-
- /**
- * Initializes the views that will represent the notification area.
- */
- protected void initializeNotificationAreaViews(Context context) {
- reloadDimens(context);
-
- LayoutInflater layoutInflater = LayoutInflater.from(context);
- mNotificationIconArea = inflateIconArea(layoutInflater);
- mNotificationIcons = mNotificationIconArea.findViewById(R.id.notificationIcons);
- }
-
- /**
- * Called by the Keyguard*ViewController whose view contains the aod icons.
- */
- public void setupAodIcons(@NonNull NotificationIconContainer aodIcons) {
- boolean changed = mAodIcons != null && aodIcons != mAodIcons;
- if (changed) {
- mAodIcons.setAnimationsEnabled(false);
- mAodIcons.removeAllViews();
- }
- mAodIcons = aodIcons;
- mAodIcons.setOnLockScreen(true);
- updateAodIconsVisibility(false /* animate */, changed);
- updateAnimations();
- if (changed) {
- updateAodNotificationIcons();
- }
- updateIconLayoutParams(mContext);
- }
-
- public void setShelfIcons(NotificationIconContainer icons) {
- mShelfIcons = icons;
- }
-
- public void onDensityOrFontScaleChanged(@NotNull Context context) {
- updateIconLayoutParams(context);
- }
-
- private void updateIconLayoutParams(Context context) {
- reloadDimens(context);
- final FrameLayout.LayoutParams params = generateIconLayoutParams();
- for (int i = 0; i < mNotificationIcons.getChildCount(); i++) {
- View child = mNotificationIcons.getChildAt(i);
- child.setLayoutParams(params);
- }
- if (mShelfIcons != null) {
- for (int i = 0; i < mShelfIcons.getChildCount(); i++) {
- View child = mShelfIcons.getChildAt(i);
- child.setLayoutParams(params);
- }
- }
- if (mAodIcons != null) {
- for (int i = 0; i < mAodIcons.getChildCount(); i++) {
- View child = mAodIcons.getChildAt(i);
- child.setLayoutParams(params);
- }
- }
- }
-
- @NonNull
- private FrameLayout.LayoutParams generateIconLayoutParams() {
- return new FrameLayout.LayoutParams(
- mIconSize + 2 * mIconHPadding, mStatusBarWindowController.getStatusBarHeight());
- }
-
- private void reloadDimens(Context context) {
- Resources res = context.getResources();
- mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size_sp);
- mIconHPadding = res.getDimensionPixelSize(R.dimen.status_bar_icon_horizontal_margin);
- mAodIconAppearTranslation = res.getDimensionPixelSize(
- R.dimen.shelf_appear_translation);
- }
-
- /**
- * Returns the view that represents the notification area.
- */
- public View getNotificationInnerAreaView() {
- return mNotificationIconArea;
- }
-
- /**
- * See {@link com.android.systemui.statusbar.policy.DarkIconDispatcher#setIconsDarkArea}.
- * Sets the color that should be used to tint any icons in the notification area.
- *
- * @param tintAreas the areas in which to tint the icons, specified in screen coordinates
- * @param darkIntensity
- */
- public void onDarkChanged(ArrayList<Rect> tintAreas, float darkIntensity, int iconTint) {
- mTintAreas.clear();
- mTintAreas.addAll(tintAreas);
-
- if (DarkIconDispatcher.isInAreas(tintAreas, mNotificationIconArea)) {
- mIconTint = iconTint;
- }
-
- applyNotificationIconsTint();
- }
-
- protected boolean shouldShowNotificationIcon(NotificationEntry entry,
- boolean showAmbient, boolean showLowPriority, boolean hideDismissed,
- boolean hideRepliedMessages, boolean hideCurrentMedia, boolean hidePulsing) {
- if (!showAmbient && mSectionStyleProvider.isMinimized(entry)) {
- return false;
- }
- if (hideCurrentMedia && entry.getKey().equals(mMediaManager.getMediaNotificationKey())) {
- return false;
- }
- if (!showLowPriority && mSectionStyleProvider.isSilent(entry)) {
- return false;
- }
- if (entry.isRowDismissed() && hideDismissed) {
- return false;
- }
- if (hideRepliedMessages && entry.isLastMessageFromReply()) {
- return false;
- }
- // showAmbient == show in shade but not shelf
- if (!showAmbient && entry.shouldSuppressStatusBar()) {
- return false;
- }
- if (hidePulsing && entry.showingPulsing()
- && (!mWakeUpCoordinator.getNotificationsFullyHidden()
- || !entry.isPulseSuppressed())) {
- return false;
- }
- if (mBubblesOptional.isPresent()
- && mBubblesOptional.get().isBubbleExpanded(entry.getKey())) {
- return false;
- }
- return true;
- }
-
- /**
- * Updates the notifications with the given list of notifications to display.
- */
- public void updateNotificationIcons(List<ListEntry> entries) {
- mNotificationEntries = entries;
- updateNotificationIcons();
- }
-
- private void updateNotificationIcons() {
- Trace.beginSection("NotificationIconAreaController.updateNotificationIcons");
- updateStatusBarIcons();
- updateShelfIcons();
- updateAodNotificationIcons();
-
- applyNotificationIconsTint();
- Trace.endSection();
- }
-
- private void updateShelfIcons() {
- if (mShelfIcons == null) {
- return;
- }
- updateIconsForLayout(entry -> entry.getIcons().getShelfIcon(), mShelfIcons,
- true /* showAmbient */,
- true /* showLowPriority */,
- false /* hideDismissed */,
- false /* hideRepliedMessages */,
- false /* hideCurrentMedia */,
- false /* hidePulsing */);
- }
-
- public void updateStatusBarIcons() {
- updateIconsForLayout(entry -> entry.getIcons().getStatusBarIcon(), mNotificationIcons,
- false /* showAmbient */,
- mShowLowPriority,
- true /* hideDismissed */,
- true /* hideRepliedMessages */,
- false /* hideCurrentMedia */,
- false /* hidePulsing */);
- }
-
- public void updateAodNotificationIcons() {
- if (mAodIcons == null) {
- return;
- }
- updateIconsForLayout(entry -> entry.getIcons().getAodIcon(), mAodIcons,
- false /* showAmbient */,
- true /* showLowPriority */,
- true /* hideDismissed */,
- true /* hideRepliedMessages */,
- true /* hideCurrentMedia */,
- mBypassController.getBypassEnabled() /* hidePulsing */);
- }
-
- @VisibleForTesting
- boolean shouldShouldLowPriorityIcons() {
- return mShowLowPriority;
- }
-
- /**
- * Updates the notification icons for a host layout. This will ensure that the notification
- * host layout will have the same icons like the ones in here.
- * @param function A function to look up an icon view based on an entry
- * @param hostLayout which layout should be updated
- * @param showAmbient should ambient notification icons be shown
- * @param showLowPriority should icons from silent notifications be shown
- * @param hideDismissed should dismissed icons be hidden
- * @param hideRepliedMessages should messages that have been replied to be hidden
- * @param hidePulsing should pulsing notifications be hidden
- */
- private void updateIconsForLayout(Function<NotificationEntry, StatusBarIconView> function,
- NotificationIconContainer hostLayout, boolean showAmbient, boolean showLowPriority,
- boolean hideDismissed, boolean hideRepliedMessages, boolean hideCurrentMedia,
- boolean hidePulsing) {
- ArrayList<StatusBarIconView> toShow = new ArrayList<>(mNotificationEntries.size());
- // Filter out ambient notifications and notification children.
- for (int i = 0; i < mNotificationEntries.size(); i++) {
- NotificationEntry entry = mNotificationEntries.get(i).getRepresentativeEntry();
- if (entry != null && entry.getRow() != null) {
- if (shouldShowNotificationIcon(entry, showAmbient, showLowPriority, hideDismissed,
- hideRepliedMessages, hideCurrentMedia, hidePulsing)) {
- StatusBarIconView iconView = function.apply(entry);
- if (iconView != null) {
- toShow.add(iconView);
- }
- }
- }
- }
-
- // In case we are changing the suppression of a group, the replacement shouldn't flicker
- // and it should just be replaced instead. We therefore look for notifications that were
- // just replaced by the child or vice-versa to suppress this.
-
- ArrayMap<String, ArrayList<StatusBarIcon>> replacingIcons = new ArrayMap<>();
- ArrayList<View> toRemove = new ArrayList<>();
- for (int i = 0; i < hostLayout.getChildCount(); i++) {
- View child = hostLayout.getChildAt(i);
- if (!(child instanceof StatusBarIconView)) {
- continue;
- }
- if (!toShow.contains(child)) {
- boolean iconWasReplaced = false;
- StatusBarIconView removedIcon = (StatusBarIconView) child;
- String removedGroupKey = removedIcon.getNotification().getGroupKey();
- for (int j = 0; j < toShow.size(); j++) {
- StatusBarIconView candidate = toShow.get(j);
- if (candidate.getSourceIcon().sameAs((removedIcon.getSourceIcon()))
- && candidate.getNotification().getGroupKey().equals(removedGroupKey)) {
- if (!iconWasReplaced) {
- iconWasReplaced = true;
- } else {
- iconWasReplaced = false;
- break;
- }
- }
- }
- if (iconWasReplaced) {
- ArrayList<StatusBarIcon> statusBarIcons = replacingIcons.get(removedGroupKey);
- if (statusBarIcons == null) {
- statusBarIcons = new ArrayList<>();
- replacingIcons.put(removedGroupKey, statusBarIcons);
- }
- statusBarIcons.add(removedIcon.getStatusBarIcon());
- }
- toRemove.add(removedIcon);
- }
- }
- // removing all duplicates
- ArrayList<String> duplicates = new ArrayList<>();
- for (String key : replacingIcons.keySet()) {
- ArrayList<StatusBarIcon> statusBarIcons = replacingIcons.get(key);
- if (statusBarIcons.size() != 1) {
- duplicates.add(key);
- }
- }
- replacingIcons.removeAll(duplicates);
- hostLayout.setReplacingIconsLegacy(replacingIcons);
-
- final int toRemoveCount = toRemove.size();
- for (int i = 0; i < toRemoveCount; i++) {
- hostLayout.removeView(toRemove.get(i));
- }
-
- final FrameLayout.LayoutParams params = generateIconLayoutParams();
- for (int i = 0; i < toShow.size(); i++) {
- StatusBarIconView v = toShow.get(i);
- // The view might still be transiently added if it was just removed and added again
- hostLayout.removeTransientView(v);
- if (v.getParent() == null) {
- if (hideDismissed) {
- v.setOnDismissListener(mUpdateStatusBarIcons);
- }
- hostLayout.addView(v, i, params);
- }
- }
-
- hostLayout.setChangingViewPositions(true);
- // Re-sort notification icons
- final int childCount = hostLayout.getChildCount();
- for (int i = 0; i < childCount; i++) {
- View actual = hostLayout.getChildAt(i);
- StatusBarIconView expected = toShow.get(i);
- if (actual == expected) {
- continue;
- }
- hostLayout.removeView(expected);
- hostLayout.addView(expected, i);
- }
- hostLayout.setChangingViewPositions(false);
- hostLayout.setReplacingIconsLegacy(null);
- }
-
- /**
- * Applies {@link #mIconTint} to the notification icons.
- */
- private void applyNotificationIconsTint() {
- for (int i = 0; i < mNotificationIcons.getChildCount(); i++) {
- final StatusBarIconView iv = (StatusBarIconView) mNotificationIcons.getChildAt(i);
- if (iv.getWidth() != 0) {
- updateTintForIcon(iv, mIconTint);
- } else {
- iv.executeOnLayout(() -> updateTintForIcon(iv, mIconTint));
- }
- }
-
- updateAodIconColors();
- }
-
- private void updateTintForIcon(StatusBarIconView v, int tint) {
- boolean isPreL = Boolean.TRUE.equals(v.getTag(R.id.icon_is_pre_L));
- int color = StatusBarIconView.NO_COLOR;
- boolean colorize = !isPreL || NotificationUtils.isGrayscale(v, mContrastColorUtil);
- if (colorize) {
- color = DarkIconDispatcher.getTint(mTintAreas, v, tint);
- }
- v.setStaticDrawableColor(color);
- v.setDecorColor(tint);
- }
-
- public void showIconIsolated(StatusBarIconView icon, boolean animated) {
- mNotificationIcons.showIconIsolatedLegacy(icon, animated);
- }
-
- public void setIsolatedIconLocation(@NotNull Rect iconDrawingRect, boolean requireStateUpdate) {
- mNotificationIcons.setIsolatedIconLocation(iconDrawingRect, requireStateUpdate);
- }
-
- @Override
- public void onDozingChanged(boolean isDozing) {
- if (mAodIcons == null) {
- return;
- }
- boolean animate = mDozeParameters.getAlwaysOn()
- && !mDozeParameters.getDisplayNeedsBlanking();
- mAodIcons.setDozing(isDozing, animate, 0);
- }
-
- public void setAnimationsEnabled(boolean enabled) {
- mAnimationsEnabled = enabled;
- updateAnimations();
- }
-
- @Override
- public void onStateChanged(int newState) {
- updateAodIconsVisibility(false /* animate */, false /* force */);
- updateAnimations();
- }
-
- private void updateAnimations() {
- boolean inShade = mStatusBarStateController.getState() == StatusBarState.SHADE;
- if (mAodIcons != null) {
- mAodIcons.setAnimationsEnabled(mAnimationsEnabled && !inShade);
- }
- mNotificationIcons.setAnimationsEnabled(mAnimationsEnabled && inShade);
- }
-
- public void onThemeChanged() {
- reloadAodColor();
- updateAodIconColors();
- }
-
- public int getHeight() {
- return mAodIcons == null ? 0 : mAodIcons.getHeight();
- }
-
- public void appearAodIcons() {
- if (mAodIcons == null) {
- return;
- }
- if (mScreenOffAnimationController.shouldAnimateAodIcons()) {
- if (!MigrateClocksToBlueprint.isEnabled()) {
- mAodIcons.setTranslationY(-mAodIconAppearTranslation);
- }
- mAodIcons.setAlpha(0);
- animateInAodIconTranslation();
- mAodIcons.animate()
- .alpha(1)
- .setInterpolator(Interpolators.LINEAR)
- .setDuration(AOD_ICONS_APPEAR_DURATION)
- .start();
- } else {
- mAodIcons.setAlpha(1.0f);
- if (!MigrateClocksToBlueprint.isEnabled()) {
- mAodIcons.setTranslationY(0);
- }
- }
- }
-
- private void animateInAodIconTranslation() {
- if (!MigrateClocksToBlueprint.isEnabled()) {
- mAodIcons.animate()
- .setInterpolator(Interpolators.DECELERATE_QUINT)
- .translationY(0)
- .setDuration(AOD_ICONS_APPEAR_DURATION)
- .start();
- }
- }
-
- private void reloadAodColor() {
- mAodIconTint = Utils.getColorAttrDefaultColor(mContext,
- R.attr.wallpaperTextColor, DEFAULT_AOD_ICON_COLOR);
- }
-
- private void updateAodIconColors() {
- if (mAodIcons != null) {
- for (int i = 0; i < mAodIcons.getChildCount(); i++) {
- final StatusBarIconView iv = (StatusBarIconView) mAodIcons.getChildAt(i);
- if (iv.getWidth() != 0) {
- updateTintForIcon(iv, mAodIconTint);
- } else {
- iv.executeOnLayout(() -> updateTintForIcon(iv, mAodIconTint));
- }
- }
- }
- }
-
- @Override
- public void onFullyHiddenChanged(boolean fullyHidden) {
- boolean animate = true;
- if (!mBypassController.getBypassEnabled()) {
- animate = mDozeParameters.getAlwaysOn() && !mDozeParameters.getDisplayNeedsBlanking();
- if (!newAodTransition()) {
- // We only want the appear animations to happen when the notifications get fully
- // hidden, since otherwise the unhide animation overlaps
- animate &= fullyHidden;
- }
- }
- updateAodIconsVisibility(animate, false /* force */);
- updateAodNotificationIcons();
- updateAodIconColors();
- }
-
- @Override
- public void onPulseExpansionAmountChanged(boolean expandingChanged) {
- if (expandingChanged) {
- updateAodIconsVisibility(true /* animate */, false /* force */);
- }
- }
-
- private void updateAodIconsVisibility(boolean animate, boolean forceUpdate) {
- if (mAodIcons == null) {
- return;
- }
- boolean visible = mBypassController.getBypassEnabled()
- || mWakeUpCoordinator.getNotificationsFullyHidden();
-
- // Hide the AOD icons if we're not in the KEYGUARD state unless the screen off animation is
- // playing, in which case we want them to be visible since we're animating in the AOD UI and
- // will be switching to KEYGUARD shortly.
- if (mStatusBarStateController.getState() != StatusBarState.KEYGUARD
- && !mScreenOffAnimationController.shouldShowAodIconsWhenShade()) {
- visible = false;
- }
- if (visible && mWakeUpCoordinator.isPulseExpanding()
- && !mBypassController.getBypassEnabled()) {
- visible = false;
- }
- if (mAodIconsVisible != visible || forceUpdate) {
- mAodIconsVisible = visible;
- mAodIcons.animate().cancel();
- if (animate) {
- if (newAodTransition()) {
- // Let's make sure the icon are translated to 0, since we cancelled it above
- animateInAodIconTranslation();
- if (mAodIconsVisible) {
- CrossFadeHelper.fadeIn(mAodIcons);
- } else {
- CrossFadeHelper.fadeOut(mAodIcons);
- }
- } else {
- boolean wasFullyInvisible = mAodIcons.getVisibility() != View.VISIBLE;
- if (mAodIconsVisible) {
- if (wasFullyInvisible) {
- // No fading here, let's just appear the icons instead!
- mAodIcons.setVisibility(View.VISIBLE);
- mAodIcons.setAlpha(1.0f);
- appearAodIcons();
- } else {
- // Let's make sure the icon are translated to 0, since we cancelled it
- // above
- animateInAodIconTranslation();
- // We were fading out, let's fade in instead
- CrossFadeHelper.fadeIn(mAodIcons);
- }
- } else {
- // Let's make sure the icon are translated to 0, since we cancelled it above
- animateInAodIconTranslation();
- CrossFadeHelper.fadeOut(mAodIcons);
- }
- }
- } else {
- mAodIcons.setAlpha(1.0f);
- if (!MigrateClocksToBlueprint.isEnabled()) {
- mAodIcons.setTranslationY(0);
- }
- mAodIcons.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
- }
- }
- }
-
- @Override
- public List<String> demoCommands() {
- ArrayList<String> commands = new ArrayList<>();
- commands.add(DemoMode.COMMAND_NOTIFICATIONS);
- return commands;
- }
-
- @Override
- public void dispatchDemoCommand(String command, Bundle args) {
- if (mNotificationIconArea != null) {
- String visible = args.getString("visible");
- int vis = "false".equals(visible) ? View.INVISIBLE : View.VISIBLE;
- mNotificationIconArea.setVisibility(vis);
- }
- }
-
- @Override
- public void onDemoModeFinished() {
- if (mNotificationIconArea != null) {
- mNotificationIconArea.setVisibility(View.VISIBLE);
- }
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.kt
deleted file mode 100644
index 4385a2e..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.kt
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.systemui.statusbar.phone
-
-import android.content.Context
-import android.graphics.Rect
-import android.view.View
-import com.android.systemui.statusbar.StatusBarIconView
-import com.android.systemui.statusbar.notification.collection.ListEntry
-
-/**
- * A controller for the space in the status bar to the left of the system icons. This area is
- * normally reserved for notifications.
- */
-interface NotificationIconAreaController {
- /** Called by the Keyguard*ViewController whose view contains the aod icons. */
- fun setupAodIcons(aodIcons: NotificationIconContainer?)
- fun setShelfIcons(icons: NotificationIconContainer)
- fun onDensityOrFontScaleChanged(context: Context)
-
- /** Returns the view that represents the notification area. */
- fun getNotificationInnerAreaView(): View?
-
- /** Updates the notifications with the given list of notifications to display. */
- fun updateNotificationIcons(entries: List<@JvmSuppressWildcards ListEntry>)
- fun updateAodNotificationIcons()
- fun showIconIsolated(icon: StatusBarIconView?, animated: Boolean)
- fun setIsolatedIconLocation(iconDrawingRect: Rect, requireStateUpdate: Boolean)
- fun setAnimationsEnabled(enabled: Boolean)
- fun onThemeChanged()
- fun getHeight(): Int
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaControllerModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaControllerModule.kt
deleted file mode 100644
index ba69370..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaControllerModule.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.systemui.statusbar.phone
-
-import com.android.systemui.statusbar.notification.icon.ui.viewbinder.NotificationIconAreaControllerViewBinderWrapperImpl
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor
-import dagger.Module
-import dagger.Provides
-import javax.inject.Provider
-
-@Module
-object NotificationIconAreaControllerModule {
- @Provides
- fun provideNotificationIconAreaControllerImpl(
- legacyProvider: Provider<LegacyNotificationIconAreaControllerImpl>,
- newProvider: Provider<NotificationIconAreaControllerViewBinderWrapperImpl>,
- ): NotificationIconAreaController =
- if (NotificationIconContainerRefactor.isEnabled) {
- newProvider.get()
- } else {
- legacyProvider.get()
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java
index 8e3d678..ecd62bd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java
@@ -26,7 +26,6 @@
import android.graphics.Rect;
import android.graphics.drawable.Icon;
import android.util.AttributeSet;
-import android.util.MathUtils;
import android.util.Property;
import android.view.ContextThemeWrapper;
import android.view.View;
@@ -42,7 +41,6 @@
import com.android.settingslib.Utils;
import com.android.systemui.res.R;
import com.android.systemui.statusbar.StatusBarIconView;
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
import com.android.systemui.statusbar.notification.stack.AnimationFilter;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.notification.stack.ViewState;
@@ -243,7 +241,7 @@
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int childCount = getChildCount();
- final int maxVisibleIcons = getMaxVisibleIcons(childCount);
+ final int maxVisibleIcons = mMaxIcons;
final int width = MeasureSpec.getSize(widthMeasureSpec);
final int childWidthSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.UNSPECIFIED);
int totalWidth = (int) (getActualPaddingStart() + getActualPaddingEnd());
@@ -284,22 +282,13 @@
@Override
public String toString() {
- if (NotificationIconContainerRefactor.isEnabled()) {
- return super.toString()
- + " {"
- + " overrideIconColor=" + mOverrideIconColor
- + ", maxIcons=" + mMaxIcons
- + ", isStaticLayout=" + mIsStaticLayout
- + ", themedTextColorPrimary=#" + Integer.toHexString(mThemedTextColorPrimary)
- + " }";
- } else {
- return "NotificationIconContainer("
- + "dozing=" + mDozing + " onLockScreen=" + mOnLockScreen
- + " overrideIconColor=" + mOverrideIconColor
- + " speedBumpIndex=" + mSpeedBumpIndex
- + " themedTextColorPrimary=#" + Integer.toHexString(mThemedTextColorPrimary)
- + ')';
- }
+ return super.toString()
+ + " {"
+ + " overrideIconColor=" + mOverrideIconColor
+ + ", maxIcons=" + mMaxIcons
+ + ", isStaticLayout=" + mIsStaticLayout
+ + ", themedTextColorPrimary=#" + Integer.toHexString(mThemedTextColorPrimary)
+ + " }";
}
@VisibleForTesting
@@ -349,13 +338,8 @@
}
}
if (child instanceof StatusBarIconView) {
- if (NotificationIconContainerRefactor.isEnabled()) {
- if (!mChangingViewPositions) {
- ((StatusBarIconView) child).updateIconDimens();
- }
- } else {
+ if (!mChangingViewPositions) {
((StatusBarIconView) child).updateIconDimens();
- ((StatusBarIconView) child).setDozing(mDozing, false, 0);
}
}
}
@@ -367,23 +351,11 @@
StatusBarIconView iconView = (StatusBarIconView) child;
Icon sourceIcon = iconView.getSourceIcon();
String groupKey = iconView.getNotification().getGroupKey();
- if (NotificationIconContainerRefactor.isEnabled()) {
- if (mReplacingIcons == null) {
- return false;
- }
- StatusBarIcon replacedIcon = mReplacingIcons.get(groupKey);
- return replacedIcon != null && sourceIcon.sameAs(replacedIcon.icon);
- } else {
- if (mReplacingIconsLegacy == null) {
- return false;
- }
- ArrayList<StatusBarIcon> statusBarIcons = mReplacingIconsLegacy.get(groupKey);
- if (statusBarIcons != null) {
- StatusBarIcon replacedIcon = statusBarIcons.get(0);
- return sourceIcon.sameAs(replacedIcon.icon);
- }
+ if (mReplacingIcons == null) {
return false;
}
+ StatusBarIcon replacedIcon = mReplacingIcons.get(groupKey);
+ return replacedIcon != null && sourceIcon.sameAs(replacedIcon.icon);
}
@Override
@@ -468,24 +440,14 @@
if (numIcons == 0) {
return 0f;
}
- final float contentWidth;
- if (NotificationIconContainerRefactor.isEnabled()) {
- contentWidth = mIconSize * numIcons;
- } else {
- contentWidth = mIconSize * MathUtils.min(numIcons, mMaxIconsOnLockscreen + 1);
- }
+ final float contentWidth = mIconSize * numIcons;
return getActualPaddingStart() + contentWidth + getActualPaddingEnd();
}
@VisibleForTesting
boolean shouldForceOverflow(int i, int speedBumpIndex, float iconAppearAmount,
int maxVisibleIcons) {
- if (NotificationIconContainerRefactor.isEnabled()) {
- return i >= maxVisibleIcons && iconAppearAmount > 0.0f;
- } else {
- return speedBumpIndex != -1 && i >= speedBumpIndex
- && iconAppearAmount > 0.0f || i >= maxVisibleIcons;
- }
+ return i >= maxVisibleIcons && iconAppearAmount > 0.0f;
}
@VisibleForTesting
@@ -510,7 +472,7 @@
float translationX = getActualPaddingStart();
int firstOverflowIndex = -1;
int childCount = getChildCount();
- int maxVisibleIcons = getMaxVisibleIcons(childCount);
+ int maxVisibleIcons = mMaxIcons;
float layoutEnd = getLayoutEnd();
mVisualOverflowStart = 0;
mFirstVisibleIconState = null;
@@ -592,27 +554,15 @@
}
private float getDrawingScale(View view) {
- final boolean useIncreasedScale = NotificationIconContainerRefactor.isEnabled()
- ? mUseIncreasedIconScale
- : mOnLockScreen;
- return useIncreasedScale && view instanceof StatusBarIconView
+ return mUseIncreasedIconScale && view instanceof StatusBarIconView
? ((StatusBarIconView) view).getIconScaleIncreased()
: 1f;
}
public void setUseIncreasedIconScale(boolean useIncreasedIconScale) {
- if (NotificationIconContainerRefactor.isUnexpectedlyInLegacyMode()) return;
mUseIncreasedIconScale = useIncreasedIconScale;
}
- private int getMaxVisibleIcons(int childCount) {
- if (NotificationIconContainerRefactor.isEnabled()) {
- return mMaxIcons;
- } else {
- return mOnLockScreen ? mMaxIconsOnAod : mIsStaticLayout ? mMaxStaticIcons : childCount;
- }
- }
-
private float getLayoutEnd() {
return getActualWidth() - getActualPaddingEnd();
}
@@ -689,50 +639,11 @@
mChangingViewPositions = changingViewPositions;
}
- public void setDozing(boolean dozing, boolean animate, long delay) {
- NotificationIconContainerRefactor.assertInLegacyMode();
- setDozing(dozing, animate, delay, /* endRunnable= */ null);
- }
-
- private void setDozing(boolean dozing, boolean animate, long delay,
- @Nullable Runnable endRunnable) {
- NotificationIconContainerRefactor.assertInLegacyMode();
- mDozing = dozing;
- mDisallowNextAnimation |= !animate;
- final int childCount = getChildCount();
- // Track all the child invocations of setDozing, invoking the top-level endRunnable once
- // they have all completed.
- final Runnable onChildCompleted = endRunnable == null ? null : new Runnable() {
- private int mPendingCallbacks = childCount;
-
- @Override
- public void run() {
- if (--mPendingCallbacks == 0) {
- endRunnable.run();
- }
- }
- };
- for (int i = 0; i < childCount; i++) {
- View view = getChildAt(i);
- if (view instanceof StatusBarIconView) {
- ((StatusBarIconView) view).setDozing(dozing, animate, delay, onChildCompleted);
- } else if (onChildCompleted != null) {
- onChildCompleted.run();
- }
- }
- }
-
public IconState getIconState(StatusBarIconView icon) {
return mIconStates.get(icon);
}
- public void setSpeedBumpIndex(int speedBumpIndex) {
- NotificationIconContainerRefactor.assertInLegacyMode();
- mSpeedBumpIndex = speedBumpIndex;
- }
-
public void setMaxIconsAmount(int maxIcons) {
- if (NotificationIconContainerRefactor.isUnexpectedlyInLegacyMode()) return;
mMaxIcons = maxIcons;
}
@@ -754,36 +665,18 @@
mAnimationsEnabled = enabled;
}
- public void setReplacingIconsLegacy(ArrayMap<String, ArrayList<StatusBarIcon>> replacingIcons) {
- NotificationIconContainerRefactor.assertInLegacyMode();
- mReplacingIconsLegacy = replacingIcons;
- }
-
public void setReplacingIcons(ArrayMap<String, StatusBarIcon> replacingIcons) {
- if (NotificationIconContainerRefactor.isUnexpectedlyInLegacyMode()) return;
mReplacingIcons = replacingIcons;
}
- @Deprecated
- public void showIconIsolatedLegacy(StatusBarIconView icon, boolean animated) {
- NotificationIconContainerRefactor.assertInLegacyMode();
- if (animated) {
- mIsolatedIconForAnimation = icon != null ? icon : mIsolatedIcon;
- }
- mIsolatedIcon = icon;
- updateState();
- }
-
public void showIconIsolatedAnimated(StatusBarIconView icon,
@Nullable Runnable onAnimationEnd) {
- if (NotificationIconContainerRefactor.isUnexpectedlyInLegacyMode()) return;
mIsolatedIconForAnimation = icon != null ? icon : mIsolatedIcon;
mIsolatedIconAnimationEndRunnable = onAnimationEnd;
showIconIsolated(icon);
}
public void showIconIsolated(StatusBarIconView icon) {
- if (NotificationIconContainerRefactor.isUnexpectedlyInLegacyMode()) return;
mIsolatedIcon = icon;
updateState();
}
@@ -795,23 +688,7 @@
}
}
- /**
- * Set whether the device is on the lockscreen and which lockscreen mode the device is
- * configured to. Depending on these values, the layout of the AOD icons change.
- */
- public void setOnLockScreen(boolean onLockScreen) {
- NotificationIconContainerRefactor.assertInLegacyMode();
- mOnLockScreen = onLockScreen;
- }
-
- @Deprecated
- public void setInNotificationIconShelf(boolean inShelf) {
- NotificationIconContainerRefactor.assertInLegacyMode();
- mOverrideIconColor = inShelf;
- }
-
public void setOverrideIconColor(boolean override) {
- if (NotificationIconContainerRefactor.isUnexpectedlyInLegacyMode()) return;
mOverrideIconColor = override;
}
@@ -922,14 +799,9 @@
}
}
icon.setVisibleState(visibleState, animationsAllowed);
- if (NotificationIconContainerRefactor.isEnabled()) {
- if (mOverrideIconColor) {
- icon.setIconColor(mThemedTextColorPrimary,
- /* animate= */ needsCannedAnimation && animationsAllowed);
- }
- } else {
- icon.setIconColor(mOverrideIconColor ? mThemedTextColorPrimary : iconColor,
- needsCannedAnimation && animationsAllowed);
+ if (mOverrideIconColor) {
+ icon.setIconColor(mThemedTextColorPrimary,
+ /* animate= */ needsCannedAnimation && animationsAllowed);
}
if (animate) {
animateTo(icon, animationProperties);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index 6b47ac1..8115c36 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -17,7 +17,6 @@
package com.android.systemui.statusbar.phone;
-import static com.android.systemui.Flags.truncatedStatusBarIconsFix;
import android.annotation.Nullable;
import android.content.Context;
@@ -108,9 +107,7 @@
Dependency.get(DarkIconDispatcher.class).addDarkReceiver(mClock);
if (updateDisplayParameters()) {
updateLayoutForCutout();
- if (truncatedStatusBarIconsFix()) {
- updateWindowHeight();
- }
+ updateWindowHeight();
}
}
@@ -135,9 +132,7 @@
updateLayoutForCutout();
requestLayout();
}
- if (truncatedStatusBarIconsFix()) {
- updateWindowHeight();
- }
+ updateWindowHeight();
}
void onDensityOrFontScaleChanged() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java
index 07c190d..5be4ba2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java
@@ -59,8 +59,6 @@
import com.android.systemui.statusbar.events.SystemStatusAnimationCallback;
import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler;
import com.android.systemui.statusbar.notification.icon.ui.viewbinder.NotificationIconContainerStatusBarViewBinder;
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
-import com.android.systemui.statusbar.phone.NotificationIconAreaController;
import com.android.systemui.statusbar.phone.NotificationIconContainer;
import com.android.systemui.statusbar.phone.PhoneStatusBarView;
import com.android.systemui.statusbar.phone.StatusBarHideIconsForBouncerManager;
@@ -140,7 +138,6 @@
private final OngoingCallController mOngoingCallController;
private final SystemStatusAnimationScheduler mAnimationScheduler;
private final StatusBarLocationPublisher mLocationPublisher;
- private final NotificationIconAreaController mNotificationIconAreaController;
private final ShadeExpansionStateManager mShadeExpansionStateManager;
private final StatusBarIconController mStatusBarIconController;
private final CarrierConfigTracker mCarrierConfigTracker;
@@ -237,7 +234,6 @@
OngoingCallController ongoingCallController,
SystemStatusAnimationScheduler animationScheduler,
StatusBarLocationPublisher locationPublisher,
- NotificationIconAreaController notificationIconAreaController,
ShadeExpansionStateManager shadeExpansionStateManager,
StatusBarIconController statusBarIconController,
DarkIconManager.Factory darkIconManagerFactory,
@@ -262,7 +258,6 @@
mOngoingCallController = ongoingCallController;
mAnimationScheduler = animationScheduler;
mLocationPublisher = locationPublisher;
- mNotificationIconAreaController = notificationIconAreaController;
mShadeExpansionStateManager = shadeExpansionStateManager;
mStatusBarIconController = statusBarIconController;
mCollapsedStatusBarViewModel = collapsedStatusBarViewModel;
@@ -313,18 +308,14 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mStatusBarWindowStateController.addListener(mStatusBarWindowStateListener);
- if (NotificationIconContainerRefactor.isEnabled()) {
- mDemoModeController.addCallback(mDemoModeCallback);
- }
+ mDemoModeController.addCallback(mDemoModeCallback);
}
@Override
public void onDestroy() {
super.onDestroy();
mStatusBarWindowStateController.removeListener(mStatusBarWindowStateListener);
- if (NotificationIconContainerRefactor.isEnabled()) {
- mDemoModeController.removeCallback(mDemoModeCallback);
- }
+ mDemoModeController.removeCallback(mDemoModeCallback);
}
@Override
@@ -471,11 +462,9 @@
mStartableStates.put(startable, Startable.State.STOPPED);
}
mDumpManager.unregisterDumpable(getClass().getSimpleName());
- if (NotificationIconContainerRefactor.isEnabled()) {
- if (mNicBindingDisposable != null) {
- mNicBindingDisposable.dispose();
- mNicBindingDisposable = null;
- }
+ if (mNicBindingDisposable != null) {
+ mNicBindingDisposable.dispose();
+ mNicBindingDisposable = null;
}
}
@@ -483,22 +472,12 @@
public void initNotificationIconArea() {
Trace.beginSection("CollapsedStatusBarFragment#initNotifIconArea");
ViewGroup notificationIconArea = mStatusBar.requireViewById(R.id.notification_icon_area);
- if (NotificationIconContainerRefactor.isEnabled()) {
- LayoutInflater.from(getContext())
- .inflate(R.layout.notification_icon_area, notificationIconArea, true);
- NotificationIconContainer notificationIcons =
- notificationIconArea.requireViewById(R.id.notificationIcons);
- mNotificationIconAreaInner = notificationIcons;
- mNicBindingDisposable = mNicViewBinder.bindWhileAttached(notificationIcons);
- } else {
- mNotificationIconAreaInner =
- mNotificationIconAreaController.getNotificationInnerAreaView();
- if (mNotificationIconAreaInner.getParent() != null) {
- ((ViewGroup) mNotificationIconAreaInner.getParent())
- .removeView(mNotificationIconAreaInner);
- }
- notificationIconArea.addView(mNotificationIconAreaInner);
- }
+ LayoutInflater.from(getContext())
+ .inflate(R.layout.notification_icon_area, notificationIconArea, true);
+ NotificationIconContainer notificationIcons =
+ notificationIconArea.requireViewById(R.id.notificationIcons);
+ mNotificationIconAreaInner = notificationIcons;
+ mNicBindingDisposable = mNicViewBinder.bindWhileAttached(notificationIcons);
updateNotificationIconAreaAndOngoingActivityChip(/* animate= */ false);
Trace.endSection();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ui/dialog/viewmodel/ModesDialogViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ui/dialog/viewmodel/ModesDialogViewModel.kt
index 9422878f6..b7531b0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/ui/dialog/viewmodel/ModesDialogViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/ui/dialog/viewmodel/ModesDialogViewModel.kt
@@ -23,9 +23,9 @@
import android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID
import com.android.settingslib.notification.modes.EnableZenModeDialog
import com.android.settingslib.notification.modes.ZenMode
-import com.android.settingslib.notification.modes.ZenModeDialogMetricsLogger
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
+import com.android.systemui.qs.tiles.dialog.QSZenModeDialogMetricsLogger
import com.android.systemui.res.R
import com.android.systemui.statusbar.phone.SystemUIDialog
import com.android.systemui.statusbar.policy.domain.interactor.ZenModeInteractor
@@ -50,7 +50,7 @@
@Background val bgDispatcher: CoroutineDispatcher,
private val dialogDelegate: ModesDialogDelegate,
) {
- private val zenDialogMetricsLogger = ZenModeDialogMetricsLogger(context)
+ private val zenDialogMetricsLogger = QSZenModeDialogMetricsLogger(context)
// Modes that should be displayed in the dialog
private val visibleModes: Flow<List<ZenMode>> =
diff --git a/packages/SystemUI/src/com/android/systemui/util/sensors/ProximityCheck.java b/packages/SystemUI/src/com/android/systemui/util/sensors/ProximityCheck.java
index 373417b..5b9a6c5 100644
--- a/packages/SystemUI/src/com/android/systemui/util/sensors/ProximityCheck.java
+++ b/packages/SystemUI/src/com/android/systemui/util/sensors/ProximityCheck.java
@@ -86,13 +86,15 @@
}
private void onProximityEvent(ThresholdSensorEvent proximityEvent) {
+ // Move the callbacks to a local to avoid ConcurrentModificationException
List<Consumer<Boolean>> oldCallbacks = mCallbacks;
mCallbacks = new ArrayList<>();
+ // Unregister from the ProximitySensor to ensure a re-entrant check will re-register
+ unregister();
+ // Notify the callbacks
oldCallbacks.forEach(
booleanConsumer ->
booleanConsumer.accept(
proximityEvent == null ? null : proximityEvent.getBelow()));
- unregister();
- mRegistered.set(false);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerBaseTest.java
index 319b615..2bb9e68 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerBaseTest.java
@@ -55,7 +55,6 @@
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController;
import com.android.systemui.statusbar.notification.icon.ui.viewbinder.NotificationIconContainerAlwaysOnDisplayViewBinder;
-import com.android.systemui.statusbar.phone.NotificationIconAreaController;
import com.android.systemui.statusbar.phone.NotificationIconContainer;
import com.android.systemui.util.concurrency.FakeExecutor;
import com.android.systemui.util.settings.SecureSettings;
@@ -78,8 +77,6 @@
@Mock
KeyguardSliceViewController mKeyguardSliceViewController;
@Mock
- NotificationIconAreaController mNotificationIconAreaController;
- @Mock
LockscreenSmartspaceController mSmartspaceController;
@Mock
@@ -176,7 +173,6 @@
mStatusBarStateController,
mClockRegistry,
mKeyguardSliceViewController,
- mNotificationIconAreaController,
mSmartspaceController,
mock(NotificationIconContainerAlwaysOnDisplayViewBinder.class),
mKeyguardUnlockAnimationController,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt
index 512d946..534f25c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt
@@ -503,11 +503,13 @@
collectLastValue(kosmos.promptViewModel.iconViewModel.contentDescriptionId)
val shouldAnimateIconView by
collectLastValue(kosmos.promptViewModel.iconViewModel.shouldAnimateIconView)
+ val message by collectLastValue(kosmos.promptViewModel.message)
verifyIconSize()
kosmos.promptViewModel.showAuthenticated(
modality = testCase.authenticatedModality,
- dismissAfterDelay = DELAY
+ dismissAfterDelay = DELAY,
+ "TEST"
)
if (testCase.isFingerprintOnly) {
@@ -531,6 +533,7 @@
assertThat(iconContentDescriptionId)
.isEqualTo(R.string.biometric_dialog_face_icon_description_authenticated)
assertThat(shouldAnimateIconView).isEqualTo(true)
+ assertThat(message).isEqualTo(PromptMessage.Empty)
}
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/interactor/OccludingAppDeviceEntryInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/interactor/OccludingAppDeviceEntryInteractorTest.kt
index 79e312f..77337d3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/interactor/OccludingAppDeviceEntryInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/interactor/OccludingAppDeviceEntryInteractorTest.kt
@@ -21,8 +21,12 @@
import android.hardware.fingerprint.FingerprintManager
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
+import com.android.compose.animation.scene.ObservableTransitionState
import com.android.systemui.SysuiTestCase
import com.android.systemui.bouncer.data.repository.keyguardBouncerRepository
+import com.android.systemui.communal.data.repository.communalSceneRepository
+import com.android.systemui.communal.data.repository.fakeCommunalSceneRepository
+import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.data.repository.biometricSettingsRepository
import com.android.systemui.keyguard.data.repository.deviceEntryFingerprintAuthRepository
@@ -41,6 +45,7 @@
import com.android.systemui.util.mockito.any
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Test
@@ -65,6 +70,7 @@
private val bouncerRepository = kosmos.keyguardBouncerRepository
private val powerRepository = kosmos.fakePowerRepository
private val biometricSettingsRepository = kosmos.biometricSettingsRepository
+ private val communalSceneRepository = kosmos.communalSceneRepository
private val mockedContext = kosmos.mockedContext
private val mockedActivityStarter = kosmos.activityStarter
@@ -143,6 +149,20 @@
}
@Test
+ fun lockout_onOccludingApp_onCommunal_neverGoToHomeScreen() =
+ testScope.runTest {
+ givenOnOccludingApp(isOnOccludingApp = true, isOnCommunal = true)
+ fingerprintAuthRepository.setAuthenticationStatus(
+ ErrorFingerprintAuthenticationStatus(
+ FingerprintManager.FINGERPRINT_ERROR_LOCKOUT,
+ "lockoutTest"
+ )
+ )
+ runCurrent()
+ verifyNeverGoToHomeScreen()
+ }
+
+ @Test
fun message_fpFailOnOccludingApp_thenNotOnOccludingApp() =
testScope.runTest {
val message by collectLastValue(underTest.message)
@@ -261,7 +281,10 @@
assertThat(message).isNull()
}
- private suspend fun givenOnOccludingApp(isOnOccludingApp: Boolean) {
+ private suspend fun givenOnOccludingApp(
+ isOnOccludingApp: Boolean,
+ isOnCommunal: Boolean = false
+ ) {
powerRepository.setInteractive(true)
keyguardRepository.setIsDozing(false)
keyguardRepository.setKeyguardOccluded(isOnOccludingApp)
@@ -270,6 +293,14 @@
bouncerRepository.setPrimaryShow(!isOnOccludingApp)
bouncerRepository.setAlternateVisible(!isOnOccludingApp)
+ kosmos.fakeCommunalSceneRepository.setTransitionState(
+ flowOf(
+ ObservableTransitionState.Idle(
+ if (isOnCommunal) CommunalScenes.Communal else CommunalScenes.Blank
+ )
+ )
+ )
+
if (isOnOccludingApp) {
kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
from = KeyguardState.LOCKSCREEN,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegateTest.kt b/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegateTest.kt
index 59602dc..6495b66 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegateTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/mediaprojection/permission/SystemCastPermissionDialogDelegateTest.kt
@@ -29,6 +29,7 @@
import com.android.systemui.res.R
import com.android.systemui.statusbar.phone.AlertDialogWithDelegate
import com.android.systemui.statusbar.phone.SystemUIDialog
+import com.google.common.truth.Truth.assertThat
import kotlin.test.assertEquals
import org.junit.After
import org.junit.Test
@@ -117,6 +118,36 @@
assertEquals(context.getString(resIdFullScreen), secondOptionText)
}
+ @Test
+ fun startButtonText_entireScreenSelected() {
+ setUpAndShowDialog()
+ onSpinnerItemSelected(ENTIRE_SCREEN)
+
+ val startButtonText = dialog.requireViewById<TextView>(android.R.id.button1).text
+
+ assertThat(startButtonText)
+ .isEqualTo(
+ context.getString(
+ R.string.media_projection_entry_cast_permission_dialog_continue_entire_screen
+ )
+ )
+ }
+
+ @Test
+ fun startButtonText_singleAppSelected() {
+ setUpAndShowDialog()
+ onSpinnerItemSelected(SINGLE_APP)
+
+ val startButtonText = dialog.requireViewById<TextView>(android.R.id.button1).text
+
+ assertThat(startButtonText)
+ .isEqualTo(
+ context.getString(
+ R.string.media_projection_entry_generic_permission_dialog_continue_single_app
+ )
+ )
+ }
+
private fun setUpAndShowDialog(
mediaProjectionConfig: MediaProjectionConfig? = null,
overrideDisableSingleAppOption: Boolean = false,
@@ -144,4 +175,10 @@
delegate.onCreate(dialog, savedInstanceState = null)
dialog.show()
}
+
+ private fun onSpinnerItemSelected(position: Int) {
+ val spinner = dialog.requireViewById<Spinner>(R.id.screen_share_mode_options)
+ checkNotNull(spinner.onItemSelectedListener)
+ .onItemSelected(spinner, mock(), position, /* id= */ 0)
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java
index 4f4f0d9..2f41ac17 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java
@@ -45,6 +45,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
+import com.android.app.viewcapture.ViewCapture;
import com.android.settingslib.fuelgauge.Estimate;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher;
@@ -54,6 +55,8 @@
import com.android.systemui.settings.UserTracker;
import com.android.systemui.statusbar.CommandQueue;
+import dagger.Lazy;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -94,6 +97,7 @@
@Mock private BroadcastDispatcher mBroadcastDispatcher;
@Mock private CommandQueue mCommandQueue;
@Mock private IVrManager mVrManager;
+ @Mock private Lazy<ViewCapture> mLazyViewCapture;
@Before
public void setup() {
@@ -705,7 +709,8 @@
mEnhancedEstimates,
mWakefulnessLifecycle,
mPowerManager,
- mUserTracker);
+ mUserTracker,
+ mLazyViewCapture);
mPowerUI.mThermalService = mThermalServiceMock;
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java
index ef1c927..27a1bb5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java
@@ -24,7 +24,6 @@
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
import android.app.Notification;
import android.app.NotificationManager;
@@ -41,7 +40,6 @@
import com.android.systemui.statusbar.NotificationListener.NotificationHandler;
import com.android.systemui.statusbar.data.repository.NotificationListenerSettingsRepository;
import com.android.systemui.statusbar.domain.interactor.SilentNotificationStatusIconsVisibilityInteractor;
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
import com.android.systemui.util.concurrency.FakeExecutor;
import com.android.systemui.util.time.FakeSystemClock;
@@ -149,30 +147,4 @@
verify(mNotificationHandler).onNotificationRankingUpdate(eq(ranking3));
verifyNoMoreInteractions(mNotificationHandler);
}
-
- @Test
- public void testOnConnectReadStatusBarSetting() {
- mSetFlagsRule.disableFlags(NotificationIconContainerRefactor.FLAG_NAME);
- NotificationListener.NotificationSettingsListener settingsListener =
- mock(NotificationListener.NotificationSettingsListener.class);
- mListener.addNotificationSettingsListener(settingsListener);
-
- when(mNotificationManager.shouldHideSilentStatusBarIcons()).thenReturn(true);
-
- mListener.onListenerConnected();
-
- verify(settingsListener).onStatusBarIconsBehaviorChanged(true);
- }
-
- @Test
- public void testOnStatusBarIconsBehaviorChanged() {
- mSetFlagsRule.disableFlags(NotificationIconContainerRefactor.FLAG_NAME);
- NotificationListener.NotificationSettingsListener settingsListener =
- mock(NotificationListener.NotificationSettingsListener.class);
- mListener.addNotificationSettingsListener(settingsListener);
-
- mListener.onSilentStatusBarIconsVisibilityChanged(true);
-
- verify(settingsListener).onStatusBarIconsBehaviorChanged(true);
- }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/StackCoordinatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/StackCoordinatorTest.kt
index c7513de..ad6aca1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/StackCoordinatorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/StackCoordinatorTest.kt
@@ -34,10 +34,8 @@
import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor
import com.android.systemui.statusbar.notification.domain.interactor.RenderNotificationListInteractor
import com.android.systemui.statusbar.notification.footer.shared.FooterViewRefactor
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor
import com.android.systemui.statusbar.notification.stack.BUCKET_ALERTING
import com.android.systemui.statusbar.notification.stack.BUCKET_SILENT
-import com.android.systemui.statusbar.phone.NotificationIconAreaController
import com.android.systemui.statusbar.policy.SensitiveNotificationProtectionController
import com.android.systemui.util.mockito.eq
import com.android.systemui.util.mockito.withArgCaptor
@@ -47,8 +45,8 @@
import org.mockito.Mock
import org.mockito.Mockito.verify
import org.mockito.Mockito.verifyZeroInteractions
-import org.mockito.MockitoAnnotations.initMocks
import org.mockito.Mockito.`when` as whenever
+import org.mockito.MockitoAnnotations.initMocks
@SmallTest
@RunWith(AndroidJUnit4::class)
@@ -61,10 +59,10 @@
@Mock private lateinit var pipeline: NotifPipeline
@Mock private lateinit var groupExpansionManagerImpl: GroupExpansionManagerImpl
- @Mock private lateinit var notificationIconAreaController: NotificationIconAreaController
@Mock private lateinit var renderListInteractor: RenderNotificationListInteractor
@Mock private lateinit var activeNotificationsInteractor: ActiveNotificationsInteractor
- @Mock private lateinit var sensitiveNotificationProtectionController:
+ @Mock
+ private lateinit var sensitiveNotificationProtectionController:
SensitiveNotificationProtectionController
@Mock private lateinit var stackController: NotifStackController
@Mock private lateinit var section: NotifSection
@@ -73,14 +71,12 @@
fun setUp() {
initMocks(this)
- whenever(sensitiveNotificationProtectionController.isSensitiveStateActive)
- .thenReturn(false)
+ whenever(sensitiveNotificationProtectionController.isSensitiveStateActive).thenReturn(false)
entry = NotificationEntryBuilder().setSection(section).build()
coordinator =
StackCoordinator(
groupExpansionManagerImpl,
- notificationIconAreaController,
renderListInteractor,
activeNotificationsInteractor,
sensitiveNotificationProtectionController,
@@ -92,15 +88,7 @@
}
@Test
- @DisableFlags(NotificationIconContainerRefactor.FLAG_NAME)
- fun testUpdateNotificationIcons() {
- afterRenderListListener.onAfterRenderList(listOf(entry), stackController)
- verify(notificationIconAreaController).updateNotificationIcons(eq(listOf(entry)))
- }
-
- @Test
- @EnableFlags(NotificationIconContainerRefactor.FLAG_NAME)
- fun testSetRenderedListOnInteractor_iconContainerFlagOn() {
+ fun testSetRenderedListOnInteractor() {
afterRenderListListener.onAfterRenderList(listOf(entry), stackController)
verify(renderListInteractor).setRenderedList(eq(listOf(entry)))
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt
index c1f2cb77..e4945fc 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt
@@ -1,6 +1,5 @@
package com.android.systemui.statusbar.notification.stack
-import android.platform.test.annotations.DisableFlags
import android.service.notification.StatusBarNotification
import android.testing.TestableLooper.RunWithLooper
import android.view.LayoutInflater
@@ -21,7 +20,6 @@
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.ExpandableView
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor
import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm.StackScrollAlgorithmState
import com.android.systemui.util.mockito.mock
import junit.framework.Assert.assertEquals
@@ -72,32 +70,6 @@
}
@Test
- @DisableFlags(NotificationIconContainerRefactor.FLAG_NAME)
- fun testShadeWidth_BasedOnFractionToShade() {
- setFractionToShade(0f)
- setOnLockscreen(true)
-
- shelf.updateActualWidth(/* fractionToShade */ 0f, /* shortestWidth */ 10f)
- assertTrue(shelf.actualWidth == 10)
-
- shelf.updateActualWidth(/* fractionToShade */ 0.5f, /* shortestWidth */ 10f)
- assertTrue(shelf.actualWidth == 20)
-
- shelf.updateActualWidth(/* fractionToShade */ 1f, /* shortestWidth */ 10f)
- assertTrue(shelf.actualWidth == 30)
- }
-
- @Test
- @DisableFlags(NotificationIconContainerRefactor.FLAG_NAME)
- fun testShelfIsLong_WhenNotOnLockscreen() {
- setFractionToShade(0f)
- setOnLockscreen(false)
-
- shelf.updateActualWidth(/* fraction */ 0f, /* shortestWidth */ 10f)
- assertTrue(shelf.actualWidth == 30)
- }
-
- @Test
fun testX_inViewForClick() {
val isXInView =
shelf.isXInView(/* localX */ 5f, /* slop */ 5f, /* left */ 0f, /* right */ 10f)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
index bd9cccd..e9c16c2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java
@@ -295,7 +295,6 @@
@Mock private Bubbles mBubbles;
@Mock private NoteTaskController mNoteTaskController;
@Mock private NotificationShadeWindowController mNotificationShadeWindowController;
- @Mock private NotificationIconAreaController mNotificationIconAreaController;
@Mock private NotificationShadeWindowViewController mNotificationShadeWindowViewController;
@Mock private Lazy<NotificationShadeWindowViewController>
mNotificationShadeWindowViewControllerLazy;
@@ -580,7 +579,6 @@
mDemoModeController,
mNotificationShadeDepthControllerLazy,
mStatusBarTouchableRegionManager,
- mNotificationIconAreaController,
mBrightnessSliderFactory,
mScreenOffAnimationController,
mWallpaperController,
@@ -1157,22 +1155,13 @@
}
@Test
- @EnableFlags(com.android.systemui.Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX)
- public void updateResources_flagEnabled_doesNotUpdateStatusBarWindowHeight() {
+ public void updateResources_doesNotUpdateStatusBarWindowHeight() {
mCentralSurfaces.updateResources();
verify(mStatusBarWindowController, never()).refreshStatusBarHeight();
}
@Test
- @DisableFlags(com.android.systemui.Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX)
- public void updateResources_flagDisabled_updatesStatusBarWindowHeight() {
- mCentralSurfaces.updateResources();
-
- verify(mStatusBarWindowController).refreshStatusBarHeight();
- }
-
- @Test
@EnableSceneContainer
public void brightnesShowingChanged_flagEnabled_ScrimControllerNotified() {
mCentralSurfaces.registerCallbacks();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java
index 0d06b64..dd03ab3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceControllerTest.java
@@ -110,7 +110,6 @@
mNotificationRoundnessManager = mock(NotificationRoundnessManager.class);
when(mShadeViewController.getShadeHeadsUpTracker()).thenReturn(mShadeHeadsUpTracker);
mHeadsUpAppearanceController = new HeadsUpAppearanceController(
- mock(NotificationIconAreaController.class),
mHeadsUpManager,
mStatusbarStateController,
mPhoneStatusBarTransitions,
@@ -197,7 +196,6 @@
when(mStackScrollerController.getExpandedHeight()).thenReturn(expandedHeight);
HeadsUpAppearanceController newController = new HeadsUpAppearanceController(
- mock(NotificationIconAreaController.class),
mHeadsUpManager,
mStatusbarStateController,
mPhoneStatusBarTransitions,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/LegacyNotificationIconAreaControllerImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/LegacyNotificationIconAreaControllerImplTest.java
deleted file mode 100644
index 8dfbb37..0000000
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/LegacyNotificationIconAreaControllerImplTest.java
+++ /dev/null
@@ -1,129 +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.systemui.statusbar.phone;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.platform.test.annotations.DisableFlags;
-import android.testing.TestableLooper;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SmallTest;
-
-import com.android.systemui.Flags;
-import com.android.systemui.SysuiTestCase;
-import com.android.systemui.demomode.DemoModeController;
-import com.android.systemui.flags.FeatureFlags;
-import com.android.systemui.plugins.DarkIconDispatcher;
-import com.android.systemui.plugins.statusbar.StatusBarStateController;
-import com.android.systemui.statusbar.NotificationListener;
-import com.android.systemui.statusbar.NotificationMediaManager;
-import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
-import com.android.systemui.statusbar.notification.collection.provider.SectionStyleProvider;
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor;
-import com.android.systemui.statusbar.window.StatusBarWindowController;
-import com.android.wm.shell.bubbles.Bubbles;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-import java.util.Optional;
-
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-@TestableLooper.RunWithLooper
-@DisableFlags(NotificationIconContainerRefactor.FLAG_NAME)
-public class LegacyNotificationIconAreaControllerImplTest extends SysuiTestCase {
-
- @Mock
- private NotificationListener mListener;
- @Mock
- StatusBarStateController mStatusBarStateController;
- @Mock
- NotificationWakeUpCoordinator mWakeUpCoordinator;
- @Mock
- KeyguardBypassController mKeyguardBypassController;
- @Mock
- NotificationMediaManager mNotificationMediaManager;
- @Mock
- DozeParameters mDozeParameters;
- @Mock
- SectionStyleProvider mSectionStyleProvider;
- @Mock
- DarkIconDispatcher mDarkIconDispatcher;
- @Mock
- StatusBarWindowController mStatusBarWindowController;
- @Mock
- ScreenOffAnimationController mScreenOffAnimationController;
- private LegacyNotificationIconAreaControllerImpl mController;
- @Mock
- private Bubbles mBubbles;
- @Mock private DemoModeController mDemoModeController;
- @Mock
- private NotificationIconContainer mAodIcons;
- @Mock
- private FeatureFlags mFeatureFlags;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- mController = new LegacyNotificationIconAreaControllerImpl(
- mContext,
- mStatusBarStateController,
- mWakeUpCoordinator,
- mKeyguardBypassController,
- mNotificationMediaManager,
- mListener,
- mDozeParameters,
- mSectionStyleProvider,
- Optional.of(mBubbles),
- mDemoModeController,
- mDarkIconDispatcher,
- mFeatureFlags,
- mStatusBarWindowController,
- mScreenOffAnimationController);
- }
-
- @Test
- public void testNotificationIcons_settingHideIcons() {
- mController.mSettingsListener.onStatusBarIconsBehaviorChanged(true);
-
- assertFalse(mController.shouldShouldLowPriorityIcons());
- }
-
- @Test
- public void testNotificationIcons_settingShowIcons() {
- mController.mSettingsListener.onStatusBarIconsBehaviorChanged(false);
-
- assertTrue(mController.shouldShouldLowPriorityIcons());
- }
-
- @Test
- @DisableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
- public void testAppearResetsTranslation() {
- mController.setupAodIcons(mAodIcons);
- when(mDozeParameters.shouldControlScreenOff()).thenReturn(false);
- mController.appearAodIcons();
- verify(mAodIcons).setTranslationY(0);
- verify(mAodIcons).setAlpha(1.0f);
- }
-}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationIconContainerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationIconContainerTest.kt
index 9d97e5a..15958ef 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationIconContainerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationIconContainerTest.kt
@@ -23,7 +23,6 @@
import com.android.systemui.statusbar.StatusBarIconView
import com.android.systemui.statusbar.StatusBarIconView.STATE_DOT
import com.android.systemui.statusbar.StatusBarIconView.STATE_HIDDEN
-import com.android.systemui.statusbar.notification.shared.NotificationIconContainerRefactor
import junit.framework.Assert.assertEquals
import junit.framework.Assert.assertFalse
import junit.framework.Assert.assertTrue
@@ -73,18 +72,6 @@
}
@Test
- fun calculateWidthFor_fiveIcons_widthForFourIcons() {
- mSetFlagsRule.disableFlags(NotificationIconContainerRefactor.FLAG_NAME)
- iconContainer.setActualPaddingStart(10f)
- iconContainer.setActualPaddingEnd(10f)
- iconContainer.setIconSize(10)
- assertEquals(
- /* expected= */ iconContainer.calculateWidthFor(/* numIcons= */ 5f),
- /* actual= */ 60f
- )
- }
-
- @Test
fun calculateIconXTranslations_shortShelfOneIcon_atCorrectXWithoutOverflowDot() {
iconContainer.setActualPaddingStart(10f)
iconContainer.setActualPaddingEnd(10f)
@@ -213,19 +200,6 @@
}
@Test
- fun shouldForceOverflow_appearingAboveSpeedBump_true() {
- mSetFlagsRule.disableFlags(NotificationIconContainerRefactor.FLAG_NAME)
- val forceOverflow =
- iconContainer.shouldForceOverflow(
- /* i= */ 1,
- /* speedBumpIndex= */ 0,
- /* iconAppearAmount= */ 1f,
- /* maxVisibleIcons= */ 5
- )
- assertTrue(forceOverflow)
- }
-
- @Test
fun shouldForceOverflow_moreThanMaxVisible_true() {
val forceOverflow =
iconContainer.shouldForceOverflow(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewTest.kt
index e670884..eae4f23 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/PhoneStatusBarViewTest.kt
@@ -30,7 +30,6 @@
import android.view.WindowInsets
import android.widget.FrameLayout
import androidx.test.filters.SmallTest
-import com.android.systemui.Flags
import com.android.systemui.Gefingerpoken
import com.android.systemui.SysuiTestCase
import com.android.systemui.plugins.DarkIconDispatcher
@@ -41,7 +40,6 @@
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
-import org.mockito.Mockito.never
import org.mockito.Mockito.spy
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
@@ -123,36 +121,21 @@
}
@Test
- fun onAttachedToWindow_flagEnabled_updatesWindowHeight() {
- mSetFlagsRule.enableFlags(Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX)
-
+ fun onAttachedToWindow_updatesWindowHeight() {
view.onAttachedToWindow()
verify(windowController).refreshStatusBarHeight()
}
@Test
- fun onAttachedToWindow_flagDisabled_doesNotUpdateWindowHeight() {
- mSetFlagsRule.disableFlags(Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX)
-
- view.onAttachedToWindow()
-
- verify(windowController, never()).refreshStatusBarHeight()
- }
-
- @Test
- fun onConfigurationChanged_flagEnabled_updatesWindowHeight() {
- mSetFlagsRule.enableFlags(Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX)
-
+ fun onConfigurationChanged_updatesWindowHeight() {
view.onConfigurationChanged(Configuration())
verify(windowController).refreshStatusBarHeight()
}
@Test
- fun onConfigurationChanged_multipleCalls_flagEnabled_updatesWindowHeightMultipleTimes() {
- mSetFlagsRule.enableFlags(Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX)
-
+ fun onConfigurationChanged_multipleCalls_updatesWindowHeightMultipleTimes() {
view.onConfigurationChanged(Configuration())
view.onConfigurationChanged(Configuration())
view.onConfigurationChanged(Configuration())
@@ -162,29 +145,8 @@
}
@Test
- fun onConfigurationChanged_flagDisabled_doesNotUpdateWindowHeight() {
- mSetFlagsRule.disableFlags(Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX)
-
- view.onConfigurationChanged(Configuration())
-
- verify(windowController, never()).refreshStatusBarHeight()
- }
-
- @Test
- fun onConfigurationChanged_multipleCalls_flagDisabled_doesNotUpdateWindowHeight() {
- mSetFlagsRule.disableFlags(Flags.FLAG_TRUNCATED_STATUS_BAR_ICONS_FIX)
-
- view.onConfigurationChanged(Configuration())
- view.onConfigurationChanged(Configuration())
- view.onConfigurationChanged(Configuration())
- view.onConfigurationChanged(Configuration())
-
- verify(windowController, never()).refreshStatusBarHeight()
- }
-
- @Test
fun onAttachedToWindow_updatesLeftTopRightPaddingsBasedOnInsets() {
- val insets = Insets.of(/* left = */ 10, /* top = */ 20, /* right = */ 30, /* bottom = */ 40)
+ val insets = Insets.of(/* left= */ 10, /* top= */ 20, /* right= */ 30, /* bottom= */ 40)
whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation())
.thenReturn(insets)
@@ -198,7 +160,7 @@
@Test
fun onConfigurationChanged_updatesLeftTopRightPaddingsBasedOnInsets() {
- val insets = Insets.of(/* left = */ 40, /* top = */ 30, /* right = */ 20, /* bottom = */ 10)
+ val insets = Insets.of(/* left= */ 40, /* top= */ 30, /* right= */ 20, /* bottom= */ 10)
whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation())
.thenReturn(insets)
@@ -213,7 +175,7 @@
@Test
fun onConfigurationChanged_noRelevantChange_doesNotUpdateInsets() {
val previousInsets =
- Insets.of(/* left = */ 40, /* top = */ 30, /* right = */ 20, /* bottom = */ 10)
+ Insets.of(/* left= */ 40, /* top= */ 30, /* right= */ 20, /* bottom= */ 10)
whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation())
.thenReturn(previousInsets)
context.orCreateTestableResources.overrideConfiguration(Configuration())
@@ -233,7 +195,7 @@
@Test
fun onConfigurationChanged_densityChanged_updatesInsets() {
val previousInsets =
- Insets.of(/* left = */ 40, /* top = */ 30, /* right = */ 20, /* bottom = */ 10)
+ Insets.of(/* left= */ 40, /* top= */ 30, /* right= */ 20, /* bottom= */ 10)
whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation())
.thenReturn(previousInsets)
val configuration = Configuration()
@@ -256,7 +218,7 @@
@Test
fun onConfigurationChanged_fontScaleChanged_updatesInsets() {
val previousInsets =
- Insets.of(/* left = */ 40, /* top = */ 30, /* right = */ 20, /* bottom = */ 10)
+ Insets.of(/* left= */ 40, /* top= */ 30, /* right= */ 20, /* bottom= */ 10)
whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation())
.thenReturn(previousInsets)
val configuration = Configuration()
@@ -291,7 +253,7 @@
@Test
fun onApplyWindowInsets_updatesLeftTopRightPaddingsBasedOnInsets() {
- val insets = Insets.of(/* left = */ 90, /* top = */ 10, /* right = */ 45, /* bottom = */ 50)
+ val insets = Insets.of(/* left= */ 90, /* top= */ 10, /* right= */ 45, /* bottom= */ 50)
whenever(contentInsetsProvider.getStatusBarContentInsetsForCurrentRotation())
.thenReturn(insets)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java
index 58ad835..bea027f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java
@@ -39,7 +39,6 @@
import android.provider.Settings;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
-import android.view.LayoutInflater;
import android.view.View;
import androidx.test.filters.SmallTest;
@@ -64,7 +63,6 @@
import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler;
import com.android.systemui.statusbar.notification.icon.ui.viewbinder.NotificationIconContainerStatusBarViewBinder;
import com.android.systemui.statusbar.phone.HeadsUpAppearanceController;
-import com.android.systemui.statusbar.phone.NotificationIconAreaController;
import com.android.systemui.statusbar.phone.StatusBarHideIconsForBouncerManager;
import com.android.systemui.statusbar.phone.StatusBarLocationPublisher;
import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentComponent;
@@ -95,7 +93,6 @@
@RunWithLooper(setAsMainLooper = true)
@SmallTest
public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
- private NotificationIconAreaController mMockNotificationAreaController;
private ShadeExpansionStateManager mShadeExpansionStateManager;
private OngoingCallController mOngoingCallController;
private SystemStatusAnimationScheduler mAnimationScheduler;
@@ -931,13 +928,11 @@
mCollapsedStatusBarViewModel = new FakeCollapsedStatusBarViewModel();
mCollapsedStatusBarViewBinder = new FakeCollapsedStatusBarViewBinder();
- setUpNotificationIconAreaController();
return new CollapsedStatusBarFragment(
mStatusBarFragmentComponentFactory,
mOngoingCallController,
mAnimationScheduler,
mLocationPublisher,
- mMockNotificationAreaController,
mShadeExpansionStateManager,
mStatusBarIconController,
mIconManagerFactory,
@@ -970,14 +965,6 @@
.thenReturn(mHeadsUpAppearanceController);
}
- private void setUpNotificationIconAreaController() {
- mMockNotificationAreaController = mock(NotificationIconAreaController.class);
- View notificationAreaInner =
- LayoutInflater.from(mContext).inflate(R.layout.notification_icon_area, null);
- when(mMockNotificationAreaController.getNotificationInnerAreaView())
- .thenReturn(notificationAreaInner);
- }
-
/**
* Configure mocks to return values consistent with the secure camera animating itself launched
* over the keyguard.
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/deviceentry/domain/interactor/OccludingAppDeviceEntryInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/deviceentry/domain/interactor/OccludingAppDeviceEntryInteractorKosmos.kt
index d5411ad..3680e65 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/deviceentry/domain/interactor/OccludingAppDeviceEntryInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/deviceentry/domain/interactor/OccludingAppDeviceEntryInteractorKosmos.kt
@@ -19,6 +19,7 @@
import android.content.mockedContext
import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor
import com.android.systemui.bouncer.domain.interactor.primaryBouncerInteractor
+import com.android.systemui.communal.domain.interactor.communalSceneInteractor
import com.android.systemui.keyguard.data.repository.deviceEntryFingerprintAuthRepository
import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor
@@ -42,5 +43,6 @@
activityStarter = activityStarter,
powerInteractor = powerInteractor,
keyguardTransitionInteractor = keyguardTransitionInteractor,
+ communalSceneInteractor = communalSceneInteractor,
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelKosmos.kt
index 550ecb3..19b32bc 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenContentViewModelKosmos.kt
@@ -20,7 +20,6 @@
import com.android.systemui.keyguard.domain.interactor.keyguardBlueprintInteractor
import com.android.systemui.keyguard.domain.interactor.keyguardClockInteractor
import com.android.systemui.kosmos.Kosmos
-import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.scene.domain.interactor.sceneContainerOcclusionInteractor
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.unfold.domain.interactor.unfoldTransitionInteractor
@@ -33,7 +32,6 @@
authController = authController,
touchHandling = keyguardTouchHandlingViewModel,
shadeInteractor = shadeInteractor,
- applicationScope = applicationCoroutineScope,
unfoldTransitionInteractor = unfoldTransitionInteractor,
occlusionInteractor = sceneContainerOcclusionInteractor,
)
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationListViewBinderKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationListViewBinderKosmos.kt
index ee3216b..bc1363a 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationListViewBinderKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/NotificationListViewBinderKosmos.kt
@@ -29,22 +29,20 @@
import com.android.systemui.statusbar.notification.stack.ui.view.notificationStatsLogger
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationListViewModel
import com.android.systemui.statusbar.notification.ui.viewbinder.headsUpNotificationViewBinder
-import com.android.systemui.statusbar.phone.notificationIconAreaController
import java.util.Optional
val Kosmos.notificationListViewBinder by Fixture {
NotificationListViewBinder(
- viewModel = notificationListViewModel,
backgroundDispatcher = testDispatcher,
+ hiderTracker = displaySwitchNotificationsHiderTracker,
configuration = configurationState,
falsingManager = falsingManager,
hunBinder = headsUpNotificationViewBinder,
- iconAreaController = notificationIconAreaController,
loggerOptional = Optional.of(notificationStatsLogger),
metricsLogger = metricsLogger,
- hiderTracker = displaySwitchNotificationsHiderTracker,
nicBinder = notificationIconContainerShelfViewBinder,
notificationActivityStarter = { notificationActivityStarter },
silentHeaderController = silentHeaderController,
+ viewModel = notificationListViewModel,
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/phone/DozeServiceHostKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/phone/DozeServiceHostKosmos.kt
index 0b5a68e..4a6757d 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/phone/DozeServiceHostKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/phone/DozeServiceHostKosmos.kt
@@ -53,7 +53,6 @@
notificationShadeWindowController,
notificationWakeUpCoordinator,
authController,
- notificationIconAreaController,
shadeLockscreenInteractor,
dozeInteractor,
)
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/phone/NotificationIconAreaControllerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/phone/NotificationIconAreaControllerKosmos.kt
deleted file mode 100644
index d44e061..0000000
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/phone/NotificationIconAreaControllerKosmos.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.statusbar.phone
-
-import com.android.systemui.kosmos.Kosmos
-import com.android.systemui.kosmos.Kosmos.Fixture
-import com.android.systemui.util.mockito.mock
-
-var Kosmos.notificationIconAreaController by Fixture { mock<NotificationIconAreaController>() }
diff --git a/ravenwood/Android.bp b/ravenwood/Android.bp
index 2de3c5e..4faf03c 100644
--- a/ravenwood/Android.bp
+++ b/ravenwood/Android.bp
@@ -280,10 +280,10 @@
src: "scripts/ravenwood-stats-checker.sh",
test_suites: ["general-tests"],
data: [
- ":framework-minus-apex.ravenwood-base{hoststubgen_framework-minus-apex_stats.csv}",
- ":framework-minus-apex.ravenwood-base{hoststubgen_framework-minus-apex_apis.csv}",
- ":framework-minus-apex.ravenwood-base{hoststubgen_framework-minus-apex_keep_all.txt}",
- ":framework-minus-apex.ravenwood-base{hoststubgen_framework-minus-apex_dump.txt}",
+ ":hoststubgen_framework-minus-apex_stats.csv",
+ ":hoststubgen_framework-minus-apex_apis.csv",
+ ":hoststubgen_framework-minus-apex_keep_all.txt",
+ ":hoststubgen_framework-minus-apex_dump.txt",
":services.core.ravenwood-base{hoststubgen_services.core_stats.csv}",
":services.core.ravenwood-base{hoststubgen_services.core_apis.csv}",
":services.core.ravenwood-base{hoststubgen_services.core_keep_all.txt}",
diff --git a/ravenwood/texts/ravenwood-framework-jarjar-rules.txt b/ravenwood/texts/ravenwood-framework-jarjar-rules.txt
index 2eeb904..afef564 100644
--- a/ravenwood/texts/ravenwood-framework-jarjar-rules.txt
+++ b/ravenwood/texts/ravenwood-framework-jarjar-rules.txt
@@ -1,2 +1 @@
-# To avoid VerifyError on nano proto files (b/324063814)
-rule com.**.nano.** devicenano.@0
+# Applying jarjar on framework-minux-apex is too slow, so we don't use jarjar for now. b/313930116
\ No newline at end of file
diff --git a/ravenwood/texts/ravenwood-framework-policies.txt b/ravenwood/texts/ravenwood-framework-policies.txt
index 9d29a05..4012bdc 100644
--- a/ravenwood/texts/ravenwood-framework-policies.txt
+++ b/ravenwood/texts/ravenwood-framework-policies.txt
@@ -9,6 +9,11 @@
# Keep all sysprops generated code implementations
class :sysprops keepclass
+# To avoid VerifyError on nano proto files (b/324063814), we rename nano proto classes.
+# Note: The "rename" directive must use shashes (/) as a package name separator.
+rename com/.*/nano/ devicenano/
+rename android/.*/nano/ devicenano/
+
# Exported to Mainline modules; cannot use annotations
class com.android.internal.util.FastXmlSerializer keepclass
class com.android.internal.util.FileRotator keepclass
diff --git a/services/companion/java/com/android/server/companion/virtual/GenericWindowPolicyController.java b/services/companion/java/com/android/server/companion/virtual/GenericWindowPolicyController.java
index 84b5c39..e57817f 100644
--- a/services/companion/java/com/android/server/companion/virtual/GenericWindowPolicyController.java
+++ b/services/companion/java/com/android/server/companion/virtual/GenericWindowPolicyController.java
@@ -33,6 +33,7 @@
import android.content.AttributionSource;
import android.content.ComponentName;
import android.content.Intent;
+import android.content.IntentSender;
import android.content.pm.ActivityInfo;
import android.os.Build;
import android.os.Handler;
@@ -51,6 +52,7 @@
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import java.util.function.Supplier;
/**
* A controller to control the policies of the windows that can be displayed on the virtual display.
@@ -73,7 +75,7 @@
*/
public interface ActivityBlockedCallback {
/** Called when an activity is blocked.*/
- void onActivityBlocked(int displayId, ActivityInfo activityInfo);
+ void onActivityBlocked(int displayId, ActivityInfo activityInfo, IntentSender intentSender);
}
private static final ComponentName BLOCKED_APP_STREAMING_COMPONENT =
new ComponentName("android", BlockedAppStreamingActivity.class.getName());
@@ -282,7 +284,8 @@
@Override
public boolean canActivityBeLaunched(@NonNull ActivityInfo activityInfo,
@Nullable Intent intent, @WindowConfiguration.WindowingMode int windowingMode,
- int launchingFromDisplayId, boolean isNewTask) {
+ int launchingFromDisplayId, boolean isNewTask, boolean isResultExpected,
+ @Nullable Supplier<IntentSender> intentSender) {
if (mIntentListenerCallback != null && intent != null
&& mIntentListenerCallback.shouldInterceptIntent(intent)) {
logActivityLaunchBlocked("Virtual device intercepting intent");
@@ -290,7 +293,10 @@
}
if (!canContainActivity(activityInfo, windowingMode, launchingFromDisplayId,
isNewTask)) {
- notifyActivityBlocked(activityInfo);
+ // If the sender of the original intent expects a result to be reported, do not pass the
+ // intent sender to the client callback. As the launch is blocked, the caller already
+ // received that activity result.
+ notifyActivityBlocked(activityInfo, isResultExpected ? null : intentSender);
return false;
}
return true;
@@ -381,7 +387,7 @@
// TODO(b/201712607): Add checks for the apps that use SurfaceView#setSecure.
if ((windowFlags & FLAG_SECURE) != 0
|| (systemWindowFlags & SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS) != 0) {
- notifyActivityBlocked(activityInfo);
+ notifyActivityBlocked(activityInfo, /* intentSender= */ null);
return false;
}
}
@@ -454,13 +460,15 @@
&& mDisplayCategories.contains(activityInfo.requiredDisplayCategory);
}
- private void notifyActivityBlocked(ActivityInfo activityInfo) {
+ private void notifyActivityBlocked(
+ ActivityInfo activityInfo, Supplier<IntentSender> intentSender) {
int displayId = waitAndGetDisplayId();
// Don't trigger activity blocked callback for mirror displays, because we can't show
// any activity or presentation on it anyway.
if (!waitAndGetIsMirrorDisplay() && mActivityBlockedCallback != null
&& displayId != INVALID_DISPLAY) {
- mActivityBlockedCallback.onActivityBlocked(displayId, activityInfo);
+ mActivityBlockedCallback.onActivityBlocked(displayId, activityInfo,
+ intentSender == null ? null : intentSender.get());
}
Counter.logIncrementWithUid(
"virtual_devices.value_activity_blocked_count",
diff --git a/services/companion/java/com/android/server/companion/virtual/VirtualDeviceImpl.java b/services/companion/java/com/android/server/companion/virtual/VirtualDeviceImpl.java
index ed2c90d..2db5443 100644
--- a/services/companion/java/com/android/server/companion/virtual/VirtualDeviceImpl.java
+++ b/services/companion/java/com/android/server/companion/virtual/VirtualDeviceImpl.java
@@ -60,6 +60,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.IntentSender;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.graphics.PointF;
@@ -241,9 +242,11 @@
@Override
public void onActivityLaunchBlocked(int displayId,
- @NonNull ComponentName componentName, @UserIdInt int userId) {
+ @NonNull ComponentName componentName, @UserIdInt int userId,
+ @Nullable IntentSender intentSender) {
try {
- mActivityListener.onActivityLaunchBlocked(displayId, componentName, userId);
+ mActivityListener.onActivityLaunchBlocked(
+ displayId, componentName, userId, intentSender);
} catch (RemoteException e) {
Slog.w(TAG, "Unable to call mActivityListener for display: " + displayId, e);
}
@@ -1364,7 +1367,8 @@
}
@RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
- private void onActivityBlocked(int displayId, ActivityInfo activityInfo) {
+ private void onActivityBlocked(int displayId, ActivityInfo activityInfo,
+ IntentSender intentSender) {
Intent intent = BlockedAppStreamingActivity.createIntent(activityInfo, getDisplayName());
if (shouldShowBlockedActivityDialog(
activityInfo.getComponentName(), intent.getComponent())) {
@@ -1380,7 +1384,8 @@
displayId,
activityInfo.getComponentName(),
UserHandle.getUserHandleForUid(
- activityInfo.applicationInfo.uid).getIdentifier());
+ activityInfo.applicationInfo.uid).getIdentifier(),
+ intentSender);
}
}
diff --git a/services/core/java/com/android/server/hdmi/DelayedMessageBuffer.java b/services/core/java/com/android/server/hdmi/DelayedMessageBuffer.java
index 46b4f48..4490745 100644
--- a/services/core/java/com/android/server/hdmi/DelayedMessageBuffer.java
+++ b/services/core/java/com/android/server/hdmi/DelayedMessageBuffer.java
@@ -17,8 +17,10 @@
package com.android.server.hdmi;
import android.hardware.hdmi.HdmiDeviceInfo;
+
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
/**
* Buffer storage to keep incoming messages for later processing. Used to
@@ -83,6 +85,16 @@
return false;
}
+ List<HdmiCecMessage> getBufferedMessagesWithOpcode(int opcode) {
+ List<HdmiCecMessage> messages = new ArrayList<>();
+ for (HdmiCecMessage message : mBuffer) {
+ if (message.getOpcode() == opcode) {
+ messages.add(message);
+ }
+ }
+ return messages;
+ }
+
void processAllMessages() {
// Use the copied buffer.
ArrayList<HdmiCecMessage> copiedBuffer = new ArrayList<>(mBuffer);
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
index 49888db..154710f 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceTv.java
@@ -217,7 +217,9 @@
resetSelectRequestBuffer();
launchDeviceDiscovery();
startQueuedActions();
- if (!mDelayedMessageBuffer.isBuffered(Constants.MESSAGE_ACTIVE_SOURCE)) {
+ List<HdmiCecMessage> bufferedActiveSource = mDelayedMessageBuffer
+ .getBufferedMessagesWithOpcode(Constants.MESSAGE_ACTIVE_SOURCE);
+ if (bufferedActiveSource.isEmpty()) {
if (hasAction(RequestActiveSourceAction.class)) {
Slog.i(TAG, "RequestActiveSourceAction is in progress. Restarting.");
removeAction(RequestActiveSourceAction.class);
@@ -236,9 +238,33 @@
}
}
}));
+ } else {
+ addCecDeviceForBufferedActiveSource(bufferedActiveSource.get(0));
}
}
+ // Add a new CEC device with known information from the buffered <Active Source> message. This
+ // helps TvInputCallback#onInputAdded to be called such that the message can be processed and
+ // the TV to switch to the new active input.
+ @ServiceThreadOnly
+ private void addCecDeviceForBufferedActiveSource(HdmiCecMessage bufferedActiveSource) {
+ assertRunOnServiceThread();
+ if (bufferedActiveSource == null) {
+ return;
+ }
+ int source = bufferedActiveSource.getSource();
+ int physicalAddress = HdmiUtils.twoBytesToInt(bufferedActiveSource.getParams());
+ List<Integer> deviceTypes = HdmiUtils.getTypeFromAddress(source);
+ HdmiDeviceInfo newDevice = HdmiDeviceInfo.cecDeviceBuilder()
+ .setLogicalAddress(source)
+ .setPhysicalAddress(physicalAddress)
+ .setDisplayName(HdmiUtils.getDefaultDeviceName(source))
+ .setDeviceType(deviceTypes.get(0))
+ .setVendorId(Constants.VENDOR_ID_UNKNOWN)
+ .build();
+ mService.getHdmiCecNetwork().addCecDevice(newDevice);
+ }
+
@ServiceThreadOnly
public void setSelectRequestBuffer(SelectRequestBuffer requestBuffer) {
assertRunOnServiceThread();
diff --git a/services/core/java/com/android/server/inputmethod/DefaultImeVisibilityApplier.java b/services/core/java/com/android/server/inputmethod/DefaultImeVisibilityApplier.java
index 5c939bc..600cf7f 100644
--- a/services/core/java/com/android/server/inputmethod/DefaultImeVisibilityApplier.java
+++ b/services/core/java/com/android/server/inputmethod/DefaultImeVisibilityApplier.java
@@ -202,7 +202,7 @@
break;
case STATE_HIDE_IME_EXPLICIT:
if (Flags.refactorInsetsController()) {
- setImeVisibilityOnFocusedWindowClient(false, userId, statsToken);
+ mService.setImeVisibilityOnFocusedWindowClient(false, userData, statsToken);
} else {
mService.hideCurrentInputLocked(windowToken, statsToken,
0 /* flags */, null /* resultReceiver */, reason, userId);
@@ -210,7 +210,7 @@
break;
case STATE_HIDE_IME_NOT_ALWAYS:
if (Flags.refactorInsetsController()) {
- setImeVisibilityOnFocusedWindowClient(false, userId, statsToken);
+ mService.setImeVisibilityOnFocusedWindowClient(false, userData, statsToken);
} else {
mService.hideCurrentInputLocked(windowToken, statsToken,
InputMethodManager.HIDE_NOT_ALWAYS, null /* resultReceiver */, reason,
@@ -221,7 +221,7 @@
if (Flags.refactorInsetsController()) {
// This can be triggered by IMMS#startInputOrWindowGainedFocus. We need to
// set the requestedVisibleTypes in InsetsController first, before applying it.
- setImeVisibilityOnFocusedWindowClient(true, userId, statsToken);
+ mService.setImeVisibilityOnFocusedWindowClient(true, userData, statsToken);
} else {
mService.showCurrentInputLocked(windowToken, statsToken,
InputMethodManager.SHOW_IMPLICIT, MotionEvent.TOOL_TYPE_UNKNOWN,
@@ -276,19 +276,4 @@
}
return false;
}
-
- @GuardedBy("ImfLock.class")
- private void setImeVisibilityOnFocusedWindowClient(boolean visibility, @UserIdInt int userId,
- @NonNull ImeTracker.Token statsToken) {
- final var userData = mService.getUserData(userId);
- if (userData.mImeBindingState != null
- && userData.mImeBindingState.mFocusedWindowClient != null
- && userData.mImeBindingState.mFocusedWindowClient.mClient != null) {
- userData.mImeBindingState.mFocusedWindowClient.mClient.setImeVisibility(visibility,
- statsToken);
- } else {
- ImeTracker.forLogging().onFailed(statsToken,
- ImeTracker.PHASE_SERVER_SET_VISIBILITY_ON_FOCUSED_WINDOW);
- }
- }
}
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java
index dba0465..4d06f50 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java
@@ -238,6 +238,33 @@
public abstract void removeImeSurface(int displayId);
/**
+ * Called when a non-IME-focusable overlay window being the IME layering target (e.g. a
+ * window with {@link android.view.WindowManager.LayoutParams#FLAG_NOT_FOCUSABLE} and
+ * {@link android.view.WindowManager.LayoutParams#FLAG_ALT_FOCUSABLE_IM} flags)
+ * has changed its window visibility.
+ *
+ * @param hasVisibleOverlay whether such an overlay window exists or not
+ * @param displayId the display ID where the overlay window exists
+ */
+ public abstract void setHasVisibleImeLayeringOverlay(boolean hasVisibleOverlay, int displayId);
+
+ /**
+ * Called when the visibility of IME input target window has changed.
+ *
+ * @param imeInputTarget the window token of the IME input target window
+ * @param visibleAndNotRemoved {@code true} when the new window is made visible by
+ * {@code imeInputTarget} and the IME input target window has not
+ * been removed. The new window is considered to be visible when
+ * switching to the new visible IME input target window and
+ * starting input, or the existing input target becomes visible.
+ * In contrast, {@code false} when closing the input target, or the
+ * existing input target becomes invisible
+ * @param displayId the display for which to update the IME window status
+ */
+ public abstract void onImeInputTargetVisibilityChanged(@NonNull IBinder imeInputTarget,
+ boolean visibleAndNotRemoved, int displayId);
+
+ /**
* Updates the IME visibility, back disposition and show IME picker status for SystemUI.
* TODO(b/189923292): Making SystemUI to be true IME icon controller vs. presenter that
* controlled by IMMS.
@@ -389,6 +416,16 @@
public void removeImeSurface(int displayId) {
}
+ @Override
+ public void setHasVisibleImeLayeringOverlay(boolean hasVisibleOverlay,
+ int displayId) {
+ }
+
+ @Override
+ public void onImeInputTargetVisibilityChanged(@NonNull IBinder imeInputTarget,
+ boolean visibleAndNotRemoved, int displayId) {
+ }
+
@ImfLockFree
@Override
public void updateImeWindowStatus(boolean disableImeIcon, int displayId) {
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index f9ab713..1b2ea89 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -44,7 +44,6 @@
import static android.view.Display.INVALID_DISPLAY;
import static android.view.WindowManager.DISPLAY_IME_POLICY_HIDE;
import static android.view.WindowManager.DISPLAY_IME_POLICY_LOCAL;
-import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static android.view.inputmethod.ConnectionlessHandwritingCallback.CONNECTIONLESS_HANDWRITING_ERROR_OTHER;
import static android.view.inputmethod.ConnectionlessHandwritingCallback.CONNECTIONLESS_HANDWRITING_ERROR_UNSUPPORTED;
@@ -188,7 +187,6 @@
import com.android.server.pm.UserManagerInternal;
import com.android.server.statusbar.StatusBarManagerInternal;
import com.android.server.utils.PriorityDump;
-import com.android.server.wm.ImeTargetChangeListener;
import com.android.server.wm.WindowManagerInternal;
import java.io.FileDescriptor;
@@ -799,63 +797,70 @@
final int userId = getChangingUserId();
final var userData = getUserData(userId);
- // Instantiating InputMethodInfo requires disk I/O.
- // Do them before acquiring the lock to minimize the chances of ANR (b/340221861).
userData.mRawInputMethodMap.set(queryRawInputMethodServiceMap(mContext, userId));
+ final InputMethodSettings settings = InputMethodSettingsRepository.get(userId);
+
+ InputMethodInfo curIm = null;
+ String curInputMethodId = settings.getSelectedInputMethod();
+ final List<InputMethodInfo> methodList = settings.getMethodList();
+
+ final ArrayList<String> imesToClearAdditionalSubtypes = new ArrayList<>();
+ final ArrayList<String> imesToBeDisabled = new ArrayList<>();
+ final int numImes = methodList.size();
+ for (int i = 0; i < numImes; i++) {
+ InputMethodInfo imi = methodList.get(i);
+ final String imiId = imi.getId();
+ if (imiId.equals(curInputMethodId)) {
+ curIm = imi;
+ }
+ if (mDataClearedPackages.contains(imi.getPackageName())) {
+ imesToClearAdditionalSubtypes.add(imiId);
+ }
+ int change = isPackageDisappearing(imi.getPackageName());
+ if (change == PACKAGE_PERMANENT_CHANGE) {
+ Slog.i(TAG, "Input method uninstalled, disabling: " + imi.getComponent());
+ imesToBeDisabled.add(imi.getId());
+ } else if (change == PACKAGE_UPDATING) {
+ Slog.i(TAG, "Input method reinstalling, clearing additional subtypes: "
+ + imi.getComponent());
+ imesToClearAdditionalSubtypes.add(imiId);
+ }
+ }
+
+ // Clear additional subtypes as a batch operation.
+ final var additionalSubtypeMap = AdditionalSubtypeMapRepository.get(userId);
+ final AdditionalSubtypeMap newAdditionalSubtypeMap =
+ additionalSubtypeMap.cloneWithRemoveOrSelf(imesToClearAdditionalSubtypes);
+ final boolean additionalSubtypeChanged =
+ (newAdditionalSubtypeMap != additionalSubtypeMap);
+ if (additionalSubtypeChanged) {
+ AdditionalSubtypeMapRepository.putAndSave(userId, newAdditionalSubtypeMap,
+ settings.getMethodMap());
+ }
+
+ final var newMethodMap = userData.mRawInputMethodMap.get().toInputMethodMap(
+ newAdditionalSubtypeMap,
+ DirectBootAwareness.AUTO,
+ mUserManagerInternal.isUserUnlockingOrUnlocked(userId));
+
+ final boolean noUpdate = InputMethodMap.areSame(settings.getMethodMap(), newMethodMap);
+ if (noUpdate && imesToBeDisabled.isEmpty()) {
+ return;
+ }
+
+ // Here we start remaining tasks that need to be done with the lock (b/340221861).
synchronized (ImfLock.class) {
- final InputMethodSettings settings = InputMethodSettingsRepository.get(userId);
-
- InputMethodInfo curIm = null;
- String curInputMethodId = settings.getSelectedInputMethod();
- final List<InputMethodInfo> methodList = settings.getMethodList();
-
- final ArrayList<String> imesToClearAdditionalSubtypes = new ArrayList<>();
- final int numImes = methodList.size();
- for (int i = 0; i < numImes; i++) {
- InputMethodInfo imi = methodList.get(i);
- final String imiId = imi.getId();
- if (imiId.equals(curInputMethodId)) {
- curIm = imi;
- }
- if (mDataClearedPackages.contains(imi.getPackageName())) {
- imesToClearAdditionalSubtypes.add(imiId);
- }
- int change = isPackageDisappearing(imi.getPackageName());
- if (change == PACKAGE_PERMANENT_CHANGE) {
- Slog.i(TAG, "Input method uninstalled, disabling: " + imi.getComponent());
- setInputMethodEnabledLocked(imi.getId(), false, userId);
- } else if (change == PACKAGE_UPDATING) {
- Slog.i(TAG, "Input method reinstalling, clearing additional subtypes: "
- + imi.getComponent());
- imesToClearAdditionalSubtypes.add(imiId);
- }
+ final int numImesToBeDisabled = imesToBeDisabled.size();
+ for (int i = 0; i < numImesToBeDisabled; ++i) {
+ setInputMethodEnabledLocked(imesToBeDisabled.get(i), false /* enabled */,
+ userId);
}
-
- // Clear additional subtypes as a batch operation.
- final var additionalSubtypeMap = AdditionalSubtypeMapRepository.get(userId);
- final AdditionalSubtypeMap newAdditionalSubtypeMap =
- additionalSubtypeMap.cloneWithRemoveOrSelf(imesToClearAdditionalSubtypes);
- final boolean additionalSubtypeChanged =
- (newAdditionalSubtypeMap != additionalSubtypeMap);
- if (additionalSubtypeChanged) {
- AdditionalSubtypeMapRepository.putAndSave(userId, newAdditionalSubtypeMap,
- settings.getMethodMap());
- }
-
- final var newMethodMap = userData.mRawInputMethodMap.get().toInputMethodMap(
- newAdditionalSubtypeMap,
- DirectBootAwareness.AUTO,
- mUserManagerInternal.isUserUnlockingOrUnlocked(userId));
-
- if (InputMethodMap.areSame(settings.getMethodMap(), newMethodMap)) {
- // No update in the actual IME map.
+ if (noUpdate) {
return;
}
-
- final InputMethodSettings newSettings =
- InputMethodSettings.create(newMethodMap, userId);
- InputMethodSettingsRepository.put(userId, newSettings);
+ InputMethodSettingsRepository.put(userId,
+ InputMethodSettings.create(newMethodMap, userId));
postInputMethodSettingUpdatedLocked(false /* resetDefaultEnabledIme */, userId);
boolean changed = false;
@@ -964,37 +969,6 @@
InputMethodDrawsNavBarResourceMonitor.registerCallback(context, mService.mIoHandler,
mService::onUpdateResourceOverlay);
- // Also hook up ImeTargetChangeListener.
- // TODO(b/356876005): Merge this into InputMethodManagerInternal.
- final var windowManagerInternal = mService.mWindowManagerInternal;
- windowManagerInternal.setInputMethodTargetChangeListener(new ImeTargetChangeListener() {
- @Override
- public void onImeTargetOverlayVisibilityChanged(@NonNull IBinder overlayWindowToken,
- @WindowManager.LayoutParams.WindowType int windowType, boolean visible,
- boolean removed, int displayId) {
- // Ignoring the starting window since it's ok to cover the IME target
- // window in temporary without affecting the IME visibility.
- final boolean hasOverlay = visible && !removed
- && windowType != TYPE_APPLICATION_STARTING;
- synchronized (ImfLock.class) {
- final var userId = mService.resolveImeUserIdFromDisplayIdLocked(displayId);
- mService.getUserData(userId).mVisibilityStateComputer
- .setHasVisibleImeLayeringOverlay(hasOverlay);
- }
- }
-
- @Override
- public void onImeInputTargetVisibilityChanged(IBinder imeInputTarget,
- boolean visibleRequested, boolean removed, int displayId) {
- final boolean visibleAndNotRemoved = visibleRequested && !removed;
- synchronized (ImfLock.class) {
- final var userId = mService.resolveImeUserIdFromDisplayIdLocked(displayId);
- mService.getUserData(userId).mVisibilityStateComputer
- .onImeInputTargetVisibilityChanged(imeInputTarget,
- visibleAndNotRemoved);
- }
- }
- });
// Also schedule user init tasks onto an I/O thread.
initializeUsersAsync(mService.mUserManagerInternal.getUserIds());
}
@@ -1443,7 +1417,7 @@
final int currentUserId = mCurrentUserId;
mStatusBarManagerInternal =
LocalServices.getService(StatusBarManagerInternal.class);
- hideStatusBarIconLocked();
+ hideStatusBarIconLocked(currentUserId);
final var bindingController = getInputMethodBindingController(currentUserId);
updateSystemUiLocked(bindingController.getImeWindowVis(),
bindingController.getBackDisposition(), currentUserId);
@@ -2586,7 +2560,7 @@
userData.mEnabledAccessibilitySessions.clear();
scheduleNotifyImeUidToAudioService(Process.INVALID_UID);
}
- hideStatusBarIconLocked();
+ hideStatusBarIconLocked(userId);
getUserData(userId).mInFullscreenMode = false;
mWindowManagerInternal.setDismissImeOnBackKeyPressed(false);
scheduleResetStylusHandwriting();
@@ -2597,6 +2571,11 @@
@DrawableRes int iconId, @NonNull UserData userData) {
final int userId = userData.mUserId;
synchronized (ImfLock.class) {
+ // To minimize app compat risk, ignore background users' request for single-user mode.
+ // TODO(b/357178609): generalize the logic and remove this special rule.
+ if (!mConcurrentMultiUserModeEnabled && userId != mCurrentUserId) {
+ return;
+ }
if (!calledWithValidTokenLocked(token, userData)) {
return;
}
@@ -2604,7 +2583,7 @@
try {
if (iconId == 0) {
if (DEBUG) Slog.d(TAG, "hide the small icon for the input method");
- hideStatusBarIconLocked();
+ hideStatusBarIconLocked(userId);
} else if (packageName != null) {
if (DEBUG) Slog.d(TAG, "show a small icon for the input method");
final PackageManager userAwarePackageManager =
@@ -2632,7 +2611,12 @@
}
@GuardedBy("ImfLock.class")
- private void hideStatusBarIconLocked() {
+ private void hideStatusBarIconLocked(@UserIdInt int userId) {
+ // To minimize app compat risk, ignore background users' request for single-user mode.
+ // TODO(b/357178609): generalize the logic and remove this special rule.
+ if (!mConcurrentMultiUserModeEnabled && userId != mCurrentUserId) {
+ return;
+ }
if (mStatusBarManagerInternal != null) {
mStatusBarManagerInternal.setIconVisibility(mSlotIme, false);
}
@@ -2839,6 +2823,11 @@
@GuardedBy("ImfLock.class")
private void updateSystemUiLocked(int vis, int backDisposition, @UserIdInt int userId) {
+ // To minimize app compat risk, ignore background users' request for single-user mode.
+ // TODO(b/357178609): generalize the logic and remove this special rule.
+ if (!mConcurrentMultiUserModeEnabled && userId != mCurrentUserId) {
+ return;
+ }
final var userData = getUserData(userId);
final var bindingController = userData.mBindingController;
final var curToken = bindingController.getCurToken();
@@ -3132,11 +3121,7 @@
if (Flags.refactorInsetsController()) {
final var visibilityStateComputer = userData.mVisibilityStateComputer;
boolean wasVisible = visibilityStateComputer.isInputShown();
- if (userData.mImeBindingState != null
- && userData.mImeBindingState.mFocusedWindowClient != null
- && userData.mImeBindingState.mFocusedWindowClient.mClient != null) {
- userData.mImeBindingState.mFocusedWindowClient.mClient
- .setImeVisibility(true, statsToken);
+ if (setImeVisibilityOnFocusedWindowClient(false, userData, statsToken)) {
if (resultReceiver != null) {
resultReceiver.send(
wasVisible ? InputMethodManager.RESULT_UNCHANGED_SHOWN
@@ -3585,13 +3570,9 @@
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMMS.hideSoftInput");
if (DEBUG) Slog.v(TAG, "Client requesting input be hidden");
if (Flags.refactorInsetsController()) {
- if (userData.mImeBindingState != null
- && userData.mImeBindingState.mFocusedWindowClient != null
- && userData.mImeBindingState.mFocusedWindowClient.mClient != null) {
- boolean wasVisible = visibilityStateComputer.isInputShown();
- // TODO add windowToken to interface
- userData.mImeBindingState.mFocusedWindowClient.mClient
- .setImeVisibility(false, statsToken);
+ boolean wasVisible = visibilityStateComputer.isInputShown();
+ // TODO add windowToken to interface
+ if (setImeVisibilityOnFocusedWindowClient(false, userData, statsToken)) {
if (resultReceiver != null) {
resultReceiver.send(wasVisible ? InputMethodManager.RESULT_HIDDEN
: InputMethodManager.RESULT_UNCHANGED_HIDDEN, null);
@@ -4928,12 +4909,7 @@
if (Flags.refactorInsetsController()) {
userData.mCurClient.mClient.setImeVisibility(false, statsToken);
// TODO we will loose the flags here
- if (userData.mImeBindingState != null
- && userData.mImeBindingState.mFocusedWindowClient != null
- && userData.mImeBindingState.mFocusedWindowClient.mClient != null) {
- userData.mImeBindingState.mFocusedWindowClient.mClient
- .setImeVisibility(false, statsToken);
- }
+ setImeVisibilityOnFocusedWindowClient(false, userData, statsToken);
} else {
final var visibilityStateComputer = userData.mVisibilityStateComputer;
hideCurrentInputLocked(visibilityStateComputer.getLastImeTargetWindow(),
@@ -4966,14 +4942,8 @@
final long ident = Binder.clearCallingIdentity();
try {
if (Flags.refactorInsetsController()) {
- userData.mCurClient.mClient.setImeVisibility(false, statsToken);
- // TODO we will loose the flags here
- if (userData.mImeBindingState != null
- && userData.mImeBindingState.mFocusedWindowClient != null
- && userData.mImeBindingState.mFocusedWindowClient.mClient != null) {
- userData.mImeBindingState.mFocusedWindowClient.mClient
- .setImeVisibility(true, statsToken);
- }
+ userData.mCurClient.mClient.setImeVisibility(true, statsToken);
+ setImeVisibilityOnFocusedWindowClient(true, userData, statsToken);
} else {
final var visibilityStateComputer = userData.mVisibilityStateComputer;
showCurrentInputLocked(visibilityStateComputer.getLastImeTargetWindow(),
@@ -5135,13 +5105,8 @@
final int userId = resolveImeUserIdFromDisplayIdLocked(originatingDisplayId);
final var userData = getUserData(userId);
if (Flags.refactorInsetsController()) {
- if (userData.mImeBindingState != null
- && userData.mImeBindingState.mFocusedWindowClient != null
- && userData.mImeBindingState.mFocusedWindowClient.mClient != null) {
- userData.mImeBindingState.mFocusedWindowClient.mClient
- .setImeVisibility(false,
- null /* TODO(b329229469) check statsToken */);
- }
+ setImeVisibilityOnFocusedWindowClient(false, userData,
+ null /* TODO(b329229469) check statsToken */);
} else {
hideCurrentInputLocked(userData.mImeBindingState.mFocusedWindow,
@@ -5991,6 +5956,25 @@
mHandler.obtainMessage(MSG_REMOVE_IME_SURFACE).sendToTarget();
}
+ @Override
+ public void setHasVisibleImeLayeringOverlay(boolean hasVisibleOverlay, int displayId) {
+ synchronized (ImfLock.class) {
+ final var userId = resolveImeUserIdFromDisplayIdLocked(displayId);
+ getUserData(userId).mVisibilityStateComputer.setHasVisibleImeLayeringOverlay(
+ hasVisibleOverlay);
+ }
+ }
+
+ @Override
+ public void onImeInputTargetVisibilityChanged(@NonNull IBinder imeInputTarget,
+ boolean visibleAndNotRemoved, int displayId) {
+ synchronized (ImfLock.class) {
+ final var userId = resolveImeUserIdFromDisplayIdLocked(displayId);
+ getUserData(userId).mVisibilityStateComputer.onImeInputTargetVisibilityChanged(
+ imeInputTarget, visibleAndNotRemoved);
+ }
+ }
+
@ImfLockFree
@Override
public void updateImeWindowStatus(boolean disableImeIcon, int displayId) {
@@ -6774,6 +6758,17 @@
out.print(imeId);
out.print(" selected for user #");
out.println(userId);
+
+ // Workaround for b/354782333.
+ final var settingsValue = SecureSettingsWrapper.getString(
+ Settings.Secure.DEFAULT_INPUT_METHOD, "", userId);
+ if (!TextUtils.equals(settingsValue, imeId)) {
+ Slog.w(TAG, "DEFAULT_INPUT_METHOD=" + settingsValue
+ + " is not updated. Fixing it up to " + imeId
+ + " See b/354782333.");
+ SecureSettingsWrapper.putString(
+ Settings.Secure.DEFAULT_INPUT_METHOD, imeId, userId);
+ }
}
hasFailed |= failedToSelectUnknownIme;
}
@@ -6810,16 +6805,8 @@
final InputMethodSettings settings = InputMethodSettingsRepository.get(userId);
final var userData = getUserData(userId);
if (Flags.refactorInsetsController()) {
- if (userData.mImeBindingState != null
- && userData.mImeBindingState.mFocusedWindowClient != null
- && userData.mImeBindingState.mFocusedWindowClient.mClient
- != null) {
- userData.mImeBindingState.mFocusedWindowClient.mClient
- .setImeVisibility(false,
- null /* TODO(b329229469) initialize statsToken here? */);
- } else {
- // TODO(b329229469): ImeTracker?
- }
+ setImeVisibilityOnFocusedWindowClient(false, userData,
+ null /* TODO(b329229469) initialize statsToken here? */);
} else {
hideCurrentInputLocked(userData.mImeBindingState.mFocusedWindow,
0 /* flags */,
@@ -6858,6 +6845,23 @@
return ShellCommandResult.SUCCESS;
}
+ @GuardedBy("ImfLock.class")
+ boolean setImeVisibilityOnFocusedWindowClient(boolean visible, UserData userData,
+ @NonNull ImeTracker.Token statsToken) {
+ if (Flags.refactorInsetsController()) {
+ if (userData.mImeBindingState != null
+ && userData.mImeBindingState.mFocusedWindowClient != null
+ && userData.mImeBindingState.mFocusedWindowClient.mClient != null) {
+ userData.mImeBindingState.mFocusedWindowClient.mClient.setImeVisibility(visible,
+ statsToken);
+ return true;
+ }
+ ImeTracker.forLogging().onFailed(statsToken,
+ ImeTracker.PHASE_SERVER_SET_VISIBILITY_ON_FOCUSED_WINDOW);
+ }
+ return false;
+ }
+
/**
* Handles {@code adb shell cmd input_method tracing start/stop/save-for-bugreport}.
*
diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubTestModeManager.java b/services/core/java/com/android/server/location/contexthub/ContextHubTestModeManager.java
index f2714db..2bb3be6 100644
--- a/services/core/java/com/android/server/location/contexthub/ContextHubTestModeManager.java
+++ b/services/core/java/com/android/server/location/contexthub/ContextHubTestModeManager.java
@@ -17,10 +17,12 @@
package com.android.server.location.contexthub;
import android.chre.flags.Flags;
+import android.hardware.location.ContextHubTransaction;
import android.hardware.location.NanoAppMessage;
import android.util.Log;
-import java.util.Random;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.Callable;
/**
* A class to manage behaviors during test mode. This is used for testing.
@@ -29,32 +31,31 @@
public class ContextHubTestModeManager {
private static final String TAG = "ContextHubTestModeManager";
- /** Probability of duplicating a message. */
- private static final double MESSAGE_DROP_PROBABILITY = 0.05;
-
- /** Probability of duplicating a message. */
- private static final double MESSAGE_DUPLICATION_PROBABILITY = 0.05;
+ private static final int DROP_MESSAGE_TO_HOST_EVENT = 0;
+ private static final int DROP_MESSAGE_TO_CONTEXT_HUB_EVENT = 1;
+ private static final int DUPLICATE_MESSAGE_TO_HOST_EVENT = 2;
+ private static final int DUPLICATE_MESSAGE_TO_CONTEXT_HUB_EVENT = 3;
+ private static final int NUMBER_OF_EVENTS = 4;
/** The number of total messages to send when the duplication event happens. */
private static final int NUM_MESSAGES_TO_DUPLICATE = 3;
- /**
- * The seed for the random number generator. This is used to make the
- * test more deterministic.
- */
- private static final long SEED = 0xDEADBEEF;
-
- private final Random mRandom = new Random(SEED);
+ /** The counter to track the number of interactions with the test mode manager. */
+ private final AtomicLong mCounter = new AtomicLong(0);
/**
* @return whether the message was handled
* @see ContextHubServiceCallback#handleNanoappMessage
*/
public boolean handleNanoappMessage(Runnable handleMessage, NanoAppMessage message) {
+ if (!message.isReliable()) {
+ return false;
+ }
+
+ long counterValue = mCounter.getAndIncrement();
if (Flags.reliableMessageDuplicateDetectionService()
- && message.isReliable()
- && mRandom.nextDouble() < MESSAGE_DUPLICATION_PROBABILITY) {
- Log.i(TAG, "[TEST MODE] Duplicating message ("
+ && counterValue % NUMBER_OF_EVENTS == DUPLICATE_MESSAGE_TO_HOST_EVENT) {
+ Log.i(TAG, "[TEST MODE] Duplicating message to host ("
+ NUM_MESSAGES_TO_DUPLICATE
+ " sends) with message sequence number: "
+ message.getMessageSequenceNumber());
@@ -63,6 +64,14 @@
}
return true;
}
+
+ if (counterValue % NUMBER_OF_EVENTS == DROP_MESSAGE_TO_HOST_EVENT) {
+ Log.i(TAG, "[TEST MODE] Dropping message to host with "
+ + "message sequence number: "
+ + message.getMessageSequenceNumber());
+ return true;
+ }
+
return false;
}
@@ -70,14 +79,39 @@
* @return whether the message was handled
* @see IContextHubWrapper#sendMessageToContextHub
*/
- public boolean sendMessageToContextHub(NanoAppMessage message) {
+ public boolean sendMessageToContextHub(Callable<Integer> sendMessage, NanoAppMessage message) {
+ if (!message.isReliable()) {
+ return false;
+ }
+
+ long counterValue = mCounter.getAndIncrement();
+ if (counterValue % NUMBER_OF_EVENTS == DUPLICATE_MESSAGE_TO_CONTEXT_HUB_EVENT) {
+ Log.i(TAG, "[TEST MODE] Duplicating message to the Context Hub ("
+ + NUM_MESSAGES_TO_DUPLICATE
+ + " sends) with message sequence number: "
+ + message.getMessageSequenceNumber());
+ for (int i = 0; i < NUM_MESSAGES_TO_DUPLICATE; ++i) {
+ try {
+ int result = sendMessage.call();
+ if (result != ContextHubTransaction.RESULT_SUCCESS) {
+ Log.e(TAG, "sendMessage returned an error: " + result);
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "Exception in sendMessageToContextHub: "
+ + e.getMessage());
+ }
+ }
+ return true;
+ }
+
if (Flags.reliableMessageRetrySupportService()
- && message.isReliable()
- && mRandom.nextDouble() < MESSAGE_DROP_PROBABILITY) {
- Log.i(TAG, "[TEST MODE] Dropping message with message sequence number: "
+ && counterValue % NUMBER_OF_EVENTS == DROP_MESSAGE_TO_CONTEXT_HUB_EVENT) {
+ Log.i(TAG, "[TEST MODE] Dropping message to the Context Hub with "
+ + "message sequence number: "
+ message.getMessageSequenceNumber());
return true;
}
+
return false;
}
}
diff --git a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java
index 4fc3d87..a8ad418 100644
--- a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java
+++ b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java
@@ -53,6 +53,7 @@
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.Callable;
/**
* @hide
@@ -659,32 +660,40 @@
@ContextHubTransaction.Result
public int sendMessageToContextHub(short hostEndpointId, int contextHubId,
- NanoAppMessage message) throws RemoteException {
+ NanoAppMessage message) {
android.hardware.contexthub.IContextHub hub = getHub();
if (hub == null) {
return ContextHubTransaction.RESULT_FAILED_BAD_PARAMS;
}
- try {
- var msg = ContextHubServiceUtil.createAidlContextHubMessage(
- hostEndpointId, message);
-
- // Only process the message normally if not using test mode manager or if
- // the test mode manager call returned false as this indicates it did not
- // process the message.
- boolean useTestModeManager = Flags.reliableMessageImplementation()
- && Flags.reliableMessageTestModeBehavior()
- && mIsTestModeEnabled.get();
- if (!useTestModeManager || !mTestModeManager.sendMessageToContextHub(message)) {
+ Callable<Integer> sendMessage = () -> {
+ try {
+ var msg = ContextHubServiceUtil.createAidlContextHubMessage(
+ hostEndpointId, message);
hub.sendMessageToHub(contextHubId, msg);
+ return ContextHubTransaction.RESULT_SUCCESS;
+ } catch (RemoteException | ServiceSpecificException e) {
+ return ContextHubTransaction.RESULT_FAILED_UNKNOWN;
+ } catch (IllegalArgumentException e) {
+ return ContextHubTransaction.RESULT_FAILED_BAD_PARAMS;
}
+ };
- return ContextHubTransaction.RESULT_SUCCESS;
- } catch (RemoteException | ServiceSpecificException e) {
- return ContextHubTransaction.RESULT_FAILED_UNKNOWN;
- } catch (IllegalArgumentException e) {
- return ContextHubTransaction.RESULT_FAILED_BAD_PARAMS;
+ // Only process the message normally if not using test mode manager or if
+ // the test mode manager call returned false as this indicates it did not
+ // process the message.
+ boolean useTestModeManager = Flags.reliableMessageImplementation()
+ && Flags.reliableMessageTestModeBehavior()
+ && mIsTestModeEnabled.get();
+ if (!useTestModeManager || !mTestModeManager.sendMessageToContextHub(
+ sendMessage, message)) {
+ try {
+ return sendMessage.call();
+ } catch (Exception e) {
+ return ContextHubTransaction.RESULT_FAILED_UNKNOWN;
+ }
}
+ return ContextHubTransaction.RESULT_SUCCESS;
}
@ContextHubTransaction.Result
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index c902fb2..829ee27 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -29,6 +29,7 @@
import static android.os.UserManager.DISALLOW_USER_SWITCH;
import static android.os.UserManager.SYSTEM_USER_MODE_EMULATION_PROPERTY;
import static android.os.UserManager.USER_OPERATION_ERROR_UNKNOWN;
+import static android.os.UserManager.USER_OPERATION_ERROR_USER_RESTRICTED;
import static android.os.UserManager.USER_TYPE_PROFILE_PRIVATE;
import static com.android.internal.app.SetScreenLockDialogActivity.EXTRA_ORIGIN_USER_ID;
@@ -8039,8 +8040,13 @@
String errorMessage = (message != null ? (message + ": ") : "")
+ restriction + " is enabled.";
Slog.w(LOG_TAG, errorMessage);
- throw new UserManager.CheckedUserOperationException(errorMessage,
+ if (android.multiuser.Flags.showDifferentCreationErrorForUnsupportedDevices()) {
+ throw new UserManager.CheckedUserOperationException(errorMessage,
+ USER_OPERATION_ERROR_USER_RESTRICTED);
+ } else {
+ throw new UserManager.CheckedUserOperationException(errorMessage,
USER_OPERATION_ERROR_UNKNOWN);
+ }
}
}
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index cc195ac..18aa9a0 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -28,6 +28,8 @@
import static android.app.ActivityManager.START_SUCCESS;
import static android.app.ActivityManager.START_TASK_TO_FRONT;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
+import static android.app.PendingIntent.FLAG_CANCEL_CURRENT;
+import static android.app.PendingIntent.FLAG_ONE_SHOT;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK;
@@ -146,6 +148,7 @@
import java.lang.annotation.RetentionPolicy;
import java.text.DateFormat;
import java.util.Date;
+import java.util.function.Supplier;
/**
* Controller for interpreting how and then launching an activity.
@@ -1618,8 +1621,10 @@
currentTop, currentTop.mDisplayContent, false /* deferResume */);
}
- if (!avoidMoveToFront() && mDoResume && mRootWindowContainer
- .hasVisibleWindowAboveButDoesNotOwnNotificationShade(started.launchedFromUid)) {
+ if (!avoidMoveToFront() && mDoResume
+ && !mService.getUserManagerInternal().isVisibleBackgroundFullUser(started.mUserId)
+ && mRootWindowContainer.hasVisibleWindowAboveButDoesNotOwnNotificationShade(
+ started.launchedFromUid)) {
// If the UID launching the activity has a visible window on top of the notification
// shade and it's launching an activity that's going to be at the front, we should move
// the shade out of the way so the user can see it. We want to avoid the case where the
@@ -2079,9 +2084,23 @@
? targetTask.getWindowingMode() : displayContent.getWindowingMode();
final int launchingFromDisplayId =
mSourceRecord != null ? mSourceRecord.getDisplayId() : DEFAULT_DISPLAY;
+ final boolean isResultExpected = r.resultTo != null;
+ Supplier<IntentSender> intentSender = null;
+ if (android.companion.virtualdevice.flags.Flags.activityControlApi()) {
+ intentSender = () -> {
+ IIntentSender target = mService.getIntentSenderLocked(
+ ActivityManager.INTENT_SENDER_ACTIVITY, mRequest.callingPackage,
+ mRequest.callingFeatureId, mCallingUid, r.mUserId,
+ /* token= */ null, /* resultCode= */ null, /* requestCode= */ 0,
+ new Intent[]{ mIntent }, new String[]{ r.resolvedType },
+ FLAG_CANCEL_CURRENT | FLAG_ONE_SHOT,
+ mOptions == null ? null : mOptions.toBundle());
+ return new IntentSender(target);
+ };
+ }
if (!displayContent.mDwpcHelper
.canActivityBeLaunched(r.info, r.intent, targetWindowingMode,
- launchingFromDisplayId, newTask)) {
+ launchingFromDisplayId, newTask, isResultExpected, intentSender)) {
Slog.w(TAG, "Abort to launch " + r.info.getComponentName()
+ " on display area " + mPreferredTaskDisplayArea);
return START_ABORTED;
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 9f3bbd1..e4cae58 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -283,6 +283,7 @@
import com.android.server.am.UserState;
import com.android.server.firewall.IntentFirewall;
import com.android.server.grammaticalinflection.GrammaticalInflectionManagerInternal;
+import com.android.server.pm.UserManagerInternal;
import com.android.server.pm.UserManagerService;
import com.android.server.policy.PermissionPolicyInternal;
import com.android.server.sdksandbox.SdkSandboxManagerLocal;
@@ -382,6 +383,7 @@
private PermissionPolicyInternal mPermissionPolicyInternal;
private StatusBarManagerInternal mStatusBarManagerInternal;
private WallpaperManagerInternal mWallpaperManagerInternal;
+ private UserManagerInternal mUserManagerInternal;
@VisibleForTesting
final ActivityTaskManagerInternal mInternal;
private PowerManagerInternal mPowerManagerInternal;
@@ -5464,6 +5466,13 @@
return mWallpaperManagerInternal;
}
+ UserManagerInternal getUserManagerInternal() {
+ if (mUserManagerInternal == null) {
+ mUserManagerInternal = LocalServices.getService(UserManagerInternal.class);
+ }
+ return mUserManagerInternal;
+ }
+
AppWarnings getAppWarningsLocked() {
return mAppWarnings;
}
diff --git a/services/core/java/com/android/server/wm/AppCompatUtils.java b/services/core/java/com/android/server/wm/AppCompatUtils.java
index a5db904..0244d27 100644
--- a/services/core/java/com/android/server/wm/AppCompatUtils.java
+++ b/services/core/java/com/android/server/wm/AppCompatUtils.java
@@ -115,8 +115,8 @@
static void fillAppCompatTaskInfo(@NonNull Task task, @NonNull TaskInfo info,
@Nullable ActivityRecord top) {
final AppCompatTaskInfo appCompatTaskInfo = info.appCompatTaskInfo;
- appCompatTaskInfo.cameraCompatTaskInfo.freeformCameraCompatMode =
- CameraCompatTaskInfo.CAMERA_COMPAT_FREEFORM_NONE;
+ clearAppCompatTaskInfo(appCompatTaskInfo);
+
if (top == null) {
return;
}
@@ -125,24 +125,28 @@
final boolean isTopActivityResumed = top.getOrganizedTask() == task && top.isState(RESUMED);
final boolean isTopActivityVisible = top.getOrganizedTask() == task && top.isVisible();
// Whether the direct top activity is in size compat mode.
- appCompatTaskInfo.topActivityInSizeCompat = isTopActivityVisible && top.inSizeCompatMode();
- if (appCompatTaskInfo.topActivityInSizeCompat
+ appCompatTaskInfo.setTopActivityInSizeCompat(
+ isTopActivityVisible && top.inSizeCompatMode());
+ if (appCompatTaskInfo.isTopActivityInSizeCompat()
&& top.mWmService.mAppCompatConfiguration.isTranslucentLetterboxingEnabled()) {
// We hide the restart button in case of transparent activities.
- appCompatTaskInfo.topActivityInSizeCompat = top.fillsParent();
+ appCompatTaskInfo.setTopActivityInSizeCompat(top.fillsParent());
}
// Whether the direct top activity is eligible for letterbox education.
- appCompatTaskInfo.topActivityEligibleForLetterboxEducation = isTopActivityResumed
- && top.isEligibleForLetterboxEducation();
- appCompatTaskInfo.isLetterboxEducationEnabled = top.mLetterboxUiController
- .isLetterboxEducationEnabled();
+ appCompatTaskInfo.setEligibleForLetterboxEducation(
+ isTopActivityResumed && top.isEligibleForLetterboxEducation());
+ appCompatTaskInfo.setLetterboxEducationEnabled(top.mLetterboxUiController
+ .isLetterboxEducationEnabled());
- appCompatTaskInfo.isUserFullscreenOverrideEnabled = top.mAppCompatController
- .getAppCompatAspectRatioOverrides().shouldApplyUserFullscreenOverride();
- appCompatTaskInfo.isSystemFullscreenOverrideEnabled = top.mAppCompatController
- .getAppCompatAspectRatioOverrides().isSystemOverrideToFullscreenEnabled();
+ final AppCompatAspectRatioOverrides aspectRatioOverrides =
+ top.mAppCompatController.getAppCompatAspectRatioOverrides();
+ appCompatTaskInfo.setUserFullscreenOverrideEnabled(
+ aspectRatioOverrides.shouldApplyUserFullscreenOverride());
+ appCompatTaskInfo.setSystemFullscreenOverrideEnabled(
+ aspectRatioOverrides.isSystemOverrideToFullscreenEnabled());
- appCompatTaskInfo.isFromLetterboxDoubleTap = reachabilityOverrides.isFromDoubleTap();
+ appCompatTaskInfo.setIsFromLetterboxDoubleTap(reachabilityOverrides.isFromDoubleTap());
+
final Rect bounds = top.getBounds();
final Rect appBounds = getAppBounds(top);
appCompatTaskInfo.topActivityLetterboxWidth = bounds.width();
@@ -152,16 +156,16 @@
// We need to consider if letterboxed or pillarboxed.
// TODO(b/336807329) Encapsulate reachability logic
- appCompatTaskInfo.isLetterboxDoubleTapEnabled = reachabilityOverrides
- .isLetterboxDoubleTapEducationEnabled();
- if (appCompatTaskInfo.isLetterboxDoubleTapEnabled) {
+ appCompatTaskInfo.setLetterboxDoubleTapEnabled(reachabilityOverrides
+ .isLetterboxDoubleTapEducationEnabled());
+ if (appCompatTaskInfo.isLetterboxDoubleTapEnabled()) {
if (appCompatTaskInfo.isTopActivityPillarboxed()) {
if (reachabilityOverrides.allowHorizontalReachabilityForThinLetterbox()) {
// Pillarboxed.
appCompatTaskInfo.topActivityLetterboxHorizontalPosition =
reachabilityOverrides.getLetterboxPositionForHorizontalReachability();
} else {
- appCompatTaskInfo.isLetterboxDoubleTapEnabled = false;
+ appCompatTaskInfo.setLetterboxDoubleTapEnabled(false);
}
} else {
if (reachabilityOverrides.allowVerticalReachabilityForThinLetterbox()) {
@@ -169,15 +173,15 @@
appCompatTaskInfo.topActivityLetterboxVerticalPosition =
reachabilityOverrides.getLetterboxPositionForVerticalReachability();
} else {
- appCompatTaskInfo.isLetterboxDoubleTapEnabled = false;
+ appCompatTaskInfo.setLetterboxDoubleTapEnabled(false);
}
}
}
- appCompatTaskInfo.topActivityEligibleForUserAspectRatioButton =
- !info.isTopActivityTransparent && !appCompatTaskInfo.topActivityInSizeCompat
- && top.mAppCompatController.getAppCompatAspectRatioOverrides()
- .shouldEnableUserAspectRatioSettings();
- appCompatTaskInfo.topActivityBoundsLetterboxed = top.areBoundsLetterboxed();
+ final boolean eligibleForAspectRatioButton =
+ !info.isTopActivityTransparent && !appCompatTaskInfo.isTopActivityInSizeCompat()
+ && aspectRatioOverrides.shouldEnableUserAspectRatioSettings();
+ appCompatTaskInfo.setEligibleForUserAspectRatioButton(eligibleForAspectRatioButton);
+ appCompatTaskInfo.setTopActivityLetterboxed(top.areBoundsLetterboxed());
appCompatTaskInfo.cameraCompatTaskInfo.freeformCameraCompatMode = top.mAppCompatController
.getAppCompatCameraOverrides().getFreeformCameraCompatMode();
}
@@ -207,4 +211,16 @@
}
return "UNKNOWN_REASON";
}
+
+ private static void clearAppCompatTaskInfo(@NonNull AppCompatTaskInfo info) {
+ info.topActivityLetterboxVerticalPosition = TaskInfo.PROPERTY_VALUE_UNSET;
+ info.topActivityLetterboxHorizontalPosition = TaskInfo.PROPERTY_VALUE_UNSET;
+ info.topActivityLetterboxWidth = TaskInfo.PROPERTY_VALUE_UNSET;
+ info.topActivityLetterboxHeight = TaskInfo.PROPERTY_VALUE_UNSET;
+ info.topActivityLetterboxAppHeight = TaskInfo.PROPERTY_VALUE_UNSET;
+ info.topActivityLetterboxAppWidth = TaskInfo.PROPERTY_VALUE_UNSET;
+ info.cameraCompatTaskInfo.freeformCameraCompatMode =
+ CameraCompatTaskInfo.CAMERA_COMPAT_FREEFORM_NONE;
+ info.clearTopActivityFlags();
+ }
}
diff --git a/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java b/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java
index 3e55e2d..f566df5 100644
--- a/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java
+++ b/services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java
@@ -238,7 +238,7 @@
taskInfo.appCompatTaskInfo.topActivityLetterboxAppWidth;
final int appLetterboxHeight =
taskInfo.appCompatTaskInfo.topActivityLetterboxAppHeight;
- if (appCompatTaskInfo.topActivityBoundsLetterboxed) {
+ if (appCompatTaskInfo.isTopActivityLetterboxed()) {
desiredAspectRatio = (float) Math.max(appLetterboxWidth, appLetterboxHeight)
/ Math.min(appLetterboxWidth, appLetterboxHeight);
} else {
diff --git a/services/core/java/com/android/server/wm/DisplayWindowPolicyControllerHelper.java b/services/core/java/com/android/server/wm/DisplayWindowPolicyControllerHelper.java
index 4ec318b..dedf35a 100644
--- a/services/core/java/com/android/server/wm/DisplayWindowPolicyControllerHelper.java
+++ b/services/core/java/com/android/server/wm/DisplayWindowPolicyControllerHelper.java
@@ -24,6 +24,7 @@
import android.companion.virtualdevice.flags.Flags;
import android.content.ComponentName;
import android.content.Intent;
+import android.content.IntentSender;
import android.content.pm.ActivityInfo;
import android.os.Process;
import android.os.UserHandle;
@@ -34,6 +35,7 @@
import java.io.PrintWriter;
import java.util.List;
+import java.util.function.Supplier;
class DisplayWindowPolicyControllerHelper {
private static final String TAG = "DisplayWindowPolicyControllerHelper";
@@ -98,7 +100,8 @@
*/
public boolean canActivityBeLaunched(ActivityInfo activityInfo,
Intent intent, @WindowConfiguration.WindowingMode int windowingMode,
- int launchingFromDisplayId, boolean isNewTask) {
+ int launchingFromDisplayId, boolean isNewTask, boolean isResultExpected,
+ Supplier<IntentSender> intentSender) {
if (mDisplayWindowPolicyController == null) {
// Missing controller means that this display has no categories for activity launch
// restriction.
@@ -111,7 +114,7 @@
return true;
}
return mDisplayWindowPolicyController.canActivityBeLaunched(activityInfo, intent,
- windowingMode, launchingFromDisplayId, isNewTask);
+ windowingMode, launchingFromDisplayId, isNewTask, isResultExpected, intentSender);
}
private boolean hasDisplayCategory(ActivityInfo aInfo) {
diff --git a/services/core/java/com/android/server/wm/ImeTargetChangeListener.java b/services/core/java/com/android/server/wm/ImeTargetChangeListener.java
deleted file mode 100644
index e94f17c..0000000
--- a/services/core/java/com/android/server/wm/ImeTargetChangeListener.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.server.wm;
-
-import android.annotation.NonNull;
-import android.os.IBinder;
-import android.view.WindowManager;
-
-/**
- * Callback the IME targeting window visibility change state for
- * {@link com.android.server.inputmethod.InputMethodManagerService} to manage the IME surface
- * visibility and z-ordering.
- */
-public interface ImeTargetChangeListener {
- /**
- * Called when a non-IME-focusable overlay window being the IME layering target (e.g. a
- * window with {@link android.view.WindowManager.LayoutParams#FLAG_NOT_FOCUSABLE} and
- * {@link android.view.WindowManager.LayoutParams#FLAG_ALT_FOCUSABLE_IM} flags)
- * has changed its window visibility.
- *
- * @param overlayWindowToken the window token of the overlay window.
- * @param windowType the window type of the overlay window.
- * @param visible the visibility of the overlay window, {@code true} means visible
- * and {@code false} otherwise.
- * @param removed Whether the IME target overlay window has being removed.
- * @param displayId display ID where the overlay window exists.
- */
- default void onImeTargetOverlayVisibilityChanged(@NonNull IBinder overlayWindowToken,
- @WindowManager.LayoutParams.WindowType int windowType,
- boolean visible, boolean removed, int displayId) {
- }
-
- /**
- * Called when the visibility of IME input target window has changed.
- *
- * @param imeInputTarget the window token of the IME input target window.
- * @param visible the new window visibility made by {@code imeInputTarget}. visible is
- * {@code true} when switching to the new visible IME input target
- * window and started input, or the same input target relayout to
- * visible from invisible. In contrast, visible is {@code false} when
- * closing the input target, or the same input target relayout to
- * invisible from visible.
- * @param removed Whether the IME input target window has being removed.
- * @param displayId display ID where the overlay window exists.
- */
- default void onImeInputTargetVisibilityChanged(@NonNull IBinder imeInputTarget, boolean visible,
- boolean removed, int displayId) {
- }
-}
diff --git a/services/core/java/com/android/server/wm/WindowManagerInternal.java b/services/core/java/com/android/server/wm/WindowManagerInternal.java
index a574845..82d39a3 100644
--- a/services/core/java/com/android/server/wm/WindowManagerInternal.java
+++ b/services/core/java/com/android/server/wm/WindowManagerInternal.java
@@ -990,16 +990,6 @@
}
/**
- * Sets by the {@link com.android.server.inputmethod.InputMethodManagerService} to monitor
- * the visibility change of the IME targeted windows.
- *
- * @see ImeTargetChangeListener#onImeTargetOverlayVisibilityChanged
- * @see ImeTargetChangeListener#onImeInputTargetVisibilityChanged
- */
- public abstract void setInputMethodTargetChangeListener(
- @NonNull ImeTargetChangeListener listener);
-
- /**
* Moves the {@link WindowToken} {@code binder} to the display specified by {@code displayId}.
*/
public abstract void moveWindowTokenToDisplay(IBinder binder, int displayId);
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index cf92f1b..5749272 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -789,7 +789,6 @@
boolean mHardKeyboardAvailable;
WindowManagerInternal.OnHardKeyboardStatusChangeListener mHardKeyboardStatusChangeListener;
WindowManagerInternal.OnImeRequestedChangedListener mOnImeRequestedChangedListener;
- @Nullable ImeTargetChangeListener mImeTargetChangeListener;
SettingsObserver mSettingsObserver;
final EmbeddedWindowController mEmbeddedWindowController;
@@ -3517,29 +3516,28 @@
void dispatchImeTargetOverlayVisibilityChanged(@NonNull IBinder token,
@WindowManager.LayoutParams.WindowType int windowType, boolean visible,
boolean removed, int displayId) {
- if (mImeTargetChangeListener != null) {
- if (DEBUG_INPUT_METHOD) {
- Slog.d(TAG, "onImeTargetOverlayVisibilityChanged, win=" + mWindowMap.get(token)
- + ", type=" + ViewDebug.intToString(WindowManager.LayoutParams.class,
- "type", windowType) + "visible=" + visible + ", removed=" + removed
- + ", displayId=" + displayId);
- }
- mH.post(() -> mImeTargetChangeListener.onImeTargetOverlayVisibilityChanged(token,
- windowType, visible, removed, displayId));
+ if (DEBUG_INPUT_METHOD) {
+ Slog.d(TAG, "onImeTargetOverlayVisibilityChanged, win=" + mWindowMap.get(token)
+ + ", type=" + ViewDebug.intToString(WindowManager.LayoutParams.class,
+ "type", windowType) + "visible=" + visible + ", removed=" + removed
+ + ", displayId=" + displayId);
}
+ // Ignoring the starting window since it's ok to cover the IME target
+ // window in temporary without affecting the IME visibility.
+ final boolean hasOverlay = visible && !removed && windowType != TYPE_APPLICATION_STARTING;
+ mH.post(() -> InputMethodManagerInternal.get().setHasVisibleImeLayeringOverlay(hasOverlay,
+ displayId));
}
void dispatchImeInputTargetVisibilityChanged(@NonNull IBinder token, boolean visible,
boolean removed, int displayId) {
- if (mImeTargetChangeListener != null) {
- if (DEBUG_INPUT_METHOD) {
- Slog.d(TAG, "onImeInputTargetVisibilityChanged, win=" + mWindowMap.get(token)
- + "visible=" + visible + ", removed=" + removed
- + ", displayId" + displayId);
- }
- mH.post(() -> mImeTargetChangeListener.onImeInputTargetVisibilityChanged(token,
- visible, removed, displayId));
+ if (DEBUG_INPUT_METHOD) {
+ Slog.d(TAG, "onImeInputTargetVisibilityChanged, win=" + mWindowMap.get(token)
+ + "visible=" + visible + ", removed=" + removed + ", displayId=" + displayId);
}
+ final boolean visibleAndNotRemoved = visible && !removed;
+ mH.post(() -> InputMethodManagerInternal.get().onImeInputTargetVisibilityChanged(token,
+ visibleAndNotRemoved, displayId));
}
@Override
@@ -8675,13 +8673,6 @@
}
@Override
- public void setInputMethodTargetChangeListener(@NonNull ImeTargetChangeListener listener) {
- synchronized (mGlobalLock) {
- mImeTargetChangeListener = listener;
- }
- }
-
- @Override
public void setOrientationRequestPolicy(boolean respected,
int[] fromOrientations, int[] toOrientations) {
synchronized (mGlobalLock) {
diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java
index 9a25104..3af5db9 100644
--- a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java
+++ b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java
@@ -53,6 +53,7 @@
import android.util.ArraySet;
import android.view.InputChannel;
import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.ImeTracker;
import android.window.ImeOnBackInvokedDispatcher;
import androidx.test.platform.app.InstrumentationRegistry;
@@ -260,6 +261,11 @@
unusedUserId -> mMockInputMethodBindingController);
spyOn(mInputMethodManagerService);
+ synchronized (ImfLock.class) {
+ doReturn(true).when(mInputMethodManagerService).setImeVisibilityOnFocusedWindowClient(
+ anyBoolean(), any(UserData.class), any(ImeTracker.Token.class));
+ }
+
// Start a InputMethodManagerService.Lifecycle to publish and manage the lifecycle of
// InputMethodManagerService, which is closer to the real situation.
InputMethodManagerService.Lifecycle lifecycle =
@@ -347,6 +353,14 @@
anyInt() /* flags */, any() /* resultReceiver */);
}
+ protected void verifySetImeVisibility(boolean setVisible, boolean invoked) {
+ synchronized (ImfLock.class) {
+ verify(mInputMethodManagerService,
+ times(invoked ? 1 : 0)).setImeVisibilityOnFocusedWindowClient(eq(setVisible),
+ any(UserData.class), any(ImeTracker.Token.class));
+ }
+ }
+
protected void createSessionForClient(IInputMethodClient client) {
synchronized (ImfLock.class) {
ClientState cs = mInputMethodManagerService.getClientStateLocked(client);
diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceWindowGainedFocusTest.java b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceWindowGainedFocusTest.java
index c5b5668..4d956b2 100644
--- a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceWindowGainedFocusTest.java
+++ b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceWindowGainedFocusTest.java
@@ -125,27 +125,52 @@
case SOFT_INPUT_STATE_UNSPECIFIED:
boolean showSoftInput =
(mSoftInputAdjustment == SOFT_INPUT_ADJUST_RESIZE) || mIsLargeScreen;
- verifyShowSoftInput(
- showSoftInput /* setVisible */, showSoftInput /* showSoftInput */);
- // Soft input was hidden by default, so it doesn't need to call
- // {@code IMS#hideSoftInput()}.
- verifyHideSoftInput(!showSoftInput /* setNotVisible */, false /* hideSoftInput */);
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ verifySetImeVisibility(true /* setVisible */, showSoftInput /* invoked */);
+ // A hide can only be triggered if there is no editorFocused, which this test
+ // always sets.
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(showSoftInput /* setVisible */,
+ showSoftInput /* showSoftInput */);
+ // Soft input was hidden by default, so it doesn't need to call
+ // {@code IMS#hideSoftInput()}.
+ verifyHideSoftInput(!showSoftInput /* setNotVisible */,
+ false /* hideSoftInput */);
+ }
break;
case SOFT_INPUT_STATE_VISIBLE:
case SOFT_INPUT_STATE_ALWAYS_VISIBLE:
- verifyShowSoftInput(true /* setVisible */, true /* showSoftInput */);
- verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ verifySetImeVisibility(true /* setVisible */, true /* invoked */);
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(true /* setVisible */, true /* showSoftInput */);
+ verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ }
break;
- case SOFT_INPUT_STATE_UNCHANGED: // Do nothing
- verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
- verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ case SOFT_INPUT_STATE_UNCHANGED:
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ verifySetImeVisibility(true /* setVisible */, false /* invoked */);
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
+ verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ }
break;
case SOFT_INPUT_STATE_HIDDEN:
case SOFT_INPUT_STATE_ALWAYS_HIDDEN:
- verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
- // Soft input was hidden by default, so it doesn't need to call
- // {@code IMS#hideSoftInput()}.
- verifyHideSoftInput(true /* setNotVisible */, false /* hideSoftInput */);
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ verifySetImeVisibility(true /* setVisible */, false /* invoked */);
+ // In this case, we don't have to manipulate the requested visible types of
+ // the WindowState, as they're already in the correct state
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
+ // Soft input was hidden by default, so it doesn't need to call
+ // {@code IMS#hideSoftInput()}.
+ verifyHideSoftInput(true /* setNotVisible */, false /* hideSoftInput */);
+ }
break;
default:
throw new IllegalStateException(
@@ -167,26 +192,52 @@
case SOFT_INPUT_STATE_UNSPECIFIED:
boolean hideSoftInput =
(mSoftInputAdjustment != SOFT_INPUT_ADJUST_RESIZE) && !mIsLargeScreen;
- verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
- // Soft input was hidden by default, so it doesn't need to call
- // {@code IMS#hideSoftInput()}.
- verifyHideSoftInput(hideSoftInput /* setNotVisible */, false /* hideSoftInput */);
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ // A show can only be triggered in forward navigation
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ // A hide can only be triggered if there is no editorFocused, which this test
+ // always sets.
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
+ // Soft input was hidden by default, so it doesn't need to call
+ // {@code IMS#hideSoftInput()}.
+ verifyHideSoftInput(hideSoftInput /* setNotVisible */,
+ false /* hideSoftInput */);
+ }
break;
case SOFT_INPUT_STATE_VISIBLE:
case SOFT_INPUT_STATE_HIDDEN:
case SOFT_INPUT_STATE_UNCHANGED: // Do nothing
- verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
- verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ verifySetImeVisibility(true /* setVisible */, false /* invoked */);
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
+ verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ }
break;
case SOFT_INPUT_STATE_ALWAYS_VISIBLE:
- verifyShowSoftInput(true /* setVisible */, true /* showSoftInput */);
- verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ verifySetImeVisibility(true /* setVisible */, true /* invoked */);
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(true /* setVisible */, true /* showSoftInput */);
+ verifyHideSoftInput(false /* setNotVisible */, false /* hideSoftInput */);
+ }
break;
case SOFT_INPUT_STATE_ALWAYS_HIDDEN:
- verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
- // Soft input was hidden by default, so it doesn't need to call
- // {@code IMS#hideSoftInput()}.
- verifyHideSoftInput(true /* setNotVisible */, false /* hideSoftInput */);
+ if (android.view.inputmethod.Flags.refactorInsetsController()) {
+ verifySetImeVisibility(true /* setVisible */, false /* invoked */);
+ // In this case, we don't have to manipulate the requested visible types of
+ // the WindowState, as they're already in the correct state
+ verifySetImeVisibility(false /* setVisible */, false /* invoked */);
+ } else {
+ verifyShowSoftInput(false /* setVisible */, false /* showSoftInput */);
+ // Soft input was hidden by default, so it doesn't need to call
+ // {@code IMS#hideSoftInput()}.
+ verifyHideSoftInput(true /* setNotVisible */, false /* hideSoftInput */);
+ }
break;
default:
throw new IllegalStateException(
diff --git a/services/tests/servicestests/src/com/android/server/companion/virtual/GenericWindowPolicyControllerTest.java b/services/tests/servicestests/src/com/android/server/companion/virtual/GenericWindowPolicyControllerTest.java
index 7eabfac..9317d06 100644
--- a/services/tests/servicestests/src/com/android/server/companion/virtual/GenericWindowPolicyControllerTest.java
+++ b/services/tests/servicestests/src/com/android/server/companion/virtual/GenericWindowPolicyControllerTest.java
@@ -42,9 +42,11 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentSender;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.net.Uri;
+import android.os.Binder;
import android.os.RemoteException;
import android.os.UserHandle;
import android.platform.test.annotations.Presubmit;
@@ -592,13 +594,15 @@
// register interceptor and intercept intent
when(mIntentListenerCallback.shouldInterceptIntent(any(Intent.class))).thenReturn(true);
assertThat(gwpc.canActivityBeLaunched(activityInfo, intent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID, /*isNewTask=*/false))
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID, /* isNewTask= */false,
+ /* isResultExpected = */ false, /* intentSender= */ null))
.isFalse();
// unregister interceptor and launch activity
when(mIntentListenerCallback.shouldInterceptIntent(any(Intent.class))).thenReturn(false);
assertThat(gwpc.canActivityBeLaunched(activityInfo, intent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID, /*isNewTask=*/false))
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID, /* isNewTask= */false,
+ /* isResultExpected = */ false, /* intentSender= */ null))
.isTrue();
}
@@ -617,13 +621,36 @@
// register interceptor with different filter
when(mIntentListenerCallback.shouldInterceptIntent(any(Intent.class))).thenReturn(false);
assertThat(gwpc.canActivityBeLaunched(activityInfo, intent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID, /*isNewTask=*/false))
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID, /* isNewTask= */false,
+ /* isResultExpected = */ false, /* intentSender= */ null))
.isTrue();
verify(mIntentListenerCallback, timeout(TIMEOUT_MILLIS))
.shouldInterceptIntent(any(Intent.class));
}
@Test
+ public void canActivityBeLaunched_resultExpected_noIntentSenderInCallback() {
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("testing"));
+
+ GenericWindowPolicyController gwpc = createGwpc();
+ gwpc.setDisplayId(DISPLAY_ID, /* isMirrorDisplay= */ false);
+ ActivityInfo activityInfo = getActivityInfo(
+ NONBLOCKED_APP_PACKAGE_NAME,
+ NONBLOCKED_APP_PACKAGE_NAME,
+ /* displayOnRemoteDevices */ false,
+ /* targetDisplayCategory */ null);
+
+ IntentSender intentSender = new IntentSender(new Binder());
+ assertThat(gwpc.canActivityBeLaunched(activityInfo, intent,
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID, /* isNewTask= */false,
+ /* isResultExpected = */ true, /* intentSender= */ () -> intentSender))
+ .isFalse();
+
+ verify(mActivityBlockedCallback, timeout(TIMEOUT_MILLIS))
+ .onActivityBlocked(DISPLAY_ID, activityInfo, /* intentSender= */ null);
+ }
+
+ @Test
public void onTopActivitychanged_null_noCallback() {
GenericWindowPolicyController gwpc = createGwpc();
gwpc.setDisplayId(DISPLAY_ID, /* isMirrorDisplay= */ false);
@@ -659,7 +686,8 @@
verify(mSecureWindowCallback, after(TIMEOUT_MILLIS).never())
.onSecureWindowShown(DISPLAY_ID, activityInfo.applicationInfo.uid);
- verify(mActivityBlockedCallback, never()).onActivityBlocked(DISPLAY_ID, activityInfo);
+ verify(mActivityBlockedCallback, never())
+ .onActivityBlocked(eq(DISPLAY_ID), eq(activityInfo), any());
}
@Test
@@ -678,7 +706,7 @@
verify(mSecureWindowCallback, timeout(TIMEOUT_MILLIS)).onSecureWindowShown(DISPLAY_ID,
activityInfo.applicationInfo.uid);
verify(mActivityBlockedCallback, after(TIMEOUT_MILLIS).never())
- .onActivityBlocked(DISPLAY_ID, activityInfo);
+ .onActivityBlocked(eq(DISPLAY_ID), eq(activityInfo), any());
}
@Test
@@ -697,7 +725,8 @@
verify(mSecureWindowCallback, after(TIMEOUT_MILLIS).never())
.onSecureWindowShown(DISPLAY_ID, activityInfo.applicationInfo.uid);
- verify(mActivityBlockedCallback, never()).onActivityBlocked(DISPLAY_ID, activityInfo);
+ verify(mActivityBlockedCallback, never())
+ .onActivityBlocked(eq(DISPLAY_ID), eq(activityInfo), any());
}
@Test
@@ -911,11 +940,12 @@
private void assertActivityCanBeLaunched(GenericWindowPolicyController gwpc, int fromDisplay,
boolean isNewTask, int windowingMode, ActivityInfo activityInfo) {
+ IntentSender intentSender = new IntentSender(new Binder());
assertThat(gwpc.canActivityBeLaunched(activityInfo, null, windowingMode, fromDisplay,
- isNewTask)).isTrue();
+ isNewTask, /* isResultExpected= */ false, () -> intentSender)).isTrue();
verify(mActivityBlockedCallback, after(TIMEOUT_MILLIS).never())
- .onActivityBlocked(fromDisplay, activityInfo);
+ .onActivityBlocked(fromDisplay, activityInfo, intentSender);
verify(mIntentListenerCallback, never()).shouldInterceptIntent(any(Intent.class));
}
@@ -927,23 +957,26 @@
private void assertActivityIsBlocked(GenericWindowPolicyController gwpc, int fromDisplay,
boolean isNewTask, int windowingMode, ActivityInfo activityInfo) {
+ IntentSender intentSender = new IntentSender(new Binder());
assertThat(gwpc.canActivityBeLaunched(activityInfo, null, windowingMode, fromDisplay,
- isNewTask)).isFalse();
+ isNewTask, /* isResultExpected= */ false, () -> intentSender)).isFalse();
verify(mActivityBlockedCallback, timeout(TIMEOUT_MILLIS))
- .onActivityBlocked(fromDisplay, activityInfo);
+ .onActivityBlocked(fromDisplay, activityInfo, intentSender);
verify(mIntentListenerCallback, after(TIMEOUT_MILLIS).never())
.shouldInterceptIntent(any(Intent.class));
}
private void assertNoActivityLaunched(GenericWindowPolicyController gwpc, int fromDisplay,
ActivityInfo activityInfo) {
+ IntentSender intentSender = new IntentSender(new Binder());
assertThat(gwpc.canActivityBeLaunched(activityInfo, null,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID, true))
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID, /* isNewTask= */false,
+ /* isResultExpected= */ false, () -> intentSender))
.isFalse();
verify(mActivityBlockedCallback, after(TIMEOUT_MILLIS).never())
- .onActivityBlocked(fromDisplay, activityInfo);
+ .onActivityBlocked(eq(fromDisplay), eq(activityInfo), any());
verify(mIntentListenerCallback, never()).shouldInterceptIntent(any(Intent.class));
}
}
diff --git a/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java
index 19712ea..c288212 100644
--- a/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/companion/virtual/VirtualDeviceManagerServiceTest.java
@@ -314,7 +314,8 @@
Intent blockedAppIntent = BlockedAppStreamingActivity.createIntent(
activityInfo, mAssociationInfo.getDisplayName());
gwpc.canActivityBeLaunched(activityInfo, blockedAppIntent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/false);
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null);
return blockedAppIntent;
}
@@ -1522,7 +1523,8 @@
Intent blockedAppIntent = BlockedAppStreamingActivity.createIntent(
activityInfo, mAssociationInfo.getDisplayName());
gwpc.canActivityBeLaunched(activityInfo, blockedAppIntent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/false);
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null);
verify(mContext, never()).startActivityAsUser(argThat(intent ->
intent.filterEquals(blockedAppIntent)), any(), any());
@@ -1543,7 +1545,8 @@
Intent blockedAppIntent = BlockedAppStreamingActivity.createIntent(
activityInfo, mAssociationInfo.getDisplayName());
gwpc.canActivityBeLaunched(activityInfo, blockedAppIntent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/false);
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null);
verify(mContext).startActivityAsUser(argThat(intent ->
intent.filterEquals(blockedAppIntent)), any(), any());
@@ -1564,7 +1567,8 @@
Intent blockedAppIntent = BlockedAppStreamingActivity.createIntent(
activityInfo, mAssociationInfo.getDisplayName());
gwpc.canActivityBeLaunched(activityInfo, blockedAppIntent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/false);
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null);
verify(mContext, never()).startActivityAsUser(argThat(intent ->
intent.filterEquals(blockedAppIntent)), any(), any());
@@ -1585,7 +1589,8 @@
Intent blockedAppIntent = BlockedAppStreamingActivity.createIntent(
activityInfo, mAssociationInfo.getDisplayName());
gwpc.canActivityBeLaunched(activityInfo, blockedAppIntent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/false);
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null);
verify(mContext).startActivityAsUser(argThat(intent ->
intent.filterEquals(blockedAppIntent)), any(), any());
@@ -1606,7 +1611,8 @@
Intent blockedAppIntent = BlockedAppStreamingActivity.createIntent(
activityInfo, mAssociationInfo.getDisplayName());
gwpc.canActivityBeLaunched(activityInfo, blockedAppIntent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/false);
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null);
verify(mContext).startActivityAsUser(argThat(intent ->
intent.filterEquals(blockedAppIntent)), any(), any());
@@ -1627,7 +1633,8 @@
Intent blockedAppIntent = BlockedAppStreamingActivity.createIntent(
activityInfo, mAssociationInfo.getDisplayName());
gwpc.canActivityBeLaunched(activityInfo, blockedAppIntent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/false);
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null);
verify(mContext).startActivityAsUser(argThat(intent ->
intent.filterEquals(blockedAppIntent)), any(), any());
@@ -1648,7 +1655,8 @@
Intent blockedAppIntent = BlockedAppStreamingActivity.createIntent(
activityInfo, mAssociationInfo.getDisplayName());
gwpc.canActivityBeLaunched(activityInfo, blockedAppIntent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/false);
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null);
verify(mContext).startActivityAsUser(argThat(intent ->
intent.filterEquals(blockedAppIntent)), any(), any());
@@ -1669,7 +1677,8 @@
Intent blockedAppIntent = BlockedAppStreamingActivity.createIntent(
activityInfo, mAssociationInfo.getDisplayName());
gwpc.canActivityBeLaunched(activityInfo, blockedAppIntent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/false);
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null);
verify(mContext).startActivityAsUser(argThat(intent ->
intent.filterEquals(blockedAppIntent)), any(), any());
@@ -1691,7 +1700,8 @@
/* displayOnRemoteDevices */ true,
/* targetDisplayCategory */ null);
assertThat(gwpc.canActivityBeLaunched(activityInfo, null,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/ false))
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null))
.isFalse();
// Verify that BlockedAppStreamingActivity also doesn't launch for mirror displays.
Intent blockedAppIntent = BlockedAppStreamingActivity.createIntent(
@@ -1716,7 +1726,8 @@
/* displayOnRemoteDevices */ true,
/* targetDisplayCategory */ null);
assertThat(gwpc.canActivityBeLaunched(activityInfo, null,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/ false))
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null))
.isTrue();
Intent blockedAppIntent = BlockedAppStreamingActivity.createIntent(
activityInfo, mAssociationInfo.getDisplayName());
@@ -1768,7 +1779,8 @@
/* displayOnRemoteDevices */ true,
/* targetDisplayCategory */ null);
assertThat(gwpc.canActivityBeLaunched(activityInfo, null,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/false))
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null))
.isTrue();
}
@@ -1784,7 +1796,8 @@
/* displayOnRemoteDevices */ true,
/* targetDisplayCategory */ null);
assertThat(gwpc.canActivityBeLaunched(activityInfo, intent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/false))
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null))
.isTrue();
}
@@ -1815,7 +1828,8 @@
// register interceptor and intercept intent
mDeviceImpl.registerIntentInterceptor(interceptor, intentFilter);
assertThat(gwpc.canActivityBeLaunched(activityInfo, intent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/false))
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null))
.isFalse();
ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
verify(interceptor).onIntentIntercepted(intentCaptor.capture());
@@ -1827,7 +1841,8 @@
// unregister interceptor and launch activity
mDeviceImpl.unregisterIntentInterceptor(interceptor);
assertThat(gwpc.canActivityBeLaunched(activityInfo, intent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/false))
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null))
.isTrue();
}
@@ -1858,7 +1873,8 @@
mDeviceImpl.registerIntentInterceptor(interceptor, intentFilter);
assertThat(gwpc.canActivityBeLaunched(activityInfo, intent,
- WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /*isNewTask=*/false))
+ WindowConfiguration.WINDOWING_MODE_FULLSCREEN, DISPLAY_ID_1, /* isNewTask= */ false,
+ /* isResultExpected = */ false, /* intentSender= */ null))
.isTrue();
}
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 f98bbf9..2b93ccb 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTvTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTvTest.java
@@ -2120,6 +2120,34 @@
assertThat(mNativeWrapper.getResultMessages()).doesNotContain(giveOsdName);
}
+ @Test
+ public void onOneTouchPlay_wakeUp_addCecDevice() {
+ assertThat(mHdmiControlService.getHdmiCecNetwork().getDeviceInfoList(false))
+ .isEmpty();
+ mHdmiCecLocalDeviceTv.mService.getHdmiCecConfig().setIntValue(
+ HdmiControlManager.CEC_SETTING_NAME_TV_WAKE_ON_ONE_TOUCH_PLAY,
+ HdmiControlManager.TV_WAKE_ON_ONE_TOUCH_PLAY_ENABLED);
+ mPowerManager.setInteractive(false);
+ mTestLooper.dispatchAll();
+
+ HdmiCecMessage textViewOn = HdmiCecMessageBuilder.buildTextViewOn(ADDR_PLAYBACK_1,
+ mTvLogicalAddress);
+ HdmiCecMessage activeSource = HdmiCecMessageBuilder.buildActiveSource(ADDR_PLAYBACK_1,
+ 0x1000);
+ assertThat(mHdmiCecLocalDeviceTv.dispatchMessage(textViewOn)).isEqualTo(Constants.HANDLED);
+ assertThat(mHdmiCecLocalDeviceTv.dispatchMessage(activeSource)).isEqualTo(
+ Constants.HANDLED);
+ mTestLooper.dispatchAll();
+ assertThat(mPowerManager.isInteractive()).isTrue();
+
+ // FakePowerManagerWrapper#wakeUp() doesn't broadcast Intent.ACTION_SCREEN_ON so we have to
+ // manually call this method.
+ mHdmiControlService.onWakeUp(WAKE_UP_SCREEN_ON);
+ mTestLooper.dispatchAll();
+ assertThat(mHdmiControlService.getHdmiCecNetwork().getDeviceInfoList(false))
+ .hasSize(1);
+ }
+
protected static class MockTvDevice extends HdmiCecLocalDeviceTv {
MockTvDevice(HdmiControlService service) {
super(service);
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayWindowPolicyControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayWindowPolicyControllerTests.java
index bb5887d..58f8eb2 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayWindowPolicyControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayWindowPolicyControllerTests.java
@@ -33,6 +33,7 @@
import android.app.WindowConfiguration;
import android.content.ComponentName;
import android.content.Intent;
+import android.content.IntentSender;
import android.content.pm.ActivityInfo;
import android.os.Process;
import android.util.ArraySet;
@@ -40,12 +41,14 @@
import android.window.DisplayWindowPolicyController;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.Set;
+import java.util.function.Supplier;
/**
* Tests for the {@link DisplayWindowPolicyController} class.
@@ -224,7 +227,7 @@
assertEquals(result, START_ABORTED);
}
- private class TestDisplayWindowPolicyController extends DisplayWindowPolicyController {
+ private static class TestDisplayWindowPolicyController extends DisplayWindowPolicyController {
public ComponentName DISALLOWED_ACTIVITY =
new ComponentName("fake.package", "DisallowedActivity");
@@ -236,7 +239,8 @@
@Override
public boolean canActivityBeLaunched(@NonNull ActivityInfo activity, Intent intent,
@WindowConfiguration.WindowingMode int windowingMode, int launchingFromDisplayId,
- boolean isNewTask) {
+ boolean isNewTask, boolean isResultExpected,
+ @Nullable Supplier<IntentSender> intentSender) {
return canContainActivity(activity, windowingMode, launchingFromDisplayId, isNewTask);
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java
index 4a9d5c7..f339d29 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DragDropControllerTests.java
@@ -218,16 +218,6 @@
}
@Test
- public void testPerformDrag_NullDataToOtherUser() {
- final WindowState otherUsersWindow =
- createDropTargetWindow("Other user's window", 1 * UserHandle.PER_USER_RANGE);
- doReturn(otherUsersWindow).when(mDisplayContent).getTouchableWinAtPointLocked(10, 10);
-
- doDragAndDrop(View.DRAG_FLAG_GLOBAL | View.DRAG_FLAG_GLOBAL_URI_READ, null, 10, 10);
- mToken = otherUsersWindow.mClient.asBinder();
- }
-
- @Test
public void testPrivateInterceptGlobalDragDropFlagChecksPermission() {
DisplayPolicy policy = mDisplayContent.getDisplayPolicy();
WindowManager.LayoutParams attrs = new WindowManager.LayoutParams();
diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
index 3e68b6b..aa997ac 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -889,7 +889,7 @@
verify(mTask).onSizeCompatActivityChanged();
ActivityManager.RunningTaskInfo taskInfo = mTask.getTaskInfo();
- assertTrue(taskInfo.appCompatTaskInfo.topActivityInSizeCompat);
+ assertTrue(taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat());
// Make the activity resizable again by restarting it
clearInvocations(mTask);
@@ -904,7 +904,7 @@
verify(mTask).onSizeCompatActivityChanged();
taskInfo = mTask.getTaskInfo();
- assertFalse(taskInfo.appCompatTaskInfo.topActivityInSizeCompat);
+ assertFalse(taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat());
}
@Test
@@ -922,7 +922,7 @@
verify(mTask).onSizeCompatActivityChanged();
ActivityManager.RunningTaskInfo taskInfo = mTask.getTaskInfo();
- assertTrue(taskInfo.appCompatTaskInfo.topActivityInSizeCompat);
+ assertTrue(taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat());
// Create another Task to hold another size compat activity.
clearInvocations(mTask);
@@ -942,7 +942,7 @@
verify(mTask, never()).onSizeCompatActivityChanged();
taskInfo = secondTask.getTaskInfo();
- assertTrue(taskInfo.appCompatTaskInfo.topActivityInSizeCompat);
+ assertTrue(taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat());
}
@Test
@@ -4744,7 +4744,7 @@
assertTrue(mActivity.inSizeCompatMode());
assertEquals(mActivity.getState(), PAUSED);
assertTrue(mActivity.isVisible());
- assertTrue(mTask.getTaskInfo().appCompatTaskInfo.topActivityInSizeCompat);
+ assertTrue(mTask.getTaskInfo().appCompatTaskInfo.isTopActivityInSizeCompat());
}
/**
diff --git a/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java b/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java
index b92af87..1e39f0b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java
@@ -139,7 +139,6 @@
private ActivityTaskManagerService mAtmService;
private WindowManagerService mWmService;
private InputManagerService mImService;
- private InputChannel mInputChannel;
private Runnable mOnBeforeServicesCreated;
/**
* Spied {@link SurfaceControl.Transaction} class than can be used to verify calls.
@@ -326,12 +325,15 @@
// InputManagerService
mImService = mock(InputManagerService.class);
- // InputChannel cannot be mocked because it may pass to InputEventReceiver.
- final InputChannel[] inputChannels = InputChannel.openInputChannelPair(TAG);
- inputChannels[0].dispose();
- mInputChannel = inputChannels[1];
- doReturn(mInputChannel).when(mImService).monitorInput(anyString(), anyInt());
- doReturn(mInputChannel).when(mImService).createInputChannel(anyString());
+ // InputChannel cannot be mocked because it may be passed to InputEventReceiver.
+ Answer<InputChannel> newInputChannel = invocation -> {
+ String name = invocation.getArgument(0);
+ final InputChannel[] channels = InputChannel.openInputChannelPair(name);
+ channels[0].dispose();
+ return channels[1];
+ };
+ when(mImService.monitorInput(anyString(), anyInt())).thenAnswer(newInputChannel);
+ when(mImService.createInputChannel(anyString())).thenAnswer(newInputChannel);
// StatusBarManagerInternal
final StatusBarManagerInternal sbmi = mock(StatusBarManagerInternal.class);
@@ -464,9 +466,6 @@
SurfaceAnimationThread.dispose();
AnimationThread.dispose();
UiThread.dispose();
- if (mInputChannel != null) {
- mInputChannel.dispose();
- }
tearDownLocalServices();
// Reset priority booster because animation thread has been changed.
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
index a232ff0..0a592f2 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
@@ -635,27 +635,27 @@
// The button should be eligible to be displayed
assertTrue(task.getTaskInfo()
- .appCompatTaskInfo.topActivityEligibleForUserAspectRatioButton);
+ .appCompatTaskInfo.eligibleForUserAspectRatioButton());
// When shouldApplyUserMinAspectRatioOverride is disable the button is not enabled
doReturn(false).when(
root.mAppCompatController.getAppCompatAspectRatioOverrides())
.shouldEnableUserAspectRatioSettings();
assertFalse(task.getTaskInfo()
- .appCompatTaskInfo.topActivityEligibleForUserAspectRatioButton);
+ .appCompatTaskInfo.eligibleForUserAspectRatioButton());
doReturn(true).when(root.mAppCompatController
.getAppCompatAspectRatioOverrides()).shouldEnableUserAspectRatioSettings();
// When in size compat mode the button is not enabled
doReturn(true).when(root).inSizeCompatMode();
assertFalse(task.getTaskInfo()
- .appCompatTaskInfo.topActivityEligibleForUserAspectRatioButton);
+ .appCompatTaskInfo.eligibleForUserAspectRatioButton());
doReturn(false).when(root).inSizeCompatMode();
// When the top activity is transparent, the button is not enabled
doReturn(false).when(root).fillsParent();
assertFalse(task.getTaskInfo()
- .appCompatTaskInfo.topActivityEligibleForUserAspectRatioButton);
+ .appCompatTaskInfo.eligibleForUserAspectRatioButton());
doReturn(true).when(root).fillsParent();
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java
index fb81a52..2b611b7 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java
@@ -1708,7 +1708,7 @@
verify(organizer).onTaskInfoChanged(infoCaptor.capture());
RunningTaskInfo info = infoCaptor.getValue();
assertEquals(rootTask.mTaskId, info.taskId);
- assertTrue(info.appCompatTaskInfo.topActivityInSizeCompat);
+ assertTrue(info.appCompatTaskInfo.isTopActivityInSizeCompat());
// Ensure task info show top activity that is not visible as not in size compat.
clearInvocations(organizer);
@@ -1718,7 +1718,7 @@
verify(organizer).onTaskInfoChanged(infoCaptor.capture());
info = infoCaptor.getValue();
assertEquals(rootTask.mTaskId, info.taskId);
- assertFalse(info.appCompatTaskInfo.topActivityInSizeCompat);
+ assertFalse(info.appCompatTaskInfo.isTopActivityInSizeCompat());
// Ensure task info show non size compat top activity as not in size compat.
clearInvocations(organizer);
@@ -1729,7 +1729,7 @@
verify(organizer).onTaskInfoChanged(infoCaptor.capture());
info = infoCaptor.getValue();
assertEquals(rootTask.mTaskId, info.taskId);
- assertFalse(info.appCompatTaskInfo.topActivityInSizeCompat);
+ assertFalse(info.appCompatTaskInfo.isTopActivityInSizeCompat());
}
@Test
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
index 11df331..39276a1 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java
@@ -77,8 +77,10 @@
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.clearInvocations;
+import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.when;
import android.content.res.CompatibilityInfo;
@@ -111,6 +113,7 @@
import androidx.test.filters.SmallTest;
+import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.testutils.StubTransaction;
import com.android.server.wm.SensitiveContentPackages.PackageInfo;
@@ -1337,8 +1340,8 @@
@Test
public void testImeTargetChangeListener_OnImeInputTargetVisibilityChanged() {
- final TestImeTargetChangeListener listener = new TestImeTargetChangeListener();
- mWm.mImeTargetChangeListener = listener;
+ final InputMethodManagerInternal immi = InputMethodManagerInternal.get();
+ spyOn(immi);
final WindowState imeTarget = createWindow(null /* parent */, TYPE_BASE_APPLICATION,
createActivityRecord(mDisplayContent), "imeTarget");
@@ -1347,32 +1350,26 @@
makeWindowVisible(imeTarget);
mDisplayContent.setImeInputTarget(imeTarget);
waitHandlerIdle(mWm.mH);
-
- assertThat(listener.mImeTargetToken).isEqualTo(imeTarget.mClient.asBinder());
- assertThat(listener.mIsRemoved).isFalse();
- assertThat(listener.mIsVisibleForImeInputTarget).isTrue();
- assertThat(listener.mDisplayId).isEqualTo(mDisplayContent.getDisplayId());
+ verify(immi).onImeInputTargetVisibilityChanged(imeTarget.mClient.asBinder(),
+ true /* visibleAndNotRemoved */, mDisplayContent.getDisplayId());
+ reset(immi);
imeTarget.mActivityRecord.setVisibleRequested(false);
waitHandlerIdle(mWm.mH);
-
- assertThat(listener.mImeTargetToken).isEqualTo(imeTarget.mClient.asBinder());
- assertThat(listener.mIsRemoved).isFalse();
- assertThat(listener.mIsVisibleForImeInputTarget).isFalse();
- assertThat(listener.mDisplayId).isEqualTo(mDisplayContent.getDisplayId());
+ verify(immi).onImeInputTargetVisibilityChanged(imeTarget.mClient.asBinder(),
+ false /* visibleAndNotRemoved */, mDisplayContent.getDisplayId());
+ reset(immi);
imeTarget.removeImmediately();
- assertThat(listener.mImeTargetToken).isEqualTo(imeTarget.mClient.asBinder());
- assertThat(listener.mIsRemoved).isTrue();
- assertThat(listener.mIsVisibleForImeInputTarget).isFalse();
- assertThat(listener.mDisplayId).isEqualTo(mDisplayContent.getDisplayId());
+ verify(immi).onImeInputTargetVisibilityChanged(imeTarget.mClient.asBinder(),
+ false /* visibleAndNotRemoved */, mDisplayContent.getDisplayId());
}
@SetupWindows(addWindows = {W_INPUT_METHOD})
@Test
public void testImeTargetChangeListener_OnImeTargetOverlayVisibilityChanged() {
- final TestImeTargetChangeListener listener = new TestImeTargetChangeListener();
- mWm.mImeTargetChangeListener = listener;
+ final InputMethodManagerInternal immi = InputMethodManagerInternal.get();
+ spyOn(immi);
// Scenario 1: test addWindow/relayoutWindow to add Ime layering overlay window as visible.
final WindowToken windowToken = createTestWindowToken(TYPE_APPLICATION_OVERLAY,
@@ -1402,10 +1399,10 @@
final WindowState imeLayeringTargetOverlay = mDisplayContent.getWindow(
w -> w.mClient.asBinder() == client.asBinder());
assertThat(imeLayeringTargetOverlay.isVisible()).isTrue();
- assertThat(listener.mImeTargetToken).isEqualTo(client.asBinder());
- assertThat(listener.mIsRemoved).isFalse();
- assertThat(listener.mIsVisibleForImeTargetOverlay).isTrue();
- assertThat(listener.mDisplayId).isEqualTo(mDisplayContent.getDisplayId());
+ verify(immi, atLeast(1))
+ .setHasVisibleImeLayeringOverlay(true /* hasVisibleOverlay */,
+ mDisplayContent.getDisplayId());
+ reset(immi);
// Scenario 2: test relayoutWindow to let the Ime layering target overlay window invisible.
mWm.relayoutWindow(session, client, params, 100, 200, View.GONE, 0, 0, 0,
@@ -1413,19 +1410,16 @@
waitHandlerIdle(mWm.mH);
assertThat(imeLayeringTargetOverlay.isVisible()).isFalse();
- assertThat(listener.mImeTargetToken).isEqualTo(client.asBinder());
- assertThat(listener.mIsRemoved).isFalse();
- assertThat(listener.mIsVisibleForImeTargetOverlay).isFalse();
- assertThat(listener.mDisplayId).isEqualTo(mDisplayContent.getDisplayId());
+ verify(immi).setHasVisibleImeLayeringOverlay(false /* hasVisibleOverlay */,
+ mDisplayContent.getDisplayId());
+ reset(immi);
// Scenario 3: test removeWindow to remove the Ime layering target overlay window.
mWm.removeClientToken(session, client.asBinder());
waitHandlerIdle(mWm.mH);
- assertThat(listener.mImeTargetToken).isEqualTo(client.asBinder());
- assertThat(listener.mIsRemoved).isTrue();
- assertThat(listener.mIsVisibleForImeTargetOverlay).isFalse();
- assertThat(listener.mDisplayId).isEqualTo(mDisplayContent.getDisplayId());
+ verify(immi).setHasVisibleImeLayeringOverlay(false /* hasVisibleOverlay */,
+ mDisplayContent.getDisplayId());
}
@Test
@@ -1468,31 +1462,4 @@
mWm.mSensitiveContentPackages.removeBlockScreenCaptureForApps(blockedPackages);
assertFalse(window.isSecureLocked());
}
-
- private static class TestImeTargetChangeListener implements ImeTargetChangeListener {
- private IBinder mImeTargetToken;
- private boolean mIsRemoved;
- private boolean mIsVisibleForImeTargetOverlay;
- private boolean mIsVisibleForImeInputTarget;
- private int mDisplayId;
-
- @Override
- public void onImeTargetOverlayVisibilityChanged(IBinder overlayWindowToken,
- @WindowManager.LayoutParams.WindowType int windowType, boolean visible,
- boolean removed, int displayId) {
- mImeTargetToken = overlayWindowToken;
- mIsVisibleForImeTargetOverlay = visible;
- mIsRemoved = removed;
- mDisplayId = displayId;
- }
-
- @Override
- public void onImeInputTargetVisibilityChanged(IBinder imeInputTarget,
- boolean visibleRequested, boolean removed, int displayId) {
- mImeTargetToken = imeInputTarget;
- mIsVisibleForImeInputTarget = visibleRequested;
- mIsRemoved = removed;
- mDisplayId = displayId;
- }
- }
}
diff --git a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGen.kt b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGen.kt
index 7212beb..5dde265 100644
--- a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGen.kt
+++ b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGen.kt
@@ -33,6 +33,8 @@
import org.objectweb.asm.ClassReader
import org.objectweb.asm.ClassVisitor
import org.objectweb.asm.ClassWriter
+import org.objectweb.asm.commons.ClassRemapper
+import org.objectweb.asm.commons.Remapper
import org.objectweb.asm.util.CheckClassAdapter
import java.io.BufferedInputStream
import java.io.FileOutputStream
@@ -70,7 +72,7 @@
}
// Build the filters.
- val filter = buildFilter(errors, allClasses, options)
+ val (filter, policyFileRemapper) = buildFilter(errors, allClasses, options)
// Transform the jar.
convert(
@@ -82,6 +84,9 @@
allClasses,
errors,
stats,
+ policyFileRemapper,
+ options.numShards.get,
+ options.shard.get,
)
// Dump statistics, if specified.
@@ -107,7 +112,7 @@
errors: HostStubGenErrors,
allClasses: ClassNodes,
options: HostStubGenOptions,
- ): OutputFilter {
+ ): Pair<OutputFilter, Remapper?> {
// We build a "chain" of multiple filters here.
//
// The filters are build in from "inside", meaning the first filter created here is
@@ -160,10 +165,14 @@
filter,
)
+ var policyFileRemapper: Remapper? = null
+
// Next, "text based" filter, which allows to override polices without touching
// the target code.
options.policyOverrideFile.ifSet {
- filter = createFilterFromTextPolicyFile(it, allClasses, filter)
+ val (f, p) = createFilterFromTextPolicyFile(it, allClasses, filter)
+ filter = f
+ policyFileRemapper = p
}
// If `--intersect-stub-jar` is provided, load from these jar files too.
@@ -178,7 +187,7 @@
// Apply the implicit filter.
filter = ImplicitOutputFilter(errors, allClasses, filter)
- return filter
+ return Pair(filter, policyFileRemapper)
}
/**
@@ -205,6 +214,9 @@
classes: ClassNodes,
errors: HostStubGenErrors,
stats: HostStubGenStats,
+ remapper: Remapper?,
+ numShards: Int,
+ shard: Int,
) {
log.i("Converting %s into [stub: %s, impl: %s] ...", inJar, outStubJar, outImplJar)
log.i("ASM CheckClassAdapter is %s", if (enableChecker) "enabled" else "disabled")
@@ -213,17 +225,32 @@
val packageRedirector = PackageRedirectRemapper(options.packageRedirects)
+ var itemIndex = 0
+ var numItemsProcessed = 0
+ var numItems = -1 // == Unknown
+
log.withIndent {
// Open the input jar file and process each entry.
ZipFile(inJar).use { inZip ->
+
+ numItems = inZip.size()
+ val shardStart = numItems * shard / numShards
+ val shardNextStart = numItems * (shard + 1) / numShards
+
maybeWithZipOutputStream(outStubJar) { stubOutStream ->
maybeWithZipOutputStream(outImplJar) { implOutStream ->
val inEntries = inZip.entries()
while (inEntries.hasMoreElements()) {
val entry = inEntries.nextElement()
+ val inShard = (shardStart <= itemIndex) && (itemIndex < shardNextStart)
+ itemIndex++
+ if (!inShard) {
+ continue
+ }
convertSingleEntry(inZip, entry, stubOutStream, implOutStream,
- filter, packageRedirector, enableChecker, classes, errors,
- stats)
+ filter, packageRedirector, remapper,
+ enableChecker, classes, errors, stats)
+ numItemsProcessed++
}
log.i("Converted all entries.")
}
@@ -233,7 +260,8 @@
}
}
val end = System.currentTimeMillis()
- log.i("Done transforming the jar in %.1f second(s).", (end - start) / 1000.0)
+ log.i("Done transforming the jar in %.1f second(s). %d / %d item(s) processed.",
+ (end - start) / 1000.0, numItemsProcessed, numItems)
}
private fun <T> maybeWithZipOutputStream(filename: String?, block: (ZipOutputStream?) -> T): T {
@@ -253,6 +281,7 @@
implOutStream: ZipOutputStream?,
filter: OutputFilter,
packageRedirector: PackageRedirectRemapper,
+ remapper: Remapper?,
enableChecker: Boolean,
classes: ClassNodes,
errors: HostStubGenErrors,
@@ -270,7 +299,7 @@
// If it's a class, convert it.
if (name.endsWith(".class")) {
processSingleClass(inZip, entry, stubOutStream, implOutStream, filter,
- packageRedirector, enableChecker, classes, errors, stats)
+ packageRedirector, remapper, enableChecker, classes, errors, stats)
return
}
@@ -321,6 +350,7 @@
implOutStream: ZipOutputStream?,
filter: OutputFilter,
packageRedirector: PackageRedirectRemapper,
+ remapper: Remapper?,
enableChecker: Boolean,
classes: ClassNodes,
errors: HostStubGenErrors,
@@ -332,16 +362,24 @@
log.d("Removing class: %s %s", classInternalName, classPolicy)
return
}
+ // If we're applying a remapper, we need to rename the file too.
+ var newName = entry.name
+ remapper?.mapType(classInternalName)?.let { remappedName ->
+ if (remappedName != classInternalName) {
+ log.d("Renaming class file: %s -> %s", classInternalName, remappedName)
+ newName = remappedName + ".class"
+ }
+ }
// Generate stub first.
if (stubOutStream != null && classPolicy.policy.needsInStub) {
log.v("Creating stub class: %s Policy: %s", classInternalName, classPolicy)
log.withIndent {
BufferedInputStream(inZip.getInputStream(entry)).use { bis ->
- val newEntry = ZipEntry(entry.name)
+ val newEntry = ZipEntry(newName)
stubOutStream.putNextEntry(newEntry)
convertClass(classInternalName, /*forImpl=*/false, bis,
- stubOutStream, filter, packageRedirector, enableChecker, classes,
- errors, null)
+ stubOutStream, filter, packageRedirector, remapper,
+ enableChecker, classes, errors, null)
stubOutStream.closeEntry()
}
}
@@ -350,11 +388,11 @@
log.v("Creating impl class: %s Policy: %s", classInternalName, classPolicy)
log.withIndent {
BufferedInputStream(inZip.getInputStream(entry)).use { bis ->
- val newEntry = ZipEntry(entry.name)
+ val newEntry = ZipEntry(newName)
implOutStream.putNextEntry(newEntry)
convertClass(classInternalName, /*forImpl=*/true, bis,
- implOutStream, filter, packageRedirector, enableChecker, classes,
- errors, stats)
+ implOutStream, filter, packageRedirector, remapper,
+ enableChecker, classes, errors, stats)
implOutStream.closeEntry()
}
}
@@ -371,6 +409,7 @@
out: OutputStream,
filter: OutputFilter,
packageRedirector: PackageRedirectRemapper,
+ remapper: Remapper?,
enableChecker: Boolean,
classes: ClassNodes,
errors: HostStubGenErrors,
@@ -387,6 +426,12 @@
if (enableChecker) {
outVisitor = CheckClassAdapter(outVisitor)
}
+
+ // Remapping should happen at the end.
+ remapper?.let {
+ outVisitor = ClassRemapper(outVisitor, remapper)
+ }
+
val visitorOptions = BaseAdapter.Options(
enablePreTrace = options.enablePreTrace.get,
enablePostTrace = options.enablePostTrace.get,
@@ -395,7 +440,7 @@
stats = stats,
)
outVisitor = BaseAdapter.getVisitor(classInternalName, classes, outVisitor, filter,
- packageRedirector, forImpl, visitorOptions)
+ packageRedirector, remapper, forImpl, visitorOptions)
cr.accept(outVisitor, ClassReader.EXPAND_FRAMES)
val data = cw.toByteArray()
diff --git a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGenOptions.kt b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGenOptions.kt
index e192516..2f833a8 100644
--- a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGenOptions.kt
+++ b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGenOptions.kt
@@ -112,6 +112,9 @@
var statsFile: SetOnce<String?> = SetOnce(null),
var apiListFile: SetOnce<String?> = SetOnce(null),
+
+ var numShards: SetOnce<Int> = SetOnce(1),
+ var shard: SetOnce<Int> = SetOnce(0),
) {
companion object {
@@ -162,6 +165,13 @@
fun SetOnce<String?>.setNextStringArg(): String = nextArg().also { this.set(it) }
fun MutableSet<String>.addUniqueAnnotationArg(): String =
nextArg().also { this += ensureUniqueAnnotation(it) }
+ fun SetOnce<Int>.setNextIntArg(): String = nextArg().also {
+ try {
+ this.set(it.toInt())
+ } catch (e: NumberFormatException) {
+ throw ArgumentsException("Invalid integer for $arg: $it")
+ }
+ }
try {
when (arg) {
@@ -259,6 +269,9 @@
"--stats-file" -> ret.statsFile.setNextStringArg()
"--supported-api-list-file" -> ret.apiListFile.setNextStringArg()
+ "--num-shards" -> ret.numShards.setNextIntArg()
+ "--shard-index" -> ret.shard.setNextIntArg()
+
else -> throw ArgumentsException("Unknown option: $arg")
}
} catch (e: SetOnce.SetMoreThanOnceException) {
@@ -396,6 +409,8 @@
enableNonStubMethodCallDetection=$enableNonStubMethodCallDetection,
statsFile=$statsFile,
apiListFile=$apiListFile,
+ numShards=$numShards,
+ shard=$shard,
}
""".trimIndent()
}
diff --git a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/TextFileFilterPolicyParser.kt b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/TextFileFilterPolicyParser.kt
index a89824e..1828003 100644
--- a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/TextFileFilterPolicyParser.kt
+++ b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/TextFileFilterPolicyParser.kt
@@ -22,11 +22,13 @@
import com.android.hoststubgen.normalizeTextLine
import com.android.hoststubgen.whitespaceRegex
import org.objectweb.asm.Opcodes
+import org.objectweb.asm.commons.Remapper
import org.objectweb.asm.tree.ClassNode
import java.io.BufferedReader
import java.io.FileReader
import java.io.PrintWriter
import java.util.Objects
+import java.util.regex.Pattern
/**
* Print a class node as a "keep" policy.
@@ -60,7 +62,7 @@
filename: String,
classes: ClassNodes,
fallback: OutputFilter,
- ): OutputFilter {
+ ): Pair<OutputFilter, Remapper?> {
log.i("Loading offloaded annotations from $filename ...")
log.withIndent {
val subclassFilter = SubclassFilter(classes, fallback)
@@ -73,6 +75,7 @@
var featureFlagsPolicy: FilterPolicyWithReason? = null
var syspropsPolicy: FilterPolicyWithReason? = null
var rFilePolicy: FilterPolicyWithReason? = null
+ val typeRenameSpec = mutableListOf<TextFilePolicyRemapper.TypeRenameSpec>()
try {
BufferedReader(FileReader(filename)).use { reader ->
@@ -251,6 +254,22 @@
imf.setRenameTo(className, fromName, signature, name)
}
}
+ "r", "rename" -> {
+ if (fields.size < 3) {
+ throw ParseException("Rename ('r') expects 2 fields.")
+ }
+ // Add ".*" to make it a prefix match.
+ val pattern = Pattern.compile(fields[1] + ".*")
+
+ // Removing the leading /'s from the prefix. This allows
+ // using a single '/' as an empty suffix, which is useful to have a
+ // "negative" rename rule to avoid subsequent raname's from getting
+ // applied. (Which is needed for services.jar)
+ val prefix = fields[2].trimStart('/')
+
+ typeRenameSpec += TextFilePolicyRemapper.TypeRenameSpec(
+ pattern, prefix)
+ }
else -> {
throw ParseException("Unknown directive \"${fields[0]}\"")
@@ -262,9 +281,16 @@
throw e.withSourceInfo(filename, lineNo)
}
+ var remapper: TextFilePolicyRemapper? = null
+ if (typeRenameSpec.isNotEmpty()) {
+ remapper = TextFilePolicyRemapper(typeRenameSpec)
+ }
+
// Wrap the in-memory-filter with AHF.
- return AndroidHeuristicsFilter(
- classes, aidlPolicy, featureFlagsPolicy, syspropsPolicy, rFilePolicy, imf)
+ return Pair(
+ AndroidHeuristicsFilter(
+ classes, aidlPolicy, featureFlagsPolicy, syspropsPolicy, rFilePolicy, imf),
+ remapper)
}
}
diff --git a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/TextFilePolicyRemapper.kt b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/TextFilePolicyRemapper.kt
new file mode 100644
index 0000000..2d94bb4
--- /dev/null
+++ b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/filters/TextFilePolicyRemapper.kt
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2024 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.hoststubgen.filters
+
+import com.android.hoststubgen.log
+import org.objectweb.asm.commons.Remapper
+import java.util.regex.Pattern
+
+/**
+ * A [Remapper] that provides a simple "jarjar" functionality.
+ */
+class TextFilePolicyRemapper(
+ val typeRenameSpecs: List<TypeRenameSpec>
+) : Remapper() {
+ /**
+ * When a package name matches [typeInternalNamePattern], we prepend [typeInternalNamePrefix]
+ * to it.
+ */
+ data class TypeRenameSpec(
+ val typeInternalNamePattern: Pattern,
+ val typeInternalNamePrefix: String,
+ )
+
+ private val cache = mutableMapOf<String, String>()
+
+ override fun mapType(typeInternalName: String): String {
+// if (typeInternalName == null) {
+// return null // do we need it??
+// }
+ cache[typeInternalName]?.let {
+ return it
+ }
+
+ var mapped: String = typeInternalName
+ typeRenameSpecs.forEach {
+ if (it.typeInternalNamePattern.matcher(typeInternalName).matches()) {
+ mapped = it.typeInternalNamePrefix + typeInternalName
+ log.d("Renaming type $typeInternalName to $mapped")
+ }
+ }
+ cache[typeInternalName] = mapped
+ return mapped
+ }
+
+ // TODO Do we need to implement mapPackage(), etc too?
+}
diff --git a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/visitors/BaseAdapter.kt b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/visitors/BaseAdapter.kt
index c99ff0e..bad0449 100644
--- a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/visitors/BaseAdapter.kt
+++ b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/visitors/BaseAdapter.kt
@@ -34,6 +34,7 @@
import org.objectweb.asm.MethodVisitor
import org.objectweb.asm.Opcodes
import org.objectweb.asm.commons.ClassRemapper
+import org.objectweb.asm.commons.Remapper
import org.objectweb.asm.util.TraceClassVisitor
import java.io.PrintWriter
@@ -259,13 +260,14 @@
companion object {
fun getVisitor(
- classInternalName: String,
- classes: ClassNodes,
- nextVisitor: ClassVisitor,
- filter: OutputFilter,
- packageRedirector: PackageRedirectRemapper,
- forImpl: Boolean,
- options: Options,
+ classInternalName: String,
+ classes: ClassNodes,
+ nextVisitor: ClassVisitor,
+ filter: OutputFilter,
+ packageRedirector: PackageRedirectRemapper,
+ remapper: Remapper?,
+ forImpl: Boolean,
+ options: Options,
): ClassVisitor {
var next = nextVisitor
diff --git a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/visitors/PackageRedirectRemapper.kt b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/visitors/PackageRedirectRemapper.kt
index b3790e1..e90ecd7 100644
--- a/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/visitors/PackageRedirectRemapper.kt
+++ b/tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/visitors/PackageRedirectRemapper.kt
@@ -20,6 +20,18 @@
/**
* A [Remapper] for `--package-redirect`
+ *
+ * This is a feature to update all calls to specific packages to another package, which allows
+ * implementing a class in a different package, when the original package isn't allowed to modify.
+ *
+ * For example, using this, we can implement `dalvik.*` APIs in a separate package, and update
+ * all calls to the `dalvik` package to a different package.
+ *
+ * For this purpose, we don't expect the "renamed-from" classes to be in the target jar,
+ * so we don't apply the remapper to them. (The exclusion happens at the callsite of this class)
+ *
+ * TODO: Currently it's not used. Maybe remove, or just unify with the other remapper feature
+ * with TextFileFilterPolicyParser.kt.
*/
class PackageRedirectRemapper(
packageRedirects: List<Pair<String, String>>,
diff --git a/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/01-hoststubgen-test-tiny-framework-orig-dump.txt b/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/01-hoststubgen-test-tiny-framework-orig-dump.txt
index 3ef1175..c127e67 100644
--- a/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/01-hoststubgen-test-tiny-framework-orig-dump.txt
+++ b/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/01-hoststubgen-test-tiny-framework-orig-dump.txt
@@ -2706,6 +2706,95 @@
RuntimeInvisibleAnnotations:
x: #x()
android.hosttest.annotation.HostSideTestWholeClassStub
+## Class: com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller.class
+ Compiled from "TinyFrameworkRenamedClassCaller.java"
+public class com.android.hoststubgen.test.tinyframework.TinyFrameworkRenamedClassCaller
+ minor version: 0
+ major version: 61
+ flags: (0x0021) ACC_PUBLIC, ACC_SUPER
+ this_class: #x // com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller
+ super_class: #x // java/lang/Object
+ interfaces: 0, fields: 0, methods: 2, attributes: 2
+ public com.android.hoststubgen.test.tinyframework.TinyFrameworkRenamedClassCaller();
+ descriptor: ()V
+ flags: (0x0001) ACC_PUBLIC
+ Code:
+ stack=1, locals=1, args_size=1
+ x: aload_0
+ x: invokespecial #x // Method java/lang/Object."<init>":()V
+ x: return
+ LineNumberTable:
+ LocalVariableTable:
+ Start Length Slot Name Signature
+ 0 5 0 this Lcom/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller;
+
+ public static int foo(int);
+ descriptor: (I)I
+ flags: (0x0009) ACC_PUBLIC, ACC_STATIC
+ Code:
+ stack=3, locals=1, args_size=1
+ x: new #x // class com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed
+ x: dup
+ x: iload_0
+ x: invokespecial #x // Method com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed."<init>":(I)V
+ x: invokevirtual #x // Method com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed.getValue:()I
+ x: ireturn
+ LineNumberTable:
+ LocalVariableTable:
+ Start Length Slot Name Signature
+ 0 12 0 value I
+}
+SourceFile: "TinyFrameworkRenamedClassCaller.java"
+RuntimeInvisibleAnnotations:
+ x: #x()
+ android.hosttest.annotation.HostSideTestWholeClassStub
+## Class: com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed.class
+ Compiled from "TinyFrameworkToBeRenamed.java"
+public class com.android.hoststubgen.test.tinyframework.TinyFrameworkToBeRenamed
+ minor version: 0
+ major version: 61
+ flags: (0x0021) ACC_PUBLIC, ACC_SUPER
+ this_class: #x // com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed
+ super_class: #x // java/lang/Object
+ interfaces: 0, fields: 1, methods: 2, attributes: 2
+ private final int mValue;
+ descriptor: I
+ flags: (0x0012) ACC_PRIVATE, ACC_FINAL
+
+ public com.android.hoststubgen.test.tinyframework.TinyFrameworkToBeRenamed(int);
+ descriptor: (I)V
+ flags: (0x0001) ACC_PUBLIC
+ Code:
+ stack=2, locals=2, args_size=2
+ x: aload_0
+ x: invokespecial #x // Method java/lang/Object."<init>":()V
+ x: aload_0
+ x: iload_1
+ x: putfield #x // Field mValue:I
+ x: return
+ LineNumberTable:
+ LocalVariableTable:
+ Start Length Slot Name Signature
+ 0 10 0 this Lcom/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed;
+ 0 10 1 value I
+
+ public int getValue();
+ descriptor: ()I
+ flags: (0x0001) ACC_PUBLIC
+ Code:
+ stack=1, locals=1, args_size=1
+ x: aload_0
+ x: getfield #x // Field mValue:I
+ x: ireturn
+ LineNumberTable:
+ LocalVariableTable:
+ Start Length Slot Name Signature
+ 0 5 0 this Lcom/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed;
+}
+SourceFile: "TinyFrameworkToBeRenamed.java"
+RuntimeInvisibleAnnotations:
+ x: #x()
+ android.hosttest.annotation.HostSideTestWholeClassStub
## Class: com/android/hoststubgen/test/tinyframework/packagetest/A.class
Compiled from "A.java"
public class com.android.hoststubgen.test.tinyframework.packagetest.A
diff --git a/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/02-hoststubgen-test-tiny-framework-host-stub-dump.txt b/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/02-hoststubgen-test-tiny-framework-host-stub-dump.txt
index 0bbb418..17ba48c 100644
--- a/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/02-hoststubgen-test-tiny-framework-host-stub-dump.txt
+++ b/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/02-hoststubgen-test-tiny-framework-host-stub-dump.txt
@@ -2177,6 +2177,56 @@
RuntimeInvisibleAnnotations:
x: #x()
android.hosttest.annotation.HostSideTestWholeClassStub
+## Class: com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller.class
+ Compiled from "TinyFrameworkRenamedClassCaller.java"
+public class com.android.hoststubgen.test.tinyframework.TinyFrameworkRenamedClassCaller
+ minor version: 0
+ major version: 61
+ flags: (0x0021) ACC_PUBLIC, ACC_SUPER
+ this_class: #x // com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller
+ super_class: #x // java/lang/Object
+ interfaces: 0, fields: 0, methods: 2, attributes: 3
+ public com.android.hoststubgen.test.tinyframework.TinyFrameworkRenamedClassCaller();
+ descriptor: ()V
+ flags: (0x0001) ACC_PUBLIC
+ Code:
+ stack=3, locals=1, args_size=1
+ x: new #x // class java/lang/RuntimeException
+ x: dup
+ x: ldc #x // String Stub!
+ x: invokespecial #x // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
+ x: athrow
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+
+ public static int foo(int);
+ descriptor: (I)I
+ flags: (0x0009) ACC_PUBLIC, ACC_STATIC
+ Code:
+ stack=3, locals=1, args_size=1
+ x: new #x // class java/lang/RuntimeException
+ x: dup
+ x: ldc #x // String Stub!
+ x: invokespecial #x // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
+ x: athrow
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+}
+SourceFile: "TinyFrameworkRenamedClassCaller.java"
+RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+RuntimeInvisibleAnnotations:
+ x: #x()
+ android.hosttest.annotation.HostSideTestWholeClassStub
## Class: com/android/hoststubgen/test/tinyframework/packagetest/A.class
Compiled from "A.java"
public class com.android.hoststubgen.test.tinyframework.packagetest.A
@@ -2419,3 +2469,62 @@
RuntimeInvisibleAnnotations:
x: #x()
android.hosttest.annotation.HostSideTestWholeClassStub
+## Class: rename_prefix/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed.class
+ Compiled from "TinyFrameworkToBeRenamed.java"
+public class rename_prefix.com.android.hoststubgen.test.tinyframework.TinyFrameworkToBeRenamed
+ minor version: 0
+ major version: 61
+ flags: (0x0021) ACC_PUBLIC, ACC_SUPER
+ this_class: #x // rename_prefix/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed
+ super_class: #x // java/lang/Object
+ interfaces: 0, fields: 1, methods: 2, attributes: 3
+ private final int mValue;
+ descriptor: I
+ flags: (0x0012) ACC_PRIVATE, ACC_FINAL
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+
+ public rename_prefix.com.android.hoststubgen.test.tinyframework.TinyFrameworkToBeRenamed(int);
+ descriptor: (I)V
+ flags: (0x0001) ACC_PUBLIC
+ Code:
+ stack=3, locals=2, args_size=2
+ x: new #x // class java/lang/RuntimeException
+ x: dup
+ x: ldc #x // String Stub!
+ x: invokespecial #x // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
+ x: athrow
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+
+ public int getValue();
+ descriptor: ()I
+ flags: (0x0001) ACC_PUBLIC
+ Code:
+ stack=3, locals=1, args_size=1
+ x: new #x // class java/lang/RuntimeException
+ x: dup
+ x: ldc #x // String Stub!
+ x: invokespecial #x // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
+ x: athrow
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+}
+SourceFile: "TinyFrameworkToBeRenamed.java"
+RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+RuntimeInvisibleAnnotations:
+ x: #x()
+ android.hosttest.annotation.HostSideTestWholeClassStub
diff --git a/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/03-hoststubgen-test-tiny-framework-host-impl-dump.txt b/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/03-hoststubgen-test-tiny-framework-host-impl-dump.txt
index 57f3783..0f5f7e7 100644
--- a/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/03-hoststubgen-test-tiny-framework-host-impl-dump.txt
+++ b/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/03-hoststubgen-test-tiny-framework-host-impl-dump.txt
@@ -3540,6 +3540,63 @@
RuntimeInvisibleAnnotations:
x: #x()
android.hosttest.annotation.HostSideTestWholeClassStub
+## Class: com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller.class
+ Compiled from "TinyFrameworkRenamedClassCaller.java"
+public class com.android.hoststubgen.test.tinyframework.TinyFrameworkRenamedClassCaller
+ minor version: 0
+ major version: 61
+ flags: (0x0021) ACC_PUBLIC, ACC_SUPER
+ this_class: #x // com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller
+ super_class: #x // java/lang/Object
+ interfaces: 0, fields: 0, methods: 2, attributes: 3
+ public com.android.hoststubgen.test.tinyframework.TinyFrameworkRenamedClassCaller();
+ descriptor: ()V
+ flags: (0x0001) ACC_PUBLIC
+ Code:
+ stack=1, locals=1, args_size=1
+ x: aload_0
+ x: invokespecial #x // Method java/lang/Object."<init>":()V
+ x: return
+ LineNumberTable:
+ LocalVariableTable:
+ Start Length Slot Name Signature
+ 0 5 0 this Lcom/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller;
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+
+ public static int foo(int);
+ descriptor: (I)I
+ flags: (0x0009) ACC_PUBLIC, ACC_STATIC
+ Code:
+ stack=3, locals=1, args_size=1
+ x: new #x // class rename_prefix/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed
+ x: dup
+ x: iload_0
+ x: invokespecial #x // Method rename_prefix/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed."<init>":(I)V
+ x: invokevirtual #x // Method rename_prefix/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed.getValue:()I
+ x: ireturn
+ LineNumberTable:
+ LocalVariableTable:
+ Start Length Slot Name Signature
+ 0 12 0 value I
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+}
+SourceFile: "TinyFrameworkRenamedClassCaller.java"
+RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+RuntimeInvisibleAnnotations:
+ x: #x()
+ android.hosttest.annotation.HostSideTestWholeClassStub
## Class: com/android/hoststubgen/test/tinyframework/packagetest/A.class
Compiled from "A.java"
public class com.android.hoststubgen.test.tinyframework.packagetest.A
@@ -3962,3 +4019,70 @@
RuntimeInvisibleAnnotations:
x: #x()
android.hosttest.annotation.HostSideTestWholeClassStub
+## Class: rename_prefix/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed.class
+ Compiled from "TinyFrameworkToBeRenamed.java"
+public class rename_prefix.com.android.hoststubgen.test.tinyframework.TinyFrameworkToBeRenamed
+ minor version: 0
+ major version: 61
+ flags: (0x0021) ACC_PUBLIC, ACC_SUPER
+ this_class: #x // rename_prefix/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed
+ super_class: #x // java/lang/Object
+ interfaces: 0, fields: 1, methods: 2, attributes: 3
+ private final int mValue;
+ descriptor: I
+ flags: (0x0012) ACC_PRIVATE, ACC_FINAL
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+
+ public rename_prefix.com.android.hoststubgen.test.tinyframework.TinyFrameworkToBeRenamed(int);
+ descriptor: (I)V
+ flags: (0x0001) ACC_PUBLIC
+ Code:
+ stack=2, locals=2, args_size=2
+ x: aload_0
+ x: invokespecial #x // Method java/lang/Object."<init>":()V
+ x: aload_0
+ x: iload_1
+ x: putfield #x // Field mValue:I
+ x: return
+ LineNumberTable:
+ LocalVariableTable:
+ Start Length Slot Name Signature
+ 0 10 0 this Lcom/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed;
+ 0 10 1 value I
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+
+ public int getValue();
+ descriptor: ()I
+ flags: (0x0001) ACC_PUBLIC
+ Code:
+ stack=1, locals=1, args_size=1
+ x: aload_0
+ x: getfield #x // Field mValue:I
+ x: ireturn
+ LineNumberTable:
+ LocalVariableTable:
+ Start Length Slot Name Signature
+ 0 5 0 this Lcom/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed;
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+}
+SourceFile: "TinyFrameworkToBeRenamed.java"
+RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+RuntimeInvisibleAnnotations:
+ x: #x()
+ android.hosttest.annotation.HostSideTestWholeClassStub
diff --git a/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/12-hoststubgen-test-tiny-framework-host-ext-stub-dump.txt b/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/12-hoststubgen-test-tiny-framework-host-ext-stub-dump.txt
index 0bbb418..17ba48c 100644
--- a/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/12-hoststubgen-test-tiny-framework-host-ext-stub-dump.txt
+++ b/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/12-hoststubgen-test-tiny-framework-host-ext-stub-dump.txt
@@ -2177,6 +2177,56 @@
RuntimeInvisibleAnnotations:
x: #x()
android.hosttest.annotation.HostSideTestWholeClassStub
+## Class: com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller.class
+ Compiled from "TinyFrameworkRenamedClassCaller.java"
+public class com.android.hoststubgen.test.tinyframework.TinyFrameworkRenamedClassCaller
+ minor version: 0
+ major version: 61
+ flags: (0x0021) ACC_PUBLIC, ACC_SUPER
+ this_class: #x // com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller
+ super_class: #x // java/lang/Object
+ interfaces: 0, fields: 0, methods: 2, attributes: 3
+ public com.android.hoststubgen.test.tinyframework.TinyFrameworkRenamedClassCaller();
+ descriptor: ()V
+ flags: (0x0001) ACC_PUBLIC
+ Code:
+ stack=3, locals=1, args_size=1
+ x: new #x // class java/lang/RuntimeException
+ x: dup
+ x: ldc #x // String Stub!
+ x: invokespecial #x // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
+ x: athrow
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+
+ public static int foo(int);
+ descriptor: (I)I
+ flags: (0x0009) ACC_PUBLIC, ACC_STATIC
+ Code:
+ stack=3, locals=1, args_size=1
+ x: new #x // class java/lang/RuntimeException
+ x: dup
+ x: ldc #x // String Stub!
+ x: invokespecial #x // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
+ x: athrow
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+}
+SourceFile: "TinyFrameworkRenamedClassCaller.java"
+RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+RuntimeInvisibleAnnotations:
+ x: #x()
+ android.hosttest.annotation.HostSideTestWholeClassStub
## Class: com/android/hoststubgen/test/tinyframework/packagetest/A.class
Compiled from "A.java"
public class com.android.hoststubgen.test.tinyframework.packagetest.A
@@ -2419,3 +2469,62 @@
RuntimeInvisibleAnnotations:
x: #x()
android.hosttest.annotation.HostSideTestWholeClassStub
+## Class: rename_prefix/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed.class
+ Compiled from "TinyFrameworkToBeRenamed.java"
+public class rename_prefix.com.android.hoststubgen.test.tinyframework.TinyFrameworkToBeRenamed
+ minor version: 0
+ major version: 61
+ flags: (0x0021) ACC_PUBLIC, ACC_SUPER
+ this_class: #x // rename_prefix/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed
+ super_class: #x // java/lang/Object
+ interfaces: 0, fields: 1, methods: 2, attributes: 3
+ private final int mValue;
+ descriptor: I
+ flags: (0x0012) ACC_PRIVATE, ACC_FINAL
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+
+ public rename_prefix.com.android.hoststubgen.test.tinyframework.TinyFrameworkToBeRenamed(int);
+ descriptor: (I)V
+ flags: (0x0001) ACC_PUBLIC
+ Code:
+ stack=3, locals=2, args_size=2
+ x: new #x // class java/lang/RuntimeException
+ x: dup
+ x: ldc #x // String Stub!
+ x: invokespecial #x // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
+ x: athrow
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+
+ public int getValue();
+ descriptor: ()I
+ flags: (0x0001) ACC_PUBLIC
+ Code:
+ stack=3, locals=1, args_size=1
+ x: new #x // class java/lang/RuntimeException
+ x: dup
+ x: ldc #x // String Stub!
+ x: invokespecial #x // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
+ x: athrow
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+}
+SourceFile: "TinyFrameworkToBeRenamed.java"
+RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+RuntimeInvisibleAnnotations:
+ x: #x()
+ android.hosttest.annotation.HostSideTestWholeClassStub
diff --git a/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/13-hoststubgen-test-tiny-framework-host-ext-impl-dump.txt b/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/13-hoststubgen-test-tiny-framework-host-ext-impl-dump.txt
index 91104de..3beea64 100644
--- a/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/13-hoststubgen-test-tiny-framework-host-ext-impl-dump.txt
+++ b/tools/hoststubgen/hoststubgen/test-tiny-framework/golden-output/13-hoststubgen-test-tiny-framework-host-ext-impl-dump.txt
@@ -4408,6 +4408,83 @@
RuntimeInvisibleAnnotations:
x: #x()
android.hosttest.annotation.HostSideTestWholeClassStub
+## Class: com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller.class
+ Compiled from "TinyFrameworkRenamedClassCaller.java"
+public class com.android.hoststubgen.test.tinyframework.TinyFrameworkRenamedClassCaller
+ minor version: 0
+ major version: 61
+ flags: (0x0021) ACC_PUBLIC, ACC_SUPER
+ this_class: #x // com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller
+ super_class: #x // java/lang/Object
+ interfaces: 0, fields: 0, methods: 3, attributes: 3
+ private static {};
+ descriptor: ()V
+ flags: (0x000a) ACC_PRIVATE, ACC_STATIC
+ Code:
+ stack=2, locals=0, args_size=0
+ x: ldc #x // class com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller
+ x: ldc #x // String com.android.hoststubgen.hosthelper.HostTestUtils.logClassLoaded
+ x: invokestatic #x // Method com/android/hoststubgen/hosthelper/HostTestUtils.onClassLoaded:(Ljava/lang/Class;Ljava/lang/String;)V
+ x: return
+
+ public com.android.hoststubgen.test.tinyframework.TinyFrameworkRenamedClassCaller();
+ descriptor: ()V
+ flags: (0x0001) ACC_PUBLIC
+ Code:
+ stack=4, locals=1, args_size=1
+ x: ldc #x // class com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller
+ x: ldc #x // String <init>
+ x: ldc #x // String ()V
+ x: ldc #x // String com.android.hoststubgen.hosthelper.HostTestUtils.logMethodCall
+ x: invokestatic #x // Method com/android/hoststubgen/hosthelper/HostTestUtils.callMethodCallHook:(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
+ x: aload_0
+ x: invokespecial #x // Method java/lang/Object."<init>":()V
+ x: return
+ LineNumberTable:
+ LocalVariableTable:
+ Start Length Slot Name Signature
+ 11 5 0 this Lcom/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller;
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+
+ public static int foo(int);
+ descriptor: (I)I
+ flags: (0x0009) ACC_PUBLIC, ACC_STATIC
+ Code:
+ stack=4, locals=1, args_size=1
+ x: ldc #x // class com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller
+ x: ldc #x // String foo
+ x: ldc #x // String (I)I
+ x: ldc #x // String com.android.hoststubgen.hosthelper.HostTestUtils.logMethodCall
+ x: invokestatic #x // Method com/android/hoststubgen/hosthelper/HostTestUtils.callMethodCallHook:(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
+ x: new #x // class rename_prefix/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed
+ x: dup
+ x: iload_0
+ x: invokespecial #x // Method rename_prefix/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed."<init>":(I)V
+ x: invokevirtual #x // Method rename_prefix/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed.getValue:()I
+ x: ireturn
+ LineNumberTable:
+ LocalVariableTable:
+ Start Length Slot Name Signature
+ 11 12 0 value I
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+}
+SourceFile: "TinyFrameworkRenamedClassCaller.java"
+RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+RuntimeInvisibleAnnotations:
+ x: #x()
+ android.hosttest.annotation.HostSideTestWholeClassStub
## Class: com/android/hoststubgen/test/tinyframework/packagetest/A.class
Compiled from "A.java"
public class com.android.hoststubgen.test.tinyframework.packagetest.A
@@ -5041,3 +5118,90 @@
RuntimeInvisibleAnnotations:
x: #x()
android.hosttest.annotation.HostSideTestWholeClassStub
+## Class: rename_prefix/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed.class
+ Compiled from "TinyFrameworkToBeRenamed.java"
+public class rename_prefix.com.android.hoststubgen.test.tinyframework.TinyFrameworkToBeRenamed
+ minor version: 0
+ major version: 61
+ flags: (0x0021) ACC_PUBLIC, ACC_SUPER
+ this_class: #x // rename_prefix/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed
+ super_class: #x // java/lang/Object
+ interfaces: 0, fields: 1, methods: 3, attributes: 3
+ private final int mValue;
+ descriptor: I
+ flags: (0x0012) ACC_PRIVATE, ACC_FINAL
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+
+ private static {};
+ descriptor: ()V
+ flags: (0x000a) ACC_PRIVATE, ACC_STATIC
+ Code:
+ stack=2, locals=0, args_size=0
+ x: ldc #x // class com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed
+ x: ldc #x // String com.android.hoststubgen.hosthelper.HostTestUtils.logClassLoaded
+ x: invokestatic #x // Method com/android/hoststubgen/hosthelper/HostTestUtils.onClassLoaded:(Ljava/lang/Class;Ljava/lang/String;)V
+ x: return
+
+ public rename_prefix.com.android.hoststubgen.test.tinyframework.TinyFrameworkToBeRenamed(int);
+ descriptor: (I)V
+ flags: (0x0001) ACC_PUBLIC
+ Code:
+ stack=4, locals=2, args_size=2
+ x: ldc #x // class com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed
+ x: ldc #x // String <init>
+ x: ldc #x // String (I)V
+ x: ldc #x // String com.android.hoststubgen.hosthelper.HostTestUtils.logMethodCall
+ x: invokestatic #x // Method com/android/hoststubgen/hosthelper/HostTestUtils.callMethodCallHook:(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
+ x: aload_0
+ x: invokespecial #x // Method java/lang/Object."<init>":()V
+ x: aload_0
+ x: iload_1
+ x: putfield #x // Field mValue:I
+ x: return
+ LineNumberTable:
+ LocalVariableTable:
+ Start Length Slot Name Signature
+ 11 10 0 this Lcom/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed;
+ 11 10 1 value I
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+
+ public int getValue();
+ descriptor: ()I
+ flags: (0x0001) ACC_PUBLIC
+ Code:
+ stack=4, locals=1, args_size=1
+ x: ldc #x // class com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed
+ x: ldc #x // String getValue
+ x: ldc #x // String ()I
+ x: ldc #x // String com.android.hoststubgen.hosthelper.HostTestUtils.logMethodCall
+ x: invokestatic #x // Method com/android/hoststubgen/hosthelper/HostTestUtils.callMethodCallHook:(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
+ x: aload_0
+ x: getfield #x // Field mValue:I
+ x: ireturn
+ LineNumberTable:
+ LocalVariableTable:
+ Start Length Slot Name Signature
+ 11 5 0 this Lcom/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed;
+ RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+}
+SourceFile: "TinyFrameworkToBeRenamed.java"
+RuntimeVisibleAnnotations:
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInStub
+ x: #x()
+ com.android.hoststubgen.hosthelper.HostStubGenKeptInImpl
+RuntimeInvisibleAnnotations:
+ x: #x()
+ android.hosttest.annotation.HostSideTestWholeClassStub
diff --git a/tools/hoststubgen/hoststubgen/test-tiny-framework/policy-override-tiny-framework.txt b/tools/hoststubgen/hoststubgen/test-tiny-framework/policy-override-tiny-framework.txt
index 530de43..75c9721 100644
--- a/tools/hoststubgen/hoststubgen/test-tiny-framework/policy-override-tiny-framework.txt
+++ b/tools/hoststubgen/hoststubgen/test-tiny-framework/policy-override-tiny-framework.txt
@@ -48,3 +48,9 @@
# The following rules are the same as above
# class com.android.hoststubgen.test.tinyframework.packagetest.A stub
# class com.android.hoststubgen.test.tinyframework.packagetest.sub.A stub
+
+
+# "rename" takes a type internal name, so '/'s is used as a separator.
+# The leading / in the prefix is not needed (it'll be stripped), but it's added to make
+# sure the stripping works.
+rename ^.*/TinyFrameworkToBeRenamed$ /rename_prefix/
\ No newline at end of file
diff --git a/tools/hoststubgen/hoststubgen/test-tiny-framework/tiny-framework/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller.java b/tools/hoststubgen/hoststubgen/test-tiny-framework/tiny-framework/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller.java
new file mode 100644
index 0000000..31a164a
--- /dev/null
+++ b/tools/hoststubgen/hoststubgen/test-tiny-framework/tiny-framework/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkRenamedClassCaller.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.hoststubgen.test.tinyframework;
+
+import android.hosttest.annotation.HostSideTestWholeClassStub;
+
+@HostSideTestWholeClassStub
+public class TinyFrameworkRenamedClassCaller {
+ /** Calls the class that'll be renamed. */
+ public static int foo(int value) {
+ // When TinyFrameworkToBeRenamed gets renamed, this callsite should be updated too,
+ // so this code should work as-is.
+ return new TinyFrameworkToBeRenamed(value).getValue();
+ }
+}
diff --git a/tools/hoststubgen/hoststubgen/test-tiny-framework/tiny-framework/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed.java b/tools/hoststubgen/hoststubgen/test-tiny-framework/tiny-framework/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed.java
new file mode 100644
index 0000000..1430bcb
--- /dev/null
+++ b/tools/hoststubgen/hoststubgen/test-tiny-framework/tiny-framework/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkToBeRenamed.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.hoststubgen.test.tinyframework;
+
+import android.hosttest.annotation.HostSideTestWholeClassStub;
+
+/**
+ * This class will be renamed by the "rename" directive in the policy file.
+ */
+@HostSideTestWholeClassStub
+public class TinyFrameworkToBeRenamed {
+ private final int mValue;
+
+ public TinyFrameworkToBeRenamed(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+}
diff --git a/tools/hoststubgen/hoststubgen/test-tiny-framework/tiny-test/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkClassTest.java b/tools/hoststubgen/hoststubgen/test-tiny-framework/tiny-test/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkClassTest.java
index 37925e8..bf0f654 100644
--- a/tools/hoststubgen/hoststubgen/test-tiny-framework/tiny-test/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkClassTest.java
+++ b/tools/hoststubgen/hoststubgen/test-tiny-framework/tiny-test/src/com/android/hoststubgen/test/tinyframework/TinyFrameworkClassTest.java
@@ -334,4 +334,9 @@
public void testRFileHeuristics() {
assertThat(Nested.ARRAY.length).isEqualTo(1);
}
+
+ @Test
+ public void testTypeRename() {
+ assertThat(TinyFrameworkRenamedClassCaller.foo(1)).isEqualTo(1);
+ }
}
diff --git a/tools/hoststubgen/scripts/dump-jar b/tools/hoststubgen/scripts/dump-jar
index 992665e..fe546fe 100755
--- a/tools/hoststubgen/scripts/dump-jar
+++ b/tools/hoststubgen/scripts/dump-jar
@@ -97,6 +97,7 @@
# - Remove the constant pool
# - Remove the line number table
# - Some other transient lines
+ # - Sometimes the javap shows mysterious warnings, so remove them too.
#
# `/PATTERN-1/,/PATTERN-1/{//!d}` is a trick to delete lines between two patterns, without
# the start and the end lines.
@@ -106,7 +107,8 @@
-e '/^ *line *[0-9][0-9]*: *[0-9][0-9]*$/d' \
-e '/SHA-256 checksum/d' \
-e '/Last modified/d' \
- -e '/^Classfile jar/d'
+ -e '/^Classfile jar/d' \
+ -e '/\[warning\]/d'
else
cat # Print as-is.
fi
diff --git a/tools/protologtool/src/com/android/protolog/tool/ViewerConfigProtoBuilder.kt b/tools/protologtool/src/com/android/protolog/tool/ViewerConfigProtoBuilder.kt
index cf0876a..0115339 100644
--- a/tools/protologtool/src/com/android/protolog/tool/ViewerConfigProtoBuilder.kt
+++ b/tools/protologtool/src/com/android/protolog/tool/ViewerConfigProtoBuilder.kt
@@ -55,6 +55,7 @@
.setLevel(
ProtoLogLevel.forNumber(log.logLevel.ordinal + 1))
.setGroupId(groupId)
+ .setLocation(log.position)
)
}
diff --git a/wifi/java/src/android/net/wifi/WifiKeystore.java b/wifi/java/src/android/net/wifi/WifiKeystore.java
index 2ba7468..59f14a9 100644
--- a/wifi/java/src/android/net/wifi/WifiKeystore.java
+++ b/wifi/java/src/android/net/wifi/WifiKeystore.java
@@ -36,6 +36,8 @@
@SuppressLint("UnflaggedApi") // Promoting from @SystemApi(MODULE_LIBRARIES)
public final class WifiKeystore {
private static final String TAG = "WifiKeystore";
+ private static final String sPrimaryDbName =
+ WifiBlobStore.supplicantCanAccessBlobstore() ? "WifiBlobstore" : "LegacyKeystore";
/** @hide */
WifiKeystore() {
@@ -57,8 +59,13 @@
// are able to access the same values.
final long identity = Binder.clearCallingIdentity();
try {
- Log.i(TAG, "put blob. alias " + alias);
- return WifiBlobStore.getInstance().put(alias, blob);
+ Log.i(TAG, "put blob. alias=" + alias + ", primaryDb=" + sPrimaryDbName);
+ if (WifiBlobStore.supplicantCanAccessBlobstore()) {
+ return WifiBlobStore.getInstance().put(alias, blob);
+ } else {
+ WifiBlobStore.getLegacyKeystore().put(alias, Process.WIFI_UID, blob);
+ return true;
+ }
} catch (Exception e) {
Log.e(TAG, "Failed to put blob.", e);
return false;
@@ -80,7 +87,7 @@
public static @NonNull byte[] get(@NonNull String alias) {
final long identity = Binder.clearCallingIdentity();
try {
- Log.i(TAG, "get blob. alias " + alias);
+ Log.i(TAG, "get blob. alias=" + alias + ", primaryDb=" + sPrimaryDbName);
byte[] blob = WifiBlobStore.getInstance().get(alias);
if (blob != null) {
return blob;
@@ -112,7 +119,7 @@
boolean legacyKsSuccess = false;
final long identity = Binder.clearCallingIdentity();
try {
- Log.i(TAG, "remove blob. alias " + alias);
+ Log.i(TAG, "remove blob. alias=" + alias + ", primaryDb=" + sPrimaryDbName);
blobStoreSuccess = WifiBlobStore.getInstance().remove(alias);
// Legacy Keystore will throw an exception if the alias is not found.
WifiBlobStore.getLegacyKeystore().remove(alias, Process.WIFI_UID);
diff --git a/wifi/java/src/android/net/wifi/WifiMigration.java b/wifi/java/src/android/net/wifi/WifiMigration.java
index 6ea20ec..7df1d4b 100644
--- a/wifi/java/src/android/net/wifi/WifiMigration.java
+++ b/wifi/java/src/android/net/wifi/WifiMigration.java
@@ -577,6 +577,10 @@
@FlaggedApi(Flags.FLAG_LEGACY_KEYSTORE_TO_WIFI_BLOBSTORE_MIGRATION_READ_ONLY)
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
public static void migrateLegacyKeystoreToWifiBlobstore() {
+ if (!WifiBlobStore.supplicantCanAccessBlobstore()) {
+ Log.i(TAG, "Avoiding migration since supplicant cannot access WifiBlobstore");
+ return;
+ }
final long identity = Binder.clearCallingIdentity();
try {
ILegacyKeystore legacyKeystore = WifiBlobStore.getLegacyKeystore();
diff --git a/wifi/tests/src/android/net/wifi/WifiKeystoreTest.java b/wifi/tests/src/android/net/wifi/WifiKeystoreTest.java
index c28a0ae..4b1dc41 100644
--- a/wifi/tests/src/android/net/wifi/WifiKeystoreTest.java
+++ b/wifi/tests/src/android/net/wifi/WifiKeystoreTest.java
@@ -61,6 +61,7 @@
mSession = ExtendedMockito.mockitoSession()
.mockStatic(WifiBlobStore.class, withSettings().lenient())
.startMocking();
+ when(WifiBlobStore.supplicantCanAccessBlobstore()).thenReturn(true);
when(WifiBlobStore.getLegacyKeystore()).thenReturn(mLegacyKeystore);
when(WifiBlobStore.getInstance()).thenReturn(mWifiBlobStore);
}
@@ -74,16 +75,30 @@
}
/**
- * Test that put() only writes to the WifiBlobStore database.
+ * Test that put() writes to the WifiBlobStore database when it
+ * is available to supplicant.
*/
@Test
- public void testPut() throws Exception {
+ public void testPut_wifiBlobstore() throws Exception {
+ when(WifiBlobStore.supplicantCanAccessBlobstore()).thenReturn(true);
WifiKeystore.put(TEST_ALIAS, TEST_VALUE);
verify(mWifiBlobStore).put(anyString(), any());
verify(mLegacyKeystore, never()).put(anyString(), anyInt(), any());
}
/**
+ * Test that put() writes to Legacy Keystore if the WifiBlobstore database
+ * is not available to supplicant.
+ */
+ @Test
+ public void testPut_legacyKeystore() throws Exception {
+ when(WifiBlobStore.supplicantCanAccessBlobstore()).thenReturn(false);
+ WifiKeystore.put(TEST_ALIAS, TEST_VALUE);
+ verify(mLegacyKeystore).put(anyString(), anyInt(), any());
+ verify(mWifiBlobStore, never()).put(anyString(), any());
+ }
+
+ /**
* Test that if the alias is found in the WifiBlobStore database,
* then the legacy database is not searched.
*/
diff --git a/wifi/tests/src/android/net/wifi/WifiMigrationTest.java b/wifi/tests/src/android/net/wifi/WifiMigrationTest.java
index 8a5912f..d95069d 100644
--- a/wifi/tests/src/android/net/wifi/WifiMigrationTest.java
+++ b/wifi/tests/src/android/net/wifi/WifiMigrationTest.java
@@ -56,6 +56,7 @@
mSession = ExtendedMockito.mockitoSession()
.mockStatic(WifiBlobStore.class, withSettings().lenient())
.startMocking();
+ when(WifiBlobStore.supplicantCanAccessBlobstore()).thenReturn(true);
when(WifiBlobStore.getLegacyKeystore()).thenReturn(mLegacyKeystore);
when(WifiBlobStore.getInstance()).thenReturn(mWifiBlobStore);
when(mLegacyKeystore.get(anyString(), anyInt())).thenReturn(TEST_VALUE);
@@ -70,6 +71,17 @@
}
/**
+ * Verify that the Keystore migration is skipped if supplicant does not have
+ * access to the WifiBlobstore database.
+ */
+ @Test
+ public void testKeystoreMigrationAvoidedOnLegacyVendorPartition() {
+ when(WifiBlobStore.supplicantCanAccessBlobstore()).thenReturn(false);
+ WifiMigration.migrateLegacyKeystoreToWifiBlobstore();
+ verifyNoMoreInteractions(mLegacyKeystore, mWifiBlobStore);
+ }
+
+ /**
* Verify that the Keystore migration method returns immediately if no aliases
* are found in Legacy Keystore.
*/